Skip to content

Commit dc1d78d

Browse files
ceyonurStephenButtolphDarioush Jalali
authored
Subnet evm 0.6.7 (#1229)
* Fix VM.GetBlockIDAtHeight (#595) * Fix and optimize GetBlockIDAtHeight * Add test --------- Co-authored-by: Darioush Jalali <[email protected]> * bump subnet-evm & avago * update coreth tip * bump mingo version * Update scripts/versions.sh Co-authored-by: Darioush Jalali <[email protected]> Signed-off-by: Ceyhun Onur <[email protected]> * go mod tidy --------- Signed-off-by: Ceyhun Onur <[email protected]> Co-authored-by: Stephen Buttolph <[email protected]> Co-authored-by: Darioush Jalali <[email protected]>
1 parent 6c018f8 commit dc1d78d

File tree

12 files changed

+70
-36
lines changed

12 files changed

+70
-36
lines changed

.github/workflows/bench.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v4
1212
- uses: actions/setup-go@v4
1313
with:
14-
go-version: "~1.21.11"
14+
go-version: "~1.21.12"
1515
check-latest: true
1616
- run: go mod download
1717
shell: bash

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Go
2424
uses: actions/setup-go@v5
2525
with:
26-
go-version: "~1.21.11"
26+
go-version: "~1.21.12"
2727
check-latest: true
2828
- name: Set up arm64 cross compiler
2929
run: |

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
pull_request:
1010

1111
env:
12-
min_go_version: "~1.21.11"
12+
min_go_version: "~1.21.12"
1313
grafana_url: https://grafana-experimental.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?orgId=1&refresh=10s&var-filter=is_ephemeral_node%7C%3D%7Cfalse&var-filter=gh_repo%7C%3D%7Cava-labs%2Fsubnet-evm&var-filter=gh_run_id%7C%3D%7C${{ github.run_id }}&var-filter=gh_run_attempt%7C%3D%7C${{ github.run_attempt }}
1414

1515
jobs:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
ARG AVALANCHE_VERSION
66

77
# ============= Compilation Stage ================
8-
FROM golang:1.21.11-bullseye AS builder
8+
FROM golang:1.21.12-bullseye AS builder
99

1010
WORKDIR /build
1111

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ The Subnet EVM runs in a separate process from the main AvalancheGo process and
5959
[v0.6.0] [email protected] (Protocol Version: 33)
6060
[v0.6.1] [email protected] (Protocol Version: 33)
6161
[v0.6.2] [email protected] (Protocol Version: 34)
62-
[v0.6.3] [email protected] (Protocol Version: 35)
63-
[v0.6.4] [email protected] (Protocol Version: 35)
64-
[v0.6.5] [email protected] (Protocol Version: 35)
65-
[v0.6.6] [email protected] (Protocol Version: 35)
62+
[v0.6.3] [email protected] (Protocol Version: 35)
63+
[v0.6.4] [email protected] (Protocol Version: 35)
64+
[v0.6.5] [email protected] (Protocol Version: 35)
65+
[v0.6.6] [email protected] (Protocol Version: 35)
66+
[v0.6.7] [email protected] (Protocol Version: 35)
6667
```
6768

6869
## API
@@ -102,7 +103,7 @@ To support these changes, there have been a number of changes to the SubnetEVM b
102103

103104
### Clone Subnet-evm
104105

105-
First install Go 1.21.11 or later. Follow the instructions [here](https://go.dev/doc/install). You can verify by running `go version`.
106+
First install Go 1.21.12 or later. Follow the instructions [here](https://go.dev/doc/install). You can verify by running `go version`.
106107

107108
Set `$GOPATH` environment variable properly for Go to look for Go Workspaces. Please read [this](https://go.dev/doc/code) for details. You can verify by running `echo $GOPATH`.
108109

compatibility.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"rpcChainVMProtocolVersion": {
3+
"v0.6.7": 35,
34
"v0.6.6": 35,
45
"v0.6.5": 35,
56
"v0.6.4": 35,

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module github.com/ava-labs/subnet-evm
22

3-
go 1.21.11
3+
go 1.21.12
44

55
require (
66
github.com/VictoriaMetrics/fastcache v1.12.1
7-
github.com/ava-labs/avalanchego v1.11.7
7+
github.com/ava-labs/avalanchego v1.11.9
88
github.com/cespare/cp v0.1.0
99
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233
1010
github.com/davecgh/go-spew v1.1.1
@@ -47,14 +47,14 @@ require (
4747
golang.org/x/sys v0.18.0
4848
golang.org/x/text v0.14.0
4949
golang.org/x/time v0.3.0
50-
google.golang.org/protobuf v1.33.0
50+
google.golang.org/protobuf v1.34.2
5151
gopkg.in/natefinch/lumberjack.v2 v2.0.0
5252
)
5353

5454
require (
5555
github.com/DataDog/zstd v1.5.2 // indirect
5656
github.com/NYTimes/gziphandler v1.1.1 // indirect
57-
github.com/ava-labs/coreth v0.13.5-rc.0 // indirect
57+
github.com/ava-labs/coreth v0.13.6-rc.1 // indirect
5858
github.com/beorn7/perks v1.0.1 // indirect
5959
github.com/bits-and-blooms/bitset v1.10.0 // indirect
6060
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
@@ -80,7 +80,7 @@ require (
8080
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
8181
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
8282
github.com/gogo/protobuf v1.3.2 // indirect
83-
github.com/golang/protobuf v1.5.3 // indirect
83+
github.com/golang/protobuf v1.5.4 // indirect
8484
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
8585
github.com/google/btree v1.1.2 // indirect
8686
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
5656
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
5757
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
5858
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
59-
github.com/ava-labs/avalanchego v1.11.7 h1:BemCJEa6+f79fzRLdR0+iJAA3v9shOyhVniAKuibFyk=
60-
github.com/ava-labs/avalanchego v1.11.7/go.mod h1:aPYTETkM0KjtC7vFwPO6S8z2L0QTKaXjVUi98pTdNO4=
61-
github.com/ava-labs/coreth v0.13.5-rc.0 h1:PJQbR9o2RrW3j9ba4r1glXnmM2PNAP3xR569+gMcBd0=
62-
github.com/ava-labs/coreth v0.13.5-rc.0/go.mod h1:cm5c12xo5NiTgtbmeduv8i2nYdzgkczz9Wm3yiwwTRU=
59+
github.com/ava-labs/avalanchego v1.11.9 h1:hPmnPADhyl/cOp6WNJKfJNW8zA644RioIMcAXSXG3TA=
60+
github.com/ava-labs/avalanchego v1.11.9/go.mod h1:1dpLzXIVhAmJeRpl59l5GgcCEO9bDdF6Y6qRDTo0QGY=
61+
github.com/ava-labs/coreth v0.13.6-rc.1 h1:gRXRokmu0WOlPqyx+mTLWB655e8/w++u6qFcq9Mo7qA=
62+
github.com/ava-labs/coreth v0.13.6-rc.1/go.mod h1:vm9T8qzP7RLo/jR2MKkliPfaiGgWeEpu/PG6fvvPmog=
6363
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
6464
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
6565
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
@@ -258,8 +258,8 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
258258
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
259259
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
260260
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
261-
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
262-
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
261+
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
262+
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
263263
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
264264
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk=
265265
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
@@ -993,8 +993,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
993993
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
994994
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
995995
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
996-
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
997-
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
996+
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
997+
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
998998
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
999999
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
10001000
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

plugin/evm/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var (
1111
// GitCommit is set by the build script
1212
GitCommit string
1313
// Version is the version of Subnet EVM
14-
Version string = "v0.6.6"
14+
Version string = "v0.6.7"
1515
)
1616

1717
func init() {

plugin/evm/vm.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -937,20 +937,21 @@ func (vm *VM) VerifyHeightIndex(context.Context) error {
937937
return nil
938938
}
939939

940-
// GetBlockAtHeight returns the canonical block at [blkHeight].
941-
// If [blkHeight] is less than the height of the last accepted block, this will return
942-
// the block accepted at that height. Otherwise, it may return a blkID that has not yet
943-
// been accepted.
944-
// Note: the engine assumes that if a block is not found at [blkHeight], then
945-
// [database.ErrNotFound] will be returned. This indicates that the VM has state synced
946-
// and does not have all historical blocks available.
947-
func (vm *VM) GetBlockIDAtHeight(_ context.Context, blkHeight uint64) (ids.ID, error) {
948-
ethBlock := vm.blockChain.GetBlockByNumber(blkHeight)
949-
if ethBlock == nil {
940+
// GetBlockAtHeight returns the canonical block at [height].
941+
// Note: the engine assumes that if a block is not found at [height], then
942+
// [database.ErrNotFound] will be returned. This indicates that the VM has state
943+
// synced and does not have all historical blocks available.
944+
func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, error) {
945+
lastAcceptedBlock := vm.LastAcceptedBlock()
946+
if lastAcceptedBlock.Height() < height {
950947
return ids.ID{}, database.ErrNotFound
951948
}
952949

953-
return ids.ID(ethBlock.Hash()), nil
950+
hash := vm.blockChain.GetCanonicalHash(height)
951+
if hash == (common.Hash{}) {
952+
return ids.ID{}, database.ErrNotFound
953+
}
954+
return ids.ID(hash), nil
954955
}
955956

956957
func (vm *VM) Version(context.Context) (string, error) {

plugin/evm/vm_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,10 @@ func TestNonCanonicalAccept(t *testing.T) {
10041004
t.Fatalf("Expected status of built block to be %s, but found %s", choices.Processing, status)
10051005
}
10061006

1007+
if _, err := vm1.GetBlockIDAtHeight(context.Background(), vm1BlkA.Height()); err != database.ErrNotFound {
1008+
t.Fatalf("Expected unaccepted block not to be indexed by height, but found %s", err)
1009+
}
1010+
10071011
if err := vm1.SetPreference(context.Background(), vm1BlkA.ID()); err != nil {
10081012
t.Fatal(err)
10091013
}
@@ -1018,16 +1022,29 @@ func TestNonCanonicalAccept(t *testing.T) {
10181022
if status := vm2BlkA.Status(); status != choices.Processing {
10191023
t.Fatalf("Expected status of block on VM2 to be %s, but found %s", choices.Processing, status)
10201024
}
1025+
if _, err := vm2.GetBlockIDAtHeight(context.Background(), vm2BlkA.Height()); err != database.ErrNotFound {
1026+
t.Fatalf("Expected unaccepted block not to be indexed by height, but found %s", err)
1027+
}
10211028
if err := vm2.SetPreference(context.Background(), vm2BlkA.ID()); err != nil {
10221029
t.Fatal(err)
10231030
}
10241031

10251032
if err := vm1BlkA.Accept(context.Background()); err != nil {
10261033
t.Fatalf("VM1 failed to accept block: %s", err)
10271034
}
1035+
if blkID, err := vm1.GetBlockIDAtHeight(context.Background(), vm1BlkA.Height()); err != nil {
1036+
t.Fatalf("Height lookuped failed on accepted block: %s", err)
1037+
} else if blkID != vm1BlkA.ID() {
1038+
t.Fatalf("Expected accepted block to be indexed by height, but found %s", blkID)
1039+
}
10281040
if err := vm2BlkA.Accept(context.Background()); err != nil {
10291041
t.Fatalf("VM2 failed to accept block: %s", err)
10301042
}
1043+
if blkID, err := vm2.GetBlockIDAtHeight(context.Background(), vm2BlkA.Height()); err != nil {
1044+
t.Fatalf("Height lookuped failed on accepted block: %s", err)
1045+
} else if blkID != vm2BlkA.ID() {
1046+
t.Fatalf("Expected accepted block to be indexed by height, but found %s", blkID)
1047+
}
10311048

10321049
newHead := <-newTxPoolHeadChan1
10331050
if newHead.Head.Hash() != common.Hash(vm1BlkA.ID()) {
@@ -1075,6 +1092,10 @@ func TestNonCanonicalAccept(t *testing.T) {
10751092
t.Fatalf("Expected status of built block to be %s, but found %s", choices.Processing, status)
10761093
}
10771094

1095+
if _, err := vm1.GetBlockIDAtHeight(context.Background(), vm1BlkB.Height()); err != database.ErrNotFound {
1096+
t.Fatalf("Expected unaccepted block not to be indexed by height, but found %s", err)
1097+
}
1098+
10781099
if err := vm1.SetPreference(context.Background(), vm1BlkB.ID()); err != nil {
10791100
t.Fatal(err)
10801101
}
@@ -1107,10 +1128,20 @@ func TestNonCanonicalAccept(t *testing.T) {
11071128
t.Fatalf("Block failed verification on VM1: %s", err)
11081129
}
11091130

1131+
if _, err := vm1.GetBlockIDAtHeight(context.Background(), vm1BlkC.Height()); err != database.ErrNotFound {
1132+
t.Fatalf("Expected unaccepted block not to be indexed by height, but found %s", err)
1133+
}
1134+
11101135
if err := vm1BlkC.Accept(context.Background()); err != nil {
11111136
t.Fatalf("VM1 failed to accept block: %s", err)
11121137
}
11131138

1139+
if blkID, err := vm1.GetBlockIDAtHeight(context.Background(), vm1BlkC.Height()); err != nil {
1140+
t.Fatalf("Height lookuped failed on accepted block: %s", err)
1141+
} else if blkID != vm1BlkC.ID() {
1142+
t.Fatalf("Expected accepted block to be indexed by height, but found %s", blkID)
1143+
}
1144+
11141145
blkCHash := vm1BlkC.(*chain.BlockWrapper).Block.(*Block).ethBlock.Hash()
11151146
if b := vm1.blockChain.GetBlockByNumber(blkBHeight); b.Hash() != blkCHash {
11161147
t.Fatalf("expected block at %d to have hash %s but got %s", blkBHeight, blkCHash.Hex(), b.Hash().Hex())

scripts/versions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# shellcheck disable=SC2034
55

66
# Don't export them as they're used in the context of other calls
7-
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'v1.11.7'}
7+
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'v1.11.9'}
88
GINKGO_VERSION=${GINKGO_VERSION:-'v2.2.0'}
99

1010
# This won't be used, but it's here to make code syncs easier
11-
LATEST_CORETH_VERSION='0.13.4'
11+
LATEST_CORETH_VERSION='7684836'

0 commit comments

Comments
 (0)