From 995f5bb34d70e61eccdea960919c76c777d6122a Mon Sep 17 00:00:00 2001 From: Austin Larson Date: Tue, 9 Dec 2025 11:42:31 -0500 Subject: [PATCH 1/6] test: Use predictable accounts fot TestTracingwithOverrides --- graft/coreth/eth/tracers/api_test.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/graft/coreth/eth/tracers/api_test.go b/graft/coreth/eth/tracers/api_test.go index 44ffb7a20483..9c2dd641a055 100644 --- a/graft/coreth/eth/tracers/api_test.go +++ b/graft/coreth/eth/tracers/api_test.go @@ -34,6 +34,7 @@ import ( "errors" "fmt" "math/big" + "math/rand" "reflect" "sync/atomic" "testing" @@ -630,7 +631,9 @@ func TestTracingWithOverrides(t *testing.T) { func testTracingWithOverrides(t *testing.T, scheme string) { // Initialize test accounts - accounts := newAccounts(3) + // This test requires deterministic block hashes, since it will fail 1/256 times, + // when the final block hash starts with 0xef. + accounts := newAccountsWithSeed(3, 0) storageAccount := common.Address{0x13, 37} genesis := &core.Genesis{ Config: params.TestChainConfig, @@ -996,6 +999,18 @@ func newAccounts(n int) (accounts []Account) { return accounts } +// WARNING: only use for tests that require deterministic accounts +func newAccountsWithSeed(n int, seed int64) (accounts []Account) { + rand := rand.New(rand.NewSource(seed)) + for i := 0; i < n; i++ { + key, _ := ecdsa.GenerateKey(crypto.S256(), rand) + addr := crypto.PubkeyToAddress(key.PublicKey) + accounts = append(accounts, Account{key: key, addr: addr}) + } + slices.SortFunc(accounts, func(a, b Account) int { return a.addr.Cmp(b.addr) }) + return accounts +} + func newRPCBalance(balance *big.Int) **hexutil.Big { rpcBalance := (*hexutil.Big)(balance) return &rpcBalance From 676f2d61819a5d3433765629c4f67bcd3d8af112 Mon Sep 17 00:00:00 2001 From: Austin Larson <78000745+alarso16@users.noreply.github.com> Date: Wed, 10 Dec 2025 10:05:28 -0500 Subject: [PATCH 2/6] Update graft/coreth/eth/tracers/api_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Austin Larson <78000745+alarso16@users.noreply.github.com> --- graft/coreth/eth/tracers/api_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graft/coreth/eth/tracers/api_test.go b/graft/coreth/eth/tracers/api_test.go index 9c2dd641a055..74ab1ffd0a33 100644 --- a/graft/coreth/eth/tracers/api_test.go +++ b/graft/coreth/eth/tracers/api_test.go @@ -1001,9 +1001,9 @@ func newAccounts(n int) (accounts []Account) { // WARNING: only use for tests that require deterministic accounts func newAccountsWithSeed(n int, seed int64) (accounts []Account) { - rand := rand.New(rand.NewSource(seed)) + rng := rand.New(rand.NewSource(seed)) for i := 0; i < n; i++ { - key, _ := ecdsa.GenerateKey(crypto.S256(), rand) + key, _ := ecdsa.GenerateKey(crypto.S256(), rng) addr := crypto.PubkeyToAddress(key.PublicKey) accounts = append(accounts, Account{key: key, addr: addr}) } From f45d5146fece9a426d4683c71cf54ab743e46371 Mon Sep 17 00:00:00 2001 From: Austin Larson Date: Thu, 11 Dec 2025 13:28:50 -0500 Subject: [PATCH 3/6] chore: Bump libevm --- go.mod | 2 +- go.sum | 4 ++-- graft/coreth/go.mod | 2 +- graft/coreth/go.sum | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index bd7cd14688da..8c53df2a8784 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/StephenButtolph/canoto v0.17.3 github.com/antithesishq/antithesis-sdk-go v0.3.8 github.com/ava-labs/avalanchego/graft/coreth v0.0.0-20251201173339-98b2978e465a - github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 + github.com/ava-labs/libevm v1.13.15-0.20251210210615-b8e76562a300 github.com/ava-labs/subnet-evm v0.8.1-0.20251201175023-067762d6ce7d github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cespare/xxhash/v2 v2.3.0 diff --git a/go.sum b/go.sum index fd6d482a2723..1e600516f06e 100644 --- a/go.sum +++ b/go.sum @@ -73,8 +73,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/ava-labs/firewood-go-ethhash/ffi v0.0.16 h1:J+evKZFzlS85Y9AL8z6ThNFthdTIF0YzRT6MTm9S+y8= github.com/ava-labs/firewood-go-ethhash/ffi v0.0.16/go.mod h1:hR/JSGXxST9B9olwu/NpLXHAykfAyNGfyKnYQqiiOeE= -github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 h1:hQ15IJxY7WOKqeJqCXawsiXh0NZTzmoQOemkWHz7rr4= -github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2/go.mod h1:DqSotSn4Dx/UJV+d3svfW8raR+cH7+Ohl9BpsQ5HlGU= +github.com/ava-labs/libevm v1.13.15-0.20251210210615-b8e76562a300 h1:9VRvqASGSAnQ9tKVRKGH8Q0Yq8efCwYTBWp0p2creho= +github.com/ava-labs/libevm v1.13.15-0.20251210210615-b8e76562a300/go.mod h1:DqSotSn4Dx/UJV+d3svfW8raR+cH7+Ohl9BpsQ5HlGU= github.com/ava-labs/simplex v0.0.0-20250919142550-9cdfff10fd19 h1:S6oFasZsplNmw8B2S8cMJQMa62nT5ZKGzZRdCpd+5qQ= github.com/ava-labs/simplex v0.0.0-20250919142550-9cdfff10fd19/go.mod h1:GVzumIo3zR23/qGRN2AdnVkIPHcKMq/D89EGWZfMGQ0= github.com/ava-labs/subnet-evm v0.8.1-0.20251201175023-067762d6ce7d h1:IlhCuTqhPEfpW+q/8ZlhmjflB/Onn9AhtXuRCRYa+oo= diff --git a/graft/coreth/go.mod b/graft/coreth/go.mod index 23b145b12e86..e47c738bc2f5 100644 --- a/graft/coreth/go.mod +++ b/graft/coreth/go.mod @@ -11,7 +11,7 @@ require ( github.com/VictoriaMetrics/fastcache v1.12.1 github.com/ava-labs/avalanchego v1.14.1-0.20251120155522-df4a8e531761 github.com/ava-labs/firewood-go-ethhash/ffi v0.0.16 - github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 + github.com/ava-labs/libevm v1.13.15-0.20251210210615-b8e76562a300 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/deckarep/golang-set/v2 v2.1.0 github.com/go-cmd/cmd v1.4.3 diff --git a/graft/coreth/go.sum b/graft/coreth/go.sum index c65f9be802c7..1c3f8ac9467e 100644 --- a/graft/coreth/go.sum +++ b/graft/coreth/go.sum @@ -28,8 +28,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/ava-labs/firewood-go-ethhash/ffi v0.0.16 h1:J+evKZFzlS85Y9AL8z6ThNFthdTIF0YzRT6MTm9S+y8= github.com/ava-labs/firewood-go-ethhash/ffi v0.0.16/go.mod h1:hR/JSGXxST9B9olwu/NpLXHAykfAyNGfyKnYQqiiOeE= -github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 h1:hQ15IJxY7WOKqeJqCXawsiXh0NZTzmoQOemkWHz7rr4= -github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2/go.mod h1:DqSotSn4Dx/UJV+d3svfW8raR+cH7+Ohl9BpsQ5HlGU= +github.com/ava-labs/libevm v1.13.15-0.20251210210615-b8e76562a300 h1:9VRvqASGSAnQ9tKVRKGH8Q0Yq8efCwYTBWp0p2creho= +github.com/ava-labs/libevm v1.13.15-0.20251210210615-b8e76562a300/go.mod h1:DqSotSn4Dx/UJV+d3svfW8raR+cH7+Ohl9BpsQ5HlGU= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= From fef9ae9c84a694caa0588b031be32585ada85d33 Mon Sep 17 00:00:00 2001 From: Austin Larson Date: Thu, 11 Dec 2025 14:06:38 -0500 Subject: [PATCH 4/6] fix: Use deterministic random keys --- graft/coreth/eth/tracers/api_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/graft/coreth/eth/tracers/api_test.go b/graft/coreth/eth/tracers/api_test.go index 74ab1ffd0a33..621adc9c4be0 100644 --- a/graft/coreth/eth/tracers/api_test.go +++ b/graft/coreth/eth/tracers/api_test.go @@ -30,11 +30,11 @@ package tracers import ( "context" "crypto/ecdsa" + "encoding/binary" "encoding/json" "errors" "fmt" "math/big" - "math/rand" "reflect" "sync/atomic" "testing" @@ -55,6 +55,7 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/ava-labs/libevm/eth/tracers/logger" "github.com/ava-labs/libevm/ethdb" + "github.com/ava-labs/libevm/libevm/ethtest" ethparams "github.com/ava-labs/libevm/params" "golang.org/x/exp/slices" ) @@ -633,7 +634,7 @@ func testTracingWithOverrides(t *testing.T, scheme string) { // Initialize test accounts // This test requires deterministic block hashes, since it will fail 1/256 times, // when the final block hash starts with 0xef. - accounts := newAccountsWithSeed(3, 0) + accounts := UNSAFEDeterministicAccounts(t, 3) storageAccount := common.Address{0x13, 37} genesis := &core.Genesis{ Config: params.TestChainConfig, @@ -1000,10 +1001,11 @@ func newAccounts(n int) (accounts []Account) { } // WARNING: only use for tests that require deterministic accounts -func newAccountsWithSeed(n int, seed int64) (accounts []Account) { - rng := rand.New(rand.NewSource(seed)) +func UNSAFEDeterministicAccounts(t *testing.T, n int) (accounts []Account) { + seed := make([]byte, 8) // int64 size for i := 0; i < n; i++ { - key, _ := ecdsa.GenerateKey(crypto.S256(), rng) + binary.BigEndian.PutUint64(seed, uint64(i)) + key := ethtest.UNSAFEDeterministicPrivateKey(t, seed) addr := crypto.PubkeyToAddress(key.PublicKey) accounts = append(accounts, Account{key: key, addr: addr}) } From 9f278abd2214e253434336cda69be8c20e862c43 Mon Sep 17 00:00:00 2001 From: Austin Larson Date: Thu, 11 Dec 2025 14:18:28 -0500 Subject: [PATCH 5/6] fix: Allow libevm import --- graft/coreth/scripts/eth-allowed-packages.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/graft/coreth/scripts/eth-allowed-packages.txt b/graft/coreth/scripts/eth-allowed-packages.txt index 1652e4a518e1..866a9eaa3c9e 100644 --- a/graft/coreth/scripts/eth-allowed-packages.txt +++ b/graft/coreth/scripts/eth-allowed-packages.txt @@ -30,6 +30,7 @@ "github.com/ava-labs/libevm/ethdb/pebble" "github.com/ava-labs/libevm/event" "github.com/ava-labs/libevm/libevm" +"github.com/ava-labs/libevm/libevm/ethtest" "github.com/ava-labs/libevm/libevm/legacy" "github.com/ava-labs/libevm/libevm/options" "github.com/ava-labs/libevm/libevm/stateconf" From a55d7afad0d60a3e6b041d94df510c64b5a49d21 Mon Sep 17 00:00:00 2001 From: Austin Larson Date: Mon, 15 Dec 2025 12:57:42 -0500 Subject: [PATCH 6/6] fix: duplciate in subnet-evm --- graft/subnet-evm/eth/tracers/api_test.go | 19 ++++++++++++++++++- graft/subnet-evm/go.mod | 2 +- graft/subnet-evm/go.sum | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/graft/subnet-evm/eth/tracers/api_test.go b/graft/subnet-evm/eth/tracers/api_test.go index 0637ac1daef4..925a822980be 100644 --- a/graft/subnet-evm/eth/tracers/api_test.go +++ b/graft/subnet-evm/eth/tracers/api_test.go @@ -30,6 +30,7 @@ package tracers import ( "context" "crypto/ecdsa" + "encoding/binary" "encoding/json" "errors" "fmt" @@ -54,6 +55,7 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/ava-labs/libevm/eth/tracers/logger" "github.com/ava-labs/libevm/ethdb" + "github.com/ava-labs/libevm/libevm/ethtest" ethparams "github.com/ava-labs/libevm/params" "golang.org/x/exp/slices" ) @@ -628,7 +630,9 @@ func TestTracingWithOverrides(t *testing.T) { func testTracingWithOverrides(t *testing.T, scheme string) { // Initialize test accounts - accounts := newAccounts(3) + // This test requires deterministic block hashes, since it will fail 1/256 times,Expand commentComment on line R635ResolvedCode has comments. Press enter to view. + // when the final block hash starts with 0xef. + accounts := UNSAFEDeterministicAccounts(t, 3) storageAccount := common.Address{0x13, 37} genesis := &core.Genesis{ Config: params.TestChainConfig, @@ -994,6 +998,19 @@ func newAccounts(n int) (accounts []Account) { return accounts } +// WARNING: only use for tests that require deterministic accounts +func UNSAFEDeterministicAccounts(t *testing.T, n int) (accounts []Account) { + seed := make([]byte, 8) // int64 size + for i := 0; i < n; i++ { + binary.BigEndian.PutUint64(seed, uint64(i)) + key := ethtest.UNSAFEDeterministicPrivateKey(t, seed) + addr := crypto.PubkeyToAddress(key.PublicKey) + accounts = append(accounts, Account{key: key, addr: addr}) + } + slices.SortFunc(accounts, func(a, b Account) int { return a.addr.Cmp(b.addr) }) + return accounts +} + func newRPCBalance(balance *big.Int) **hexutil.Big { rpcBalance := (*hexutil.Big)(balance) return &rpcBalance diff --git a/graft/subnet-evm/go.mod b/graft/subnet-evm/go.mod index 12245aabfe3e..60e3c7715244 100644 --- a/graft/subnet-evm/go.mod +++ b/graft/subnet-evm/go.mod @@ -18,7 +18,7 @@ require ( github.com/antithesishq/antithesis-sdk-go v0.3.8 github.com/ava-labs/avalanchego v1.14.1-antithesis-docker-image-fix github.com/ava-labs/firewood-go-ethhash/ffi v0.0.16 - github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 + github.com/ava-labs/libevm v1.13.15-0.20251210210615-b8e76562a300 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/deckarep/golang-set/v2 v2.1.0 github.com/go-cmd/cmd v1.4.3 diff --git a/graft/subnet-evm/go.sum b/graft/subnet-evm/go.sum index 75dc5695d916..5a489dc94f21 100644 --- a/graft/subnet-evm/go.sum +++ b/graft/subnet-evm/go.sum @@ -32,8 +32,8 @@ github.com/ava-labs/avalanchego/graft/coreth v0.0.0-20251203215505-70148edc6eca github.com/ava-labs/avalanchego/graft/coreth v0.0.0-20251203215505-70148edc6eca/go.mod h1:y+/5DAxCTLAXdWRxAYN1V8DV0DIF7uHhOOeNa9oASuU= github.com/ava-labs/firewood-go-ethhash/ffi v0.0.16 h1:J+evKZFzlS85Y9AL8z6ThNFthdTIF0YzRT6MTm9S+y8= github.com/ava-labs/firewood-go-ethhash/ffi v0.0.16/go.mod h1:hR/JSGXxST9B9olwu/NpLXHAykfAyNGfyKnYQqiiOeE= -github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 h1:hQ15IJxY7WOKqeJqCXawsiXh0NZTzmoQOemkWHz7rr4= -github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2/go.mod h1:DqSotSn4Dx/UJV+d3svfW8raR+cH7+Ohl9BpsQ5HlGU= +github.com/ava-labs/libevm v1.13.15-0.20251210210615-b8e76562a300 h1:9VRvqASGSAnQ9tKVRKGH8Q0Yq8efCwYTBWp0p2creho= +github.com/ava-labs/libevm v1.13.15-0.20251210210615-b8e76562a300/go.mod h1:DqSotSn4Dx/UJV+d3svfW8raR+cH7+Ohl9BpsQ5HlGU= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=