From 9fa28945281f22d389fc273114688288341bbb7d Mon Sep 17 00:00:00 2001 From: Austin Larson Date: Mon, 15 Dec 2025 16:39:31 -0500 Subject: [PATCH 01/16] refactor: Share EVM Utils --- go.mod | 2 +- go.sum | 4 +- graft/coreth/consensus/dummy/consensus.go | 2 +- graft/coreth/core/extstate/options.go | 2 +- graft/coreth/core/genesis_extra_test.go | 2 +- graft/coreth/core/genesis_test.go | 2 +- .../core/state/snapshot/difflayer_test.go | 2 +- graft/coreth/core/state/snapshot/disklayer.go | 2 +- graft/coreth/core/state/snapshot/generate.go | 2 +- .../core/state/snapshot/snapshot_ext.go | 2 +- graft/coreth/core/state_processor_test.go | 2 +- .../core/txpool/legacypool/legacypool.go | 2 +- graft/coreth/go.mod | 3 +- graft/coreth/go.sum | 4 +- graft/coreth/internal/ethapi/api_test.go | 2 +- graft/coreth/network/peer_tracker.go | 2 +- graft/coreth/params/config.go | 2 +- graft/coreth/params/config_extra.go | 2 +- graft/coreth/params/config_extra_test.go | 2 +- graft/coreth/params/config_test.go | 2 +- graft/coreth/params/extras/config.go | 2 +- .../coreth/params/extras/config_extra_test.go | 2 +- .../coreth/params/extras/network_upgrades.go | 2 +- .../params/extras/precompile_upgrade.go | 2 +- .../plugin/evm/atomic/vm/block_extension.go | 2 +- .../plugin/evm/atomic/vm/export_tx_test.go | 2 +- .../plugin/evm/atomic/vm/import_tx_test.go | 2 +- .../plugin/evm/atomic/vm/tx_gossip_test.go | 2 +- graft/coreth/plugin/evm/atomic/vm/tx_test.go | 2 +- graft/coreth/plugin/evm/atomic/vm/vm.go | 4 +- graft/coreth/plugin/evm/atomic/vm/vm_test.go | 2 +- .../plugin/evm/config/default_config.go | 2 +- .../plugin/evm/customheader/base_fee_test.go | 2 +- .../plugin/evm/customheader/extra_test.go | 2 +- .../plugin/evm/customheader/gas_limit_test.go | 2 +- .../evm/customheader/min_delay_excess_test.go | 4 +- .../plugin/evm/customheader/time_test.go | 2 +- .../plugin/evm/customtypes/block_ext_test.go | 4 +- .../plugin/evm/customtypes/header_ext_test.go | 2 +- graft/coreth/plugin/evm/gossip_test.go | 2 +- graft/coreth/plugin/evm/tx_gossip_test.go | 2 +- graft/coreth/plugin/evm/upgrade/ap0/params.go | 2 +- graft/coreth/plugin/evm/upgrade/ap1/params.go | 2 +- graft/coreth/plugin/evm/upgrade/ap3/window.go | 2 +- graft/coreth/plugin/evm/upgrade/ap4/cost.go | 2 +- .../coreth/plugin/evm/upgrade/etna/params.go | 2 +- graft/coreth/plugin/evm/vm.go | 2 +- graft/coreth/plugin/evm/vm_test.go | 4 +- graft/coreth/plugin/evm/vm_warp_test.go | 2 +- .../coreth/plugin/evm/vmsync/registry_test.go | 2 +- .../coreth/plugin/evm/vmtest/test_syncervm.go | 2 +- .../precompile/contracts/warp/config_test.go | 2 +- .../contracts/warp/predicate_test.go | 2 +- graft/coreth/precompile/modules/registerer.go | 2 +- .../precompileconfig/upgradeable.go | 2 +- graft/coreth/sync/client/leaf_syncer.go | 2 +- graft/coreth/sync/handlers/leafs_request.go | 2 +- .../sync/statesync/statesynctest/test_sync.go | 2 +- .../sync/statesync/statesynctest/test_trie.go | 2 +- graft/coreth/sync/statesync/trie_segments.go | 2 +- graft/coreth/tests/init.go | 2 +- graft/coreth/triedb/hashdb/database.go | 2 +- graft/coreth/utils/metered_cache.go | 113 ------------- graft/coreth/utils/utilstest/snow.go | 40 ----- graft/evm/go.mod | 58 ++++++- graft/evm/go.sum | 153 ++++++++++++++++++ graft/{coreth => evm}/utils/address_range.go | 0 .../{coreth => evm}/utils/bounded_workers.go | 0 graft/{coreth => evm}/utils/bytes.go | 0 graft/{coreth => evm}/utils/bytes_test.go | 0 graft/{coreth => evm}/utils/denomination.go | 0 .../utils/metered_cache.go | 0 graft/{coreth => evm}/utils/numbers.go | 0 graft/{coreth => evm}/utils/numbers_test.go | 0 graft/{coreth => evm}/utils/rand/rand.go | 0 graft/{coreth => evm}/utils/rpc/handler.go | 3 +- .../utils/utilstest/context.go | 0 graft/{coreth => evm}/utils/utilstest/key.go | 0 .../utils/utilstest/pointer.go | 0 .../utils/utilstest/snow.go | 18 +-- .../utils/utilstest/snow_test.go} | 2 +- .../utils/utilstest/timeout.go | 0 .../precompile_config_test_template.go | 2 +- graft/subnet-evm/commontype/fee_config.go | 16 +- graft/subnet-evm/consensus/dummy/consensus.go | 2 +- graft/subnet-evm/core/blockchain_ext_test.go | 2 +- graft/subnet-evm/core/extstate/options.go | 2 +- graft/subnet-evm/core/genesis_extra_test.go | 2 +- graft/subnet-evm/core/genesis_test.go | 2 +- .../core/state/snapshot/difflayer_test.go | 2 +- .../core/state/snapshot/disklayer.go | 2 +- .../core/state/snapshot/generate.go | 2 +- .../core/state/snapshot/snapshot_ext.go | 2 +- .../core/state_processor_ext_test.go | 2 +- graft/subnet-evm/core/state_processor_test.go | 2 +- .../core/txpool/legacypool/legacypool.go | 2 +- graft/subnet-evm/go.mod | 2 +- graft/subnet-evm/go.sum | 4 +- graft/subnet-evm/internal/ethapi/api_test.go | 2 +- graft/subnet-evm/network/peer_tracker.go | 2 +- graft/subnet-evm/params/config.go | 2 +- graft/subnet-evm/params/config_extra.go | 2 +- graft/subnet-evm/params/config_extra_test.go | 2 +- graft/subnet-evm/params/config_test.go | 2 +- graft/subnet-evm/params/extras/config.go | 2 +- .../params/extras/config_extra_test.go | 2 +- .../params/extras/network_upgrades.go | 2 +- .../params/extras/network_upgrades_test.go | 2 +- .../params/extras/precompile_config_test.go | 14 +- .../params/extras/precompile_upgrade.go | 2 +- .../params/extras/precompile_upgrade_test.go | 2 +- .../params/extras/state_upgrade_test.go | 6 +- .../plugin/evm/customheader/base_fee_test.go | 2 +- .../evm/customheader/block_gas_cost_test.go | 2 +- .../plugin/evm/customheader/extra_test.go | 2 +- .../evm/customheader/min_delay_excess_test.go | 4 +- .../plugin/evm/customheader/time_test.go | 2 +- .../plugin/evm/customtypes/block_ext_test.go | 4 +- .../plugin/evm/customtypes/header_ext_test.go | 2 +- graft/subnet-evm/plugin/evm/gossip_test.go | 2 +- graft/subnet-evm/plugin/evm/syncervm_test.go | 2 +- graft/subnet-evm/plugin/evm/tx_gossip_test.go | 8 +- graft/subnet-evm/plugin/evm/vm_test.go | 10 +- .../plugin/evm/vm_upgrade_bytes_test.go | 2 +- graft/subnet-evm/plugin/evm/vm_warp_test.go | 2 +- .../allowlisttest/test_allowlist_config.go | 2 +- .../deployerallowlist/config_test.go | 2 +- .../deployerallowlist/simulated_test.go | 2 +- .../contracts/feemanager/config_test.go | 2 +- .../contracts/feemanager/simulated_test.go | 2 +- .../contracts/nativeminter/config.go | 4 +- .../contracts/nativeminter/config_test.go | 2 +- .../contracts/nativeminter/simulated_test.go | 2 +- .../contracts/rewardmanager/config_test.go | 2 +- .../contracts/rewardmanager/simulated_test.go | 2 +- .../contracts/txallowlist/config_test.go | 2 +- .../contracts/txallowlist/simulated_test.go | 2 +- .../precompile/contracts/warp/config_test.go | 2 +- .../contracts/warp/contract_test.go | 6 +- .../contracts/warp/predicate_test.go | 11 +- .../precompile/modules/registerer.go | 2 +- .../precompileconfig/upgradeable.go | 2 +- .../precompiletest/test_precompile.go | 4 +- graft/subnet-evm/sync/client/leaf_syncer.go | 2 +- .../subnet-evm/sync/handlers/leafs_request.go | 2 +- .../sync/statesync/statesynctest/test_sync.go | 2 +- .../sync/statesync/statesynctest/test_trie.go | 2 +- .../sync/statesync/trie_segments.go | 2 +- graft/subnet-evm/tests/init.go | 2 +- graft/subnet-evm/triedb/hashdb/database.go | 2 +- graft/subnet-evm/utils/address_range.go | 23 --- graft/subnet-evm/utils/bounded_workers.go | 81 ---------- graft/subnet-evm/utils/bytes.go | 44 ----- graft/subnet-evm/utils/bytes_test.go | 66 -------- graft/subnet-evm/utils/denomination.go | 10 -- graft/subnet-evm/utils/numbers.go | 64 -------- graft/subnet-evm/utils/numbers_test.go | 139 ---------------- graft/subnet-evm/utils/rand/rand.go | 32 ---- graft/subnet-evm/utils/utilstest/key.go | 32 ---- graft/subnet-evm/utils/utilstest/pointer.go | 6 - .../subnet-evm/warp/verifier_backend_test.go | 8 +- 161 files changed, 395 insertions(+), 837 deletions(-) delete mode 100644 graft/coreth/utils/metered_cache.go delete mode 100644 graft/coreth/utils/utilstest/snow.go rename graft/{coreth => evm}/utils/address_range.go (100%) rename graft/{coreth => evm}/utils/bounded_workers.go (100%) rename graft/{coreth => evm}/utils/bytes.go (100%) rename graft/{coreth => evm}/utils/bytes_test.go (100%) rename graft/{coreth => evm}/utils/denomination.go (100%) rename graft/{subnet-evm => evm}/utils/metered_cache.go (100%) rename graft/{coreth => evm}/utils/numbers.go (100%) rename graft/{coreth => evm}/utils/numbers_test.go (100%) rename graft/{coreth => evm}/utils/rand/rand.go (100%) rename graft/{coreth => evm}/utils/rpc/handler.go (99%) rename graft/{coreth => evm}/utils/utilstest/context.go (100%) rename graft/{coreth => evm}/utils/utilstest/key.go (100%) rename graft/{coreth => evm}/utils/utilstest/pointer.go (100%) rename graft/{subnet-evm => evm}/utils/utilstest/snow.go (84%) rename graft/{subnet-evm/utils/utilstest/context_test.go => evm/utils/utilstest/snow_test.go} (95%) rename graft/{coreth => evm}/utils/utilstest/timeout.go (100%) delete mode 100644 graft/subnet-evm/utils/address_range.go delete mode 100644 graft/subnet-evm/utils/bounded_workers.go delete mode 100644 graft/subnet-evm/utils/bytes.go delete mode 100644 graft/subnet-evm/utils/bytes_test.go delete mode 100644 graft/subnet-evm/utils/denomination.go delete mode 100644 graft/subnet-evm/utils/numbers.go delete mode 100644 graft/subnet-evm/utils/numbers_test.go delete mode 100644 graft/subnet-evm/utils/rand/rand.go delete mode 100644 graft/subnet-evm/utils/utilstest/key.go delete mode 100644 graft/subnet-evm/utils/utilstest/pointer.go diff --git a/go.mod b/go.mod index ed08b5e0dd22..cef9828a89a2 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/google/renameio/v2 v2.0.0 github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.0 - github.com/gorilla/rpc v1.2.0 + github.com/gorilla/rpc v1.2.1 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/holiman/uint256 v1.2.4 github.com/huin/goupnp v1.3.0 diff --git a/go.sum b/go.sum index 7118fd339ecf..44c29a4af826 100644 --- a/go.sum +++ b/go.sum @@ -366,8 +366,8 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk= -github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ= +github.com/gorilla/rpc v1.2.1 h1:yC+LMV5esttgpVvNORL/xX4jvTTEUE30UZhZ5JF7K9k= +github.com/gorilla/rpc v1.2.1/go.mod h1:uNpOihAlF5xRFLuTYhfR0yfCTm0WTQSQttkMSptRfGk= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= diff --git a/graft/coreth/consensus/dummy/consensus.go b/graft/coreth/consensus/dummy/consensus.go index 179a5bae7d0f..8568ea5bc494 100644 --- a/graft/coreth/consensus/dummy/consensus.go +++ b/graft/coreth/consensus/dummy/consensus.go @@ -18,7 +18,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params/extras" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/customheader" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/customtypes" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/vms/components/gas" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/coreth/core/extstate/options.go b/graft/coreth/core/extstate/options.go index 78dec2e8908b..e9776910c64d 100644 --- a/graft/coreth/core/extstate/options.go +++ b/graft/coreth/core/extstate/options.go @@ -6,7 +6,7 @@ package extstate import ( "github.com/ava-labs/libevm/core/state" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) type workerPool struct { diff --git a/graft/coreth/core/genesis_extra_test.go b/graft/coreth/core/genesis_extra_test.go index 83cbeed12fe7..b312c28152ff 100644 --- a/graft/coreth/core/genesis_extra_test.go +++ b/graft/coreth/core/genesis_extra_test.go @@ -35,7 +35,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" "github.com/ava-labs/avalanchego/graft/coreth/params/paramstest" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade/upgradetest" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" diff --git a/graft/coreth/core/genesis_test.go b/graft/coreth/core/genesis_test.go index cb8aa520c314..8d76c1c9fa01 100644 --- a/graft/coreth/core/genesis_test.go +++ b/graft/coreth/core/genesis_test.go @@ -42,7 +42,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/precompile/contracts/warp" "github.com/ava-labs/avalanchego/graft/coreth/triedb/firewood" "github.com/ava-labs/avalanchego/graft/coreth/triedb/pathdb" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" diff --git a/graft/coreth/core/state/snapshot/difflayer_test.go b/graft/coreth/core/state/snapshot/difflayer_test.go index c32a7b09a213..b20845806bcd 100644 --- a/graft/coreth/core/state/snapshot/difflayer_test.go +++ b/graft/coreth/core/state/snapshot/difflayer_test.go @@ -33,7 +33,7 @@ import ( "math/rand" "testing" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/crypto" "github.com/ava-labs/libevm/ethdb/memorydb" diff --git a/graft/coreth/core/state/snapshot/disklayer.go b/graft/coreth/core/state/snapshot/disklayer.go index eaf6edc0c4ac..dfa2891c35d4 100644 --- a/graft/coreth/core/state/snapshot/disklayer.go +++ b/graft/coreth/core/state/snapshot/disklayer.go @@ -32,7 +32,7 @@ import ( "sync" "time" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" diff --git a/graft/coreth/core/state/snapshot/generate.go b/graft/coreth/core/state/snapshot/generate.go index dc1020ad41a9..33c4e4402a4b 100644 --- a/graft/coreth/core/state/snapshot/generate.go +++ b/graft/coreth/core/state/snapshot/generate.go @@ -32,7 +32,7 @@ import ( "fmt" "time" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" diff --git a/graft/coreth/core/state/snapshot/snapshot_ext.go b/graft/coreth/core/state/snapshot/snapshot_ext.go index 446d21b38f9d..165a1cb12869 100644 --- a/graft/coreth/core/state/snapshot/snapshot_ext.go +++ b/graft/coreth/core/state/snapshot/snapshot_ext.go @@ -9,7 +9,7 @@ import ( "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/ethdb" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) func (t *Tree) DiskAccountIterator(seek common.Hash) AccountIterator { diff --git a/graft/coreth/core/state_processor_test.go b/graft/coreth/core/state_processor_test.go index 430f3a77a0ef..7ee64bc6594e 100644 --- a/graft/coreth/core/state_processor_test.go +++ b/graft/coreth/core/state_processor_test.go @@ -41,7 +41,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap1" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap3" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/cortina" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/vms/evm/acp176" "github.com/ava-labs/libevm/common" diff --git a/graft/coreth/core/txpool/legacypool/legacypool.go b/graft/coreth/core/txpool/legacypool/legacypool.go index f1acc9112817..20728a6e1e94 100644 --- a/graft/coreth/core/txpool/legacypool/legacypool.go +++ b/graft/coreth/core/txpool/legacypool/legacypool.go @@ -41,7 +41,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/core/txpool" "github.com/ava-labs/avalanchego/graft/coreth/params" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/customheader" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/common/prque" "github.com/ava-labs/libevm/core/state" diff --git a/graft/coreth/go.mod b/graft/coreth/go.mod index eb965913a091..5ac1ca0556f9 100644 --- a/graft/coreth/go.mod +++ b/graft/coreth/go.mod @@ -17,7 +17,6 @@ require ( github.com/deckarep/golang-set/v2 v2.1.0 github.com/go-cmd/cmd v1.4.3 github.com/google/go-cmp v0.7.0 - github.com/gorilla/rpc v1.2.0 github.com/gorilla/websocket v1.5.0 github.com/hashicorp/go-bexpr v0.1.10 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d @@ -48,7 +47,6 @@ require ( require ( connectrpc.com/connect v1.18.1 // indirect connectrpc.com/grpcreflect v1.3.0 // indirect - github.com/BurntSushi/toml v1.5.0 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/StephenButtolph/canoto v0.17.3 // indirect @@ -98,6 +96,7 @@ require ( github.com/google/renameio/v2 v2.0.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/mux v1.8.0 // indirect + github.com/gorilla/rpc v1.2.1 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // indirect github.com/huin/goupnp v1.3.0 // indirect diff --git a/graft/coreth/go.sum b/graft/coreth/go.sum index c65f9be802c7..6f9b34db9c77 100644 --- a/graft/coreth/go.sum +++ b/graft/coreth/go.sum @@ -251,8 +251,8 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk= -github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ= +github.com/gorilla/rpc v1.2.1 h1:yC+LMV5esttgpVvNORL/xX4jvTTEUE30UZhZ5JF7K9k= +github.com/gorilla/rpc v1.2.1/go.mod h1:uNpOihAlF5xRFLuTYhfR0yfCTm0WTQSQttkMSptRfGk= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= diff --git a/graft/coreth/internal/ethapi/api_test.go b/graft/coreth/internal/ethapi/api_test.go index 1cd365845c4b..440fb42ec166 100644 --- a/graft/coreth/internal/ethapi/api_test.go +++ b/graft/coreth/internal/ethapi/api_test.go @@ -49,7 +49,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap3" "github.com/ava-labs/avalanchego/graft/coreth/rpc" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/libevm/accounts" "github.com/ava-labs/libevm/accounts/keystore" "github.com/ava-labs/libevm/common" diff --git a/graft/coreth/network/peer_tracker.go b/graft/coreth/network/peer_tracker.go index 9240af664d4d..9768aa5ae34d 100644 --- a/graft/coreth/network/peer_tracker.go +++ b/graft/coreth/network/peer_tracker.go @@ -10,7 +10,7 @@ import ( "github.com/ava-labs/libevm/log" "github.com/ava-labs/libevm/metrics" - "github.com/ava-labs/avalanchego/graft/coreth/utils/rand" + "github.com/ava-labs/avalanchego/graft/evm/utils/rand" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/version" diff --git a/graft/coreth/params/config.go b/graft/coreth/params/config.go index 277fd57a2565..95761e167c0f 100644 --- a/graft/coreth/params/config.go +++ b/graft/coreth/params/config.go @@ -31,7 +31,7 @@ import ( "math/big" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/libevm/libevm" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/coreth/params/config_extra.go b/graft/coreth/params/config_extra.go index a49b03ed7f65..05a967ea7da2 100644 --- a/graft/coreth/params/config_extra.go +++ b/graft/coreth/params/config_extra.go @@ -10,7 +10,7 @@ import ( "math/big" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade" ) diff --git a/graft/coreth/params/config_extra_test.go b/graft/coreth/params/config_extra_test.go index 026a8d45c6b3..01fad0674c02 100644 --- a/graft/coreth/params/config_extra_test.go +++ b/graft/coreth/params/config_extra_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade/upgradetest" ) diff --git a/graft/coreth/params/config_test.go b/graft/coreth/params/config_test.go index 6594ecd15de1..e832409a34a0 100644 --- a/graft/coreth/params/config_test.go +++ b/graft/coreth/params/config_test.go @@ -35,7 +35,7 @@ import ( "time" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/coreth/params/extras/config.go b/graft/coreth/params/extras/config.go index 468dfcc65514..91407f32a9bb 100644 --- a/graft/coreth/params/extras/config.go +++ b/graft/coreth/params/extras/config.go @@ -10,7 +10,7 @@ import ( "github.com/ava-labs/libevm/common" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/snow" ethparams "github.com/ava-labs/libevm/params" diff --git a/graft/coreth/params/extras/config_extra_test.go b/graft/coreth/params/extras/config_extra_test.go index f6e0adf6c6e3..ffc1997b5aaf 100644 --- a/graft/coreth/params/extras/config_extra_test.go +++ b/graft/coreth/params/extras/config_extra_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) func TestIsTimestampForked(t *testing.T) { diff --git a/graft/coreth/params/extras/network_upgrades.go b/graft/coreth/params/extras/network_upgrades.go index 3d25a57b45b9..3943be83a7d1 100644 --- a/graft/coreth/params/extras/network_upgrades.go +++ b/graft/coreth/params/extras/network_upgrades.go @@ -8,7 +8,7 @@ import ( "reflect" "strconv" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade" ethparams "github.com/ava-labs/libevm/params" diff --git a/graft/coreth/params/extras/precompile_upgrade.go b/graft/coreth/params/extras/precompile_upgrade.go index f6bb261af3eb..f5ef7b184a50 100644 --- a/graft/coreth/params/extras/precompile_upgrade.go +++ b/graft/coreth/params/extras/precompile_upgrade.go @@ -12,7 +12,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/precompile/modules" "github.com/ava-labs/avalanchego/graft/coreth/precompile/precompileconfig" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/coreth/plugin/evm/atomic/vm/block_extension.go b/graft/coreth/plugin/evm/atomic/vm/block_extension.go index 74a30a11522f..d41dfdec9236 100644 --- a/graft/coreth/plugin/evm/atomic/vm/block_extension.go +++ b/graft/coreth/plugin/evm/atomic/vm/block_extension.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/customtypes" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/extension" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap5" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" safemath "github.com/ava-labs/avalanchego/utils/math" ) diff --git a/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go b/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go index 4a990a80ec2a..8023f68fe4e2 100644 --- a/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go +++ b/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go @@ -15,7 +15,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params/extras/extrastest" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/atomic" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmtest" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/upgrade/upgradetest" diff --git a/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go b/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go index 60624f8b5330..719e9d6fda97 100644 --- a/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go +++ b/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/atomic" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap0" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmtest" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/upgrade/upgradetest" diff --git a/graft/coreth/plugin/evm/atomic/vm/tx_gossip_test.go b/graft/coreth/plugin/evm/atomic/vm/tx_gossip_test.go index a17e6294e6e1..b2b120645ef5 100644 --- a/graft/coreth/plugin/evm/atomic/vm/tx_gossip_test.go +++ b/graft/coreth/plugin/evm/atomic/vm/tx_gossip_test.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/avalanchego/database/memdb" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/atomic" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmtest" - "github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/network/p2p/gossip" diff --git a/graft/coreth/plugin/evm/atomic/vm/tx_test.go b/graft/coreth/plugin/evm/atomic/vm/tx_test.go index dc2d66e1075e..b8104520ba59 100644 --- a/graft/coreth/plugin/evm/atomic/vm/tx_test.go +++ b/graft/coreth/plugin/evm/atomic/vm/tx_test.go @@ -12,7 +12,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params/extras" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/atomic" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/upgrade/upgradetest" diff --git a/graft/coreth/plugin/evm/atomic/vm/vm.go b/graft/coreth/plugin/evm/atomic/vm/vm.go index 53e53918634c..60bf1d68aaa1 100644 --- a/graft/coreth/plugin/evm/atomic/vm/vm.go +++ b/graft/coreth/plugin/evm/atomic/vm/vm.go @@ -32,8 +32,8 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/message" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap5" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmerrors" - "github.com/ava-labs/avalanchego/graft/coreth/utils" - "github.com/ava-labs/avalanchego/graft/coreth/utils/rpc" + "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils/rpc" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/snow" diff --git a/graft/coreth/plugin/evm/atomic/vm/vm_test.go b/graft/coreth/plugin/evm/atomic/vm/vm_test.go index d7cbc79404bb..4399052eedef 100644 --- a/graft/coreth/plugin/evm/atomic/vm/vm_test.go +++ b/graft/coreth/plugin/evm/atomic/vm/vm_test.go @@ -29,7 +29,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap0" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap1" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmtest" - "github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/upgrade/upgradetest" diff --git a/graft/coreth/plugin/evm/config/default_config.go b/graft/coreth/plugin/evm/config/default_config.go index 5f070a0ce62b..6d01b9080e89 100644 --- a/graft/coreth/plugin/evm/config/default_config.go +++ b/graft/coreth/plugin/evm/config/default_config.go @@ -8,7 +8,7 @@ import ( "github.com/ava-labs/libevm/common" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) const defaultCommitInterval = 4096 diff --git a/graft/coreth/plugin/evm/customheader/base_fee_test.go b/graft/coreth/plugin/evm/customheader/base_fee_test.go index 6145b3687ebd..293f60f000bb 100644 --- a/graft/coreth/plugin/evm/customheader/base_fee_test.go +++ b/graft/coreth/plugin/evm/customheader/base_fee_test.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap4" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap5" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/etna" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/vms/components/gas" "github.com/ava-labs/avalanchego/vms/evm/acp176" ) diff --git a/graft/coreth/plugin/evm/customheader/extra_test.go b/graft/coreth/plugin/evm/customheader/extra_test.go index 856f465e79c3..8fa49413163f 100644 --- a/graft/coreth/plugin/evm/customheader/extra_test.go +++ b/graft/coreth/plugin/evm/customheader/extra_test.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap3" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap4" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap5" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/vms/components/gas" "github.com/ava-labs/avalanchego/vms/evm/acp176" ) diff --git a/graft/coreth/plugin/evm/customheader/gas_limit_test.go b/graft/coreth/plugin/evm/customheader/gas_limit_test.go index a2cbf73da4f8..18dceed980bb 100644 --- a/graft/coreth/plugin/evm/customheader/gas_limit_test.go +++ b/graft/coreth/plugin/evm/customheader/gas_limit_test.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap1" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap5" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/cortina" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/utils/math" "github.com/ava-labs/avalanchego/vms/components/gas" "github.com/ava-labs/avalanchego/vms/evm/acp176" diff --git a/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go b/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go index 99947b1cea97..966c0c757d60 100644 --- a/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go +++ b/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go @@ -11,8 +11,8 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params/extras" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/customtypes" - "github.com/ava-labs/avalanchego/graft/coreth/utils" - "github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/coreth/plugin/evm/customheader/time_test.go b/graft/coreth/plugin/evm/customheader/time_test.go index 80c81736b457..7faf0cd91f4e 100644 --- a/graft/coreth/plugin/evm/customheader/time_test.go +++ b/graft/coreth/plugin/evm/customheader/time_test.go @@ -12,7 +12,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params/extras" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/customtypes" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/coreth/plugin/evm/customtypes/block_ext_test.go b/graft/coreth/plugin/evm/customtypes/block_ext_test.go index 1fd90208bfe0..55aca7f4dc49 100644 --- a/graft/coreth/plugin/evm/customtypes/block_ext_test.go +++ b/graft/coreth/plugin/evm/customtypes/block_ext_test.go @@ -16,8 +16,8 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/coreth/utils" - "github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/coreth/plugin/evm/customtypes/header_ext_test.go b/graft/coreth/plugin/evm/customtypes/header_ext_test.go index 2b8c5d69750b..c6857a4d5d4e 100644 --- a/graft/coreth/plugin/evm/customtypes/header_ext_test.go +++ b/graft/coreth/plugin/evm/customtypes/header_ext_test.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/libevm/rlp" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/coreth/plugin/evm/gossip_test.go b/graft/coreth/plugin/evm/gossip_test.go index 15523adc24b6..8cda531b8501 100644 --- a/graft/coreth/plugin/evm/gossip_test.go +++ b/graft/coreth/plugin/evm/gossip_test.go @@ -24,7 +24,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/core/txpool" "github.com/ava-labs/avalanchego/graft/coreth/core/txpool/legacypool" "github.com/ava-labs/avalanchego/graft/coreth/params" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/network/p2p/gossip" ) diff --git a/graft/coreth/plugin/evm/tx_gossip_test.go b/graft/coreth/plugin/evm/tx_gossip_test.go index 5b4159eeb708..2e1332ba9ec7 100644 --- a/graft/coreth/plugin/evm/tx_gossip_test.go +++ b/graft/coreth/plugin/evm/tx_gossip_test.go @@ -19,7 +19,7 @@ import ( "github.com/ava-labs/avalanchego/database/memdb" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap0" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmtest" - "github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/network/p2p/gossip" diff --git a/graft/coreth/plugin/evm/upgrade/ap0/params.go b/graft/coreth/plugin/evm/upgrade/ap0/params.go index 59651c6d24be..f06d73724f22 100644 --- a/graft/coreth/plugin/evm/upgrade/ap0/params.go +++ b/graft/coreth/plugin/evm/upgrade/ap0/params.go @@ -5,7 +5,7 @@ package ap0 import ( - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/utils/units" ) diff --git a/graft/coreth/plugin/evm/upgrade/ap1/params.go b/graft/coreth/plugin/evm/upgrade/ap1/params.go index 732d7070ea0e..f3ae849b2542 100644 --- a/graft/coreth/plugin/evm/upgrade/ap1/params.go +++ b/graft/coreth/plugin/evm/upgrade/ap1/params.go @@ -4,7 +4,7 @@ // AP1 defines constants used after the Apricot Phase 1 upgrade. package ap1 -import "github.com/ava-labs/avalanchego/graft/coreth/utils" +import "github.com/ava-labs/avalanchego/graft/evm/utils" const ( // MinGasPrice is the minimum gas price of a transaction after the Apricot diff --git a/graft/coreth/plugin/evm/upgrade/ap3/window.go b/graft/coreth/plugin/evm/upgrade/ap3/window.go index 5b99ad028de7..de20c4380efd 100644 --- a/graft/coreth/plugin/evm/upgrade/ap3/window.go +++ b/graft/coreth/plugin/evm/upgrade/ap3/window.go @@ -10,7 +10,7 @@ import ( "fmt" "math" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/utils/wrappers" safemath "github.com/ava-labs/libevm/common/math" diff --git a/graft/coreth/plugin/evm/upgrade/ap4/cost.go b/graft/coreth/plugin/evm/upgrade/ap4/cost.go index ad7b437aaf02..4b311f7d4c99 100644 --- a/graft/coreth/plugin/evm/upgrade/ap4/cost.go +++ b/graft/coreth/plugin/evm/upgrade/ap4/cost.go @@ -8,7 +8,7 @@ package ap4 import ( "math" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" safemath "github.com/ava-labs/avalanchego/utils/math" ) diff --git a/graft/coreth/plugin/evm/upgrade/etna/params.go b/graft/coreth/plugin/evm/upgrade/etna/params.go index d3ea0bd06063..c1bb7c3b7635 100644 --- a/graft/coreth/plugin/evm/upgrade/etna/params.go +++ b/graft/coreth/plugin/evm/upgrade/etna/params.go @@ -4,7 +4,7 @@ // Etna defines constants used after the Etna upgrade. package etna -import "github.com/ava-labs/avalanchego/graft/coreth/utils" +import "github.com/ava-labs/avalanchego/graft/evm/utils" // MinBaseFee is the minimum base fee specified in ACP-125 that is allowed after // the Etna upgrade. diff --git a/graft/coreth/plugin/evm/vm.go b/graft/coreth/plugin/evm/vm.go index e1a926874715..df47eea9e14b 100644 --- a/graft/coreth/plugin/evm/vm.go +++ b/graft/coreth/plugin/evm/vm.go @@ -85,7 +85,7 @@ import ( warpcontract "github.com/ava-labs/avalanchego/graft/coreth/precompile/contracts/warp" statesyncclient "github.com/ava-labs/avalanchego/graft/coreth/sync/client" handlerstats "github.com/ava-labs/avalanchego/graft/coreth/sync/handlers/stats" - utilsrpc "github.com/ava-labs/avalanchego/graft/coreth/utils/rpc" + utilsrpc "github.com/ava-labs/avalanchego/graft/evm/utils/rpc" avalanchegossip "github.com/ava-labs/avalanchego/network/p2p/gossip" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" avalancheUtils "github.com/ava-labs/avalanchego/utils" diff --git a/graft/coreth/plugin/evm/vm_test.go b/graft/coreth/plugin/evm/vm_test.go index 7bbd216e58d9..772298fdf396 100644 --- a/graft/coreth/plugin/evm/vm_test.go +++ b/graft/coreth/plugin/evm/vm_test.go @@ -42,9 +42,9 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap1" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmtest" "github.com/ava-labs/avalanchego/graft/coreth/rpc" - "github.com/ava-labs/avalanchego/graft/coreth/utils" - "github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest" "github.com/ava-labs/avalanchego/graft/evm/constants" + "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/upgrade" diff --git a/graft/coreth/plugin/evm/vm_warp_test.go b/graft/coreth/plugin/evm/vm_warp_test.go index 353f0e45f977..3cdc377fe04a 100644 --- a/graft/coreth/plugin/evm/vm_warp_test.go +++ b/graft/coreth/plugin/evm/vm_warp_test.go @@ -27,8 +27,8 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap0" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmtest" "github.com/ava-labs/avalanchego/graft/coreth/precompile/contract" - "github.com/ava-labs/avalanchego/graft/coreth/utils" "github.com/ava-labs/avalanchego/graft/coreth/warp" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/network/p2p/acp118" diff --git a/graft/coreth/plugin/evm/vmsync/registry_test.go b/graft/coreth/plugin/evm/vmsync/registry_test.go index 55f17d15d01f..6f27849a069c 100644 --- a/graft/coreth/plugin/evm/vmsync/registry_test.go +++ b/graft/coreth/plugin/evm/vmsync/registry_test.go @@ -15,7 +15,7 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/message" - "github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" syncpkg "github.com/ava-labs/avalanchego/graft/coreth/sync" ) diff --git a/graft/coreth/plugin/evm/vmtest/test_syncervm.go b/graft/coreth/plugin/evm/vmtest/test_syncervm.go index 14b448d57e3a..1c9d28e4307b 100644 --- a/graft/coreth/plugin/evm/vmtest/test_syncervm.go +++ b/graft/coreth/plugin/evm/vmtest/test_syncervm.go @@ -30,8 +30,8 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/extension" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmsync" "github.com/ava-labs/avalanchego/graft/coreth/sync/statesync/statesynctest" - "github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest" "github.com/ava-labs/avalanchego/graft/evm/constants" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/engine/enginetest" diff --git a/graft/coreth/precompile/contracts/warp/config_test.go b/graft/coreth/precompile/contracts/warp/config_test.go index 068523433ec3..cdd2ade7eb2d 100644 --- a/graft/coreth/precompile/contracts/warp/config_test.go +++ b/graft/coreth/precompile/contracts/warp/config_test.go @@ -10,7 +10,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/coreth/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/coreth/precompile/contracts/warp/predicate_test.go b/graft/coreth/precompile/contracts/warp/predicate_test.go index 709181d09b3b..364161fbc660 100644 --- a/graft/coreth/precompile/contracts/warp/predicate_test.go +++ b/graft/coreth/precompile/contracts/warp/predicate_test.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params/extras/extrastest" "github.com/ava-labs/avalanchego/graft/coreth/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/coreth/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" diff --git a/graft/coreth/precompile/modules/registerer.go b/graft/coreth/precompile/modules/registerer.go index 79379c755105..5e9d76d21408 100644 --- a/graft/coreth/precompile/modules/registerer.go +++ b/graft/coreth/precompile/modules/registerer.go @@ -10,8 +10,8 @@ import ( "github.com/ava-labs/libevm/common" - "github.com/ava-labs/avalanchego/graft/coreth/utils" "github.com/ava-labs/avalanchego/graft/evm/constants" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) var ( diff --git a/graft/coreth/precompile/precompileconfig/upgradeable.go b/graft/coreth/precompile/precompileconfig/upgradeable.go index 130673dd45a2..7cdd3244e7d8 100644 --- a/graft/coreth/precompile/precompileconfig/upgradeable.go +++ b/graft/coreth/precompile/precompileconfig/upgradeable.go @@ -3,7 +3,7 @@ package precompileconfig -import "github.com/ava-labs/avalanchego/graft/coreth/utils" +import "github.com/ava-labs/avalanchego/graft/evm/utils" // Upgrade contains the timestamp for the upgrade along with // a boolean [Disable]. If [Disable] is set, the upgrade deactivates diff --git a/graft/coreth/sync/client/leaf_syncer.go b/graft/coreth/sync/client/leaf_syncer.go index e1f3242e005e..0c0b06fecee5 100644 --- a/graft/coreth/sync/client/leaf_syncer.go +++ b/graft/coreth/sync/client/leaf_syncer.go @@ -13,7 +13,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/message" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) var ErrFailedToFetchLeafs = errors.New("failed to fetch leafs") diff --git a/graft/coreth/sync/handlers/leafs_request.go b/graft/coreth/sync/handlers/leafs_request.go index 33653b5738da..2f90b7562269 100644 --- a/graft/coreth/sync/handlers/leafs_request.go +++ b/graft/coreth/sync/handlers/leafs_request.go @@ -21,7 +21,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/message" "github.com/ava-labs/avalanchego/graft/coreth/sync/handlers/stats" "github.com/ava-labs/avalanchego/graft/coreth/sync/syncutils" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/ids" ) diff --git a/graft/coreth/sync/statesync/statesynctest/test_sync.go b/graft/coreth/sync/statesync/statesynctest/test_sync.go index 88159513ab1e..63104f3a8a45 100644 --- a/graft/coreth/sync/statesync/statesynctest/test_sync.go +++ b/graft/coreth/sync/statesync/statesynctest/test_sync.go @@ -11,7 +11,7 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/ava-labs/libevm/triedb" - "github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" ) // FillAccountsWithOverlappingStorage adds [numAccounts] randomly generated accounts to the secure trie at [root] diff --git a/graft/coreth/sync/statesync/statesynctest/test_trie.go b/graft/coreth/sync/statesync/statesynctest/test_trie.go index e9b3c79ca280..a07a929aa8e8 100644 --- a/graft/coreth/sync/statesync/statesynctest/test_trie.go +++ b/graft/coreth/sync/statesync/statesynctest/test_trie.go @@ -18,7 +18,7 @@ import ( "github.com/holiman/uint256" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/coreth/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/utils/wrappers" ) diff --git a/graft/coreth/sync/statesync/trie_segments.go b/graft/coreth/sync/statesync/trie_segments.go index 61f2068a72bf..e91980f290e4 100644 --- a/graft/coreth/sync/statesync/trie_segments.go +++ b/graft/coreth/sync/statesync/trie_segments.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/libevm/trie" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/message" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/utils/wrappers" "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" diff --git a/graft/coreth/tests/init.go b/graft/coreth/tests/init.go index b4a17047e755..23a8b59e73ab 100644 --- a/graft/coreth/tests/init.go +++ b/graft/coreth/tests/init.go @@ -36,7 +36,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/libevm/libevm" ) diff --git a/graft/coreth/triedb/hashdb/database.go b/graft/coreth/triedb/hashdb/database.go index 86b9c6a02a9c..30b6bb09c80a 100644 --- a/graft/coreth/triedb/hashdb/database.go +++ b/graft/coreth/triedb/hashdb/database.go @@ -34,7 +34,7 @@ import ( "sync" "time" - "github.com/ava-labs/avalanchego/graft/coreth/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" diff --git a/graft/coreth/utils/metered_cache.go b/graft/coreth/utils/metered_cache.go deleted file mode 100644 index f754f87ff892..000000000000 --- a/graft/coreth/utils/metered_cache.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utils - -import ( - "sync/atomic" - "time" - - "github.com/VictoriaMetrics/fastcache" - "github.com/ava-labs/libevm/metrics" -) - -// MeteredCache wraps *fastcache.Cache and periodically pulls stats from it. -type MeteredCache struct { - *fastcache.Cache - namespace string - - // stats to be surfaced - entriesCount metrics.Gauge - bytesSize metrics.Gauge - collisions metrics.Gauge - gets metrics.Gauge - sets metrics.Gauge - misses metrics.Gauge - statsTime metrics.Gauge - - // count all operations to decide when to update stats - ops uint64 - updateFrequency uint64 -} - -// NewMeteredCache returns a new MeteredCache that will update stats to the -// provided namespace once per each [updateFrequency] operations. -// Note: if [updateFrequency] is passed as 0, it will be treated as 1. -func NewMeteredCache(size int, namespace string, updateFrequency uint64) *MeteredCache { - if updateFrequency == 0 { - updateFrequency = 1 // avoid division by zero - } - mc := &MeteredCache{ - Cache: fastcache.New(size), - namespace: namespace, - updateFrequency: updateFrequency, - } - if namespace != "" { - // only register stats if a namespace is provided. - mc.entriesCount = metrics.GetOrRegisterGauge(namespace+"/entriesCount", nil) - mc.bytesSize = metrics.GetOrRegisterGauge(namespace+"/bytesSize", nil) - mc.collisions = metrics.GetOrRegisterGauge(namespace+"/collisions", nil) - mc.gets = metrics.GetOrRegisterGauge(namespace+"/gets", nil) - mc.sets = metrics.GetOrRegisterGauge(namespace+"/sets", nil) - mc.misses = metrics.GetOrRegisterGauge(namespace+"/misses", nil) - mc.statsTime = metrics.GetOrRegisterGauge(namespace+"/statsTime", nil) - } - return mc -} - -// updateStats updates metrics from fastcache -func (mc *MeteredCache) updateStatsIfNeeded() { - if mc.namespace == "" { - return - } - ops := atomic.AddUint64(&mc.ops, 1) - if ops%mc.updateFrequency != 0 { - return - } - - start := time.Now() - s := fastcache.Stats{} - mc.UpdateStats(&s) - mc.entriesCount.Update(int64(s.EntriesCount)) - mc.bytesSize.Update(int64(s.BytesSize)) - mc.collisions.Update(int64(s.Collisions)) - mc.gets.Update(int64(s.GetCalls)) - mc.sets.Update(int64(s.SetCalls)) - mc.misses.Update(int64(s.Misses)) - mc.statsTime.Inc(int64(time.Since(start))) // cumulative metric -} - -func (mc *MeteredCache) Del(k []byte) { - mc.updateStatsIfNeeded() - mc.Cache.Del(k) -} - -func (mc *MeteredCache) Get(dst, k []byte) []byte { - mc.updateStatsIfNeeded() - return mc.Cache.Get(dst, k) -} - -func (mc *MeteredCache) GetBig(dst, k []byte) []byte { - mc.updateStatsIfNeeded() - return mc.Cache.GetBig(dst, k) -} - -func (mc *MeteredCache) Has(k []byte) bool { - mc.updateStatsIfNeeded() - return mc.Cache.Has(k) -} - -func (mc *MeteredCache) HasGet(dst, k []byte) ([]byte, bool) { - mc.updateStatsIfNeeded() - return mc.Cache.HasGet(dst, k) -} - -func (mc *MeteredCache) Set(k, v []byte) { - mc.updateStatsIfNeeded() - mc.Cache.Set(k, v) -} - -func (mc *MeteredCache) SetBig(k, v []byte) { - mc.updateStatsIfNeeded() - mc.Cache.SetBig(k, v) -} diff --git a/graft/coreth/utils/utilstest/snow.go b/graft/coreth/utils/utilstest/snow.go deleted file mode 100644 index 931220cc6cde..000000000000 --- a/graft/coreth/utils/utilstest/snow.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utilstest - -import ( - "context" - "errors" - - "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/snowtest" - "github.com/ava-labs/avalanchego/snow/validators" - "github.com/ava-labs/avalanchego/snow/validators/validatorstest" - "github.com/ava-labs/avalanchego/utils/constants" -) - -func NewTestValidatorState() *validatorstest.State { - return &validatorstest.State{ - GetCurrentHeightF: func(context.Context) (uint64, error) { - return 0, nil - }, - GetSubnetIDF: func(_ context.Context, chainID ids.ID) (ids.ID, error) { - subnetID, ok := map[ids.ID]ids.ID{ - constants.PlatformChainID: constants.PrimaryNetworkID, - snowtest.XChainID: constants.PrimaryNetworkID, - snowtest.CChainID: constants.PrimaryNetworkID, - }[chainID] - if !ok { - return ids.Empty, errors.New("unknown chain") - } - return subnetID, nil - }, - GetValidatorSetF: func(context.Context, uint64, ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error) { - return map[ids.NodeID]*validators.GetValidatorOutput{}, nil - }, - GetCurrentValidatorSetF: func(context.Context, ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { - return map[ids.ID]*validators.GetCurrentValidatorOutput{}, 0, nil - }, - } -} diff --git a/graft/evm/go.mod b/graft/evm/go.mod index 855ca12e1a9a..45c5604472ed 100644 --- a/graft/evm/go.mod +++ b/graft/evm/go.mod @@ -2,12 +2,68 @@ module github.com/ava-labs/avalanchego/graft/evm go 1.24.9 -require github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 +require ( + github.com/VictoriaMetrics/fastcache v1.12.1 + github.com/ava-labs/avalanchego v0.0.0-00010101000000-000000000000 + github.com/ava-labs/libevm v1.13.15-0.20251016142715-1bccf4f2ddb2 + github.com/gorilla/rpc v1.2.1 + github.com/stretchr/testify v1.11.1 +) require ( + github.com/BurntSushi/toml v1.5.0 // indirect + github.com/DataDog/zstd v1.5.2 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.3.5 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/cenkalti/backoff/v5 v5.0.2 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect + github.com/google/renameio/v2 v2.0.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // indirect github.com/holiman/uint256 v1.2.4 // indirect + github.com/mr-tron/base58 v1.2.0 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/prometheus/client_golang v1.23.0 // indirect + github.com/prometheus/client_model v0.6.2 // indirect + github.com/prometheus/common v0.65.0 // indirect + github.com/prometheus/procfs v0.16.1 // indirect + github.com/shirou/gopsutil v3.21.11+incompatible // indirect + github.com/supranational/blst v0.3.14 // indirect + github.com/tklauser/go-sysconf v0.3.15 // indirect + github.com/tklauser/numcpus v0.10.0 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect + go.opentelemetry.io/otel v1.37.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.37.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0 // indirect + go.opentelemetry.io/otel/metric v1.37.0 // indirect + go.opentelemetry.io/otel/sdk v1.37.0 // indirect + go.opentelemetry.io/otel/trace v1.37.0 // indirect + go.opentelemetry.io/proto/otlp v1.7.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.45.0 // indirect + golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e // indirect + golang.org/x/net v0.47.0 // indirect golang.org/x/sys v0.38.0 // indirect + golang.org/x/term v0.37.0 // indirect + golang.org/x/text v0.31.0 // indirect + gonum.org/v1/gonum v0.16.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c // indirect + google.golang.org/grpc v1.75.0 // indirect + google.golang.org/protobuf v1.36.8 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) replace github.com/ava-labs/avalanchego => ../../ diff --git a/graft/evm/go.sum b/graft/evm/go.sum index b59abce5d4bf..45d2ad5470db 100644 --- a/graft/evm/go.sum +++ b/graft/evm/go.sum @@ -1,8 +1,161 @@ +github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= +github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= +github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= +github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= +github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= +github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= 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/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/btcsuite/btcd/btcec/v2 v2.3.5 h1:dpAlnAwmT1yIBm3exhT1/8iUSD98RDJM5vqJVQDQLiU= +github.com/btcsuite/btcd/btcec/v2 v2.3.5/go.mod h1:m22FrOAiuxl/tht9wIqAoGHcbnCCaPWyauO8y2LGGtQ= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cenkalti/backoff/v5 v5.0.2 h1:rIfFVxEf1QsI7E1ZHfp/B4DF/6QBAUhmgkxc0H7Zss8= +github.com/cenkalti/backoff/v5 v5.0.2/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U0x++OzVrdms8= +github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg= +github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/rpc v1.2.1 h1:yC+LMV5esttgpVvNORL/xX4jvTTEUE30UZhZ5JF7K9k= +github.com/gorilla/rpc v1.2.1/go.mod h1:uNpOihAlF5xRFLuTYhfR0yfCTm0WTQSQttkMSptRfGk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 h1:X5VWvz21y3gzm9Nw/kaUeku/1+uBhcekkmy4IkffJww= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1/go.mod h1:Zanoh4+gvIgluNqcfMVTJueD4wSS5hT7zTt4Mrutd90= github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= +github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.23.0 h1:ust4zpdl9r4trLY/gSjlm07PuiBq2ynaXXlptpfy8Uc= +github.com/prometheus/client_golang v1.23.0/go.mod h1:i/o0R9ByOnHX0McrTMTyhYvKE4haaf2mW08I+jGAjEE= +github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= +github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= +github.com/prometheus/common v0.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2VzE= +github.com/prometheus/common v0.65.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8= +github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg= +github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/sanity-io/litter v1.5.1 h1:dwnrSypP6q56o3lFxTU+t2fwQ9A+U5qrXVO4Qg9KwVU= +github.com/sanity-io/litter v1.5.1/go.mod h1:5Z71SvaYy5kcGtyglXOC9rrUi3c1E8CamFWjQsazTh0= +github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= +github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/supranational/blst v0.3.14 h1:xNMoHRJOTwMn63ip6qoWJ2Ymgvj7E2b9jY2FAwY+qRo= +github.com/supranational/blst v0.3.14/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/thepudds/fzgen v0.4.3 h1:srUP/34BulQaEwPP/uHZkdjUcUjIzL7Jkf4CBVryiP8= +github.com/thepudds/fzgen v0.4.3/go.mod h1:BhhwtRhzgvLWAjjcHDJ9pEiLD2Z9hrVIFjBCHJ//zJ4= +github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= +github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= +github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= +github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= +go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 h1:Ahq7pZmv87yiyn3jeFz/LekZmPLLdKejuO3NcK9MssM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0/go.mod h1:MJTqhM0im3mRLw1i8uGHnCvUEeS7VwRyxlLC78PA18M= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.37.0 h1:EtFWSnwW9hGObjkIdmlnWSydO+Qs8OwzfzXLUPg4xOc= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.37.0/go.mod h1:QjUEoiGCPkvFZ/MjK6ZZfNOS6mfVEVKYE99dFhuN2LI= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0 h1:FyjCyI9jVEfqhUh2MoSkmolPjfh5fp2hnV0b0irxH4Q= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0/go.mod h1:hYwym2nDEeZfG/motx0p7L7J1N1vyzIThemQsb4g2qY= +go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= +go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= +go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= +go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= +go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= +go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= +go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= +go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= +go.opentelemetry.io/proto/otlp v1.7.0 h1:jX1VolD6nHuFzOYso2E73H85i92Mv8JQYk0K9vz09os= +go.opentelemetry.io/proto/otlp v1.7.0/go.mod h1:fSKjH6YJ7HDlwzltzyMj036AJ3ejJLCgCSHGj4efDDo= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= +go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= +golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e h1:4qufH0hlUYs6AO6XmZC3GqfDPGSXHVXUFR6OND+iJX4= +golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= +golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= +gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= +google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 h1:FiusG7LWj+4byqhbvmB+Q93B/mOxJLN2DTozDuZm4EU= +google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7/go.mod h1:kXqgZtrWaf6qS3jZOCnCH7WYfrvFjkC51bM8fz3RsCA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c h1:qXWI/sQtv5UKboZ/zUk7h+mrf/lXORyI+n9DKDAusdg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c/go.mod h1:gw1tLEfykwDz2ET4a12jcXt4couGAm7IwsVaTy0Sflo= +google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4= +google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ= +google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= +google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/graft/coreth/utils/address_range.go b/graft/evm/utils/address_range.go similarity index 100% rename from graft/coreth/utils/address_range.go rename to graft/evm/utils/address_range.go diff --git a/graft/coreth/utils/bounded_workers.go b/graft/evm/utils/bounded_workers.go similarity index 100% rename from graft/coreth/utils/bounded_workers.go rename to graft/evm/utils/bounded_workers.go diff --git a/graft/coreth/utils/bytes.go b/graft/evm/utils/bytes.go similarity index 100% rename from graft/coreth/utils/bytes.go rename to graft/evm/utils/bytes.go diff --git a/graft/coreth/utils/bytes_test.go b/graft/evm/utils/bytes_test.go similarity index 100% rename from graft/coreth/utils/bytes_test.go rename to graft/evm/utils/bytes_test.go diff --git a/graft/coreth/utils/denomination.go b/graft/evm/utils/denomination.go similarity index 100% rename from graft/coreth/utils/denomination.go rename to graft/evm/utils/denomination.go diff --git a/graft/subnet-evm/utils/metered_cache.go b/graft/evm/utils/metered_cache.go similarity index 100% rename from graft/subnet-evm/utils/metered_cache.go rename to graft/evm/utils/metered_cache.go diff --git a/graft/coreth/utils/numbers.go b/graft/evm/utils/numbers.go similarity index 100% rename from graft/coreth/utils/numbers.go rename to graft/evm/utils/numbers.go diff --git a/graft/coreth/utils/numbers_test.go b/graft/evm/utils/numbers_test.go similarity index 100% rename from graft/coreth/utils/numbers_test.go rename to graft/evm/utils/numbers_test.go diff --git a/graft/coreth/utils/rand/rand.go b/graft/evm/utils/rand/rand.go similarity index 100% rename from graft/coreth/utils/rand/rand.go rename to graft/evm/utils/rand/rand.go diff --git a/graft/coreth/utils/rpc/handler.go b/graft/evm/utils/rpc/handler.go similarity index 99% rename from graft/coreth/utils/rpc/handler.go rename to graft/evm/utils/rpc/handler.go index 0dab358d6167..5f3d63c02d5e 100644 --- a/graft/coreth/utils/rpc/handler.go +++ b/graft/evm/utils/rpc/handler.go @@ -6,8 +6,9 @@ package rpc import ( "net/http" - "github.com/ava-labs/avalanchego/utils/json" "github.com/gorilla/rpc/v2" + + "github.com/ava-labs/avalanchego/utils/json" ) // NewHandler returns a new Handler for a service where: diff --git a/graft/coreth/utils/utilstest/context.go b/graft/evm/utils/utilstest/context.go similarity index 100% rename from graft/coreth/utils/utilstest/context.go rename to graft/evm/utils/utilstest/context.go diff --git a/graft/coreth/utils/utilstest/key.go b/graft/evm/utils/utilstest/key.go similarity index 100% rename from graft/coreth/utils/utilstest/key.go rename to graft/evm/utils/utilstest/key.go diff --git a/graft/coreth/utils/utilstest/pointer.go b/graft/evm/utils/utilstest/pointer.go similarity index 100% rename from graft/coreth/utils/utilstest/pointer.go rename to graft/evm/utils/utilstest/pointer.go diff --git a/graft/subnet-evm/utils/utilstest/snow.go b/graft/evm/utils/utilstest/snow.go similarity index 84% rename from graft/subnet-evm/utils/utilstest/snow.go rename to graft/evm/utils/utilstest/snow.go index 5dafe8ad6b93..b006fa96518b 100644 --- a/graft/subnet-evm/utils/utilstest/snow.go +++ b/graft/evm/utils/utilstest/snow.go @@ -19,8 +19,6 @@ import ( // SubnetEVMTestChainID is a subnet-evm specific chain ID for testing var SubnetEVMTestChainID = ids.GenerateTestID() -// @TODO: This should eventually be replaced by a more robust solution, or alternatively, the presence of nil -// validator states shouldn't be depended upon by tests func NewTestValidatorState() *validatorstest.State { return &validatorstest.State{ GetCurrentHeightF: func(context.Context) (uint64, error) { @@ -41,15 +39,15 @@ func NewTestValidatorState() *validatorstest.State { GetValidatorSetF: func(context.Context, uint64, ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error) { return map[ids.NodeID]*validators.GetValidatorOutput{}, nil }, + GetCurrentValidatorSetF: func(context.Context, ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { + return map[ids.ID]*validators.GetCurrentValidatorOutput{}, 0, nil + }, GetWarpValidatorSetsF: func(context.Context, uint64) (map[ids.ID]validators.WarpSet, error) { return nil, nil }, GetWarpValidatorSetF: func(context.Context, uint64, ids.ID) (validators.WarpSet, error) { return validators.WarpSet{}, nil }, - GetCurrentValidatorSetF: func(context.Context, ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { - return map[ids.ID]*validators.GetCurrentValidatorOutput{}, 0, nil - }, } } @@ -64,18 +62,18 @@ func NewTestValidatorState() *validatorstest.State { // // snowCtx.ValidatorState = validatorState // // // Use: -// snowCtx := utils.NewTestSnowContext(t) +// snowCtx := utils.NewTestSnowContext(t, snowtest.CChainID) // // This function ensures that the snow context has a properly configured validator state // that includes the GetValidatorSetF function, which is required by many tests. -func NewTestSnowContext(t testing.TB) *snow.Context { - return NewTestSnowContextWithValidatorState(t, NewTestValidatorState()) +func NewTestSnowContext(t testing.TB, chainID ids.ID) *snow.Context { + return NewTestSnowContextWithValidatorState(t, chainID, NewTestValidatorState()) } // NewTestSnowContextWithValidatorState returns a snow.Context with the provided validator state. // This is useful when you need to customize the validator state behavior for specific tests. -func NewTestSnowContextWithValidatorState(t testing.TB, validatorState validators.State) *snow.Context { - snowCtx := snowtest.Context(t, SubnetEVMTestChainID) +func NewTestSnowContextWithValidatorState(t testing.TB, chainID ids.ID, validatorState validators.State) *snow.Context { + snowCtx := snowtest.Context(t, chainID) snowCtx.ValidatorState = validatorState return snowCtx } diff --git a/graft/subnet-evm/utils/utilstest/context_test.go b/graft/evm/utils/utilstest/snow_test.go similarity index 95% rename from graft/subnet-evm/utils/utilstest/context_test.go rename to graft/evm/utils/utilstest/snow_test.go index f6fc29639b99..f2c89a55568a 100644 --- a/graft/subnet-evm/utils/utilstest/context_test.go +++ b/graft/evm/utils/utilstest/snow_test.go @@ -13,7 +13,7 @@ import ( func TestNewTestSnowContext(t *testing.T) { // Test that NewTestSnowContext creates a context with validator state - snowCtx := NewTestSnowContext(t) + snowCtx := NewTestSnowContext(t, SubnetEVMTestChainID) require.NotNil(t, snowCtx.ValidatorState) // Test that the validator state has the required functions diff --git a/graft/coreth/utils/utilstest/timeout.go b/graft/evm/utils/utilstest/timeout.go similarity index 100% rename from graft/coreth/utils/utilstest/timeout.go rename to graft/evm/utils/utilstest/timeout.go diff --git a/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go b/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go index 29312e6042e3..87af5c8e39eb 100644 --- a/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go +++ b/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" {{- if .Contract.AllowList}} "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" diff --git a/graft/subnet-evm/commontype/fee_config.go b/graft/subnet-evm/commontype/fee_config.go index 0373d17030a9..10c452989ba3 100644 --- a/graft/subnet-evm/commontype/fee_config.go +++ b/graft/subnet-evm/commontype/fee_config.go @@ -10,7 +10,7 @@ import ( "github.com/ava-labs/libevm/common" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) var ( @@ -137,14 +137,14 @@ func (f *FeeConfig) Equal(other *FeeConfig) bool { return false } - return utils.BigNumEqual(f.GasLimit, other.GasLimit) && + return utils.BigEqual(f.GasLimit, other.GasLimit) && f.TargetBlockRate == other.TargetBlockRate && - utils.BigNumEqual(f.MinBaseFee, other.MinBaseFee) && - utils.BigNumEqual(f.TargetGas, other.TargetGas) && - utils.BigNumEqual(f.BaseFeeChangeDenominator, other.BaseFeeChangeDenominator) && - utils.BigNumEqual(f.MinBlockGasCost, other.MinBlockGasCost) && - utils.BigNumEqual(f.MaxBlockGasCost, other.MaxBlockGasCost) && - utils.BigNumEqual(f.BlockGasCostStep, other.BlockGasCostStep) + utils.BigEqual(f.MinBaseFee, other.MinBaseFee) && + utils.BigEqual(f.TargetGas, other.TargetGas) && + utils.BigEqual(f.BaseFeeChangeDenominator, other.BaseFeeChangeDenominator) && + utils.BigEqual(f.MinBlockGasCost, other.MinBlockGasCost) && + utils.BigEqual(f.MaxBlockGasCost, other.MaxBlockGasCost) && + utils.BigEqual(f.BlockGasCostStep, other.BlockGasCostStep) } // checkByteLens checks byte lengths against common.HashLen (32 bytes) and returns error diff --git a/graft/subnet-evm/consensus/dummy/consensus.go b/graft/subnet-evm/consensus/dummy/consensus.go index 7d233c8bfae8..bff6c874ddd2 100644 --- a/graft/subnet-evm/consensus/dummy/consensus.go +++ b/graft/subnet-evm/consensus/dummy/consensus.go @@ -13,13 +13,13 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/ava-labs/libevm/trie" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customheader" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/vmerrors" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/subnet-evm/core/blockchain_ext_test.go b/graft/subnet-evm/core/blockchain_ext_test.go index d828817c6cae..d2184e2e7e54 100644 --- a/graft/subnet-evm/core/blockchain_ext_test.go +++ b/graft/subnet-evm/core/blockchain_ext_test.go @@ -20,6 +20,7 @@ import ( "github.com/holiman/uint256" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" @@ -28,7 +29,6 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/feemanager" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/subnet-evm/core/extstate/options.go b/graft/subnet-evm/core/extstate/options.go index 2aee217b7597..e9776910c64d 100644 --- a/graft/subnet-evm/core/extstate/options.go +++ b/graft/subnet-evm/core/extstate/options.go @@ -6,7 +6,7 @@ package extstate import ( "github.com/ava-labs/libevm/core/state" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) type workerPool struct { diff --git a/graft/subnet-evm/core/genesis_extra_test.go b/graft/subnet-evm/core/genesis_extra_test.go index 9ec1a555b94c..a94b749d0ba4 100644 --- a/graft/subnet-evm/core/genesis_extra_test.go +++ b/graft/subnet-evm/core/genesis_extra_test.go @@ -14,11 +14,11 @@ import ( "github.com/ava-labs/libevm/triedb" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/paramstest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/upgrade/upgradetest" ) diff --git a/graft/subnet-evm/core/genesis_test.go b/graft/subnet-evm/core/genesis_test.go index c17fc91693d3..24e18a2b0686 100644 --- a/graft/subnet-evm/core/genesis_test.go +++ b/graft/subnet-evm/core/genesis_test.go @@ -35,6 +35,7 @@ import ( "reflect" "testing" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" @@ -44,7 +45,6 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/triedb/firewood" "github.com/ava-labs/avalanchego/graft/subnet-evm/triedb/pathdb" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/state" diff --git a/graft/subnet-evm/core/state/snapshot/difflayer_test.go b/graft/subnet-evm/core/state/snapshot/difflayer_test.go index a6940c3daccb..b20845806bcd 100644 --- a/graft/subnet-evm/core/state/snapshot/difflayer_test.go +++ b/graft/subnet-evm/core/state/snapshot/difflayer_test.go @@ -33,7 +33,7 @@ import ( "math/rand" "testing" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/crypto" "github.com/ava-labs/libevm/ethdb/memorydb" diff --git a/graft/subnet-evm/core/state/snapshot/disklayer.go b/graft/subnet-evm/core/state/snapshot/disklayer.go index 5b97ce29f238..dfa2891c35d4 100644 --- a/graft/subnet-evm/core/state/snapshot/disklayer.go +++ b/graft/subnet-evm/core/state/snapshot/disklayer.go @@ -32,7 +32,7 @@ import ( "sync" "time" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" diff --git a/graft/subnet-evm/core/state/snapshot/generate.go b/graft/subnet-evm/core/state/snapshot/generate.go index d50c10f383b4..5acc09da8a50 100644 --- a/graft/subnet-evm/core/state/snapshot/generate.go +++ b/graft/subnet-evm/core/state/snapshot/generate.go @@ -32,8 +32,8 @@ import ( "fmt" "time" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customrawdb" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" diff --git a/graft/subnet-evm/core/state/snapshot/snapshot_ext.go b/graft/subnet-evm/core/state/snapshot/snapshot_ext.go index d73e67a2a88d..165a1cb12869 100644 --- a/graft/subnet-evm/core/state/snapshot/snapshot_ext.go +++ b/graft/subnet-evm/core/state/snapshot/snapshot_ext.go @@ -9,7 +9,7 @@ import ( "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/ethdb" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) func (t *Tree) DiskAccountIterator(seek common.Hash) AccountIterator { diff --git a/graft/subnet-evm/core/state_processor_ext_test.go b/graft/subnet-evm/core/state_processor_ext_test.go index 817647f9ea4c..79d8beba15e6 100644 --- a/graft/subnet-evm/core/state_processor_ext_test.go +++ b/graft/subnet-evm/core/state_processor_ext_test.go @@ -14,12 +14,12 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/vmerrors" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/subnet-evm/core/state_processor_test.go b/graft/subnet-evm/core/state_processor_test.go index 8765c7dae0a8..f946a7b94754 100644 --- a/graft/subnet-evm/core/state_processor_test.go +++ b/graft/subnet-evm/core/state_processor_test.go @@ -32,6 +32,7 @@ import ( "math/big" "testing" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" @@ -39,7 +40,6 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customheader" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/upgrade/legacy" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/consensus/misc/eip4844" diff --git a/graft/subnet-evm/core/txpool/legacypool/legacypool.go b/graft/subnet-evm/core/txpool/legacypool/legacypool.go index 0746af6f5300..708a30d9cc6e 100644 --- a/graft/subnet-evm/core/txpool/legacypool/legacypool.go +++ b/graft/subnet-evm/core/txpool/legacypool/legacypool.go @@ -37,13 +37,13 @@ import ( "sync/atomic" "time" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/core/txpool" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customheader" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/feemanager" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/common/prque" "github.com/ava-labs/libevm/core/state" diff --git a/graft/subnet-evm/go.mod b/graft/subnet-evm/go.mod index bf2425df45a5..031de09d3a90 100644 --- a/graft/subnet-evm/go.mod +++ b/graft/subnet-evm/go.mod @@ -23,7 +23,7 @@ require ( 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 - github.com/gorilla/rpc v1.2.0 + github.com/gorilla/rpc v1.2.1 github.com/gorilla/websocket v1.5.0 github.com/hashicorp/go-bexpr v0.1.10 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d diff --git a/graft/subnet-evm/go.sum b/graft/subnet-evm/go.sum index 75dc5695d916..864ef188970e 100644 --- a/graft/subnet-evm/go.sum +++ b/graft/subnet-evm/go.sum @@ -278,8 +278,8 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk= -github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ= +github.com/gorilla/rpc v1.2.1 h1:yC+LMV5esttgpVvNORL/xX4jvTTEUE30UZhZ5JF7K9k= +github.com/gorilla/rpc v1.2.1/go.mod h1:uNpOihAlF5xRFLuTYhfR0yfCTm0WTQSQttkMSptRfGk= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= diff --git a/graft/subnet-evm/internal/ethapi/api_test.go b/graft/subnet-evm/internal/ethapi/api_test.go index 5f57ea545221..499983474365 100644 --- a/graft/subnet-evm/internal/ethapi/api_test.go +++ b/graft/subnet-evm/internal/ethapi/api_test.go @@ -42,6 +42,7 @@ import ( "testing" "time" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" @@ -50,7 +51,6 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/upgrade/legacy" "github.com/ava-labs/avalanchego/graft/subnet-evm/rpc" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/libevm/accounts" "github.com/ava-labs/libevm/accounts/keystore" diff --git a/graft/subnet-evm/network/peer_tracker.go b/graft/subnet-evm/network/peer_tracker.go index 635ec726c98d..9768aa5ae34d 100644 --- a/graft/subnet-evm/network/peer_tracker.go +++ b/graft/subnet-evm/network/peer_tracker.go @@ -10,7 +10,7 @@ import ( "github.com/ava-labs/libevm/log" "github.com/ava-labs/libevm/metrics" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/rand" + "github.com/ava-labs/avalanchego/graft/evm/utils/rand" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/version" diff --git a/graft/subnet-evm/params/config.go b/graft/subnet-evm/params/config.go index be4b1e747832..30e820a771e5 100644 --- a/graft/subnet-evm/params/config.go +++ b/graft/subnet-evm/params/config.go @@ -30,8 +30,8 @@ package params import ( "math/big" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/libevm/libevm" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/subnet-evm/params/config_extra.go b/graft/subnet-evm/params/config_extra.go index 0ab1874c86b7..afc8cb8459b7 100644 --- a/graft/subnet-evm/params/config_extra.go +++ b/graft/subnet-evm/params/config_extra.go @@ -8,8 +8,8 @@ import ( "errors" "math/big" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/upgrade" ) diff --git a/graft/subnet-evm/params/config_extra_test.go b/graft/subnet-evm/params/config_extra_test.go index 6a5532463863..8178a32e92b9 100644 --- a/graft/subnet-evm/params/config_extra_test.go +++ b/graft/subnet-evm/params/config_extra_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/upgrade/upgradetest" ) diff --git a/graft/subnet-evm/params/config_test.go b/graft/subnet-evm/params/config_test.go index aac1af6902b3..b64e8401226d 100644 --- a/graft/subnet-evm/params/config_test.go +++ b/graft/subnet-evm/params/config_test.go @@ -35,11 +35,11 @@ import ( "testing" "time" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/libevm/common" ethparams "github.com/ava-labs/libevm/params" "github.com/stretchr/testify/require" diff --git a/graft/subnet-evm/params/extras/config.go b/graft/subnet-evm/params/extras/config.go index e034c46d0f01..f806a4f80ea4 100644 --- a/graft/subnet-evm/params/extras/config.go +++ b/graft/subnet-evm/params/extras/config.go @@ -10,8 +10,8 @@ import ( "github.com/ava-labs/libevm/common" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/constants" diff --git a/graft/subnet-evm/params/extras/config_extra_test.go b/graft/subnet-evm/params/extras/config_extra_test.go index ab8f6e50589b..ffc1997b5aaf 100644 --- a/graft/subnet-evm/params/extras/config_extra_test.go +++ b/graft/subnet-evm/params/extras/config_extra_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) func TestIsTimestampForked(t *testing.T) { diff --git a/graft/subnet-evm/params/extras/network_upgrades.go b/graft/subnet-evm/params/extras/network_upgrades.go index eeb3af7e03e5..40c8d8981ec4 100644 --- a/graft/subnet-evm/params/extras/network_upgrades.go +++ b/graft/subnet-evm/params/extras/network_upgrades.go @@ -9,7 +9,7 @@ import ( "reflect" "strconv" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade" ethparams "github.com/ava-labs/libevm/params" diff --git a/graft/subnet-evm/params/extras/network_upgrades_test.go b/graft/subnet-evm/params/extras/network_upgrades_test.go index 2d37c9578d52..2af3baf97765 100644 --- a/graft/subnet-evm/params/extras/network_upgrades_test.go +++ b/graft/subnet-evm/params/extras/network_upgrades_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/upgrade/upgradetest" "github.com/ava-labs/avalanchego/utils/constants" diff --git a/graft/subnet-evm/params/extras/precompile_config_test.go b/graft/subnet-evm/params/extras/precompile_config_test.go index 6aab2c9b5f4f..697a22e910d4 100644 --- a/graft/subnet-evm/params/extras/precompile_config_test.go +++ b/graft/subnet-evm/params/extras/precompile_config_test.go @@ -11,6 +11,8 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" @@ -18,15 +20,13 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" ) func TestVerifyWithChainConfig(t *testing.T) { admins := []common.Address{{1}} c := *TestChainConfig config := &c - config.SnowCtx = utilstest.NewTestSnowContext(t) + config.SnowCtx = utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) config.GenesisPrecompiles = Precompiles{ txallowlist.ConfigKey: txallowlist.NewConfig(utils.NewUint64(2), nil, nil, nil), } @@ -72,7 +72,7 @@ func TestVerifyWithChainConfigAtNilTimestamp(t *testing.T) { admins := []common.Address{{0}} c := *TestChainConfig config := &c - config.SnowCtx = utilstest.NewTestSnowContext(t) + config.SnowCtx = utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) config.PrecompileUpgrades = []PrecompileUpgrade{ // this does NOT enable the precompile, so it should be upgradeable. {Config: txallowlist.NewConfig(nil, nil, nil, nil)}, @@ -193,7 +193,7 @@ func TestVerifyPrecompileUpgrades(t *testing.T) { require := require.New(t) c := *TestChainConfig config := &c - config.SnowCtx = utilstest.NewTestSnowContext(t) + config.SnowCtx = utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) config.PrecompileUpgrades = tt.upgrades err := config.Verify() @@ -234,7 +234,7 @@ func TestVerifyPrecompiles(t *testing.T) { require := require.New(t) c := *TestChainConfig config := &c - config.SnowCtx = utilstest.NewTestSnowContext(t) + config.SnowCtx = utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) config.GenesisPrecompiles = tt.precompiles err := config.Verify() @@ -248,7 +248,7 @@ func TestVerifyRequiresSortedTimestamps(t *testing.T) { config := &ChainConfig{ FeeConfig: DefaultFeeConfig, AvalancheContext: AvalancheContext{ - SnowCtx: utilstest.NewTestSnowContext(t), + SnowCtx: utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID), }, } config.PrecompileUpgrades = []PrecompileUpgrade{ diff --git a/graft/subnet-evm/params/extras/precompile_upgrade.go b/graft/subnet-evm/params/extras/precompile_upgrade.go index e84deee7122d..54504e88e37d 100644 --- a/graft/subnet-evm/params/extras/precompile_upgrade.go +++ b/graft/subnet-evm/params/extras/precompile_upgrade.go @@ -10,9 +10,9 @@ import ( "github.com/ava-labs/libevm/common" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/modules" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/subnet-evm/params/extras/precompile_upgrade_test.go b/graft/subnet-evm/params/extras/precompile_upgrade_test.go index e9974f6ce093..c5cd3b160524 100644 --- a/graft/subnet-evm/params/extras/precompile_upgrade_test.go +++ b/graft/subnet-evm/params/extras/precompile_upgrade_test.go @@ -10,9 +10,9 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) func TestVerifyUpgradeConfig(t *testing.T) { diff --git a/graft/subnet-evm/params/extras/state_upgrade_test.go b/graft/subnet-evm/params/extras/state_upgrade_test.go index 263c77e080d7..5a6cbcebad23 100644 --- a/graft/subnet-evm/params/extras/state_upgrade_test.go +++ b/graft/subnet-evm/params/extras/state_upgrade_test.go @@ -12,8 +12,8 @@ import ( "github.com/ava-labs/libevm/common/math" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" ) func TestVerifyStateUpgrades(t *testing.T) { @@ -64,7 +64,7 @@ func TestVerifyStateUpgrades(t *testing.T) { require := require.New(t) c := *TestChainConfig config := &c - config.SnowCtx = utilstest.NewTestSnowContext(t) + config.SnowCtx = utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) config.StateUpgrades = tt.upgrades err := config.Verify() diff --git a/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go b/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go index c7fbc7540ad4..892a7850f570 100644 --- a/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go @@ -11,10 +11,10 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/upgrade/subnetevm" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) const ( diff --git a/graft/subnet-evm/plugin/evm/customheader/block_gas_cost_test.go b/graft/subnet-evm/plugin/evm/customheader/block_gas_cost_test.go index 5191d20c413c..03f90a1ca242 100644 --- a/graft/subnet-evm/plugin/evm/customheader/block_gas_cost_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/block_gas_cost_test.go @@ -12,10 +12,10 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) var ( diff --git a/graft/subnet-evm/plugin/evm/customheader/extra_test.go b/graft/subnet-evm/plugin/evm/customheader/extra_test.go index 876565184b3a..3a7e6261513c 100644 --- a/graft/subnet-evm/plugin/evm/customheader/extra_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/extra_test.go @@ -11,10 +11,10 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/upgrade/subnetevm" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) func TestMain(m *testing.M) { diff --git a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go index d3c77dc2e0db..f49f698580b9 100644 --- a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go @@ -9,10 +9,10 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/subnet-evm/plugin/evm/customheader/time_test.go b/graft/subnet-evm/plugin/evm/customheader/time_test.go index 3884cff49d15..788377aa9204 100644 --- a/graft/subnet-evm/plugin/evm/customheader/time_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/time_test.go @@ -10,9 +10,9 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go b/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go index a3e9d91a151d..f9c8a2d7cf2f 100644 --- a/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go +++ b/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go @@ -12,9 +12,9 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/internal/blocktest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go b/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go index dc062c1787a7..603345d98aa6 100644 --- a/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go +++ b/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/libevm/rlp" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/subnet-evm/plugin/evm/gossip_test.go b/graft/subnet-evm/plugin/evm/gossip_test.go index 9bfb91143dce..38af2f31cd5e 100644 --- a/graft/subnet-evm/plugin/evm/gossip_test.go +++ b/graft/subnet-evm/plugin/evm/gossip_test.go @@ -19,12 +19,12 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/core/txpool" "github.com/ava-labs/avalanchego/graft/subnet-evm/core/txpool/legacypool" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/network/p2p/gossip" ) diff --git a/graft/subnet-evm/plugin/evm/syncervm_test.go b/graft/subnet-evm/plugin/evm/syncervm_test.go index 4b182b40b77d..aaac11315afa 100644 --- a/graft/subnet-evm/plugin/evm/syncervm_test.go +++ b/graft/subnet-evm/plugin/evm/syncervm_test.go @@ -25,13 +25,13 @@ import ( "github.com/ava-labs/avalanchego/api/metrics" "github.com/ava-labs/avalanchego/database/prefixdb" "github.com/ava-labs/avalanchego/graft/evm/constants" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/core/coretest" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/paramstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customrawdb" "github.com/ava-labs/avalanchego/graft/subnet-evm/sync/statesync/statesynctest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/engine/enginetest" diff --git a/graft/subnet-evm/plugin/evm/tx_gossip_test.go b/graft/subnet-evm/plugin/evm/tx_gossip_test.go index 050f7edee90a..7ff045874732 100644 --- a/graft/subnet-evm/plugin/evm/tx_gossip_test.go +++ b/graft/subnet-evm/plugin/evm/tx_gossip_test.go @@ -17,8 +17,8 @@ import ( "google.golang.org/protobuf/proto" "github.com/ava-labs/avalanchego/database/memdb" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/paramstest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/network/p2p/gossip" @@ -38,7 +38,7 @@ func TestEthTxGossip(t *testing.T) { require := require.New(t) ctx := t.Context() validatorState := utilstest.NewTestValidatorState() - snowCtx := utilstest.NewTestSnowContextWithValidatorState(t, validatorState) + snowCtx := utilstest.NewTestSnowContextWithValidatorState(t, utilstest.SubnetEVMTestChainID, validatorState) responseSender := &enginetest.SenderStub{ SentAppResponse: make(chan []byte, 1), @@ -159,7 +159,7 @@ func TestEthTxGossip(t *testing.T) { func TestEthTxPushGossipOutbound(t *testing.T) { require := require.New(t) ctx := t.Context() - snowCtx := utilstest.NewTestSnowContext(t) + snowCtx := utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) sender := &enginetest.SenderStub{ SentAppGossip: make(chan []byte, 1), } @@ -212,7 +212,7 @@ func TestEthTxPushGossipOutbound(t *testing.T) { func TestEthTxPushGossipInbound(t *testing.T) { require := require.New(t) ctx := t.Context() - snowCtx := utilstest.NewTestSnowContext(t) + snowCtx := utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) sender := &enginetest.Sender{} vm := &VM{ diff --git a/graft/subnet-evm/plugin/evm/vm_test.go b/graft/subnet-evm/plugin/evm/vm_test.go index 2db384e2cb7c..ba91943a4486 100644 --- a/graft/subnet-evm/plugin/evm/vm_test.go +++ b/graft/subnet-evm/plugin/evm/vm_test.go @@ -30,6 +30,8 @@ import ( "github.com/ava-labs/avalanchego/database/memdb" "github.com/ava-labs/avalanchego/database/prefixdb" "github.com/ava-labs/avalanchego/graft/evm/constants" + "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/core/txpool" @@ -50,8 +52,6 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/rpc" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/consensus/snowman" @@ -153,7 +153,7 @@ type testVM struct { } func newVM(t *testing.T, config testVMConfig) *testVM { - ctx := utilstest.NewTestSnowContext(t) + ctx := utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) fork := upgradetest.Latest if config.fork != nil { fork = *config.fork @@ -228,7 +228,7 @@ func setupGenesis( *prefixdb.Database, []byte, ) { - ctx := utilstest.NewTestSnowContext(t) + ctx := utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) genesisJSON := toGenesisJSON(paramstest.ForkToChainConfig[fork]) ctx.NetworkUpgrades = upgradetest.GetConfig(fork) @@ -2671,7 +2671,7 @@ func TestParentBeaconRootBlock(t *testing.T) { func TestStandaloneDB(t *testing.T) { vm := &VM{} - ctx := utilstest.NewTestSnowContext(t) + ctx := utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) baseDB := memdb.New() atomicMemory := atomic.NewMemory(prefixdb.New([]byte{0}, baseDB)) ctx.SharedMemory = atomicMemory.NewSharedMemory(ctx.ChainID) diff --git a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go index d85eddf4a53d..17b6ff99b6d2 100644 --- a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go +++ b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go @@ -19,13 +19,13 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/api/metrics" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/paramstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/vmerrors" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/upgrade/upgradetest" diff --git a/graft/subnet-evm/plugin/evm/vm_warp_test.go b/graft/subnet-evm/plugin/evm/vm_warp_test.go index f6a04ebee773..a3cdf85e3d1b 100644 --- a/graft/subnet-evm/plugin/evm/vm_warp_test.go +++ b/graft/subnet-evm/plugin/evm/vm_warp_test.go @@ -20,6 +20,7 @@ import ( _ "embed" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/eth/tracers" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" @@ -28,7 +29,6 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customheader" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/extension" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contract" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/warp" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" diff --git a/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go b/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go index 59565cf171e9..a5f69bfb86c6 100644 --- a/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go +++ b/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go @@ -11,11 +11,11 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/modules" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) // mkConfigWithAllowList creates a new config with the correct type for [module] diff --git a/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go b/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go index 6c3ee256d9db..416cb8ef06a2 100644 --- a/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go +++ b/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go @@ -9,11 +9,11 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go b/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go index cfb8c9bb8a35..aef41b7e0ed1 100644 --- a/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go @@ -11,6 +11,7 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" @@ -19,7 +20,6 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/utilstest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" sim "github.com/ava-labs/avalanchego/graft/subnet-evm/ethclient/simulated" allowlistbindings "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest/bindings" diff --git a/graft/subnet-evm/precompile/contracts/feemanager/config_test.go b/graft/subnet-evm/precompile/contracts/feemanager/config_test.go index 9e2a5e6b263e..337695002261 100644 --- a/graft/subnet-evm/precompile/contracts/feemanager/config_test.go +++ b/graft/subnet-evm/precompile/contracts/feemanager/config_test.go @@ -10,12 +10,12 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/feemanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) var validFeeConfig = commontype.FeeConfig{ diff --git a/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go b/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go index b434dd3b976c..1ea75e7768b7 100644 --- a/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go @@ -13,6 +13,7 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" @@ -23,7 +24,6 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/feemanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/utilstest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" sim "github.com/ava-labs/avalanchego/graft/subnet-evm/ethclient/simulated" feemanagerbindings "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/feemanager/feemanagertest/bindings" diff --git a/graft/subnet-evm/precompile/contracts/nativeminter/config.go b/graft/subnet-evm/precompile/contracts/nativeminter/config.go index 2a2fc298a265..c12f2cc70524 100644 --- a/graft/subnet-evm/precompile/contracts/nativeminter/config.go +++ b/graft/subnet-evm/precompile/contracts/nativeminter/config.go @@ -11,9 +11,9 @@ import ( "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/common/math" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) var ( @@ -84,7 +84,7 @@ func (c *Config) Equal(cfg precompileconfig.Config) bool { } bigIntAmount := (*big.Int)(amount) bigIntVal := (*big.Int)(val) - if !utils.BigNumEqual(bigIntAmount, bigIntVal) { + if !utils.BigEqual(bigIntAmount, bigIntVal) { return false } } diff --git a/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go b/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go index 39ca5e93419b..156938728f6d 100644 --- a/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go +++ b/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go @@ -10,12 +10,12 @@ import ( "github.com/ava-labs/libevm/common/math" "go.uber.org/mock/gomock" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go b/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go index e7b8ad23a11a..a97ceb875846 100644 --- a/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go @@ -12,6 +12,7 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" @@ -20,7 +21,6 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/utilstest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" sim "github.com/ava-labs/avalanchego/graft/subnet-evm/ethclient/simulated" nativeminterbindings "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter/nativemintertest/bindings" diff --git a/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go b/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go index e3238a933dcc..ee096478b004 100644 --- a/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go +++ b/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go @@ -9,11 +9,11 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go b/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go index 915cd01d814a..de1e0fdce811 100644 --- a/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go @@ -15,6 +15,7 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/graft/evm/constants" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/eth/ethconfig" @@ -25,7 +26,6 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/utilstest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" sim "github.com/ava-labs/avalanchego/graft/subnet-evm/ethclient/simulated" rewardmanagerbindings "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager/rewardmanagertest/bindings" diff --git a/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go b/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go index 0254b25be435..c5d920376b84 100644 --- a/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go +++ b/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go @@ -9,11 +9,11 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go b/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go index e9bde832a02c..55441b6793dd 100644 --- a/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go @@ -11,6 +11,7 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" @@ -20,7 +21,6 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/utilstest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" sim "github.com/ava-labs/avalanchego/graft/subnet-evm/ethclient/simulated" allowlistbindings "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest/bindings" diff --git a/graft/subnet-evm/precompile/contracts/warp/config_test.go b/graft/subnet-evm/precompile/contracts/warp/config_test.go index ef37fca44f37..9236fd30ca85 100644 --- a/graft/subnet-evm/precompile/contracts/warp/config_test.go +++ b/graft/subnet-evm/precompile/contracts/warp/config_test.go @@ -8,9 +8,9 @@ import ( "go.uber.org/mock/gomock" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/subnet-evm/precompile/contracts/warp/contract_test.go b/graft/subnet-evm/precompile/contracts/warp/contract_test.go index ef3ac23beb17..d7bf4a7892f2 100644 --- a/graft/subnet-evm/precompile/contracts/warp/contract_test.go +++ b/graft/subnet-evm/precompile/contracts/warp/contract_test.go @@ -12,12 +12,12 @@ import ( "github.com/ava-labs/libevm/core/vm" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/core/extstate" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras/extrastest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contract" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/upgrade/upgradetest" "github.com/ava-labs/avalanchego/utils/set" @@ -62,7 +62,7 @@ func runBenchmarks( func getBlockchainIDTests(tb testing.TB, rules extras.AvalancheRules) []precompiletest.PrecompileTest { callerAddr := common.HexToAddress("0x0123") - defaultSnowCtx := utilstest.NewTestSnowContext(tb) + defaultSnowCtx := utilstest.NewTestSnowContext(tb, utilstest.SubnetEVMTestChainID) blockchainID := defaultSnowCtx.ChainID gasConfig := CurrentGasConfig(rules) @@ -128,7 +128,7 @@ func BenchmarkGetBlockchainID(b *testing.B) { func sendWarpMessageTests(tb testing.TB, rules extras.AvalancheRules) []precompiletest.PrecompileTest { callerAddr := common.HexToAddress("0x0123") - defaultSnowCtx := utilstest.NewTestSnowContext(tb) + defaultSnowCtx := utilstest.NewTestSnowContext(tb, utilstest.SubnetEVMTestChainID) blockchainID := defaultSnowCtx.ChainID sendWarpMessagePayload := agoUtils.RandomBytes(100) diff --git a/graft/subnet-evm/precompile/contracts/warp/predicate_test.go b/graft/subnet-evm/precompile/contracts/warp/predicate_test.go index 0931a7f62769..09025e7e1bbf 100644 --- a/graft/subnet-evm/precompile/contracts/warp/predicate_test.go +++ b/graft/subnet-evm/precompile/contracts/warp/predicate_test.go @@ -12,15 +12,16 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras/extrastest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/snow/validators/validatorstest" "github.com/ava-labs/avalanchego/upgrade/upgradetest" @@ -225,7 +226,7 @@ func createSnowCtx(tb testing.TB, validatorRanges []validatorRange) *snow.Contex // results. warpValidators, warpValidatorsErr := validators.FlattenValidatorSet(validatorSet) - snowCtx := utilstest.NewTestSnowContext(tb) + snowCtx := snowtest.Context(tb, utilstest.SubnetEVMTestChainID) snowCtx.ValidatorState = &validatorstest.State{ GetSubnetIDF: func(context.Context, ids.ID) (ids.ID, error) { return sourceSubnetID, nil @@ -313,7 +314,7 @@ func testWarpMessageFromPrimaryNetwork(t *testing.T, requirePrimaryNetworkSigner pred := predicate.New(warpMsg.Bytes()) - snowCtx := utilstest.NewTestSnowContext(t) + snowCtx := utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) snowCtx.SubnetID = ids.GenerateTestID() snowCtx.ChainID = ids.GenerateTestID() snowCtx.CChainID = cChainID @@ -787,7 +788,7 @@ func makeWarpPredicateTests(tb testing.TB, rules extras.AvalancheRules) []precom warpValidators, err := validators.FlattenValidatorSet(validatorSet) require.NoError(tb, err) - snowCtx := utilstest.NewTestSnowContext(tb) + snowCtx := utilstest.NewTestSnowContext(tb, utilstest.SubnetEVMTestChainID) snowCtx.ValidatorState = &validatorstest.State{ GetSubnetIDF: func(context.Context, ids.ID) (ids.ID, error) { diff --git a/graft/subnet-evm/precompile/modules/registerer.go b/graft/subnet-evm/precompile/modules/registerer.go index e3a1f5e09f2e..5e9d76d21408 100644 --- a/graft/subnet-evm/precompile/modules/registerer.go +++ b/graft/subnet-evm/precompile/modules/registerer.go @@ -11,7 +11,7 @@ import ( "github.com/ava-labs/libevm/common" "github.com/ava-labs/avalanchego/graft/evm/constants" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" ) var ( diff --git a/graft/subnet-evm/precompile/precompileconfig/upgradeable.go b/graft/subnet-evm/precompile/precompileconfig/upgradeable.go index 1ef8ef62e51e..7cdd3244e7d8 100644 --- a/graft/subnet-evm/precompile/precompileconfig/upgradeable.go +++ b/graft/subnet-evm/precompile/precompileconfig/upgradeable.go @@ -3,7 +3,7 @@ package precompileconfig -import "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" +import "github.com/ava-labs/avalanchego/graft/evm/utils" // Upgrade contains the timestamp for the upgrade along with // a boolean [Disable]. If [Disable] is set, the upgrade deactivates diff --git a/graft/subnet-evm/precompile/precompiletest/test_precompile.go b/graft/subnet-evm/precompile/precompiletest/test_precompile.go index 1d9ef0ce24ab..d87f6bddb031 100644 --- a/graft/subnet-evm/precompile/precompiletest/test_precompile.go +++ b/graft/subnet-evm/precompile/precompiletest/test_precompile.go @@ -14,13 +14,13 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/core/extstate" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contract" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/modules" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" "github.com/ava-labs/avalanchego/vms/evm/predicate" ) @@ -178,7 +178,7 @@ func (test PrecompileTest) setup(t testing.TB, module modules.Module, state *tes } else { blockContext.EXPECT().Number().Return(big.NewInt(0)).AnyTimes() } - snowContext := utilstest.NewTestSnowContext(t) + snowContext := utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) // If Rules is explicitly set, use it; otherwise derive from ChainConfig rules := test.Rules diff --git a/graft/subnet-evm/sync/client/leaf_syncer.go b/graft/subnet-evm/sync/client/leaf_syncer.go index 186b56ca7200..006f2cbba0a5 100644 --- a/graft/subnet-evm/sync/client/leaf_syncer.go +++ b/graft/subnet-evm/sync/client/leaf_syncer.go @@ -13,8 +13,8 @@ import ( "github.com/ava-labs/libevm/log" "golang.org/x/sync/errgroup" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/message" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" ) var errFailedToFetchLeafs = errors.New("failed to fetch leafs") diff --git a/graft/subnet-evm/sync/handlers/leafs_request.go b/graft/subnet-evm/sync/handlers/leafs_request.go index 2bb177f41dc4..9bd2009e98e9 100644 --- a/graft/subnet-evm/sync/handlers/leafs_request.go +++ b/graft/subnet-evm/sync/handlers/leafs_request.go @@ -17,11 +17,11 @@ import ( "github.com/ava-labs/libevm/triedb" "github.com/ava-labs/avalanchego/codec" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/core/state/snapshot" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/message" "github.com/ava-labs/avalanchego/graft/subnet-evm/sync/handlers/stats" "github.com/ava-labs/avalanchego/graft/subnet-evm/sync/syncutils" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/ids" ) diff --git a/graft/subnet-evm/sync/statesync/statesynctest/test_sync.go b/graft/subnet-evm/sync/statesync/statesynctest/test_sync.go index 3d3a72219734..b8c2a004bf66 100644 --- a/graft/subnet-evm/sync/statesync/statesynctest/test_sync.go +++ b/graft/subnet-evm/sync/statesync/statesynctest/test_sync.go @@ -17,8 +17,8 @@ import ( "github.com/ava-labs/libevm/triedb" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customrawdb" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" ) // AssertDBConsistency checks [serverTrieDB] and [clientTrieDB] have the same EVM state trie at [root], diff --git a/graft/subnet-evm/sync/statesync/statesynctest/test_trie.go b/graft/subnet-evm/sync/statesync/statesynctest/test_trie.go index 7a1296cd20f6..a07a929aa8e8 100644 --- a/graft/subnet-evm/sync/statesync/statesynctest/test_trie.go +++ b/graft/subnet-evm/sync/statesync/statesynctest/test_trie.go @@ -18,7 +18,7 @@ import ( "github.com/holiman/uint256" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/utils/wrappers" ) diff --git a/graft/subnet-evm/sync/statesync/trie_segments.go b/graft/subnet-evm/sync/statesync/trie_segments.go index 96b8917a930e..0edd3302c3aa 100644 --- a/graft/subnet-evm/sync/statesync/trie_segments.go +++ b/graft/subnet-evm/sync/statesync/trie_segments.go @@ -16,8 +16,8 @@ import ( "github.com/ava-labs/libevm/log" "github.com/ava-labs/libevm/trie" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customrawdb" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/avalanchego/utils/wrappers" syncclient "github.com/ava-labs/avalanchego/graft/subnet-evm/sync/client" diff --git a/graft/subnet-evm/tests/init.go b/graft/subnet-evm/tests/init.go index ac4f1a6e227b..6dfe3f0b3786 100644 --- a/graft/subnet-evm/tests/init.go +++ b/graft/subnet-evm/tests/init.go @@ -34,9 +34,9 @@ import ( "sort" "strings" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" "github.com/ava-labs/libevm/libevm" ) diff --git a/graft/subnet-evm/triedb/hashdb/database.go b/graft/subnet-evm/triedb/hashdb/database.go index 8273cec6b6b0..30b6bb09c80a 100644 --- a/graft/subnet-evm/triedb/hashdb/database.go +++ b/graft/subnet-evm/triedb/hashdb/database.go @@ -34,7 +34,7 @@ import ( "sync" "time" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" diff --git a/graft/subnet-evm/utils/address_range.go b/graft/subnet-evm/utils/address_range.go deleted file mode 100644 index 6b8cd5b73f5c..000000000000 --- a/graft/subnet-evm/utils/address_range.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utils - -import ( - "bytes" - - "github.com/ava-labs/libevm/common" -) - -// AddressRange represents a continuous range of addresses -type AddressRange struct { - Start common.Address - End common.Address -} - -// Contains returns true iff [addr] is contained within the (inclusive) -// range of addresses defined by [a]. -func (a *AddressRange) Contains(addr common.Address) bool { - addrBytes := addr.Bytes() - return bytes.Compare(addrBytes, a.Start[:]) >= 0 && bytes.Compare(addrBytes, a.End[:]) <= 0 -} diff --git a/graft/subnet-evm/utils/bounded_workers.go b/graft/subnet-evm/utils/bounded_workers.go deleted file mode 100644 index a2bbe8007a53..000000000000 --- a/graft/subnet-evm/utils/bounded_workers.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utils - -import ( - "sync" - "sync/atomic" -) - -type BoundedWorkers struct { - workerCount atomic.Int32 - workerSpawner chan struct{} - outstandingWorkers sync.WaitGroup - - work chan func() - workClose sync.Once -} - -// NewBoundedWorkers returns an instance of [BoundedWorkers] that -// will spawn up to count goroutines. -func NewBoundedWorkers(count int) *BoundedWorkers { - return &BoundedWorkers{ - workerSpawner: make(chan struct{}, count), - work: make(chan func()), - } -} - -// startWorker creates a new goroutine to execute [f] immediately and then keeps the goroutine -// alive to continue executing new work. -func (b *BoundedWorkers) startWorker(f func()) { - b.workerCount.Add(1) - b.outstandingWorkers.Add(1) - - go func() { - defer b.outstandingWorkers.Done() - - if f != nil { - f() - } - for f := range b.work { - f() - } - }() -} - -// Execute the given function on an existing goroutine waiting for more work, a new goroutine, -// or return if the context is canceled. -// -// Execute must not be called after Wait, otherwise it might panic. -func (b *BoundedWorkers) Execute(f func()) { - // Ensure we feed idle workers first - select { - case b.work <- f: - return - default: - } - - // Fallback to waiting for an idle worker or allocating - // a new worker (if we aren't yet at max concurrency) - select { - case b.work <- f: - case b.workerSpawner <- struct{}{}: - b.startWorker(f) - } -} - -// Wait returns after all enqueued work finishes and all goroutines to exit. -// Wait returns the number of workers that were spawned during the run. -// -// Wait can only be called after ALL calls to [Execute] have returned. -// -// It is safe to call Wait multiple times but not safe to call [Execute] -// after [Wait] has been called. -func (b *BoundedWorkers) Wait() int { - b.workClose.Do(func() { - close(b.work) - }) - b.outstandingWorkers.Wait() - return int(b.workerCount.Load()) -} diff --git a/graft/subnet-evm/utils/bytes.go b/graft/subnet-evm/utils/bytes.go deleted file mode 100644 index 043d0b91bcb9..000000000000 --- a/graft/subnet-evm/utils/bytes.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utils - -import "github.com/ava-labs/libevm/common" - -// IncrOne increments bytes value by one -func IncrOne(bytes []byte) { - index := len(bytes) - 1 - for index >= 0 { - if bytes[index] < 255 { - bytes[index]++ - break - } else { - bytes[index] = 0 - index-- - } - } -} - -// HashSliceToBytes serializes a []common.Hash into a tightly packed byte array. -func HashSliceToBytes(hashes []common.Hash) []byte { - bytes := make([]byte, common.HashLength*len(hashes)) - for i, hash := range hashes { - copy(bytes[i*common.HashLength:], hash[:]) - } - return bytes -} - -// BytesToHashSlice packs [b] into a slice of hash values with zero padding -// to the right if the length of b is not a multiple of 32. -func BytesToHashSlice(b []byte) []common.Hash { - var ( - numHashes = (len(b) + 31) / 32 - hashes = make([]common.Hash, numHashes) - ) - - for i := range hashes { - start := i * common.HashLength - copy(hashes[i][:], b[start:]) - } - return hashes -} diff --git a/graft/subnet-evm/utils/bytes_test.go b/graft/subnet-evm/utils/bytes_test.go deleted file mode 100644 index f79dbfdbddee..000000000000 --- a/graft/subnet-evm/utils/bytes_test.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utils - -import ( - "bytes" - "testing" - - "github.com/ava-labs/libevm/common" - "github.com/stretchr/testify/require" - - "github.com/ava-labs/avalanchego/utils" -) - -func TestIncrOne(t *testing.T) { - type test struct { - input []byte - expected []byte - } - for name, test := range map[string]test{ - "increment no overflow no carry": { - input: []byte{0, 0}, - expected: []byte{0, 1}, - }, - "increment overflow": { - input: []byte{255, 255}, - expected: []byte{0, 0}, - }, - "increment carry": { - input: []byte{0, 255}, - expected: []byte{1, 0}, - }, - } { - t.Run(name, func(t *testing.T) { - output := common.CopyBytes(test.input) - IncrOne(output) - require.Equal(t, test.expected, output) - }) - } -} - -func testBytesToHashSlice(t testing.TB, b []byte) { - hashSlice := BytesToHashSlice(b) - - copiedBytes := HashSliceToBytes(hashSlice) - - if len(b)%32 == 0 { - require.Equal(t, b, copiedBytes) - } else { - require.Equal(t, b, copiedBytes[:len(b)]) - // Require that any additional padding is all zeroes - padding := copiedBytes[len(b):] - require.Equal(t, bytes.Repeat([]byte{0x00}, len(padding)), padding) - } -} - -func FuzzHashSliceToBytes(f *testing.F) { - for i := 0; i < 100; i++ { - f.Add(utils.RandomBytes(i)) - } - - f.Fuzz(func(t *testing.T, b []byte) { - testBytesToHashSlice(t, b) - }) -} diff --git a/graft/subnet-evm/utils/denomination.go b/graft/subnet-evm/utils/denomination.go deleted file mode 100644 index bc813a7c4d76..000000000000 --- a/graft/subnet-evm/utils/denomination.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utils - -const ( - Wei = 1 - GWei = 1_000_000_000 * Wei - Ether = 1_000_000_000 * GWei -) diff --git a/graft/subnet-evm/utils/numbers.go b/graft/subnet-evm/utils/numbers.go deleted file mode 100644 index 546fe1668f6b..000000000000 --- a/graft/subnet-evm/utils/numbers.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utils - -import ( - "math/big" - "time" -) - -func NewUint64(val uint64) *uint64 { return &val } - -func TimeToNewUint64(time time.Time) *uint64 { - unix := uint64(time.Unix()) - return NewUint64(unix) -} - -func Uint64ToTime(val *uint64) time.Time { - timestamp := int64(*val) - return time.Unix(timestamp, 0) -} - -// BigNumEqual returns true if x and y are equivalent ie. both nil or both -// contain the same value. -func BigNumEqual(x, y *big.Int) bool { - if x == nil || y == nil { - return x == y - } - return x.Cmp(y) == 0 -} - -// Uint64PtrEqual returns true if x and y pointers are equivalent ie. both nil or both -// contain the same value. -func Uint64PtrEqual(x, y *uint64) bool { - if x == nil || y == nil { - return x == y - } - return *x == *y -} - -// BigEqual returns true if a is equal to b. If a and b are nil, it returns -// true. -func BigEqual(a, b *big.Int) bool { - if a == nil || b == nil { - return a == b - } - return a.Cmp(b) == 0 -} - -// BigEqualUint64 returns true if a is equal to b. If a is nil or not a uint64, -// it returns false. -func BigEqualUint64(a *big.Int, b uint64) bool { - return a != nil && - a.IsUint64() && - a.Uint64() == b -} - -// BigLessOrEqualUint64 returns true if a is less than or equal to b. If a is -// nil or not a uint64, it returns false. -func BigLessOrEqualUint64(a *big.Int, b uint64) bool { - return a != nil && - a.IsUint64() && - a.Uint64() <= b -} diff --git a/graft/subnet-evm/utils/numbers_test.go b/graft/subnet-evm/utils/numbers_test.go deleted file mode 100644 index cee2bae2ae8e..000000000000 --- a/graft/subnet-evm/utils/numbers_test.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utils - -import ( - "math/big" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestBigEqual(t *testing.T) { - tests := []struct { - name string - a *big.Int - b *big.Int - want bool - }{ - { - name: "nil_nil", - a: nil, - b: nil, - want: true, - }, - { - name: "0_nil", - a: big.NewInt(0), - b: nil, - want: false, - }, - { - name: "0_1", - a: big.NewInt(0), - b: big.NewInt(1), - want: false, - }, - { - name: "1_1", - a: big.NewInt(1), - b: big.NewInt(1), - want: true, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - require := require.New(t) - - require.Equal(test.want, BigEqual(test.a, test.b)) - require.Equal(test.want, BigEqual(test.b, test.a)) - }) - } -} - -func TestBigEqualUint64(t *testing.T) { - tests := []struct { - name string - a *big.Int - b uint64 - want bool - }{ - { - name: "nil", - a: nil, - b: 0, - want: false, - }, - { - name: "not_uint64", - a: big.NewInt(-1), - b: 0, - want: false, - }, - { - name: "equal", - a: big.NewInt(1), - b: 1, - want: true, - }, - { - name: "not_equal", - a: big.NewInt(1), - b: 2, - want: false, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got := BigEqualUint64(test.a, test.b) - require.Equal(t, test.want, got) - }) - } -} - -func TestLessOrEqualUint64(t *testing.T) { - tests := []struct { - name string - a *big.Int - b uint64 - want bool - }{ - { - name: "nil", - a: nil, - b: 0, - want: false, - }, - { - name: "not_uint64", - a: big.NewInt(-1), - b: 0, - want: false, - }, - { - name: "less", - a: big.NewInt(1), - b: 2, - want: true, - }, - { - name: "equal", - a: big.NewInt(1), - b: 1, - want: true, - }, - { - name: "greater", - a: big.NewInt(2), - b: 1, - want: false, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got := BigLessOrEqualUint64(test.a, test.b) - require.Equal(t, test.want, got) - }) - } -} diff --git a/graft/subnet-evm/utils/rand/rand.go b/graft/subnet-evm/utils/rand/rand.go deleted file mode 100644 index e0cc23c12661..000000000000 --- a/graft/subnet-evm/utils/rand/rand.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package rand - -import ( - "crypto/rand" - "math/big" -) - -// Credit to Brandur Leach (@Brandur) for this implementation. -// https://brandur.org/fragments/crypto-rand-float64 - -// Intn is a shortcut for generating a random integer between 0 and -// n using crypto/rand. -func Intn(n int64) (int64, error) { - nBig, err := rand.Int(rand.Reader, big.NewInt(n)) - if err != nil { - return 0, err - } - return nBig.Int64(), nil -} - -// SecureFloat64 is a shortcut for generating a random float between 0 and -// 1 using crypto/rand. -func SecureFloat64() (float64, error) { - n, err := Intn(1 << 53) - if err != nil { - return 0, err - } - return float64(n) / (1 << 53), nil -} diff --git a/graft/subnet-evm/utils/utilstest/key.go b/graft/subnet-evm/utils/utilstest/key.go deleted file mode 100644 index 8b2eadaaa4c0..000000000000 --- a/graft/subnet-evm/utils/utilstest/key.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utilstest - -import ( - "crypto/ecdsa" - "crypto/rand" - "testing" - - "github.com/ava-labs/libevm/common" - "github.com/ava-labs/libevm/crypto" - "github.com/stretchr/testify/require" -) - -// Key contains an ecdsa private key field as well as an address field -// obtained from converting the ecdsa public key. -type Key struct { - Address common.Address - PrivateKey *ecdsa.PrivateKey -} - -// NewKey generates a new key pair and returns a pointer to a [Key]. -func NewKey(t *testing.T) *Key { - t.Helper() - privateKeyECDSA, err := ecdsa.GenerateKey(crypto.S256(), rand.Reader) - require.NoError(t, err) - return &Key{ - Address: crypto.PubkeyToAddress(privateKeyECDSA.PublicKey), - PrivateKey: privateKeyECDSA, - } -} diff --git a/graft/subnet-evm/utils/utilstest/pointer.go b/graft/subnet-evm/utils/utilstest/pointer.go deleted file mode 100644 index 27b36369d7ce..000000000000 --- a/graft/subnet-evm/utils/utilstest/pointer.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utilstest - -func PointerTo[T any](x T) *T { return &x } diff --git a/graft/subnet-evm/warp/verifier_backend_test.go b/graft/subnet-evm/warp/verifier_backend_test.go index a157e64a3bbc..5b2e3fbe32e2 100644 --- a/graft/subnet-evm/warp/verifier_backend_test.go +++ b/graft/subnet-evm/warp/verifier_backend_test.go @@ -15,7 +15,7 @@ import ( "github.com/ava-labs/avalanchego/cache" "github.com/ava-labs/avalanchego/cache/lru" "github.com/ava-labs/avalanchego/database/memdb" - "github.com/ava-labs/avalanchego/graft/subnet-evm/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/warp/messages" "github.com/ava-labs/avalanchego/graft/subnet-evm/warp/warptest" "github.com/ava-labs/avalanchego/ids" @@ -36,7 +36,7 @@ func TestAddressedCallSignatures(t *testing.T) { metricstest.WithMetrics(t) database := memdb.New() - snowCtx := utilstest.NewTestSnowContext(t) + snowCtx := utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) offChainPayload, err := payload.NewAddressedCall([]byte{1, 2, 3}, []byte{1, 2, 3}) require.NoError(t, err) @@ -151,7 +151,7 @@ func TestBlockSignatures(t *testing.T) { metricstest.WithMetrics(t) database := memdb.New() - snowCtx := utilstest.NewTestSnowContext(t) + snowCtx := utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) knownBlkID := ids.GenerateTestID() blockClient := warptest.MakeBlockClient(knownBlkID) @@ -255,7 +255,7 @@ func TestBlockSignatures(t *testing.T) { func TestUptimeSignatures(t *testing.T) { database := memdb.New() - snowCtx := utilstest.NewTestSnowContext(t) + snowCtx := utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) validationID := ids.GenerateTestID() nodeID := ids.GenerateTestNodeID() From a1d757153948a4dddb6332706e1d6f485d775576 Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Mon, 15 Dec 2025 17:54:36 -0500 Subject: [PATCH 02/16] refactor: align PointerTo functions --- graft/coreth/core/genesis_extra_test.go | 4 +- graft/coreth/core/genesis_test.go | 8 +- graft/coreth/core/state_processor_test.go | 6 +- graft/coreth/internal/ethapi/api_test.go | 4 +- graft/coreth/params/config.go | 22 ++-- graft/coreth/params/config_extra.go | 4 +- graft/coreth/params/config_extra_test.go | 2 +- graft/coreth/params/config_test.go | 6 +- graft/coreth/params/extras/config.go | 32 +++--- .../coreth/params/extras/config_extra_test.go | 34 +++--- .../params/extras/precompile_upgrade.go | 2 +- graft/coreth/plugin/evm/config/config_test.go | 9 +- .../plugin/evm/customheader/base_fee_test.go | 14 +-- .../plugin/evm/customheader/extra_test.go | 8 +- .../plugin/evm/customheader/gas_limit_test.go | 20 ++-- .../evm/customheader/min_delay_excess_test.go | 17 ++- .../plugin/evm/customheader/time_test.go | 86 +++++++------- .../plugin/evm/customtypes/block_ext_test.go | 9 +- .../plugin/evm/customtypes/header_ext_test.go | 10 +- graft/coreth/plugin/evm/vm_test.go | 27 +++-- .../precompile/contracts/warp/config_test.go | 32 +++--- .../contracts/warp/predicate_test.go | 20 ++-- graft/coreth/tests/init.go | 92 +++++++-------- graft/evm/utils/numbers.go | 4 +- graft/evm/utils/utilstest/pointer.go | 6 - .../precompile_config_test_template.go | 16 +-- graft/subnet-evm/core/blockchain_ext_test.go | 4 +- graft/subnet-evm/core/genesis_extra_test.go | 2 +- graft/subnet-evm/core/genesis_test.go | 10 +- .../core/state_processor_ext_test.go | 4 +- graft/subnet-evm/core/state_processor_test.go | 2 +- graft/subnet-evm/internal/ethapi/api_test.go | 4 +- graft/subnet-evm/params/config.go | 22 ++-- graft/subnet-evm/params/config_extra.go | 4 +- graft/subnet-evm/params/config_extra_test.go | 2 +- graft/subnet-evm/params/config_test.go | 20 ++-- graft/subnet-evm/params/extras/config.go | 14 +-- .../params/extras/config_extra_test.go | 34 +++--- .../params/extras/network_upgrades.go | 2 +- .../params/extras/network_upgrades_test.go | 108 +++++++++--------- .../params/extras/precompile_config_test.go | 52 ++++----- .../params/extras/precompile_upgrade.go | 2 +- .../params/extras/precompile_upgrade_test.go | 64 +++++------ .../params/extras/state_upgrade_test.go | 36 +++--- .../plugin/evm/customheader/base_fee_test.go | 2 +- .../plugin/evm/customheader/extra_test.go | 2 +- .../evm/customheader/min_delay_excess_test.go | 17 ++- .../plugin/evm/customheader/time_test.go | 86 +++++++------- .../plugin/evm/customtypes/block_ext_test.go | 9 +- .../plugin/evm/customtypes/header_ext_test.go | 10 +- graft/subnet-evm/plugin/evm/vm_test.go | 34 +++--- .../plugin/evm/vm_upgrade_bytes_test.go | 4 +- .../allowlisttest/test_allowlist_config.go | 2 +- .../deployerallowlist/config_test.go | 10 +- .../deployerallowlist/simulated_test.go | 4 +- .../contracts/feemanager/config_test.go | 24 ++-- .../contracts/feemanager/simulated_test.go | 4 +- .../contracts/nativeminter/config_test.go | 32 +++--- .../contracts/nativeminter/simulated_test.go | 4 +- .../contracts/rewardmanager/config_test.go | 22 ++-- .../contracts/rewardmanager/simulated_test.go | 6 +- .../contracts/txallowlist/config_test.go | 10 +- .../contracts/txallowlist/simulated_test.go | 4 +- .../precompile/contracts/warp/config_test.go | 32 +++--- .../contracts/warp/predicate_test.go | 20 ++-- graft/subnet-evm/tests/init.go | 14 +-- 66 files changed, 608 insertions(+), 624 deletions(-) delete mode 100644 graft/evm/utils/utilstest/pointer.go diff --git a/graft/coreth/core/genesis_extra_test.go b/graft/coreth/core/genesis_extra_test.go index b312c28152ff..ae53ff663f65 100644 --- a/graft/coreth/core/genesis_extra_test.go +++ b/graft/coreth/core/genesis_extra_test.go @@ -68,8 +68,8 @@ func TestGenesisEthUpgrades(t *testing.T) { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.NewUint64(0), - ApricotPhase2BlockTimestamp: utils.NewUint64(0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), }, }, ) diff --git a/graft/coreth/core/genesis_test.go b/graft/coreth/core/genesis_test.go index 8d76c1c9fa01..dd6e6b24df82 100644 --- a/graft/coreth/core/genesis_test.go +++ b/graft/coreth/core/genesis_test.go @@ -78,7 +78,7 @@ func TestSetupGenesis(t *testing.T) { func testSetupGenesis(t *testing.T, scheme string) { apricotPhase1Config := params.Copy(params.TestApricotPhase1Config) - params.GetExtra(&apricotPhase1Config).ApricotPhase1BlockTimestamp = utils.NewUint64(100) + params.GetExtra(&apricotPhase1Config).ApricotPhase1BlockTimestamp = utils.PointerTo[uint64](100) var ( customghash = common.HexToHash("0x1099a11e9e454bd3ef31d688cf21936671966407bc330f051d754b5ce401e7ed") customg = Genesis{ @@ -91,7 +91,7 @@ func testSetupGenesis(t *testing.T, scheme string) { ) rollbackApricotPhase1Config := params.Copy(&apricotPhase1Config) - params.GetExtra(&rollbackApricotPhase1Config).ApricotPhase1BlockTimestamp = utils.NewUint64(90) + params.GetExtra(&rollbackApricotPhase1Config).ApricotPhase1BlockTimestamp = utils.PointerTo[uint64](90) oldcustomg.Config = &rollbackApricotPhase1Config tests := []struct { name string @@ -237,7 +237,7 @@ func TestNetworkUpgradeBetweenHeadAndAcceptedBlock(t *testing.T) { require.Greater(block.Time, bc.lastAccepted.Time()) activatedGenesis := customg - apricotPhase2Timestamp := utils.NewUint64(51) + apricotPhase2Timestamp := utils.PointerTo[uint64](51) updatedApricotPhase2Config := params.Copy(params.TestApricotPhase1Config) params.GetExtra(&updatedApricotPhase2Config).ApricotPhase2BlockTimestamp = apricotPhase2Timestamp @@ -275,7 +275,7 @@ func TestGenesisWriteUpgradesRegression(t *testing.T) { params.GetExtra(genesis.Config).UpgradeConfig.PrecompileUpgrades = []extras.PrecompileUpgrade{ { - Config: warp.NewConfig(utils.NewUint64(51), 0, false), + Config: warp.NewConfig(utils.PointerTo[uint64](51), 0, false), }, } _, _, err = SetupGenesisBlock(db, trieDB, genesis, genesisBlock.Hash(), false) diff --git a/graft/coreth/core/state_processor_test.go b/graft/coreth/core/state_processor_test.go index 7ee64bc6594e..17e746622279 100644 --- a/graft/coreth/core/state_processor_test.go +++ b/graft/coreth/core/state_processor_test.go @@ -283,8 +283,8 @@ func TestStateProcessorErrors(t *testing.T) { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.NewUint64(0), - ApricotPhase2BlockTimestamp: utils.NewUint64(0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), }, }, ), @@ -391,7 +391,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr } if configExtra.IsGranite(header.Time) { headerExtra := customtypes.GetHeaderExtra(header) - headerExtra.TimeMilliseconds = utils.NewUint64(timeMS) + headerExtra.TimeMilliseconds = utils.PointerTo(timeMS) } if configExtra.IsApricotPhase4(header.Time) { headerExtra := customtypes.GetHeaderExtra(header) diff --git a/graft/coreth/internal/ethapi/api_test.go b/graft/coreth/internal/ethapi/api_test.go index 440fb42ec166..9d4f28d3664a 100644 --- a/graft/coreth/internal/ethapi/api_test.go +++ b/graft/coreth/internal/ethapi/api_test.go @@ -796,8 +796,8 @@ func TestEstimateGas(t *testing.T) { func TestCall(t *testing.T) { // Enable BLOBHASH opcode in Cancun cfg := *params.TestChainConfig - cfg.ShanghaiTime = utils.NewUint64(0) - cfg.CancunTime = utils.NewUint64(0) + cfg.ShanghaiTime = utils.PointerTo[uint64](0) + cfg.CancunTime = utils.PointerTo[uint64](0) t.Parallel() // Initialize test accounts var ( diff --git a/graft/coreth/params/config.go b/graft/coreth/params/config.go index 95761e167c0f..0a829ff70df1 100644 --- a/graft/coreth/params/config.go +++ b/graft/coreth/params/config.go @@ -96,8 +96,8 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, extras.TestChainConfig, ) @@ -333,7 +333,7 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), }, extras.TestDurangoChainConfig, ) @@ -354,8 +354,8 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, extras.TestEtnaChainConfig, ) @@ -376,8 +376,8 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, extras.TestFortunaChainConfig, ) @@ -398,8 +398,8 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, extras.TestGraniteChainConfig, ) @@ -420,8 +420,8 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, extras.TestHeliconChainConfig, ) diff --git a/graft/coreth/params/config_extra.go b/graft/coreth/params/config_extra.go index 05a967ea7da2..78f7b73fb436 100644 --- a/graft/coreth/params/config_extra.go +++ b/graft/coreth/params/config_extra.go @@ -80,11 +80,11 @@ func SetEthUpgrades(c *ChainConfig) error { // We only mark Shanghai and Cancun as enabled if we have marked them as // scheduled. if durango := extra.DurangoBlockTimestamp; durango != nil && *durango < unscheduledActivation { - c.ShanghaiTime = utils.NewUint64(*durango) + c.ShanghaiTime = utils.PointerTo(*durango) } if etna := extra.EtnaTimestamp; etna != nil && *etna < unscheduledActivation { - c.CancunTime = utils.NewUint64(*etna) + c.CancunTime = utils.PointerTo(*etna) } return nil } diff --git a/graft/coreth/params/config_extra_test.go b/graft/coreth/params/config_extra_test.go index 01fad0674c02..8dfb0fdcdac7 100644 --- a/graft/coreth/params/config_extra_test.go +++ b/graft/coreth/params/config_extra_test.go @@ -22,7 +22,7 @@ func TestMain(m *testing.M) { func TestSetEthUpgrades(t *testing.T) { genesisBlock := big.NewInt(0) - genesisTimestamp := utils.NewUint64(initiallyActive) + genesisTimestamp := utils.PointerTo(initiallyActive) tests := []struct { fork upgradetest.Fork expected *ChainConfig diff --git a/graft/coreth/params/config_test.go b/graft/coreth/params/config_test.go index e832409a34a0..14aec6b39e83 100644 --- a/graft/coreth/params/config_test.go +++ b/graft/coreth/params/config_test.go @@ -119,7 +119,7 @@ func TestCheckCompatible(t *testing.T) { headTimestamp: 0, wantErr: ðparams.ConfigCompatError{ What: "ApricotPhase5 fork block timestamp", - StoredTime: utils.NewUint64(0), + StoredTime: utils.PointerTo[uint64](0), NewTime: nil, RewindToTime: 0, }, @@ -131,7 +131,7 @@ func TestCheckCompatible(t *testing.T) { headTimestamp: 100, wantErr: ðparams.ConfigCompatError{ What: "ApricotPhase5 fork block timestamp", - StoredTime: utils.NewUint64(0), + StoredTime: utils.PointerTo[uint64](0), NewTime: nil, RewindToTime: 0, }, @@ -151,7 +151,7 @@ func TestConfigRules(t *testing.T) { &ChainConfig{}, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - CortinaBlockTimestamp: utils.NewUint64(500), + CortinaBlockTimestamp: utils.PointerTo[uint64](500), }, }, ) diff --git a/graft/coreth/params/extras/config.go b/graft/coreth/params/extras/config.go index 91407f32a9bb..68f39b7c5554 100644 --- a/graft/coreth/params/extras/config.go +++ b/graft/coreth/params/extras/config.go @@ -20,63 +20,63 @@ var ( TestLaunchConfig = &ChainConfig{} TestApricotPhase1Config = copyAndSet(TestLaunchConfig, func(c *ChainConfig) { - c.NetworkUpgrades.ApricotPhase1BlockTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.ApricotPhase1BlockTimestamp = utils.PointerTo[uint64](0) }) TestApricotPhase2Config = copyAndSet(TestApricotPhase1Config, func(c *ChainConfig) { - c.NetworkUpgrades.ApricotPhase2BlockTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.ApricotPhase2BlockTimestamp = utils.PointerTo[uint64](0) }) TestApricotPhase3Config = copyAndSet(TestApricotPhase2Config, func(c *ChainConfig) { - c.NetworkUpgrades.ApricotPhase3BlockTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.ApricotPhase3BlockTimestamp = utils.PointerTo[uint64](0) }) TestApricotPhase4Config = copyAndSet(TestApricotPhase3Config, func(c *ChainConfig) { - c.NetworkUpgrades.ApricotPhase4BlockTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.ApricotPhase4BlockTimestamp = utils.PointerTo[uint64](0) }) TestApricotPhase5Config = copyAndSet(TestApricotPhase4Config, func(c *ChainConfig) { - c.NetworkUpgrades.ApricotPhase5BlockTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.ApricotPhase5BlockTimestamp = utils.PointerTo[uint64](0) }) TestApricotPhasePre6Config = copyAndSet(TestApricotPhase5Config, func(c *ChainConfig) { - c.NetworkUpgrades.ApricotPhasePre6BlockTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.ApricotPhasePre6BlockTimestamp = utils.PointerTo[uint64](0) }) TestApricotPhase6Config = copyAndSet(TestApricotPhasePre6Config, func(c *ChainConfig) { - c.NetworkUpgrades.ApricotPhase6BlockTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.ApricotPhase6BlockTimestamp = utils.PointerTo[uint64](0) }) TestApricotPhasePost6Config = copyAndSet(TestApricotPhase6Config, func(c *ChainConfig) { - c.NetworkUpgrades.ApricotPhasePost6BlockTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.ApricotPhasePost6BlockTimestamp = utils.PointerTo[uint64](0) }) TestBanffChainConfig = copyAndSet(TestApricotPhasePost6Config, func(c *ChainConfig) { - c.NetworkUpgrades.BanffBlockTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.BanffBlockTimestamp = utils.PointerTo[uint64](0) }) TestCortinaChainConfig = copyAndSet(TestBanffChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.CortinaBlockTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.CortinaBlockTimestamp = utils.PointerTo[uint64](0) }) TestDurangoChainConfig = copyAndSet(TestCortinaChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.DurangoBlockTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.DurangoBlockTimestamp = utils.PointerTo[uint64](0) }) TestEtnaChainConfig = copyAndSet(TestDurangoChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.EtnaTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.EtnaTimestamp = utils.PointerTo[uint64](0) }) TestFortunaChainConfig = copyAndSet(TestEtnaChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.FortunaTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.FortunaTimestamp = utils.PointerTo[uint64](0) }) TestGraniteChainConfig = copyAndSet(TestFortunaChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.GraniteTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.GraniteTimestamp = utils.PointerTo[uint64](0) }) TestHeliconChainConfig = copyAndSet(TestGraniteChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.HeliconTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.HeliconTimestamp = utils.PointerTo[uint64](0) }) TestChainConfig = copyConfig(TestHeliconChainConfig) @@ -125,7 +125,7 @@ func (c *ChainConfig) CheckConfigCompatible(newcfg_ *ethparams.ChainConfig, head // Return an error to prevent the chain from starting, just in case. return ethparams.NewTimestampCompatError( fmt.Sprintf("ChainConfig.Hooks() is not of the expected type *extras.ChainConfig, got %T", newcfg_.Hooks()), - utils.NewUint64(0), + utils.PointerTo[uint64](0), nil, ) } diff --git a/graft/coreth/params/extras/config_extra_test.go b/graft/coreth/params/extras/config_extra_test.go index ffc1997b5aaf..bee75618a8c2 100644 --- a/graft/coreth/params/extras/config_extra_test.go +++ b/graft/coreth/params/extras/config_extra_test.go @@ -30,22 +30,22 @@ func TestIsTimestampForked(t *testing.T) { isForked: false, }, "zero fork at genesis": { - fork: utils.NewUint64(0), + fork: utils.PointerTo[uint64](0), block: 0, isForked: true, }, "pre fork timestamp": { - fork: utils.NewUint64(100), + fork: utils.PointerTo[uint64](100), block: 50, isForked: false, }, "at fork timestamp": { - fork: utils.NewUint64(100), + fork: utils.PointerTo[uint64](100), block: 100, isForked: true, }, "post fork timestamp": { - fork: utils.NewUint64(100), + fork: utils.PointerTo[uint64](100), block: 150, isForked: true, }, @@ -72,50 +72,50 @@ func TestIsForkTransition(t *testing.T) { transitioned: false, }, "activate at genesis": { - fork: utils.NewUint64(0), + fork: utils.PointerTo[uint64](0), parent: nil, current: 0, transitioned: true, }, "nil fork arbitrary transition": { fork: nil, - parent: utils.NewUint64(100), + parent: utils.PointerTo[uint64](100), current: 101, transitioned: false, }, "nil fork transition same timestamp": { fork: nil, - parent: utils.NewUint64(100), + parent: utils.PointerTo[uint64](100), current: 100, transitioned: false, }, "exact match on current timestamp": { - fork: utils.NewUint64(100), - parent: utils.NewUint64(99), + fork: utils.PointerTo[uint64](100), + parent: utils.PointerTo[uint64](99), current: 100, transitioned: true, }, "current same as parent does not transition twice": { - fork: utils.NewUint64(100), - parent: utils.NewUint64(101), + fork: utils.PointerTo[uint64](100), + parent: utils.PointerTo[uint64](101), current: 101, transitioned: false, }, "current, parent, and fork same should not transition twice": { - fork: utils.NewUint64(100), - parent: utils.NewUint64(100), + fork: utils.PointerTo[uint64](100), + parent: utils.PointerTo[uint64](100), current: 100, transitioned: false, }, "current transitions after fork": { - fork: utils.NewUint64(100), - parent: utils.NewUint64(99), + fork: utils.PointerTo[uint64](100), + parent: utils.PointerTo[uint64](99), current: 101, transitioned: true, }, "current and parent come after fork": { - fork: utils.NewUint64(100), - parent: utils.NewUint64(101), + fork: utils.PointerTo[uint64](100), + parent: utils.PointerTo[uint64](101), current: 102, transitioned: false, }, diff --git a/graft/coreth/params/extras/precompile_upgrade.go b/graft/coreth/params/extras/precompile_upgrade.go index f5ef7b184a50..6a36d4172ee5 100644 --- a/graft/coreth/params/extras/precompile_upgrade.go +++ b/graft/coreth/params/extras/precompile_upgrade.go @@ -97,7 +97,7 @@ func (c *ChainConfig) verifyPrecompileUpgrades() error { lastTimestamp = nil } else { disabled = lastUpgradeByKey.disabled - lastTimestamp = utils.NewUint64(lastUpgradeByKey.blockTimestamp) + lastTimestamp = utils.PointerTo(lastUpgradeByKey.blockTimestamp) } upgradeTimestamp := upgrade.Timestamp() diff --git a/graft/coreth/plugin/evm/config/config_test.go b/graft/coreth/plugin/evm/config/config_test.go index bed780c21042..bb887da55b80 100644 --- a/graft/coreth/plugin/evm/config/config_test.go +++ b/graft/coreth/plugin/evm/config/config_test.go @@ -12,15 +12,10 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/utils/constants" ) -// newTrue returns a pointer to a bool that is true -func newTrue() *bool { - b := true - return &b -} - func TestUnmarshalConfig(t *testing.T) { tests := []struct { name string @@ -70,7 +65,7 @@ func TestUnmarshalConfig(t *testing.T) { { "state sync enabled", []byte(`{"state-sync-enabled":true}`), - Config{StateSyncEnabled: newTrue()}, + Config{StateSyncEnabled: utils.PointerTo(true)}, false, }, { diff --git a/graft/coreth/plugin/evm/customheader/base_fee_test.go b/graft/coreth/plugin/evm/customheader/base_fee_test.go index 293f60f000bb..7337a1674f67 100644 --- a/graft/coreth/plugin/evm/customheader/base_fee_test.go +++ b/graft/coreth/plugin/evm/customheader/base_fee_test.go @@ -40,7 +40,7 @@ func TestBaseFee(t *testing.T) { { name: "ap3_first_block", upgrades: extras.NetworkUpgrades{ - ApricotPhase3BlockTimestamp: utils.NewUint64(1), + ApricotPhase3BlockTimestamp: utils.PointerTo[uint64](1), }, parent: &types.Header{ Number: big.NewInt(1), @@ -347,7 +347,7 @@ func TestBaseFee(t *testing.T) { { name: "fortuna_first_block", upgrades: extras.NetworkUpgrades{ - FortunaTimestamp: utils.NewUint64(1), + FortunaTimestamp: utils.PointerTo[uint64](1), }, parent: &types.Header{ Number: big.NewInt(1), @@ -409,7 +409,7 @@ func TestBaseFee(t *testing.T) { Time: 1, Extra: (&acp176.State{}).Bytes(), }, &customtypes.HeaderExtra{ - TimeMilliseconds: utils.NewUint64(1000), + TimeMilliseconds: utils.PointerTo[uint64](1000), }), timeMS: 0, wantErr: errInvalidTimestamp, @@ -417,8 +417,8 @@ func TestBaseFee(t *testing.T) { { name: "granite_first_block_with_state", upgrades: extras.NetworkUpgrades{ - FortunaTimestamp: utils.NewUint64(1), - GraniteTimestamp: utils.NewUint64(1), + FortunaTimestamp: utils.PointerTo[uint64](1), + GraniteTimestamp: utils.PointerTo[uint64](1), }, parent: &types.Header{ Number: big.NewInt(1), @@ -430,8 +430,8 @@ func TestBaseFee(t *testing.T) { { name: "granite_first_block_after_fortuna", upgrades: extras.NetworkUpgrades{ - FortunaTimestamp: utils.NewUint64(0), - GraniteTimestamp: utils.NewUint64(1), + FortunaTimestamp: utils.PointerTo[uint64](0), + GraniteTimestamp: utils.PointerTo[uint64](1), }, parent: &types.Header{ Number: big.NewInt(1), diff --git a/graft/coreth/plugin/evm/customheader/extra_test.go b/graft/coreth/plugin/evm/customheader/extra_test.go index 8fa49413163f..f6a0e956d3a7 100644 --- a/graft/coreth/plugin/evm/customheader/extra_test.go +++ b/graft/coreth/plugin/evm/customheader/extra_test.go @@ -47,7 +47,7 @@ func TestExtraPrefix(t *testing.T) { { name: "ap3_first_block", upgrades: extras.NetworkUpgrades{ - ApricotPhase3BlockTimestamp: utils.NewUint64(1), + ApricotPhase3BlockTimestamp: utils.PointerTo[uint64](1), }, parent: &types.Header{ Number: big.NewInt(1), @@ -278,7 +278,7 @@ func TestExtraPrefix(t *testing.T) { { name: "fortuna_first_block", upgrades: extras.NetworkUpgrades{ - FortunaTimestamp: utils.NewUint64(1), + FortunaTimestamp: utils.PointerTo[uint64](1), }, parent: &types.Header{ Number: big.NewInt(1), @@ -315,7 +315,7 @@ func TestExtraPrefix(t *testing.T) { ExtDataGasUsed: big.NewInt(1), }, ), - desiredTargetExcess: (*gas.Gas)(utils.NewUint64(3)), + desiredTargetExcess: (*gas.Gas)(utils.PointerTo[uint64](3)), want: (&acp176.State{ Gas: gas.State{ Capacity: acp176.MinMaxPerSecond - 3, @@ -366,7 +366,7 @@ func TestExtraPrefix(t *testing.T) { ExtDataGasUsed: big.NewInt(1), }, ), - desiredTargetExcess: (*gas.Gas)(utils.NewUint64(0)), + desiredTargetExcess: (*gas.Gas)(utils.PointerTo[uint64](0)), want: (&acp176.State{ Gas: gas.State{ Capacity: 10_009_770, // [acp176.MinMaxCapacity] * e^([acp176.MaxTargetExcessDiff] / [acp176.TargetConversion]) diff --git a/graft/coreth/plugin/evm/customheader/gas_limit_test.go b/graft/coreth/plugin/evm/customheader/gas_limit_test.go index 18dceed980bb..1f6c45d0bc3c 100644 --- a/graft/coreth/plugin/evm/customheader/gas_limit_test.go +++ b/graft/coreth/plugin/evm/customheader/gas_limit_test.go @@ -94,13 +94,13 @@ func TestVerifyGasUsed(t *testing.T) { parent: customtypes.WithHeaderExtra(&types.Header{ Number: big.NewInt(0), }, &customtypes.HeaderExtra{ - TimeMilliseconds: utils.NewUint64(0), + TimeMilliseconds: utils.PointerTo[uint64](0), }), header: customtypes.WithHeaderExtra(&types.Header{ Time: 1, GasUsed: acp176.MinMaxPerSecond + 500, }, &customtypes.HeaderExtra{ - TimeMilliseconds: utils.NewUint64(1500), + TimeMilliseconds: utils.PointerTo[uint64](1500), }), want: nil, }, @@ -206,12 +206,12 @@ func TestVerifyGasLimit(t *testing.T) { parent: customtypes.WithHeaderExtra(&types.Header{ Number: big.NewInt(0), }, &customtypes.HeaderExtra{ - TimeMilliseconds: utils.NewUint64(0), + TimeMilliseconds: utils.PointerTo[uint64](0), }), header: customtypes.WithHeaderExtra(&types.Header{ GasLimit: acp176.MinMaxPerSecond - 1, }, &customtypes.HeaderExtra{ - TimeMilliseconds: utils.NewUint64(0), + TimeMilliseconds: utils.PointerTo[uint64](0), }), want: errInvalidGasLimit, }, @@ -221,12 +221,12 @@ func TestVerifyGasLimit(t *testing.T) { parent: customtypes.WithHeaderExtra(&types.Header{ Number: big.NewInt(0), }, &customtypes.HeaderExtra{ - TimeMilliseconds: utils.NewUint64(0), + TimeMilliseconds: utils.PointerTo[uint64](0), }), header: customtypes.WithHeaderExtra(&types.Header{ GasLimit: acp176.MinMaxCapacity, }, &customtypes.HeaderExtra{ - TimeMilliseconds: utils.NewUint64(0), + TimeMilliseconds: utils.PointerTo[uint64](0), }), }, { @@ -390,7 +390,7 @@ func TestGasCapacity(t *testing.T) { parent: customtypes.WithHeaderExtra(&types.Header{ Number: big.NewInt(0), }, &customtypes.HeaderExtra{ - TimeMilliseconds: utils.NewUint64(0), + TimeMilliseconds: utils.PointerTo[uint64](0), }), timestamp: 1000, want: acp176.MinMaxPerSecond, @@ -401,7 +401,7 @@ func TestGasCapacity(t *testing.T) { parent: customtypes.WithHeaderExtra(&types.Header{ Number: big.NewInt(0), }, &customtypes.HeaderExtra{ - TimeMilliseconds: utils.NewUint64(0), + TimeMilliseconds: utils.PointerTo[uint64](0), }), timestamp: 1500, want: acp176.MinMaxPerSecond * 3 / 2, @@ -474,13 +474,13 @@ func TestRemainingAtomicGasCapacity(t *testing.T) { parent: customtypes.WithHeaderExtra(&types.Header{ Number: big.NewInt(0), }, &customtypes.HeaderExtra{ - TimeMilliseconds: utils.NewUint64(0), + TimeMilliseconds: utils.PointerTo[uint64](0), }), header: customtypes.WithHeaderExtra(&types.Header{ Time: 1, GasUsed: 1, }, &customtypes.HeaderExtra{ - TimeMilliseconds: utils.NewUint64(1500), + TimeMilliseconds: utils.PointerTo[uint64](1500), }), want: acp176.MinMaxPerSecond*3/2 - 1, }, diff --git a/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go b/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go index 966c0c757d60..a18cc3b338c4 100644 --- a/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go +++ b/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go @@ -12,14 +12,13 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params/extras" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/customtypes" "github.com/ava-labs/avalanchego/graft/evm/utils" - "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) func TestMinDelayExcess(t *testing.T) { activatingGraniteConfig := *extras.TestGraniteChainConfig activatingGraniteTimestamp := uint64(1000) - activatingGraniteConfig.NetworkUpgrades.GraniteTimestamp = utils.NewUint64(activatingGraniteTimestamp) + activatingGraniteConfig.NetworkUpgrades.GraniteTimestamp = utils.PointerTo(activatingGraniteTimestamp) tests := []struct { name string @@ -52,7 +51,7 @@ func TestMinDelayExcess(t *testing.T) { header: &types.Header{ Time: 1001, }, - desiredMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(1000)), + desiredMinDelayExcess: utils.PointerTo(acp226.DelayExcess(1000)), expectedDelayExcess: nil, }, { @@ -65,7 +64,7 @@ func TestMinDelayExcess(t *testing.T) { Time: activatingGraniteTimestamp + 1, }, desiredMinDelayExcess: nil, - expectedDelayExcess: utilstest.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), + expectedDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), }, { name: "granite_no_parent_min_delay_error", @@ -88,7 +87,7 @@ func TestMinDelayExcess(t *testing.T) { Time: 1001, }, desiredMinDelayExcess: nil, - expectedDelayExcess: utilstest.PointerTo(acp226.DelayExcess(500)), + expectedDelayExcess: utils.PointerTo(acp226.DelayExcess(500)), }, { name: "granite_with_desired_min_delay_excess", @@ -97,8 +96,8 @@ func TestMinDelayExcess(t *testing.T) { header: &types.Header{ Time: 1001, }, - desiredMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(1000)), - expectedDelayExcess: utilstest.PointerTo(acp226.DelayExcess(500 + acp226.MaxDelayExcessDiff)), + desiredMinDelayExcess: utils.PointerTo(acp226.DelayExcess(1000)), + expectedDelayExcess: utils.PointerTo(acp226.DelayExcess(500 + acp226.MaxDelayExcessDiff)), }, { name: "granite_with_zero_desired_value", @@ -107,8 +106,8 @@ func TestMinDelayExcess(t *testing.T) { header: &types.Header{ Time: 1001, }, - desiredMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(0)), - expectedDelayExcess: utilstest.PointerTo(acp226.DelayExcess(500 - acp226.MaxDelayExcessDiff)), + desiredMinDelayExcess: utils.PointerTo(acp226.DelayExcess(0)), + expectedDelayExcess: utils.PointerTo(acp226.DelayExcess(500 - acp226.MaxDelayExcessDiff)), }, } diff --git a/graft/coreth/plugin/evm/customheader/time_test.go b/graft/coreth/plugin/evm/customheader/time_test.go index 7faf0cd91f4e..9b0eee16d5aa 100644 --- a/graft/coreth/plugin/evm/customheader/time_test.go +++ b/graft/coreth/plugin/evm/customheader/time_test.go @@ -31,7 +31,7 @@ func TestVerifyTime(t *testing.T) { }{ { name: "pre_granite_time_milliseconds_should_fail", - header: generateHeader(timeSeconds, utils.NewUint64(timeMillis)), + header: generateHeader(timeSeconds, utils.PointerTo(timeMillis)), extraConfig: extras.TestFortunaChainConfig, expectedErr: ErrTimeMillisecondsBeforeGranite, }, @@ -48,23 +48,23 @@ func TestVerifyTime(t *testing.T) { }, { name: "granite_time_milliseconds_matching_time_should_work", - header: generateHeader(timeSeconds, utils.NewUint64(timeSeconds*1000)), + header: generateHeader(timeSeconds, utils.PointerTo(timeSeconds*1000)), extraConfig: extras.TestGraniteChainConfig, }, { name: "granite_time_milliseconds_matching_time_rounded_should_work", - header: generateHeader(timeSeconds, utils.NewUint64(timeMillis)), + header: generateHeader(timeSeconds, utils.PointerTo(timeMillis)), extraConfig: extras.TestGraniteChainConfig, }, { name: "granite_time_milliseconds_less_than_time_should_fail", - header: generateHeader(timeSeconds, utils.NewUint64((timeSeconds-1)*1000)), + header: generateHeader(timeSeconds, utils.PointerTo((timeSeconds-1)*1000)), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrTimeMillisecondsMismatched, }, { name: "granite_time_milliseconds_greater_than_time_should_fail", - header: generateHeader(timeSeconds, utils.NewUint64((timeSeconds+1)*1000)), + header: generateHeader(timeSeconds, utils.PointerTo((timeSeconds+1)*1000)), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrTimeMillisecondsMismatched, }, @@ -77,10 +77,10 @@ func TestVerifyTime(t *testing.T) { }, { name: "granite_time_earlier_than_parent_should_fail", - header: generateHeader(timeSeconds, utils.NewUint64(timeSeconds*1000)), + header: generateHeader(timeSeconds, utils.PointerTo(timeSeconds*1000)), parentHeader: generateHeader( timeSeconds+1, - utils.NewUint64((timeSeconds+1)*1000), + utils.PointerTo((timeSeconds+1)*1000), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: errBlockTooOld, @@ -89,11 +89,11 @@ func TestVerifyTime(t *testing.T) { name: "granite_time_milliseconds_earlier_than_parent_should_fail", header: generateHeader( timeSeconds, - utils.NewUint64(timeSeconds*1000), + utils.PointerTo(timeSeconds*1000), ), parentHeader: generateHeader( timeSeconds, - utils.NewUint64(timeSeconds*1000+1), + utils.PointerTo(timeSeconds*1000+1), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: errBlockTooOld, @@ -108,7 +108,7 @@ func TestVerifyTime(t *testing.T) { name: "granite_time_too_far_in_future_should_fail", header: generateHeader( uint64(now.Add(MaxFutureBlockTime).Add(1*time.Second).Unix()), - utils.NewUint64(uint64(now.Add(MaxFutureBlockTime).Add(1*time.Second).UnixMilli())), + utils.PointerTo(uint64(now.Add(MaxFutureBlockTime).Add(1*time.Second).UnixMilli())), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrBlockTooFarInFuture, @@ -117,14 +117,14 @@ func TestVerifyTime(t *testing.T) { name: "granite_time_milliseconds_too_far_in_future_should_fail", header: generateHeader( uint64(now.Add(MaxFutureBlockTime).Unix()), - utils.NewUint64(uint64(now.Add(MaxFutureBlockTime).Add(1*time.Millisecond).UnixMilli())), + utils.PointerTo(uint64(now.Add(MaxFutureBlockTime).Add(1*time.Millisecond).UnixMilli())), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrBlockTooFarInFuture, }, { name: "first_granite_block_should_work", - header: generateHeader(timeSeconds, utils.NewUint64(timeMillis)), + header: generateHeader(timeSeconds, utils.PointerTo(timeMillis)), parentHeader: generateHeader(timeSeconds, nil), extraConfig: extras.TestGraniteChainConfig, }, @@ -139,8 +139,8 @@ func TestVerifyTime(t *testing.T) { name: "granite_first_block_no_parent_min_delay_excess", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), parentHeader: generateHeader(timeSeconds-1, nil), // Pre-Granite parent extraConfig: extras.TestGraniteChainConfig, @@ -149,13 +149,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_initial_delay_met", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, - utils.NewUint64(timeMillis-2000), // 2000 ms is the exact initial delay - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis-2000), // 2000 ms is the exact initial delay + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, }, @@ -163,13 +163,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_initial_delay_not_met", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, - utils.NewUint64(timeMillis-1999), // 1 ms less than required - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis-1999), // 1 ms less than required + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrMinDelayNotMet, @@ -178,13 +178,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_future_timestamp_within_limits", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds+5, // 5 seconds in future - utils.NewUint64(timeMillis+5000), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis+5000), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, - utils.NewUint64(timeMillis-2000), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis-2000), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, }, @@ -192,13 +192,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_future_timestamp_abuse", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds+15, // 15 seconds in future, exceeds MaxFutureBlockTime - utils.NewUint64(timeMillis+15000), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis+15000), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, - utils.NewUint64(timeMillis-2000), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis-2000), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrBlockTooFarInFuture, @@ -207,13 +207,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_zero_delay_excess", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), - utils.NewUint64(0), + utils.PointerTo(timeMillis), + utils.PointerTo[uint64](0), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis-1), // 1ms delay, meets zero requirement - utils.NewUint64(0), // Parent has zero delay excess + utils.PointerTo(timeMillis-1), // 1ms delay, meets zero requirement + utils.PointerTo[uint64](0), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, }, @@ -221,13 +221,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_zero_delay_excess_but_zero_delay", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), - utils.NewUint64(0), + utils.PointerTo(timeMillis), + utils.PointerTo[uint64](0), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), // Same timestamp, zero delay - utils.NewUint64(0), // Parent has zero delay excess + utils.PointerTo(timeMillis), // Same timestamp, zero delay + utils.PointerTo[uint64](0), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrMinDelayNotMet, @@ -269,7 +269,7 @@ func TestGetNextTimestamp(t *testing.T) { }, { name: "current_time_after_parent_time_with_milliseconds", - parent: generateHeader(nowSeconds-10, utils.NewUint64(nowMillis-500)), + parent: generateHeader(nowSeconds-10, utils.PointerTo(nowMillis-500)), now: now, expectedSec: nowSeconds, expectedMillis: nowMillis, @@ -290,28 +290,28 @@ func TestGetNextTimestamp(t *testing.T) { }, { name: "current_time_before_parent_time_with_milliseconds", - parent: generateHeader(nowSeconds+10, utils.NewUint64(nowMillis)), + parent: generateHeader(nowSeconds+10, utils.PointerTo(nowMillis)), now: now, expectedSec: nowSeconds, expectedMillis: nowMillis, }, { name: "current_time_milliseconds_before_parent_time_milliseconds", - parent: generateHeader(nowSeconds, utils.NewUint64(nowMillis+10)), + parent: generateHeader(nowSeconds, utils.PointerTo(nowMillis+10)), now: now, expectedSec: nowSeconds, expectedMillis: nowMillis, }, { name: "current_time_equals_parent_time_with_milliseconds_granite", - parent: generateHeader(nowSeconds, utils.NewUint64(nowMillis)), + parent: generateHeader(nowSeconds, utils.PointerTo(nowMillis)), now: now, expectedSec: nowSeconds, expectedMillis: nowMillis, }, { name: "current_timesec_equals_parent_time_with_less_milliseconds", - parent: generateHeader(nowSeconds, utils.NewUint64(nowMillis-10)), + parent: generateHeader(nowSeconds, utils.PointerTo(nowMillis-10)), now: now, expectedSec: nowSeconds, expectedMillis: nowMillis, diff --git a/graft/coreth/plugin/evm/customtypes/block_ext_test.go b/graft/coreth/plugin/evm/customtypes/block_ext_test.go index 55aca7f4dc49..5a2ff0e258d8 100644 --- a/graft/coreth/plugin/evm/customtypes/block_ext_test.go +++ b/graft/coreth/plugin/evm/customtypes/block_ext_test.go @@ -17,7 +17,6 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/graft/evm/utils" - "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) @@ -325,8 +324,8 @@ func TestBlockGetters(t *testing.T) { headerExtra: &HeaderExtra{ ExtDataGasUsed: big.NewInt(1), BlockGasCost: big.NewInt(2), - TimeMilliseconds: utils.NewUint64(3), - MinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(4)), + TimeMilliseconds: utils.PointerTo[uint64](3), + MinDelayExcess: utils.PointerTo(acp226.DelayExcess(4)), }, blockExtra: &BlockBodyExtra{ Version: 3, @@ -336,8 +335,8 @@ func TestBlockGetters(t *testing.T) { wantBlockGasCost: big.NewInt(2), wantVersion: 3, wantExtData: []byte{4}, - wantTimeMilliseconds: utils.NewUint64(3), - wantMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(4)), + wantTimeMilliseconds: utils.PointerTo[uint64](3), + wantMinDelayExcess: utils.PointerTo(acp226.DelayExcess(4)), }, } diff --git a/graft/coreth/plugin/evm/customtypes/header_ext_test.go b/graft/coreth/plugin/evm/customtypes/header_ext_test.go index c6857a4d5d4e..4d8de5fc9342 100644 --- a/graft/coreth/plugin/evm/customtypes/header_ext_test.go +++ b/graft/coreth/plugin/evm/customtypes/header_ext_test.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/libevm/rlp" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) @@ -106,16 +106,16 @@ func headerWithNonZeroFields() (*Header, *HeaderExtra) { Nonce: BlockNonce{15}, BaseFee: big.NewInt(16), WithdrawalsHash: &common.Hash{17}, - BlobGasUsed: utilstest.PointerTo(uint64(18)), - ExcessBlobGas: utilstest.PointerTo(uint64(19)), + BlobGasUsed: utils.PointerTo(uint64(18)), + ExcessBlobGas: utils.PointerTo(uint64(19)), ParentBeaconRoot: &common.Hash{20}, } extra := &HeaderExtra{ ExtDataHash: common.Hash{21}, ExtDataGasUsed: big.NewInt(22), BlockGasCost: big.NewInt(23), - TimeMilliseconds: utilstest.PointerTo(uint64(24)), - MinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(25)), + TimeMilliseconds: utils.PointerTo(uint64(24)), + MinDelayExcess: utils.PointerTo(acp226.DelayExcess(25)), } return WithHeaderExtra(header, extra), extra } diff --git a/graft/coreth/plugin/evm/vm_test.go b/graft/coreth/plugin/evm/vm_test.go index 772298fdf396..555f6cb3fe24 100644 --- a/graft/coreth/plugin/evm/vm_test.go +++ b/graft/coreth/plugin/evm/vm_test.go @@ -44,7 +44,6 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/rpc" "github.com/ava-labs/avalanchego/graft/evm/constants" "github.com/ava-labs/avalanchego/graft/evm/utils" - "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/upgrade" @@ -80,8 +79,8 @@ var ( activateCancun = func(cfg *params.ChainConfig) *params.ChainConfig { cpy := *cfg - cpy.ShanghaiTime = utils.NewUint64(0) - cpy.CancunTime = utils.NewUint64(0) + cpy.ShanghaiTime = utils.PointerTo[uint64](0) + cpy.CancunTime = utils.PointerTo[uint64](0) return &cpy } ) @@ -1012,13 +1011,13 @@ func TestTimeSemanticVerify(t *testing.T) { name: "Granite with TimeMilliseconds", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.NewUint64(uint64(timestamp.UnixMilli())), + timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli())), }, { name: "Fortuna with TimeMilliseconds", fork: upgradetest.Fortuna, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.NewUint64(uint64(timestamp.UnixMilli())), + timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli())), expectedError: customheader.ErrTimeMillisecondsBeforeGranite, }, { @@ -1032,14 +1031,14 @@ func TestTimeSemanticVerify(t *testing.T) { name: "Granite with mismatched TimeMilliseconds", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.NewUint64(uint64(timestamp.UnixMilli()) + 1000), + timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli()) + 1000), expectedError: customheader.ErrTimeMillisecondsMismatched, }, { name: "Block too far in the future", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Add(2 * time.Hour).Unix()), - timeMilliseconds: utils.NewUint64(uint64(timestamp.Add(2 * time.Hour).UnixMilli())), + timeMilliseconds: utils.PointerTo(uint64(timestamp.Add(2 * time.Hour).UnixMilli())), expectedError: customheader.ErrBlockTooFarInFuture, }, } @@ -1104,7 +1103,7 @@ func TestBuildTimeMilliseconds(t *testing.T) { { name: "granite_should_have_timestamp_milliseconds", fork: upgradetest.Granite, - expectedTimeMilliseconds: utils.NewUint64(uint64(buildTime.UnixMilli())), + expectedTimeMilliseconds: utils.PointerTo(uint64(buildTime.UnixMilli())), }, } @@ -2144,26 +2143,26 @@ func TestMinDelayExcessInHeader(t *testing.T) { { name: "pre_granite_min_delay_excess", fork: upgradetest.Fortuna, - desiredMinDelay: utils.NewUint64(1000), + desiredMinDelay: utils.PointerTo[uint64](1000), expectedMinDelayExcess: nil, }, { name: "granite_first_block_initial_delay_excess", fork: upgradetest.Granite, desiredMinDelay: nil, - expectedMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), + expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), }, { name: "granite_with_excessive_desired_min_delay_excess", fork: upgradetest.Granite, - desiredMinDelay: utils.NewUint64(4000), - expectedMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), + desiredMinDelay: utils.PointerTo[uint64](4000), + expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), }, { name: "granite_with_zero_desired_min_delay_excess", fork: upgradetest.Granite, - desiredMinDelay: utils.NewUint64(0), - expectedMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), + desiredMinDelay: utils.PointerTo[uint64](0), + expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), }, } diff --git a/graft/coreth/precompile/contracts/warp/config_test.go b/graft/coreth/precompile/contracts/warp/config_test.go index cdd2ade7eb2d..cfe27b404711 100644 --- a/graft/coreth/precompile/contracts/warp/config_test.go +++ b/graft/coreth/precompile/contracts/warp/config_test.go @@ -16,24 +16,24 @@ import ( func TestVerify(t *testing.T) { tests := map[string]precompiletest.ConfigVerifyTest{ "quorum numerator less than minimum": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum-1, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum-1, false), ExpectedError: ErrInvalidQuorumRatio, }, "quorum numerator greater than quorum denominator": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumDenominator+1, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumDenominator+1, false), ExpectedError: ErrInvalidQuorumRatio, }, "default quorum numerator": { - Config: NewDefaultConfig(utils.NewUint64(3)), + Config: NewDefaultConfig(utils.PointerTo[uint64](3)), }, "valid quorum numerator 1 less than denominator": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumDenominator-1, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumDenominator-1, false), }, "valid quorum numerator 1 more than minimum": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+1, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum+1, false), }, "invalid cannot activated before Durango activation": { - Config: NewConfig(utils.NewUint64(3), 0, false), + Config: NewConfig(utils.PointerTo[uint64](3), 0, false), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) config.EXPECT().IsDurango(gomock.Any()).Return(false) @@ -48,38 +48,38 @@ func TestVerify(t *testing.T) { func TestEqualWarpConfig(t *testing.T) { tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: NewDefaultConfig(utils.NewUint64(3)), + Config: NewDefaultConfig(utils.PointerTo[uint64](3)), Other: nil, Expected: false, }, "different type": { - Config: NewDefaultConfig(utils.NewUint64(3)), + Config: NewDefaultConfig(utils.PointerTo[uint64](3)), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: NewDefaultConfig(utils.NewUint64(3)), - Other: NewDefaultConfig(utils.NewUint64(4)), + Config: NewDefaultConfig(utils.PointerTo[uint64](3)), + Other: NewDefaultConfig(utils.PointerTo[uint64](4)), Expected: false, }, "different quorum numerator": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+1, false), - Other: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+2, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum+1, false), + Other: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum+2, false), Expected: false, }, "same default config": { - Config: NewDefaultConfig(utils.NewUint64(3)), - Other: NewDefaultConfig(utils.NewUint64(3)), + Config: NewDefaultConfig(utils.PointerTo[uint64](3)), + Other: NewDefaultConfig(utils.PointerTo[uint64](3)), Expected: true, }, "same non-default config": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+5, false), - Other: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+5, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum+5, false), + Other: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum+5, false), Expected: true, }, } diff --git a/graft/coreth/precompile/contracts/warp/predicate_test.go b/graft/coreth/precompile/contracts/warp/predicate_test.go index 364161fbc660..d6f3ba9013cd 100644 --- a/graft/coreth/precompile/contracts/warp/predicate_test.go +++ b/graft/coreth/precompile/contracts/warp/predicate_test.go @@ -244,7 +244,7 @@ func createValidPredicateTest( ) precompiletest.PredicateTest { gasCost := CurrentGasConfig(rules) return precompiletest.PredicateTest{ - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -331,7 +331,7 @@ func testWarpMessageFromPrimaryNetwork(t *testing.T, requirePrimaryNetworkSigner } test := precompiletest.PredicateTest{ - Config: NewConfig(utils.NewUint64(0), 0, requirePrimaryNetworkSigners), + Config: NewConfig(utils.PointerTo[uint64](0), 0, requirePrimaryNetworkSigners), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -362,7 +362,7 @@ func TestInvalidPredicatePacking(t *testing.T) { pred = append(pred, common.Hash{1}) // Invalidate the predicate byte packing test := precompiletest.PredicateTest{ - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -394,7 +394,7 @@ func TestInvalidWarpMessage(t *testing.T) { pred := predicate.New(warpMsgBytes) test := precompiletest.PredicateTest{ - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -439,7 +439,7 @@ func TestInvalidAddressedPayload(t *testing.T) { pred := predicate.New(warpMsgBytes) test := precompiletest.PredicateTest{ - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -485,7 +485,7 @@ func TestInvalidBitSet(t *testing.T) { }) pred := predicate.New(msg.Bytes()) test := precompiletest.PredicateTest{ - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -533,7 +533,7 @@ func TestWarpSignatureWeightsDefaultQuorumNumerator(t *testing.T) { tests[i] = precompiletest.PredicateTest{ Name: fmt.Sprintf("default quorum %d signature(s)", numSigners), - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -593,7 +593,7 @@ func TestWarpMultiplePredicates(t *testing.T) { tests = append(tests, precompiletest.PredicateTest{ Name: fmt.Sprintf("multiple predicates %v", validMessageIndices), - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -645,7 +645,7 @@ func TestWarpSignatureWeightsNonDefaultQuorumNumerator(t *testing.T) { tests[i] = precompiletest.PredicateTest{ Name: fmt.Sprintf("non-default quorum %d signature(s)", numSigners), - Config: NewConfig(utils.NewUint64(0), uint64(nonDefaultQuorumNumerator), false), + Config: NewConfig(utils.PointerTo[uint64](0), uint64(nonDefaultQuorumNumerator), false), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -665,7 +665,7 @@ func TestWarpSignatureWeightsNonDefaultQuorumNumerator(t *testing.T) { func TestWarpNoValidatorsAndOverflowUseSameGas(t *testing.T) { var ( - config = NewConfig(utils.NewUint64(0), 0, false) + config = NewConfig(utils.PointerTo[uint64](0), 0, false) proposervmContext = &block.Context{ PChainHeight: 1, } diff --git a/graft/coreth/tests/init.go b/graft/coreth/tests/init.go index 23a8b59e73ab..c58ff3060d15 100644 --- a/graft/coreth/tests/init.go +++ b/graft/coreth/tests/init.go @@ -199,7 +199,7 @@ func initializeForks() { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.NewUint64(0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), }, }, ), @@ -219,8 +219,8 @@ func initializeForks() { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.NewUint64(0), - ApricotPhase2BlockTimestamp: utils.NewUint64(0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), }, }, ), @@ -241,9 +241,9 @@ func initializeForks() { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.NewUint64(0), - ApricotPhase2BlockTimestamp: utils.NewUint64(0), - ApricotPhase3BlockTimestamp: utils.NewUint64(0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase3BlockTimestamp: utils.PointerTo[uint64](0), }, }, ), @@ -264,10 +264,10 @@ func initializeForks() { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.NewUint64(0), - ApricotPhase2BlockTimestamp: utils.NewUint64(0), - ApricotPhase3BlockTimestamp: utils.NewUint64(0), - ApricotPhase4BlockTimestamp: utils.NewUint64(0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase3BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase4BlockTimestamp: utils.PointerTo[uint64](0), }, }, ), @@ -287,11 +287,11 @@ func initializeForks() { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.NewUint64(0), - ApricotPhase2BlockTimestamp: utils.NewUint64(0), - ApricotPhase3BlockTimestamp: utils.NewUint64(0), - ApricotPhase4BlockTimestamp: utils.NewUint64(0), - ApricotPhase5BlockTimestamp: utils.NewUint64(0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase3BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase4BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase5BlockTimestamp: utils.PointerTo[uint64](0), }, }, ), @@ -311,12 +311,12 @@ func initializeForks() { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.NewUint64(0), - ApricotPhase2BlockTimestamp: utils.NewUint64(0), - ApricotPhase3BlockTimestamp: utils.NewUint64(0), - ApricotPhase4BlockTimestamp: utils.NewUint64(0), - ApricotPhase5BlockTimestamp: utils.NewUint64(0), - BanffBlockTimestamp: utils.NewUint64(0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase3BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase4BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase5BlockTimestamp: utils.PointerTo[uint64](0), + BanffBlockTimestamp: utils.PointerTo[uint64](0), }, }, ), @@ -336,13 +336,13 @@ func initializeForks() { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.NewUint64(0), - ApricotPhase2BlockTimestamp: utils.NewUint64(0), - ApricotPhase3BlockTimestamp: utils.NewUint64(0), - ApricotPhase4BlockTimestamp: utils.NewUint64(0), - ApricotPhase5BlockTimestamp: utils.NewUint64(0), - BanffBlockTimestamp: utils.NewUint64(0), - CortinaBlockTimestamp: utils.NewUint64(0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase3BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase4BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase5BlockTimestamp: utils.PointerTo[uint64](0), + BanffBlockTimestamp: utils.PointerTo[uint64](0), + CortinaBlockTimestamp: utils.PointerTo[uint64](0), }, }, ), @@ -362,14 +362,14 @@ func initializeForks() { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.NewUint64(0), - ApricotPhase2BlockTimestamp: utils.NewUint64(0), - ApricotPhase3BlockTimestamp: utils.NewUint64(0), - ApricotPhase4BlockTimestamp: utils.NewUint64(0), - ApricotPhase5BlockTimestamp: utils.NewUint64(0), - BanffBlockTimestamp: utils.NewUint64(0), - CortinaBlockTimestamp: utils.NewUint64(0), - DurangoBlockTimestamp: utils.NewUint64(0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase3BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase4BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase5BlockTimestamp: utils.PointerTo[uint64](0), + BanffBlockTimestamp: utils.PointerTo[uint64](0), + CortinaBlockTimestamp: utils.PointerTo[uint64](0), + DurangoBlockTimestamp: utils.PointerTo[uint64](0), }, }, ), @@ -386,19 +386,19 @@ func initializeForks() { IstanbulBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.NewUint64(0), - ApricotPhase2BlockTimestamp: utils.NewUint64(0), - ApricotPhase3BlockTimestamp: utils.NewUint64(0), - ApricotPhase4BlockTimestamp: utils.NewUint64(0), - ApricotPhase5BlockTimestamp: utils.NewUint64(0), - BanffBlockTimestamp: utils.NewUint64(0), - CortinaBlockTimestamp: utils.NewUint64(0), - DurangoBlockTimestamp: utils.NewUint64(0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase3BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase4BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase5BlockTimestamp: utils.PointerTo[uint64](0), + BanffBlockTimestamp: utils.PointerTo[uint64](0), + CortinaBlockTimestamp: utils.PointerTo[uint64](0), + DurangoBlockTimestamp: utils.PointerTo[uint64](0), }, }, ), diff --git a/graft/evm/utils/numbers.go b/graft/evm/utils/numbers.go index 5d983a25fe39..1361f011db4b 100644 --- a/graft/evm/utils/numbers.go +++ b/graft/evm/utils/numbers.go @@ -8,11 +8,11 @@ import ( "time" ) -func NewUint64(val uint64) *uint64 { return &val } +func PointerTo[T any](x T) *T { return &x } func TimeToNewUint64(time time.Time) *uint64 { unix := uint64(time.Unix()) - return NewUint64(unix) + return PointerTo(unix) } func Uint64ToTime(val *uint64) time.Time { diff --git a/graft/evm/utils/utilstest/pointer.go b/graft/evm/utils/utilstest/pointer.go deleted file mode 100644 index 27b36369d7ce..000000000000 --- a/graft/evm/utils/utilstest/pointer.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package utilstest - -func PointerTo[T any](x T) *T { return &x } diff --git a/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go b/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go index 87af5c8e39eb..fe4e4277b1f2 100644 --- a/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go +++ b/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go @@ -34,7 +34,7 @@ func TestVerify(t *testing.T) { {{- end}} tests := map[string]precompiletest.ConfigVerifyTest{ "valid config": { - Config: NewConfig(utils.NewUint64(3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() @@ -45,7 +45,7 @@ func TestVerify(t *testing.T) { // CUSTOM CODE STARTS HERE // Add your own Verify tests here, e.g.: // "your custom test name": { - // Config: NewConfig(utils.NewUint64(3), {{- if .Contract.AllowList}} admins, enableds, managers{{- end}}), + // Config: NewConfig(utils.PointerTo[uint64](3), {{- if .Contract.AllowList}} admins, enableds, managers{{- end}}), // ExpectedError: ErrYourCustomError, // }, } @@ -71,23 +71,23 @@ func TestEqual(t *testing.T) { {{- end}} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: NewConfig(utils.NewUint64(3){{- if .Contract.AllowList}}, admins, enableds,managers{{- end}}), + Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds,managers{{- end}}), Other: nil, Expected: false, }, "different type": { - Config: NewConfig(utils.NewUint64(3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: NewConfig(utils.NewUint64(3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), - Other: NewConfig(utils.NewUint64(4){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Other: NewConfig(utils.PointerTo[uint64](4){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Expected: false, }, "same config": { - Config: NewConfig(utils.NewUint64(3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), - Other: NewConfig(utils.NewUint64(3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Other: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Expected: true, }, // CUSTOM CODE STARTS HERE diff --git a/graft/subnet-evm/core/blockchain_ext_test.go b/graft/subnet-evm/core/blockchain_ext_test.go index d2184e2e7e54..2150317a1077 100644 --- a/graft/subnet-evm/core/blockchain_ext_test.go +++ b/graft/subnet-evm/core/blockchain_ext_test.go @@ -1405,8 +1405,8 @@ func StatefulPrecompiles(t *testing.T, create createFunc) { config := params.Copy(params.TestChainConfig) // Set all of the required config parameters params.GetExtra(&config).GenesisPrecompiles = extras.Precompiles{ - deployerallowlist.ConfigKey: deployerallowlist.NewConfig(utils.NewUint64(0), []common.Address{addr1}, nil, nil), - feemanager.ConfigKey: feemanager.NewConfig(utils.NewUint64(0), []common.Address{addr1}, nil, nil, nil), + deployerallowlist.ConfigKey: deployerallowlist.NewConfig(utils.PointerTo[uint64](0), []common.Address{addr1}, nil, nil), + feemanager.ConfigKey: feemanager.NewConfig(utils.PointerTo[uint64](0), []common.Address{addr1}, nil, nil, nil), } gspec := &Genesis{ Config: &config, diff --git a/graft/subnet-evm/core/genesis_extra_test.go b/graft/subnet-evm/core/genesis_extra_test.go index a94b749d0ba4..64f3d3b19dd4 100644 --- a/graft/subnet-evm/core/genesis_extra_test.go +++ b/graft/subnet-evm/core/genesis_extra_test.go @@ -49,7 +49,7 @@ func TestGenesisEthUpgrades(t *testing.T) { MinBaseFee: big.NewInt(1), }, NetworkUpgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), }, }, ) diff --git a/graft/subnet-evm/core/genesis_test.go b/graft/subnet-evm/core/genesis_test.go index 24e18a2b0686..2ccd59e17a4d 100644 --- a/graft/subnet-evm/core/genesis_test.go +++ b/graft/subnet-evm/core/genesis_test.go @@ -81,7 +81,7 @@ func TestSetupGenesis(t *testing.T) { func testSetupGenesis(t *testing.T, scheme string) { preSubnetConfig := params.Copy(params.TestPreSubnetEVMChainConfig) - params.GetExtra(&preSubnetConfig).SubnetEVMTimestamp = utils.NewUint64(100) + params.GetExtra(&preSubnetConfig).SubnetEVMTimestamp = utils.PointerTo[uint64](100) var ( customghash = common.HexToHash("0x4a12fe7bf8d40d152d7e9de22337b115186a4662aa3a97217b36146202bbfc66") customg = Genesis{ @@ -95,7 +95,7 @@ func testSetupGenesis(t *testing.T, scheme string) { ) rollbackpreSubnetConfig := params.Copy(&preSubnetConfig) - params.GetExtra(&rollbackpreSubnetConfig).SubnetEVMTimestamp = utils.NewUint64(90) + params.GetExtra(&rollbackpreSubnetConfig).SubnetEVMTimestamp = utils.PointerTo[uint64](90) oldcustomg.Config = &rollbackpreSubnetConfig tests := []struct { @@ -226,7 +226,7 @@ func TestStatefulPrecompilesConfigure(t *testing.T) { getConfig: func() *params.ChainConfig { config := params.Copy(params.TestChainConfig) params.GetExtra(&config).GenesisPrecompiles = extras.Precompiles{ - deployerallowlist.ConfigKey: deployerallowlist.NewConfig(utils.NewUint64(0), []common.Address{addr}, nil, nil), + deployerallowlist.ConfigKey: deployerallowlist.NewConfig(utils.PointerTo[uint64](0), []common.Address{addr}, nil, nil), } return &config }, @@ -300,7 +300,7 @@ func TestPrecompileActivationAfterHeaderBlock(t *testing.T) { require.Greater(block.Time, bc.lastAccepted.Time()) activatedGenesisConfig := params.Copy(customg.Config) - contractDeployerConfig := deployerallowlist.NewConfig(utils.NewUint64(51), nil, nil, nil) + contractDeployerConfig := deployerallowlist.NewConfig(utils.PointerTo[uint64](51), nil, nil, nil) params.GetExtra(&activatedGenesisConfig).UpgradeConfig.PrecompileUpgrades = []extras.PrecompileUpgrade{ { Config: contractDeployerConfig, @@ -341,7 +341,7 @@ func TestGenesisWriteUpgradesRegression(t *testing.T) { params.GetExtra(genesis.Config).UpgradeConfig.PrecompileUpgrades = []extras.PrecompileUpgrade{ { - Config: deployerallowlist.NewConfig(utils.NewUint64(51), nil, nil, nil), + Config: deployerallowlist.NewConfig(utils.PointerTo[uint64](51), nil, nil, nil), }, } _, _, err = SetupGenesisBlock(db, trieDB, genesis, genesisBlock.Hash(), false) diff --git a/graft/subnet-evm/core/state_processor_ext_test.go b/graft/subnet-evm/core/state_processor_ext_test.go index 79d8beba15e6..9424ec92f757 100644 --- a/graft/subnet-evm/core/state_processor_ext_test.go +++ b/graft/subnet-evm/core/state_processor_ext_test.go @@ -50,10 +50,10 @@ func TestBadTxAllowListBlock(t *testing.T) { &extras.ChainConfig{ FeeConfig: params.DefaultFeeConfig, NetworkUpgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), }, GenesisPrecompiles: extras.Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(utils.NewUint64(0), nil, nil, nil), + txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](0), nil, nil, nil), }, }, ) diff --git a/graft/subnet-evm/core/state_processor_test.go b/graft/subnet-evm/core/state_processor_test.go index f946a7b94754..e05b36d546f7 100644 --- a/graft/subnet-evm/core/state_processor_test.go +++ b/graft/subnet-evm/core/state_processor_test.go @@ -385,7 +385,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr } if configExtra.IsGranite(header.Time) { headerExtra := customtypes.GetHeaderExtra(header) - headerExtra.TimeMilliseconds = utils.NewUint64(timeMS) + headerExtra.TimeMilliseconds = utils.PointerTo(timeMS) } if params.GetExtra(config).IsSubnetEVM(header.Time) { diff --git a/graft/subnet-evm/internal/ethapi/api_test.go b/graft/subnet-evm/internal/ethapi/api_test.go index 499983474365..a434a9e9ee06 100644 --- a/graft/subnet-evm/internal/ethapi/api_test.go +++ b/graft/subnet-evm/internal/ethapi/api_test.go @@ -800,8 +800,8 @@ func TestEstimateGas(t *testing.T) { func TestCall(t *testing.T) { // Enable BLOBHASH opcode in Cancun cfg := *params.TestChainConfig - cfg.ShanghaiTime = utils.NewUint64(0) - cfg.CancunTime = utils.NewUint64(0) + cfg.ShanghaiTime = utils.PointerTo[uint64](0) + cfg.CancunTime = utils.PointerTo[uint64](0) t.Parallel() // Initialize test accounts var ( diff --git a/graft/subnet-evm/params/config.go b/graft/subnet-evm/params/config.go index 30e820a771e5..1910061f6b67 100644 --- a/graft/subnet-evm/params/config.go +++ b/graft/subnet-evm/params/config.go @@ -97,8 +97,8 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, extras.TestChainConfig, ) @@ -153,7 +153,7 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), }, extras.TestDurangoChainConfig, ) @@ -172,8 +172,8 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, extras.TestEtnaChainConfig, ) @@ -192,8 +192,8 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, extras.TestFortunaChainConfig, ) @@ -212,8 +212,8 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, extras.TestGraniteChainConfig, ) @@ -232,8 +232,8 @@ func initialiseChainConfigs() { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, extras.TestHeliconChainConfig, ) diff --git a/graft/subnet-evm/params/config_extra.go b/graft/subnet-evm/params/config_extra.go index afc8cb8459b7..c808193226d8 100644 --- a/graft/subnet-evm/params/config_extra.go +++ b/graft/subnet-evm/params/config_extra.go @@ -73,11 +73,11 @@ func SetEthUpgrades(c *ChainConfig) error { extra := GetExtra(c) // We only mark Eth upgrades as enabled if we have marked them as scheduled. if durango := extra.DurangoTimestamp; durango != nil && *durango < unscheduledActivation { - c.ShanghaiTime = utils.NewUint64(*durango) + c.ShanghaiTime = utils.PointerTo(*durango) } if etna := extra.EtnaTimestamp; etna != nil && *etna < unscheduledActivation { - c.CancunTime = utils.NewUint64(*etna) + c.CancunTime = utils.PointerTo(*etna) } return nil } diff --git a/graft/subnet-evm/params/config_extra_test.go b/graft/subnet-evm/params/config_extra_test.go index 8178a32e92b9..cf345a40fe6b 100644 --- a/graft/subnet-evm/params/config_extra_test.go +++ b/graft/subnet-evm/params/config_extra_test.go @@ -22,7 +22,7 @@ func TestMain(m *testing.M) { func TestSetEthUpgrades(t *testing.T) { genesisBlock := big.NewInt(0) - genesisTimestamp := utils.NewUint64(initiallyActive) + genesisTimestamp := utils.PointerTo(initiallyActive) tests := []struct { fork upgradetest.Fork expected *ChainConfig diff --git a/graft/subnet-evm/params/config_test.go b/graft/subnet-evm/params/config_test.go index b64e8401226d..5915b52c3166 100644 --- a/graft/subnet-evm/params/config_test.go +++ b/graft/subnet-evm/params/config_test.go @@ -125,7 +125,7 @@ func TestCheckCompatible(t *testing.T) { headTimestamp: 0, wantErr: ðparams.ConfigCompatError{ What: "SubnetEVM fork block timestamp", - StoredTime: utils.NewUint64(0), + StoredTime: utils.PointerTo[uint64](0), NewTime: GetExtra(TestPreSubnetEVMChainConfig).NetworkUpgrades.SubnetEVMTimestamp, RewindToTime: 0, }, @@ -137,7 +137,7 @@ func TestCheckCompatible(t *testing.T) { headTimestamp: 100, wantErr: ðparams.ConfigCompatError{ What: "SubnetEVM fork block timestamp", - StoredTime: utils.NewUint64(0), + StoredTime: utils.PointerTo[uint64](0), NewTime: GetExtra(TestPreSubnetEVMChainConfig).NetworkUpgrades.SubnetEVMTimestamp, RewindToTime: 0, }, @@ -157,7 +157,7 @@ func TestConfigRules(t *testing.T) { &ChainConfig{}, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(500), + SubnetEVMTimestamp: utils.PointerTo[uint64](500), }, }, ) @@ -180,7 +180,7 @@ func TestConfigUnmarshalJSON(t *testing.T) { require := require.New(t) testRewardManagerConfig := rewardmanager.NewConfig( - utils.NewUint64(1671542573), + utils.PointerTo[uint64](1671542573), []common.Address{common.HexToAddress("0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC")}, nil, nil, @@ -189,7 +189,7 @@ func TestConfigUnmarshalJSON(t *testing.T) { }) testContractNativeMinterConfig := nativeminter.NewConfig( - utils.NewUint64(0), + utils.PointerTo[uint64](0), []common.Address{common.HexToAddress("0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC")}, nil, nil, @@ -249,10 +249,10 @@ func TestActivePrecompiles(t *testing.T) { UpgradeConfig: extras.UpgradeConfig{ PrecompileUpgrades: []extras.PrecompileUpgrade{ { - Config: nativeminter.NewConfig(utils.NewUint64(0), nil, nil, nil, nil), // enable at genesis + Config: nativeminter.NewConfig(utils.PointerTo[uint64](0), nil, nil, nil, nil), // enable at genesis }, { - Config: nativeminter.NewDisableConfig(utils.NewUint64(1)), // disable at timestamp 1 + Config: nativeminter.NewDisableConfig(utils.PointerTo[uint64](1)), // disable at timestamp 1 }, }, }, @@ -285,8 +285,8 @@ func TestChainConfigMarshalWithUpgrades(t *testing.T) { FeeConfig: DefaultFeeConfig, AllowFeeRecipients: false, NetworkUpgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), - DurangoTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), + DurangoTimestamp: utils.PointerTo[uint64](0), }, GenesisPrecompiles: extras.Precompiles{}, }, @@ -294,7 +294,7 @@ func TestChainConfigMarshalWithUpgrades(t *testing.T) { UpgradeConfig: extras.UpgradeConfig{ PrecompileUpgrades: []extras.PrecompileUpgrade{ { - Config: txallowlist.NewConfig(utils.NewUint64(100), nil, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](100), nil, nil, nil), }, }, }, diff --git a/graft/subnet-evm/params/extras/config.go b/graft/subnet-evm/params/extras/config.go index f806a4f80ea4..5e47c1d4abfc 100644 --- a/graft/subnet-evm/params/extras/config.go +++ b/graft/subnet-evm/params/extras/config.go @@ -46,27 +46,27 @@ var ( } TestSubnetEVMChainConfig = copyAndSet(TestPreSubnetEVMChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.SubnetEVMTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.SubnetEVMTimestamp = utils.PointerTo[uint64](0) }) TestDurangoChainConfig = copyAndSet(TestSubnetEVMChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.DurangoTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.DurangoTimestamp = utils.PointerTo[uint64](0) }) TestEtnaChainConfig = copyAndSet(TestDurangoChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.EtnaTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.EtnaTimestamp = utils.PointerTo[uint64](0) }) TestFortunaChainConfig = copyAndSet(TestEtnaChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.FortunaTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.FortunaTimestamp = utils.PointerTo[uint64](0) }) TestGraniteChainConfig = copyAndSet(TestFortunaChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.GraniteTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.GraniteTimestamp = utils.PointerTo[uint64](0) }) TestHeliconChainConfig = copyAndSet(TestGraniteChainConfig, func(c *ChainConfig) { - c.NetworkUpgrades.HeliconTimestamp = utils.NewUint64(0) + c.NetworkUpgrades.HeliconTimestamp = utils.PointerTo[uint64](0) }) TestChainConfig = copyConfig(TestHeliconChainConfig) @@ -123,7 +123,7 @@ func (c *ChainConfig) CheckConfigCompatible(newConfig *ethparams.ChainConfig, he // Return an error to prevent the chain from starting, just in case. return ethparams.NewTimestampCompatError( fmt.Sprintf("ChainConfig.Hooks() is not of the expected type *extras.ChainConfig, got %T", newConfig.Hooks()), - utils.NewUint64(0), + utils.PointerTo[uint64](0), nil, ) } diff --git a/graft/subnet-evm/params/extras/config_extra_test.go b/graft/subnet-evm/params/extras/config_extra_test.go index ffc1997b5aaf..bee75618a8c2 100644 --- a/graft/subnet-evm/params/extras/config_extra_test.go +++ b/graft/subnet-evm/params/extras/config_extra_test.go @@ -30,22 +30,22 @@ func TestIsTimestampForked(t *testing.T) { isForked: false, }, "zero fork at genesis": { - fork: utils.NewUint64(0), + fork: utils.PointerTo[uint64](0), block: 0, isForked: true, }, "pre fork timestamp": { - fork: utils.NewUint64(100), + fork: utils.PointerTo[uint64](100), block: 50, isForked: false, }, "at fork timestamp": { - fork: utils.NewUint64(100), + fork: utils.PointerTo[uint64](100), block: 100, isForked: true, }, "post fork timestamp": { - fork: utils.NewUint64(100), + fork: utils.PointerTo[uint64](100), block: 150, isForked: true, }, @@ -72,50 +72,50 @@ func TestIsForkTransition(t *testing.T) { transitioned: false, }, "activate at genesis": { - fork: utils.NewUint64(0), + fork: utils.PointerTo[uint64](0), parent: nil, current: 0, transitioned: true, }, "nil fork arbitrary transition": { fork: nil, - parent: utils.NewUint64(100), + parent: utils.PointerTo[uint64](100), current: 101, transitioned: false, }, "nil fork transition same timestamp": { fork: nil, - parent: utils.NewUint64(100), + parent: utils.PointerTo[uint64](100), current: 100, transitioned: false, }, "exact match on current timestamp": { - fork: utils.NewUint64(100), - parent: utils.NewUint64(99), + fork: utils.PointerTo[uint64](100), + parent: utils.PointerTo[uint64](99), current: 100, transitioned: true, }, "current same as parent does not transition twice": { - fork: utils.NewUint64(100), - parent: utils.NewUint64(101), + fork: utils.PointerTo[uint64](100), + parent: utils.PointerTo[uint64](101), current: 101, transitioned: false, }, "current, parent, and fork same should not transition twice": { - fork: utils.NewUint64(100), - parent: utils.NewUint64(100), + fork: utils.PointerTo[uint64](100), + parent: utils.PointerTo[uint64](100), current: 100, transitioned: false, }, "current transitions after fork": { - fork: utils.NewUint64(100), - parent: utils.NewUint64(99), + fork: utils.PointerTo[uint64](100), + parent: utils.PointerTo[uint64](99), current: 101, transitioned: true, }, "current and parent come after fork": { - fork: utils.NewUint64(100), - parent: utils.NewUint64(101), + fork: utils.PointerTo[uint64](100), + parent: utils.PointerTo[uint64](101), current: 102, transitioned: false, }, diff --git a/graft/subnet-evm/params/extras/network_upgrades.go b/graft/subnet-evm/params/extras/network_upgrades.go index 40c8d8981ec4..a1476857b08c 100644 --- a/graft/subnet-evm/params/extras/network_upgrades.go +++ b/graft/subnet-evm/params/extras/network_upgrades.go @@ -237,7 +237,7 @@ func (n *NetworkUpgrades) GetAvalancheRules(time uint64) AvalancheRules { // Nil values are used to indicate optional upgrades. func GetNetworkUpgrades(agoUpgrade upgrade.Config) NetworkUpgrades { return NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(agoUpgrade.DurangoTime), EtnaTimestamp: utils.TimeToNewUint64(agoUpgrade.EtnaTime), FortunaTimestamp: nil, // Fortuna is optional and has no effect on Subnet-EVM diff --git a/graft/subnet-evm/params/extras/network_upgrades_test.go b/graft/subnet-evm/params/extras/network_upgrades_test.go index 2af3baf97765..1d4986f560c0 100644 --- a/graft/subnet-evm/params/extras/network_upgrades_test.go +++ b/graft/subnet-evm/params/extras/network_upgrades_test.go @@ -24,32 +24,32 @@ func TestNetworkUpgradesEqual(t *testing.T) { { name: "EqualNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, expected: true, }, { name: "NotEqualNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(3), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](3), }, expected: false, }, { name: "NilNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: nil, expected: false, @@ -57,11 +57,11 @@ func TestNetworkUpgradesEqual(t *testing.T) { { name: "NilNetworkUpgrade", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), DurangoTimestamp: nil, }, expected: false, @@ -85,12 +85,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_same_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, time: 1, valid: true, @@ -98,12 +98,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_different_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(3), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](3), }, time: 1, valid: true, @@ -111,11 +111,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_nil_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), DurangoTimestamp: nil, }, time: 1, @@ -124,12 +124,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_rewinded_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](1), }, time: 1, valid: false, @@ -137,12 +137,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_fastforward_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(3), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](3), }, time: 4, valid: false, @@ -150,11 +150,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_nil_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), DurangoTimestamp: nil, }, time: 2, @@ -211,7 +211,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Durango_nil_upgrade", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), DurangoTimestamp: nil, }, avagoUpgrades: upgrade.Mainnet, @@ -220,8 +220,8 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Subnet-EVM_non-zero", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, avagoUpgrades: upgrade.Mainnet, wantError: errTimestampTooEarly, @@ -229,8 +229,8 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Durango_before_default_upgrade", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), - DurangoTimestamp: utils.NewUint64(1), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), + DurangoTimestamp: utils.PointerTo[uint64](1), }, avagoUpgrades: upgrade.Mainnet, wantError: errTimestampTooEarly, @@ -238,7 +238,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Mainnet_Durango_reconfigured_to_Fuji", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.GetConfig(constants.FujiID).DurangoTime), }, avagoUpgrades: upgrade.Mainnet, @@ -247,7 +247,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Valid_Fuji_Durango_reconfigured_to_Mainnet", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.GetConfig(constants.MainnetID).DurangoTime), }, avagoUpgrades: upgrade.Fuji, @@ -256,7 +256,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Etna_nil", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime), EtnaTimestamp: nil, }, @@ -266,7 +266,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Etna_before_Durango", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime), EtnaTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime.Add(-1)), }, @@ -276,7 +276,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Valid_Granite_After_nil_Fortuna", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Fuji.DurangoTime), EtnaTimestamp: utils.TimeToNewUint64(upgrade.Fuji.EtnaTime), FortunaTimestamp: nil, @@ -303,16 +303,16 @@ func TestForkOrder(t *testing.T) { { name: "ValidNetworkUpgrades", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), - DurangoTimestamp: utils.NewUint64(2), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), + DurangoTimestamp: utils.PointerTo[uint64](2), }, wantError: nil, }, { name: "Invalid order", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), - DurangoTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](0), }, wantError: errUnsupportedForkOrdering, }, @@ -327,12 +327,12 @@ func TestForkOrder(t *testing.T) { func TestSetDefaultsTreatsZeroAsUnset(t *testing.T) { upgrades := &NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), - DurangoTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), + DurangoTimestamp: utils.PointerTo[uint64](0), EtnaTimestamp: nil, - FortunaTimestamp: utils.NewUint64(0), - GraniteTimestamp: utils.NewUint64(0), - HeliconTimestamp: utils.NewUint64(0), + FortunaTimestamp: utils.PointerTo[uint64](0), + GraniteTimestamp: utils.PointerTo[uint64](0), + HeliconTimestamp: utils.PointerTo[uint64](0), } agoUpgrades := upgradetest.GetConfig(upgradetest.Latest) upgrades.SetDefaults(agoUpgrades) diff --git a/graft/subnet-evm/params/extras/precompile_config_test.go b/graft/subnet-evm/params/extras/precompile_config_test.go index 697a22e910d4..0d8d8f8a2b03 100644 --- a/graft/subnet-evm/params/extras/precompile_config_test.go +++ b/graft/subnet-evm/params/extras/precompile_config_test.go @@ -28,16 +28,16 @@ func TestVerifyWithChainConfig(t *testing.T) { config := &c config.SnowCtx = utilstest.NewTestSnowContext(t, utilstest.SubnetEVMTestChainID) config.GenesisPrecompiles = Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(utils.NewUint64(2), nil, nil, nil), + txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](2), nil, nil, nil), } config.PrecompileUpgrades = []PrecompileUpgrade{ { // disable TxAllowList at timestamp 4 - txallowlist.NewDisableConfig(utils.NewUint64(4)), + txallowlist.NewDisableConfig(utils.PointerTo[uint64](4)), }, { // re-enable TxAllowList at timestamp 5 - txallowlist.NewConfig(utils.NewUint64(5), admins, nil, nil), + txallowlist.NewConfig(utils.PointerTo[uint64](5), admins, nil, nil), }, } @@ -50,7 +50,7 @@ func TestVerifyWithChainConfig(t *testing.T) { badConfig.PrecompileUpgrades = append( badConfig.PrecompileUpgrades, PrecompileUpgrade{ - Config: txallowlist.NewDisableConfig(utils.NewUint64(5)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](5)), }, ) err = badConfig.Verify() @@ -61,7 +61,7 @@ func TestVerifyWithChainConfig(t *testing.T) { badConfig.PrecompileUpgrades = append( badConfig.PrecompileUpgrades, PrecompileUpgrade{ - Config: txallowlist.NewConfig(utils.NewUint64(5), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](5), admins, nil, nil), }, ) err = badConfig.Verify() @@ -81,7 +81,7 @@ func TestVerifyWithChainConfigAtNilTimestamp(t *testing.T) { config.PrecompileUpgrades = []PrecompileUpgrade{ { // enable TxAllowList at timestamp 5 - Config: txallowlist.NewConfig(utils.NewUint64(5), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](5), admins, nil, nil), }, } @@ -100,10 +100,10 @@ func TestVerifyPrecompileUpgrades(t *testing.T) { name: "enable and disable tx allow list", upgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewConfig(utils.NewUint64(1), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](1), admins, nil, nil), }, { - Config: txallowlist.NewDisableConfig(utils.NewUint64(2)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](2)), }, }, expectedError: nil, @@ -112,13 +112,13 @@ func TestVerifyPrecompileUpgrades(t *testing.T) { name: "invalid allow list config in tx allowlist", upgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewConfig(utils.NewUint64(1), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](1), admins, nil, nil), }, { - Config: txallowlist.NewDisableConfig(utils.NewUint64(2)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](2)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(3), admins, admins, admins), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](3), admins, admins, admins), }, }, expectedError: allowlist.ErrAdminAndEnabledAddress, @@ -127,7 +127,7 @@ func TestVerifyPrecompileUpgrades(t *testing.T) { name: "invalid initial fee manager config", upgrades: []PrecompileUpgrade{ { - Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, func() *commontype.FeeConfig { feeConfig := DefaultFeeConfig feeConfig.GasLimit = big.NewInt(-1) @@ -141,7 +141,7 @@ func TestVerifyPrecompileUpgrades(t *testing.T) { name: "invalid initial fee manager config gas limit 0", upgrades: []PrecompileUpgrade{ { - Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, func() *commontype.FeeConfig { feeConfig := DefaultFeeConfig feeConfig.GasLimit = common.Big0 @@ -155,10 +155,10 @@ func TestVerifyPrecompileUpgrades(t *testing.T) { name: "different upgrades are allowed to configure same timestamp for different precompiles", upgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewConfig(utils.NewUint64(1), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](1), admins, nil, nil), }, { - Config: feemanager.NewConfig(utils.NewUint64(1), admins, nil, nil, nil), + Config: feemanager.NewConfig(utils.PointerTo[uint64](1), admins, nil, nil, nil), }, }, expectedError: nil, @@ -167,10 +167,10 @@ func TestVerifyPrecompileUpgrades(t *testing.T) { name: "different upgrades must be monotonically increasing", upgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewConfig(utils.NewUint64(2), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](2), admins, nil, nil), }, { - Config: feemanager.NewConfig(utils.NewUint64(1), admins, nil, nil, nil), + Config: feemanager.NewConfig(utils.PointerTo[uint64](1), admins, nil, nil, nil), }, }, expectedError: errPrecompileUpgradeTimestampNotMonotonic, @@ -179,10 +179,10 @@ func TestVerifyPrecompileUpgrades(t *testing.T) { name: "upgrades with same keys are not allowed to configure same timestamp for same precompiles", upgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewConfig(utils.NewUint64(1), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](1), admins, nil, nil), }, { - Config: txallowlist.NewDisableConfig(utils.NewUint64(1)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](1)), }, }, expectedError: errPrecompileUpgradeSameKeyTimestampNotStrictly, @@ -212,14 +212,14 @@ func TestVerifyPrecompiles(t *testing.T) { { name: "invalid allow list config in tx allowlist", precompiles: Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(utils.NewUint64(3), admins, admins, admins), + txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](3), admins, admins, admins), }, expectedError: allowlist.ErrAdminAndEnabledAddress, }, { name: "invalid initial fee manager config", precompiles: Precompiles{ - feemanager.ConfigKey: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, + feemanager.ConfigKey: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, func() *commontype.FeeConfig { feeConfig := DefaultFeeConfig feeConfig.GasLimit = big.NewInt(-1) @@ -253,10 +253,10 @@ func TestVerifyRequiresSortedTimestamps(t *testing.T) { } config.PrecompileUpgrades = []PrecompileUpgrade{ { - Config: txallowlist.NewConfig(utils.NewUint64(2), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](2), admins, nil, nil), }, { - Config: deployerallowlist.NewConfig(utils.NewUint64(1), admins, nil, nil), + Config: deployerallowlist.NewConfig(utils.PointerTo[uint64](1), admins, nil, nil), }, } @@ -269,7 +269,7 @@ func TestGetPrecompileConfig(t *testing.T) { require := require.New(t) config := &ChainConfig{} config.GenesisPrecompiles = Precompiles{ - deployerallowlist.ConfigKey: deployerallowlist.NewConfig(utils.NewUint64(10), nil, nil, nil), + deployerallowlist.ConfigKey: deployerallowlist.NewConfig(utils.PointerTo[uint64](10), nil, nil, nil), } deployerConfig := config.GetActivePrecompileConfig(deployerallowlist.ContractAddress, 0) @@ -320,7 +320,7 @@ func TestPrecompileUpgradeUnmarshalJSON(t *testing.T) { rewardManagerConf := upgradeConfig.PrecompileUpgrades[0] require.Equal(rewardmanager.ConfigKey, rewardManagerConf.Key()) testRewardManagerConfig := rewardmanager.NewConfig( - utils.NewUint64(1671542573), + utils.PointerTo[uint64](1671542573), []common.Address{common.HexToAddress("0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC")}, nil, nil, @@ -331,7 +331,7 @@ func TestPrecompileUpgradeUnmarshalJSON(t *testing.T) { nativeMinterConfig := upgradeConfig.PrecompileUpgrades[1] require.Equal(nativeminter.ConfigKey, nativeMinterConfig.Key()) - expectedNativeMinterConfig := nativeminter.NewConfig(utils.NewUint64(1671543172), nil, nil, nil, nil) + expectedNativeMinterConfig := nativeminter.NewConfig(utils.PointerTo[uint64](1671543172), nil, nil, nil, nil) require.True(nativeMinterConfig.Equal(expectedNativeMinterConfig)) // Marshal and unmarshal again and check that the result is the same diff --git a/graft/subnet-evm/params/extras/precompile_upgrade.go b/graft/subnet-evm/params/extras/precompile_upgrade.go index 54504e88e37d..eb69cae2f3a8 100644 --- a/graft/subnet-evm/params/extras/precompile_upgrade.go +++ b/graft/subnet-evm/params/extras/precompile_upgrade.go @@ -119,7 +119,7 @@ func (c *ChainConfig) verifyPrecompileUpgrades() error { lastTimestamp = nil } else { disabled = lastUpgradeByKey.disabled - lastTimestamp = utils.NewUint64(lastUpgradeByKey.blockTimestamp) + lastTimestamp = utils.PointerTo(lastUpgradeByKey.blockTimestamp) } upgradeTimestamp := upgrade.Timestamp() diff --git a/graft/subnet-evm/params/extras/precompile_upgrade_test.go b/graft/subnet-evm/params/extras/precompile_upgrade_test.go index c5cd3b160524..1d4daee011c9 100644 --- a/graft/subnet-evm/params/extras/precompile_upgrade_test.go +++ b/graft/subnet-evm/params/extras/precompile_upgrade_test.go @@ -21,7 +21,7 @@ func TestVerifyUpgradeConfig(t *testing.T) { FeeConfig: DefaultFeeConfig, } chainConfig.GenesisPrecompiles = Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(utils.NewUint64(1), admins, nil, nil), + txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](1), admins, nil, nil), } type test struct { @@ -34,7 +34,7 @@ func TestVerifyUpgradeConfig(t *testing.T) { expectedError: errPrecompileUpgradeInvalidDisable, upgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewConfig(utils.NewUint64(2), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](2), admins, nil, nil), }, }, }, @@ -42,7 +42,7 @@ func TestVerifyUpgradeConfig(t *testing.T) { expectedError: errPrecompileUpgradeSameKeyTimestampNotStrictly, upgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(0)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](0)), }, }, }, @@ -50,7 +50,7 @@ func TestVerifyUpgradeConfig(t *testing.T) { expectedError: errPrecompileUpgradeSameKeyTimestampNotStrictly, upgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(1)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](1)), }, }, }, @@ -79,8 +79,8 @@ func TestCheckCompatibleUpgradeConfigs(t *testing.T) { admins := []common.Address{{1}} chainConfig := &ChainConfig{} chainConfig.GenesisPrecompiles = Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(utils.NewUint64(1), admins, nil, nil), - deployerallowlist.ConfigKey: deployerallowlist.NewConfig(utils.NewUint64(10), admins, nil, nil), + txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](1), admins, nil, nil), + deployerallowlist.ConfigKey: deployerallowlist.NewConfig(utils.PointerTo[uint64](10), admins, nil, nil), } tests := map[string]upgradeCompatibilityTest{ @@ -90,10 +90,10 @@ func TestCheckCompatibleUpgradeConfigs(t *testing.T) { { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(7), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](7), admins, nil, nil), }, }, }, @@ -105,20 +105,20 @@ func TestCheckCompatibleUpgradeConfigs(t *testing.T) { { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(7), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](7), admins, nil, nil), }, }, }, { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(8), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](8), admins, nil, nil), }, }, }, @@ -131,20 +131,20 @@ func TestCheckCompatibleUpgradeConfigs(t *testing.T) { { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(7), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](7), admins, nil, nil), }, }, }, { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(8), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](8), admins, nil, nil), }, }, }, @@ -156,17 +156,17 @@ func TestCheckCompatibleUpgradeConfigs(t *testing.T) { { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(7), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](7), admins, nil, nil), }, }, }, { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, }, }, @@ -179,17 +179,17 @@ func TestCheckCompatibleUpgradeConfigs(t *testing.T) { { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(7), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](7), admins, nil, nil), }, }, }, { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, }, }, @@ -202,21 +202,21 @@ func TestCheckCompatibleUpgradeConfigs(t *testing.T) { { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(7), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](7), admins, nil, nil), }, }, }, { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, { // uses a different (empty) admin list, not allowed - Config: txallowlist.NewConfig(utils.NewUint64(7), []common.Address{}, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](7), []common.Address{}, nil, nil), }, }, }, @@ -228,20 +228,20 @@ func TestCheckCompatibleUpgradeConfigs(t *testing.T) { { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(7), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](7), admins, nil, nil), }, }, }, { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(6)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](6)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(7), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](7), admins, nil, nil), }, }, }, @@ -254,10 +254,10 @@ func TestCheckCompatibleUpgradeConfigs(t *testing.T) { { PrecompileUpgrades: []PrecompileUpgrade{ { - Config: txallowlist.NewDisableConfig(utils.NewUint64(5)), + Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](5)), }, { - Config: txallowlist.NewConfig(utils.NewUint64(6), admins, nil, nil), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](6), admins, nil, nil), }, }, }, diff --git a/graft/subnet-evm/params/extras/state_upgrade_test.go b/graft/subnet-evm/params/extras/state_upgrade_test.go index 5a6cbcebad23..6a0e43f712b4 100644 --- a/graft/subnet-evm/params/extras/state_upgrade_test.go +++ b/graft/subnet-evm/params/extras/state_upgrade_test.go @@ -30,31 +30,31 @@ func TestVerifyStateUpgrades(t *testing.T) { { name: "valid upgrade", upgrades: []StateUpgrade{ - {BlockTimestamp: utils.NewUint64(1), StateUpgradeAccounts: modifiedAccounts}, - {BlockTimestamp: utils.NewUint64(2), StateUpgradeAccounts: modifiedAccounts}, + {BlockTimestamp: utils.PointerTo[uint64](1), StateUpgradeAccounts: modifiedAccounts}, + {BlockTimestamp: utils.PointerTo[uint64](2), StateUpgradeAccounts: modifiedAccounts}, }, expectedError: nil, }, { name: "upgrade block timestamp is not strictly increasing", upgrades: []StateUpgrade{ - {BlockTimestamp: utils.NewUint64(1), StateUpgradeAccounts: modifiedAccounts}, - {BlockTimestamp: utils.NewUint64(1), StateUpgradeAccounts: modifiedAccounts}, + {BlockTimestamp: utils.PointerTo[uint64](1), StateUpgradeAccounts: modifiedAccounts}, + {BlockTimestamp: utils.PointerTo[uint64](1), StateUpgradeAccounts: modifiedAccounts}, }, expectedError: errStateUpgradeTimestampNotMonotonic, }, { name: "upgrade block timestamp decreases", upgrades: []StateUpgrade{ - {BlockTimestamp: utils.NewUint64(2), StateUpgradeAccounts: modifiedAccounts}, - {BlockTimestamp: utils.NewUint64(1), StateUpgradeAccounts: modifiedAccounts}, + {BlockTimestamp: utils.PointerTo[uint64](2), StateUpgradeAccounts: modifiedAccounts}, + {BlockTimestamp: utils.PointerTo[uint64](1), StateUpgradeAccounts: modifiedAccounts}, }, expectedError: errStateUpgradeTimestampNotMonotonic, }, { name: "upgrade block timestamp is zero", upgrades: []StateUpgrade{ - {BlockTimestamp: utils.NewUint64(0), StateUpgradeAccounts: modifiedAccounts}, + {BlockTimestamp: utils.PointerTo[uint64](0), StateUpgradeAccounts: modifiedAccounts}, }, expectedError: errStateUpgradeTimestampZero, }, @@ -88,12 +88,12 @@ func TestCheckCompatibleStateUpgrades(t *testing.T) { configs: []*UpgradeConfig{ { StateUpgrades: []StateUpgrade{ - {BlockTimestamp: utils.NewUint64(6), StateUpgradeAccounts: stateUpgrade}, + {BlockTimestamp: utils.PointerTo[uint64](6), StateUpgradeAccounts: stateUpgrade}, }, }, { StateUpgrades: []StateUpgrade{ - {BlockTimestamp: utils.NewUint64(6), StateUpgradeAccounts: stateUpgrade}, + {BlockTimestamp: utils.PointerTo[uint64](6), StateUpgradeAccounts: stateUpgrade}, }, }, }, @@ -104,14 +104,14 @@ func TestCheckCompatibleStateUpgrades(t *testing.T) { configs: []*UpgradeConfig{ { StateUpgrades: []StateUpgrade{ - {BlockTimestamp: utils.NewUint64(6), StateUpgradeAccounts: stateUpgrade}, - {BlockTimestamp: utils.NewUint64(7), StateUpgradeAccounts: stateUpgrade}, + {BlockTimestamp: utils.PointerTo[uint64](6), StateUpgradeAccounts: stateUpgrade}, + {BlockTimestamp: utils.PointerTo[uint64](7), StateUpgradeAccounts: stateUpgrade}, }, }, { StateUpgrades: []StateUpgrade{ - {BlockTimestamp: utils.NewUint64(6), StateUpgradeAccounts: stateUpgrade}, - {BlockTimestamp: utils.NewUint64(7), StateUpgradeAccounts: differentStateUpgrade}, + {BlockTimestamp: utils.PointerTo[uint64](6), StateUpgradeAccounts: stateUpgrade}, + {BlockTimestamp: utils.PointerTo[uint64](7), StateUpgradeAccounts: differentStateUpgrade}, }, }, }, @@ -121,13 +121,13 @@ func TestCheckCompatibleStateUpgrades(t *testing.T) { configs: []*UpgradeConfig{ { StateUpgrades: []StateUpgrade{ - {BlockTimestamp: utils.NewUint64(6), StateUpgradeAccounts: stateUpgrade}, - {BlockTimestamp: utils.NewUint64(7), StateUpgradeAccounts: stateUpgrade}, + {BlockTimestamp: utils.PointerTo[uint64](6), StateUpgradeAccounts: stateUpgrade}, + {BlockTimestamp: utils.PointerTo[uint64](7), StateUpgradeAccounts: stateUpgrade}, }, }, { StateUpgrades: []StateUpgrade{ - {BlockTimestamp: utils.NewUint64(6), StateUpgradeAccounts: stateUpgrade}, + {BlockTimestamp: utils.PointerTo[uint64](6), StateUpgradeAccounts: stateUpgrade}, }, }, }, @@ -138,7 +138,7 @@ func TestCheckCompatibleStateUpgrades(t *testing.T) { configs: []*UpgradeConfig{ { StateUpgrades: []StateUpgrade{ - {BlockTimestamp: utils.NewUint64(5), StateUpgradeAccounts: stateUpgrade}, + {BlockTimestamp: utils.PointerTo[uint64](5), StateUpgradeAccounts: stateUpgrade}, }, }, }, @@ -171,7 +171,7 @@ func TestUnmarshalStateUpgradeJSON(t *testing.T) { upgradeConfig := UpgradeConfig{ StateUpgrades: []StateUpgrade{ { - BlockTimestamp: utils.NewUint64(1677608400), + BlockTimestamp: utils.PointerTo[uint64](1677608400), StateUpgradeAccounts: map[common.Address]StateUpgradeAccount{ common.HexToAddress("0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"): { BalanceChange: (*math.HexOrDecimal256)(big.NewInt(100)), diff --git a/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go b/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go index 892a7850f570..850cac1c2790 100644 --- a/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go @@ -48,7 +48,7 @@ func BaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) { { name: "subnet_evm_first_block", upgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), }, parent: &types.Header{ Number: big.NewInt(1), diff --git a/graft/subnet-evm/plugin/evm/customheader/extra_test.go b/graft/subnet-evm/plugin/evm/customheader/extra_test.go index 3a7e6261513c..a0826688c666 100644 --- a/graft/subnet-evm/plugin/evm/customheader/extra_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/extra_test.go @@ -46,7 +46,7 @@ func TestExtraPrefix(t *testing.T) { { name: "subnet_evm_first_block", upgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), }, parent: &types.Header{ Number: big.NewInt(1), diff --git a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go index f49f698580b9..6cc4104f431d 100644 --- a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/graft/evm/utils" - "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" "github.com/ava-labs/avalanchego/vms/evm/acp226" @@ -19,7 +18,7 @@ import ( func TestMinDelayExcess(t *testing.T) { activatingGraniteConfig := *extras.TestGraniteChainConfig activatingGraniteTimestamp := uint64(1000) - activatingGraniteConfig.NetworkUpgrades.GraniteTimestamp = utils.NewUint64(activatingGraniteTimestamp) + activatingGraniteConfig.NetworkUpgrades.GraniteTimestamp = utils.PointerTo(activatingGraniteTimestamp) tests := []struct { name string @@ -52,7 +51,7 @@ func TestMinDelayExcess(t *testing.T) { header: &types.Header{ Time: 1001, }, - desiredMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(1000)), + desiredMinDelayExcess: utils.PointerTo(acp226.DelayExcess(1000)), expectedDelayExcess: nil, }, { @@ -65,7 +64,7 @@ func TestMinDelayExcess(t *testing.T) { Time: activatingGraniteTimestamp + 1, }, desiredMinDelayExcess: nil, - expectedDelayExcess: utilstest.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), + expectedDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), }, { name: "granite_no_parent_min_delay_error", @@ -88,7 +87,7 @@ func TestMinDelayExcess(t *testing.T) { Time: 1001, }, desiredMinDelayExcess: nil, - expectedDelayExcess: utilstest.PointerTo(acp226.DelayExcess(500)), + expectedDelayExcess: utils.PointerTo(acp226.DelayExcess(500)), }, { name: "granite_with_desired_min_delay_excess", @@ -97,8 +96,8 @@ func TestMinDelayExcess(t *testing.T) { header: &types.Header{ Time: 1001, }, - desiredMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(1000)), - expectedDelayExcess: utilstest.PointerTo(acp226.DelayExcess(500 + acp226.MaxDelayExcessDiff)), + desiredMinDelayExcess: utils.PointerTo(acp226.DelayExcess(1000)), + expectedDelayExcess: utils.PointerTo(acp226.DelayExcess(500 + acp226.MaxDelayExcessDiff)), }, { name: "granite_with_zero_desired_value", @@ -107,8 +106,8 @@ func TestMinDelayExcess(t *testing.T) { header: &types.Header{ Time: 1001, }, - desiredMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(0)), - expectedDelayExcess: utilstest.PointerTo(acp226.DelayExcess(500 - acp226.MaxDelayExcessDiff)), + desiredMinDelayExcess: utils.PointerTo(acp226.DelayExcess(0)), + expectedDelayExcess: utils.PointerTo(acp226.DelayExcess(500 - acp226.MaxDelayExcessDiff)), }, } diff --git a/graft/subnet-evm/plugin/evm/customheader/time_test.go b/graft/subnet-evm/plugin/evm/customheader/time_test.go index 788377aa9204..b232195d9a0d 100644 --- a/graft/subnet-evm/plugin/evm/customheader/time_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/time_test.go @@ -31,7 +31,7 @@ func TestVerifyTime(t *testing.T) { }{ { name: "pre_granite_time_milliseconds_should_fail", - header: generateHeader(timeSeconds, utils.NewUint64(timeMillis)), + header: generateHeader(timeSeconds, utils.PointerTo(timeMillis)), extraConfig: extras.TestFortunaChainConfig, expectedErr: ErrTimeMillisecondsBeforeGranite, }, @@ -48,23 +48,23 @@ func TestVerifyTime(t *testing.T) { }, { name: "granite_time_milliseconds_matching_time_should_work", - header: generateHeader(timeSeconds, utils.NewUint64(timeSeconds*1000)), + header: generateHeader(timeSeconds, utils.PointerTo(timeSeconds*1000)), extraConfig: extras.TestGraniteChainConfig, }, { name: "granite_time_milliseconds_matching_time_rounded_should_work", - header: generateHeader(timeSeconds, utils.NewUint64(timeMillis)), + header: generateHeader(timeSeconds, utils.PointerTo(timeMillis)), extraConfig: extras.TestGraniteChainConfig, }, { name: "granite_time_milliseconds_less_than_time_should_fail", - header: generateHeader(timeSeconds, utils.NewUint64((timeSeconds-1)*1000)), + header: generateHeader(timeSeconds, utils.PointerTo((timeSeconds-1)*1000)), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrTimeMillisecondsMismatched, }, { name: "granite_time_milliseconds_greater_than_time_should_fail", - header: generateHeader(timeSeconds, utils.NewUint64((timeSeconds+1)*1000)), + header: generateHeader(timeSeconds, utils.PointerTo((timeSeconds+1)*1000)), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrTimeMillisecondsMismatched, }, @@ -77,10 +77,10 @@ func TestVerifyTime(t *testing.T) { }, { name: "granite_time_earlier_than_parent_should_fail", - header: generateHeader(timeSeconds, utils.NewUint64(timeSeconds*1000)), + header: generateHeader(timeSeconds, utils.PointerTo(timeSeconds*1000)), parentHeader: generateHeader( timeSeconds+1, - utils.NewUint64((timeSeconds+1)*1000), + utils.PointerTo((timeSeconds+1)*1000), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: errBlockTooOld, @@ -89,11 +89,11 @@ func TestVerifyTime(t *testing.T) { name: "granite_time_milliseconds_earlier_than_parent_should_fail", header: generateHeader( timeSeconds, - utils.NewUint64(timeSeconds*1000), + utils.PointerTo(timeSeconds*1000), ), parentHeader: generateHeader( timeSeconds, - utils.NewUint64(timeSeconds*1000+1), + utils.PointerTo(timeSeconds*1000+1), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: errBlockTooOld, @@ -108,7 +108,7 @@ func TestVerifyTime(t *testing.T) { name: "granite_time_too_far_in_future_should_fail", header: generateHeader( uint64(now.Add(MaxFutureBlockTime).Add(1*time.Second).Unix()), - utils.NewUint64(uint64(now.Add(MaxFutureBlockTime).Add(1*time.Second).UnixMilli())), + utils.PointerTo(uint64(now.Add(MaxFutureBlockTime).Add(1*time.Second).UnixMilli())), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrBlockTooFarInFuture, @@ -117,14 +117,14 @@ func TestVerifyTime(t *testing.T) { name: "granite_time_milliseconds_too_far_in_future_should_fail", header: generateHeader( uint64(now.Add(MaxFutureBlockTime).Unix()), - utils.NewUint64(uint64(now.Add(MaxFutureBlockTime).Add(1*time.Millisecond).UnixMilli())), + utils.PointerTo(uint64(now.Add(MaxFutureBlockTime).Add(1*time.Millisecond).UnixMilli())), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrBlockTooFarInFuture, }, { name: "first_granite_block_should_work", - header: generateHeader(timeSeconds, utils.NewUint64(timeMillis)), + header: generateHeader(timeSeconds, utils.PointerTo(timeMillis)), parentHeader: generateHeader(timeSeconds, nil), extraConfig: extras.TestGraniteChainConfig, }, @@ -139,8 +139,8 @@ func TestVerifyTime(t *testing.T) { name: "granite_first_block_no_parent_min_delay_excess", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), parentHeader: generateHeader(timeSeconds-1, nil), // Pre-Granite parent extraConfig: extras.TestGraniteChainConfig, @@ -149,13 +149,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_initial_delay_met", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, - utils.NewUint64(timeMillis-2000), // 2000 ms is the exact initial delay - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis-2000), // 2000 ms is the exact initial delay + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, }, @@ -163,13 +163,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_initial_delay_not_met", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, - utils.NewUint64(timeMillis-1999), // 1 ms less than required - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis-1999), // 1 ms less than required + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrMinDelayNotMet, @@ -178,13 +178,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_future_timestamp_within_limits", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds+5, // 5 seconds in future - utils.NewUint64(timeMillis+5000), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis+5000), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, - utils.NewUint64(timeMillis-2000), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis-2000), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, }, @@ -192,13 +192,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_future_timestamp_abuse", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds+15, // 15 seconds in future, exceeds MaxFutureBlockTime - utils.NewUint64(timeMillis+15000), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis+15000), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, - utils.NewUint64(timeMillis-2000), - utils.NewUint64(acp226.InitialDelayExcess), + utils.PointerTo(timeMillis-2000), + utils.PointerTo[uint64](acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrBlockTooFarInFuture, @@ -207,13 +207,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_zero_delay_excess", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), - utils.NewUint64(0), + utils.PointerTo(timeMillis), + utils.PointerTo[uint64](0), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis-1), // 1ms delay, meets zero requirement - utils.NewUint64(0), // Parent has zero delay excess + utils.PointerTo(timeMillis-1), // 1ms delay, meets zero requirement + utils.PointerTo[uint64](0), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, }, @@ -221,13 +221,13 @@ func TestVerifyTime(t *testing.T) { name: "granite_zero_delay_excess_but_zero_delay", header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), - utils.NewUint64(0), + utils.PointerTo(timeMillis), + utils.PointerTo[uint64](0), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.NewUint64(timeMillis), // Same timestamp, zero delay - utils.NewUint64(0), // Parent has zero delay excess + utils.PointerTo(timeMillis), // Same timestamp, zero delay + utils.PointerTo[uint64](0), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrMinDelayNotMet, @@ -269,7 +269,7 @@ func TestGetNextTimestamp(t *testing.T) { }, { name: "current_time_after_parent_time_with_milliseconds", - parent: generateHeader(nowSeconds-10, utils.NewUint64(nowMillis-500)), + parent: generateHeader(nowSeconds-10, utils.PointerTo(nowMillis-500)), now: now, expectedSec: nowSeconds, expectedMillis: nowMillis, @@ -290,28 +290,28 @@ func TestGetNextTimestamp(t *testing.T) { }, { name: "current_time_before_parent_time_with_milliseconds", - parent: generateHeader(nowSeconds+10, utils.NewUint64(nowMillis)), + parent: generateHeader(nowSeconds+10, utils.PointerTo(nowMillis)), now: now, expectedSec: nowSeconds, expectedMillis: nowMillis, }, { name: "current_time_milliseconds_before_parent_time_milliseconds", - parent: generateHeader(nowSeconds, utils.NewUint64(nowMillis+10)), + parent: generateHeader(nowSeconds, utils.PointerTo(nowMillis+10)), now: now, expectedSec: nowSeconds, expectedMillis: nowMillis, }, { name: "current_time_equals_parent_time_with_milliseconds_granite", - parent: generateHeader(nowSeconds, utils.NewUint64(nowMillis)), + parent: generateHeader(nowSeconds, utils.PointerTo(nowMillis)), now: now, expectedSec: nowSeconds, expectedMillis: nowMillis, }, { name: "current_timesec_equals_parent_time_with_less_milliseconds", - parent: generateHeader(nowSeconds, utils.NewUint64(nowMillis-10)), + parent: generateHeader(nowSeconds, utils.PointerTo(nowMillis-10)), now: now, expectedSec: nowSeconds, expectedMillis: nowMillis, diff --git a/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go b/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go index f9c8a2d7cf2f..94a913906b85 100644 --- a/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go +++ b/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go @@ -13,7 +13,6 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/graft/evm/utils" - "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/internal/blocktest" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) @@ -37,12 +36,12 @@ func TestBlockGetters(t *testing.T) { name: "fields_set", headerExtra: &HeaderExtra{ BlockGasCost: big.NewInt(2), - TimeMilliseconds: utils.NewUint64(3), - MinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(4)), + TimeMilliseconds: utils.PointerTo[uint64](3), + MinDelayExcess: utils.PointerTo(acp226.DelayExcess(4)), }, wantBlockGasCost: big.NewInt(2), - wantTimeMilliseconds: utils.NewUint64(3), - wantMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(4)), + wantTimeMilliseconds: utils.PointerTo[uint64](3), + wantMinDelayExcess: utils.PointerTo(acp226.DelayExcess(4)), }, } for _, test := range tests { diff --git a/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go b/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go index 603345d98aa6..f2a6d18299c4 100644 --- a/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go +++ b/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/libevm/rlp" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) @@ -112,14 +112,14 @@ func headerWithNonZeroFields() (*Header, *HeaderExtra) { Nonce: BlockNonce{15}, BaseFee: big.NewInt(16), WithdrawalsHash: &common.Hash{17}, - BlobGasUsed: utilstest.PointerTo(uint64(18)), - ExcessBlobGas: utilstest.PointerTo(uint64(19)), + BlobGasUsed: utils.PointerTo(uint64(18)), + ExcessBlobGas: utils.PointerTo(uint64(19)), ParentBeaconRoot: &common.Hash{20}, } extra := &HeaderExtra{ BlockGasCost: big.NewInt(23), - TimeMilliseconds: utilstest.PointerTo(uint64(24)), - MinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(25)), + TimeMilliseconds: utils.PointerTo(uint64(24)), + MinDelayExcess: utils.PointerTo(acp226.DelayExcess(25)), } return WithHeaderExtra(header, extra), extra } diff --git a/graft/subnet-evm/plugin/evm/vm_test.go b/graft/subnet-evm/plugin/evm/vm_test.go index ba91943a4486..9b3e8cf823a4 100644 --- a/graft/subnet-evm/plugin/evm/vm_test.go +++ b/graft/subnet-evm/plugin/evm/vm_test.go @@ -1479,13 +1479,13 @@ func TestTimeSemanticVerify(t *testing.T) { name: "Granite with TimeMilliseconds", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.NewUint64(uint64(timestamp.UnixMilli())), + timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli())), }, { name: "Fortuna with TimeMilliseconds", fork: upgradetest.Fortuna, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.NewUint64(uint64(timestamp.UnixMilli())), + timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli())), expectedError: customheader.ErrTimeMillisecondsBeforeGranite, }, { @@ -1499,14 +1499,14 @@ func TestTimeSemanticVerify(t *testing.T) { name: "Granite with mismatched TimeMilliseconds", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.NewUint64(uint64(timestamp.UnixMilli()) + 1000), + timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli()) + 1000), expectedError: customheader.ErrTimeMillisecondsMismatched, }, { name: "Block too far in the future", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Add(2 * time.Hour).Unix()), - timeMilliseconds: utils.NewUint64(uint64(timestamp.Add(2 * time.Hour).UnixMilli())), + timeMilliseconds: utils.PointerTo(uint64(timestamp.Add(2 * time.Hour).UnixMilli())), expectedError: customheader.ErrBlockTooFarInFuture, }, } @@ -1582,7 +1582,7 @@ func TestBuildTimeMilliseconds(t *testing.T) { { name: "granite_should_have_timestamp_milliseconds", fork: upgradetest.Granite, - expectedTimeMilliseconds: utils.NewUint64(uint64(buildTime.UnixMilli())), + expectedTimeMilliseconds: utils.PointerTo(uint64(buildTime.UnixMilli())), }, } @@ -1742,7 +1742,7 @@ func TestTxAllowListSuccessfulTx(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(toGenesisJSON(paramstest.ForkToChainConfig[upgradetest.Durango])))) // this manager role should not be activated because DurangoTimestamp is in the future params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(utils.NewUint64(0), testEthAddrs[0:1], nil, nil), + txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil), } durangoTime := time.Now().Add(10 * time.Hour) params.GetExtra(genesis.Config).DurangoTimestamp = utils.TimeToNewUint64(durangoTime) @@ -1885,7 +1885,7 @@ func TestVerifyManagerConfig(t *testing.T) { params.GetExtra(genesis.Config).DurangoTimestamp = utils.TimeToNewUint64(durangoTimestamp) // this manager role should not be activated because DurangoTimestamp is in the future params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(utils.NewUint64(0), testEthAddrs[0:1], nil, []common.Address{testEthAddrs[1]}), + txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, []common.Address{testEthAddrs[1]}), } genesisJSON, err := genesis.MarshalJSON() @@ -2037,7 +2037,7 @@ func TestFeeManagerChangeFee(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) configExtra := params.GetExtra(genesis.Config) configExtra.GenesisPrecompiles = extras.Precompiles{ - feemanager.ConfigKey: feemanager.NewConfig(utils.NewUint64(0), testEthAddrs[0:1], nil, nil, nil), + feemanager.ConfigKey: feemanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } // set a lower fee config now @@ -2253,7 +2253,7 @@ func TestRewardManagerPrecompileSetRewardAddress(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - rewardmanager.ConfigKey: rewardmanager.NewConfig(utils.NewUint64(0), testEthAddrs[0:1], nil, nil, nil), + rewardmanager.ConfigKey: rewardmanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } params.GetExtra(genesis.Config).AllowFeeRecipients = true // enable this in genesis to test if this is recognized by the reward manager genesisJSON, err := genesis.MarshalJSON() @@ -2397,7 +2397,7 @@ func TestRewardManagerPrecompileAllowFeeRecipients(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - rewardmanager.ConfigKey: rewardmanager.NewConfig(utils.NewUint64(0), testEthAddrs[0:1], nil, nil, nil), + rewardmanager.ConfigKey: rewardmanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } params.GetExtra(genesis.Config).AllowFeeRecipients = false // disable this in genesis genesisJSON, err := genesis.MarshalJSON() @@ -2733,7 +2733,7 @@ func TestFeeManagerRegressionMempoolMinFeeAfterRestart(t *testing.T) { // Setup chain params genesis := &core.Genesis{} require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) - precompileActivationTime := utils.NewUint64(genesis.Timestamp + 5) // 5 seconds after genesis + precompileActivationTime := utils.PointerTo(genesis.Timestamp + 5) // 5 seconds after genesis configExtra := params.GetExtra(genesis.Config) configExtra.GenesisPrecompiles = extras.Precompiles{ feemanager.ConfigKey: feemanager.NewConfig(precompileActivationTime, testEthAddrs[0:1], nil, nil, nil), @@ -3582,26 +3582,26 @@ func TestMinDelayExcessInHeader(t *testing.T) { { name: "pre_granite_min_delay_excess", fork: upgradetest.Fortuna, - desiredMinDelay: utils.NewUint64(1000), + desiredMinDelay: utils.PointerTo[uint64](1000), expectedMinDelayExcess: nil, }, { name: "granite_first_block_initial_delay_excess", fork: upgradetest.Granite, desiredMinDelay: nil, - expectedMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), + expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), }, { name: "granite_with_excessive_desired_min_delay_excess", fork: upgradetest.Granite, - desiredMinDelay: utils.NewUint64(4000), - expectedMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), + desiredMinDelay: utils.PointerTo[uint64](4000), + expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), }, { name: "granite_with_zero_desired_min_delay_excess", fork: upgradetest.Granite, - desiredMinDelay: utils.NewUint64(0), - expectedMinDelayExcess: utilstest.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), + desiredMinDelay: utils.PointerTo[uint64](0), + expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), }, } diff --git a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go index 17b6ff99b6d2..f9e40e0a2e44 100644 --- a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go +++ b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go @@ -142,7 +142,7 @@ func TestNetworkUpgradesOverridden(t *testing.T) { fork := upgradetest.Granite chainConfig := paramstest.ForkToChainConfig[fork] extraConfig := params.GetExtra(chainConfig) - extraConfig.NetworkUpgrades.GraniteTimestamp = utils.NewUint64(uint64(upgrade.InitiallyActiveTime.Unix())) + extraConfig.NetworkUpgrades.GraniteTimestamp = utils.PointerTo(uint64(upgrade.InitiallyActiveTime.Unix())) genesis := &core.Genesis{} require.NoError(t, json.Unmarshal([]byte(toGenesisJSON(chainConfig)), genesis)) // Set the genesis timestamp to before the Granite activation time @@ -351,7 +351,7 @@ func TestVMEtnaActivatesCancun(t *testing.T) { upgradeJSON: func() string { upgrade := &extras.UpgradeConfig{ NetworkUpgradeOverrides: &extras.NetworkUpgrades{ - EtnaTimestamp: utils.NewUint64(defaultEtnaTime + 2), + EtnaTimestamp: utils.PointerTo(defaultEtnaTime + 2), }, } b, err := json.Marshal(upgrade) diff --git a/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go b/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go index a5f69bfb86c6..13572d1e7176 100644 --- a/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go +++ b/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go @@ -105,7 +105,7 @@ func AllowListConfigVerifyTests(t testing.TB, module modules.Module) map[string] ManagerAddresses: []common.Address{TestManagerAddr}, EnabledAddresses: nil, }, precompileconfig.Upgrade{ - BlockTimestamp: utils.NewUint64(1), + BlockTimestamp: utils.PointerTo[uint64](1), }), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) diff --git a/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go b/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go index 416cb8ef06a2..95779e07154d 100644 --- a/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go +++ b/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go @@ -26,7 +26,7 @@ func TestEqual(t *testing.T) { managers := []common.Address{allowlisttest.TestManagerAddr} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: deployerallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), + Config: deployerallowlist.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers), Other: nil, Expected: false, }, @@ -36,13 +36,13 @@ func TestEqual(t *testing.T) { Expected: false, }, "different timestamp": { - Config: deployerallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), - Other: deployerallowlist.NewConfig(utils.NewUint64(4), admins, enableds, managers), + Config: deployerallowlist.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers), + Other: deployerallowlist.NewConfig(utils.PointerTo[uint64](4), admins, enableds, managers), Expected: false, }, "same config": { - Config: deployerallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), - Other: deployerallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), + Config: deployerallowlist.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers), + Other: deployerallowlist.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers), Expected: true, }, } diff --git a/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go b/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go index aef41b7e0ed1..6de5231d8249 100644 --- a/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go @@ -182,7 +182,7 @@ func TestDeployerAllowList(t *testing.T) { }, } - precompileCfg := deployerallowlist.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil) + precompileCfg := deployerallowlist.NewConfig(utils.PointerTo[uint64](0), []common.Address{adminAddress}, nil, nil) for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { backend := utilstest.NewBackendWithPrecompile(t, precompileCfg, []common.Address{adminAddress, unprivilegedAddress}) @@ -197,7 +197,7 @@ func TestDeployerAllowList(t *testing.T) { } func TestIAllowList_Events(t *testing.T) { - precompileCfg := deployerallowlist.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil) + precompileCfg := deployerallowlist.NewConfig(utils.PointerTo[uint64](0), []common.Address{adminAddress}, nil, nil) admin := utilstest.NewAuth(t, adminKey, params.TestChainConfig.ChainID) allowlisttest.RunAllowListEventTests(t, precompileCfg, deployerallowlist.ContractAddress, admin, adminAddress, unprivilegedAddress) } diff --git a/graft/subnet-evm/precompile/contracts/feemanager/config_test.go b/graft/subnet-evm/precompile/contracts/feemanager/config_test.go index 337695002261..a02a8a9e6232 100644 --- a/graft/subnet-evm/precompile/contracts/feemanager/config_test.go +++ b/graft/subnet-evm/precompile/contracts/feemanager/config_test.go @@ -37,11 +37,11 @@ func TestVerify(t *testing.T) { invalidFeeConfig.GasLimit = big.NewInt(0) tests := map[string]precompiletest.ConfigVerifyTest{ "invalid initial fee manager config": { - Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &invalidFeeConfig), + Config: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, &invalidFeeConfig), ExpectedError: commontype.ErrGasLimitTooLow, }, "nil initial fee manager config": { - Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &commontype.FeeConfig{}), + Config: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, &commontype.FeeConfig{}), ExpectedError: commontype.ErrGasLimitNil, }, } @@ -53,28 +53,28 @@ func TestEqual(t *testing.T) { enableds := []common.Address{allowlisttest.TestEnabledAddr} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: feemanager.NewConfig(utils.NewUint64(3), admins, enableds, nil, nil), + Config: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, enableds, nil, nil), Other: nil, Expected: false, }, "different type": { - Config: feemanager.NewConfig(utils.NewUint64(3), admins, enableds, nil, nil), + Config: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, enableds, nil, nil), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, nil), - Other: feemanager.NewConfig(utils.NewUint64(4), admins, nil, nil, nil), + Config: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, nil), + Other: feemanager.NewConfig(utils.PointerTo[uint64](4), admins, nil, nil, nil), Expected: false, }, "non-nil initial config and nil initial config": { - Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), - Other: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, nil), + Config: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, &validFeeConfig), + Other: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, nil), Expected: false, }, "different initial config": { - Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), - Other: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, &validFeeConfig), + Other: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, func() *commontype.FeeConfig { c := validFeeConfig c.GasLimit = big.NewInt(123) @@ -83,8 +83,8 @@ func TestEqual(t *testing.T) { Expected: false, }, "same config": { - Config: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), - Other: feemanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &validFeeConfig), + Config: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, &validFeeConfig), + Other: feemanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, &validFeeConfig), Expected: true, }, } diff --git a/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go b/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go index 1ea75e7768b7..cfbf107298df 100644 --- a/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go @@ -233,7 +233,7 @@ func TestFeeManager(t *testing.T) { }, } - precompileCfg := feemanager.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil, &genesisFeeConfig) + precompileCfg := feemanager.NewConfig(utils.PointerTo[uint64](0), []common.Address{adminAddress}, nil, nil, &genesisFeeConfig) for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { backend := utilstest.NewBackendWithPrecompile(t, precompileCfg, []common.Address{adminAddress, unprivilegedAddress}) @@ -251,7 +251,7 @@ func TestIFeeManager_Events(t *testing.T) { chainID := params.TestChainConfig.ChainID admin := utilstest.NewAuth(t, adminKey, chainID) - precompileCfg := feemanager.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil, &genesisFeeConfig) + precompileCfg := feemanager.NewConfig(utils.PointerTo[uint64](0), []common.Address{adminAddress}, nil, nil, &genesisFeeConfig) backend := utilstest.NewBackendWithPrecompile(t, precompileCfg, []common.Address{adminAddress, unprivilegedAddress}) defer backend.Close() diff --git a/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go b/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go index 156938728f6d..b97f55927a56 100644 --- a/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go +++ b/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go @@ -24,7 +24,7 @@ func TestVerify(t *testing.T) { managers := []common.Address{allowlisttest.TestManagerAddr} tests := map[string]precompiletest.ConfigVerifyTest{ "valid config": { - Config: nativeminter.NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers, nil), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() @@ -33,19 +33,19 @@ func TestVerify(t *testing.T) { ExpectedError: nil, }, "invalid allow list config in native minter allowlisttest": { - Config: nativeminter.NewConfig(utils.NewUint64(3), admins, admins, nil, nil), + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, admins, nil, nil), ExpectedError: allowlist.ErrAdminAndEnabledAddress, }, "duplicate admins in config in native minter allowlisttest": { - Config: nativeminter.NewConfig(utils.NewUint64(3), append(admins, admins[0]), enableds, managers, nil), + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), append(admins, admins[0]), enableds, managers, nil), ExpectedError: allowlist.ErrDuplicateAdminAddress, }, "duplicate enableds in config in native minter allowlisttest": { - Config: nativeminter.NewConfig(utils.NewUint64(3), admins, append(enableds, enableds[0]), managers, nil), + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, append(enableds, enableds[0]), managers, nil), ExpectedError: allowlist.ErrDuplicateEnabledAddress, }, "nil amount in native minter config": { - Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(123), common.HexToAddress("0x02"): nil, @@ -53,7 +53,7 @@ func TestVerify(t *testing.T) { ExpectedError: nativeminter.ErrInitialMintNilAmount, }, "negative amount in native minter config": { - Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(123), common.HexToAddress("0x02"): math.NewHexOrDecimal256(-1), @@ -70,48 +70,48 @@ func TestEqual(t *testing.T) { managers := []common.Address{allowlisttest.TestManagerAddr} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: nativeminter.NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers, nil), Other: nil, Expected: false, }, "different type": { - Config: nativeminter.NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers, nil), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, nil), - Other: nativeminter.NewConfig(utils.NewUint64(4), admins, nil, nil, nil), + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, nil), + Other: nativeminter.NewConfig(utils.PointerTo[uint64](4), admins, nil, nil, nil), Expected: false, }, "different initial mint amounts": { - Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), - Other: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, + Other: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(2), }), Expected: false, }, "different initial mint addresses": { - Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), - Other: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, + Other: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x02"): math.NewHexOrDecimal256(1), }), Expected: false, }, "same config": { - Config: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, + Config: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), - Other: nativeminter.NewConfig(utils.NewUint64(3), admins, nil, nil, + Other: nativeminter.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), diff --git a/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go b/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go index a97ceb875846..a87e52d83839 100644 --- a/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go @@ -143,7 +143,7 @@ func TestNativeMinter(t *testing.T) { }, } - precompileCfg := nativeminter.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil, nil) + precompileCfg := nativeminter.NewConfig(utils.PointerTo[uint64](0), []common.Address{adminAddress}, nil, nil, nil) for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { backend := utilstest.NewBackendWithPrecompile(t, precompileCfg, []common.Address{adminAddress, unprivilegedAddress}) @@ -163,7 +163,7 @@ func TestINativeMinter_Events(t *testing.T) { testKey, _ := crypto.GenerateKey() testAddress := crypto.PubkeyToAddress(testKey.PublicKey) - precompileCfg := nativeminter.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil, nil) + precompileCfg := nativeminter.NewConfig(utils.PointerTo[uint64](0), []common.Address{adminAddress}, nil, nil, nil) backend := utilstest.NewBackendWithPrecompile(t, precompileCfg, []common.Address{adminAddress, unprivilegedAddress}) defer backend.Close() diff --git a/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go b/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go index ee096478b004..dca4badf6b4a 100644 --- a/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go +++ b/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go @@ -22,7 +22,7 @@ func TestVerify(t *testing.T) { managers := []common.Address{allowlisttest.TestManagerAddr} tests := map[string]precompiletest.ConfigVerifyTest{ "both reward mechanisms should not be activated at the same time in reward manager": { - Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, enableds, managers, &rewardmanager.InitialRewardConfig{ + Config: rewardmanager.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers, &rewardmanager.InitialRewardConfig{ AllowFeeRecipients: true, RewardAddress: common.HexToAddress("0x01"), }), @@ -38,42 +38,42 @@ func TestEqual(t *testing.T) { managers := []common.Address{allowlisttest.TestManagerAddr} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), + Config: rewardmanager.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers, nil), Other: nil, Expected: false, }, "different type": { - Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), + Config: rewardmanager.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers, nil), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, nil), - Other: rewardmanager.NewConfig(utils.NewUint64(4), admins, nil, nil, nil), + Config: rewardmanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, nil), + Other: rewardmanager.NewConfig(utils.PointerTo[uint64](4), admins, nil, nil, nil), Expected: false, }, "non-nil initial config and nil initial config": { - Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ + Config: rewardmanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ AllowFeeRecipients: true, }), - Other: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, nil), + Other: rewardmanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, nil), Expected: false, }, "different initial config": { - Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ + Config: rewardmanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ RewardAddress: common.HexToAddress("0x01"), }), - Other: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, + Other: rewardmanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ RewardAddress: common.HexToAddress("0x02"), }), Expected: false, }, "same config": { - Config: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ + Config: rewardmanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ RewardAddress: common.HexToAddress("0x01"), }), - Other: rewardmanager.NewConfig(utils.NewUint64(3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ + Other: rewardmanager.NewConfig(utils.PointerTo[uint64](3), admins, nil, nil, &rewardmanager.InitialRewardConfig{ RewardAddress: common.HexToAddress("0x01"), }), Expected: true, diff --git a/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go b/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go index de1e0fdce811..8a81af42f987 100644 --- a/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go @@ -297,7 +297,7 @@ func TestRewardManager(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - cfg := rewardmanager.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil, tc.initialRewardConfig) + cfg := rewardmanager.NewConfig(utils.PointerTo[uint64](0), []common.Address{adminAddress}, nil, nil, tc.initialRewardConfig) backend := utilstest.NewBackendWithPrecompile(t, cfg, []common.Address{adminAddress, unprivilegedAddress}, tc.backendOpts...) defer backend.Close() @@ -392,7 +392,7 @@ func TestIRewardManager_Events(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - backend := utilstest.NewBackendWithPrecompile(t, rewardmanager.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil, nil), []common.Address{adminAddress, unprivilegedAddress}) + backend := utilstest.NewBackendWithPrecompile(t, rewardmanager.NewConfig(utils.PointerTo[uint64](0), []common.Address{adminAddress}, nil, nil, nil), []common.Address{adminAddress, unprivilegedAddress}) defer backend.Close() rewardManager, err := rewardmanagerbindings.NewIRewardManager(rewardmanager.ContractAddress, backend.Client()) @@ -404,7 +404,7 @@ func TestIRewardManager_Events(t *testing.T) { } func TestIAllowList_Events(t *testing.T) { - precompileCfg := rewardmanager.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil, nil) + precompileCfg := rewardmanager.NewConfig(utils.PointerTo[uint64](0), []common.Address{adminAddress}, nil, nil, nil) admin := utilstest.NewAuth(t, adminKey, params.TestChainConfig.ChainID) allowlisttest.RunAllowListEventTests(t, precompileCfg, rewardmanager.ContractAddress, admin, adminAddress) } diff --git a/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go b/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go index c5d920376b84..28472e0775c0 100644 --- a/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go +++ b/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go @@ -26,7 +26,7 @@ func TestEqual(t *testing.T) { managers := []common.Address{allowlisttest.TestManagerAddr} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: txallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers), Other: nil, Expected: false, }, @@ -36,13 +36,13 @@ func TestEqual(t *testing.T) { Expected: false, }, "different timestamp": { - Config: txallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), - Other: txallowlist.NewConfig(utils.NewUint64(4), admins, enableds, managers), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers), + Other: txallowlist.NewConfig(utils.PointerTo[uint64](4), admins, enableds, managers), Expected: false, }, "same config": { - Config: txallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), - Other: txallowlist.NewConfig(utils.NewUint64(3), admins, enableds, managers), + Config: txallowlist.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers), + Other: txallowlist.NewConfig(utils.PointerTo[uint64](3), admins, enableds, managers), Expected: true, }, } diff --git a/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go b/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go index 55441b6793dd..840b1e21bdf5 100644 --- a/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go @@ -268,7 +268,7 @@ func TestTxAllowList(t *testing.T) { }, } - precompileCfg := txallowlist.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil) + precompileCfg := txallowlist.NewConfig(utils.PointerTo[uint64](0), []common.Address{adminAddress}, nil, nil) for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { backend := utilstest.NewBackendWithPrecompile(t, precompileCfg, []common.Address{adminAddress, unprivilegedAddress}) @@ -283,7 +283,7 @@ func TestTxAllowList(t *testing.T) { } func TestIAllowList_Events(t *testing.T) { - precompileCfg := txallowlist.NewConfig(utils.NewUint64(0), []common.Address{adminAddress}, nil, nil) + precompileCfg := txallowlist.NewConfig(utils.PointerTo[uint64](0), []common.Address{adminAddress}, nil, nil) admin := utilstest.NewAuth(t, adminKey, params.TestChainConfig.ChainID) allowlisttest.RunAllowListEventTests(t, precompileCfg, txallowlist.ContractAddress, admin, adminAddress, unprivilegedAddress) } diff --git a/graft/subnet-evm/precompile/contracts/warp/config_test.go b/graft/subnet-evm/precompile/contracts/warp/config_test.go index 9236fd30ca85..cda6b39c51a4 100644 --- a/graft/subnet-evm/precompile/contracts/warp/config_test.go +++ b/graft/subnet-evm/precompile/contracts/warp/config_test.go @@ -16,24 +16,24 @@ import ( func TestVerify(t *testing.T) { tests := map[string]precompiletest.ConfigVerifyTest{ "quorum numerator less than minimum": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum-1, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum-1, false), ExpectedError: ErrInvalidQuorumRatio, }, "quorum numerator greater than quorum denominator": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumDenominator+1, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumDenominator+1, false), ExpectedError: ErrInvalidQuorumRatio, }, "default quorum numerator": { - Config: NewDefaultConfig(utils.NewUint64(3)), + Config: NewDefaultConfig(utils.PointerTo[uint64](3)), }, "valid quorum numerator 1 less than denominator": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumDenominator-1, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumDenominator-1, false), }, "valid quorum numerator 1 more than minimum": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+1, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum+1, false), }, "invalid cannot activated before Durango activation": { - Config: NewConfig(utils.NewUint64(3), 0, false), + Config: NewConfig(utils.PointerTo[uint64](3), 0, false), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) config.EXPECT().IsDurango(gomock.Any()).Return(false) @@ -48,38 +48,38 @@ func TestVerify(t *testing.T) { func TestEqualWarpConfig(t *testing.T) { tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: NewDefaultConfig(utils.NewUint64(3)), + Config: NewDefaultConfig(utils.PointerTo[uint64](3)), Other: nil, Expected: false, }, "different type": { - Config: NewDefaultConfig(utils.NewUint64(3)), + Config: NewDefaultConfig(utils.PointerTo[uint64](3)), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: NewDefaultConfig(utils.NewUint64(3)), - Other: NewDefaultConfig(utils.NewUint64(4)), + Config: NewDefaultConfig(utils.PointerTo[uint64](3)), + Other: NewDefaultConfig(utils.PointerTo[uint64](4)), Expected: false, }, "different quorum numerator": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+1, false), - Other: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+2, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum+1, false), + Other: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum+2, false), Expected: false, }, "same default config": { - Config: NewDefaultConfig(utils.NewUint64(3)), - Other: NewDefaultConfig(utils.NewUint64(3)), + Config: NewDefaultConfig(utils.PointerTo[uint64](3)), + Other: NewDefaultConfig(utils.PointerTo[uint64](3)), Expected: true, }, "same non-default config": { - Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+5, false), - Other: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+5, false), + Config: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum+5, false), + Other: NewConfig(utils.PointerTo[uint64](3), WarpQuorumNumeratorMinimum+5, false), Expected: true, }, } diff --git a/graft/subnet-evm/precompile/contracts/warp/predicate_test.go b/graft/subnet-evm/precompile/contracts/warp/predicate_test.go index 09025e7e1bbf..30055cf24c16 100644 --- a/graft/subnet-evm/precompile/contracts/warp/predicate_test.go +++ b/graft/subnet-evm/precompile/contracts/warp/predicate_test.go @@ -246,7 +246,7 @@ func createValidPredicateTest( ) precompiletest.PredicateTest { gasCost := CurrentGasConfig(rules) return precompiletest.PredicateTest{ - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -334,7 +334,7 @@ func testWarpMessageFromPrimaryNetwork(t *testing.T, requirePrimaryNetworkSigner } test := precompiletest.PredicateTest{ - Config: NewConfig(utils.NewUint64(0), 0, requirePrimaryNetworkSigners), + Config: NewConfig(utils.PointerTo[uint64](0), 0, requirePrimaryNetworkSigners), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -365,7 +365,7 @@ func TestInvalidPredicatePacking(t *testing.T) { pred = append(pred, common.Hash{1}) // Invalidate the predicate byte packing test := precompiletest.PredicateTest{ - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -397,7 +397,7 @@ func TestInvalidWarpMessage(t *testing.T) { pred := predicate.New(warpMsgBytes) test := precompiletest.PredicateTest{ - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -442,7 +442,7 @@ func TestInvalidAddressedPayload(t *testing.T) { pred := predicate.New(warpMsgBytes) test := precompiletest.PredicateTest{ - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -488,7 +488,7 @@ func TestInvalidBitSet(t *testing.T) { }) pred := predicate.New(msg.Bytes()) test := precompiletest.PredicateTest{ - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -536,7 +536,7 @@ func TestWarpSignatureWeightsDefaultQuorumNumerator(t *testing.T) { tests[i] = precompiletest.PredicateTest{ Name: fmt.Sprintf("default quorum %d signature(s)", numSigners), - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -596,7 +596,7 @@ func TestWarpMultiplePredicates(t *testing.T) { tests = append(tests, precompiletest.PredicateTest{ Name: fmt.Sprintf("multiple predicates %v", validMessageIndices), - Config: NewDefaultConfig(utils.NewUint64(0)), + Config: NewDefaultConfig(utils.PointerTo[uint64](0)), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -648,7 +648,7 @@ func TestWarpSignatureWeightsNonDefaultQuorumNumerator(t *testing.T) { tests[i] = precompiletest.PredicateTest{ Name: fmt.Sprintf("non-default quorum %d signature(s)", numSigners), - Config: NewConfig(utils.NewUint64(0), uint64(nonDefaultQuorumNumerator), false), + Config: NewConfig(utils.PointerTo[uint64](0), uint64(nonDefaultQuorumNumerator), false), PredicateContext: &precompileconfig.PredicateContext{ SnowCtx: snowCtx, ProposerVMBlockCtx: &block.Context{ @@ -668,7 +668,7 @@ func TestWarpSignatureWeightsNonDefaultQuorumNumerator(t *testing.T) { func TestWarpNoValidatorsAndOverflowUseSameGas(t *testing.T) { var ( - config = NewConfig(utils.NewUint64(0), 0, false) + config = NewConfig(utils.PointerTo[uint64](0), 0, false) proposervmContext = &block.Context{ PChainHeight: 1, } diff --git a/graft/subnet-evm/tests/init.go b/graft/subnet-evm/tests/init.go index 6dfe3f0b3786..d8f516075b3b 100644 --- a/graft/subnet-evm/tests/init.go +++ b/graft/subnet-evm/tests/init.go @@ -202,7 +202,7 @@ func initializeForks() { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), }, }, ), @@ -222,8 +222,8 @@ func initializeForks() { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), - DurangoTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), + DurangoTimestamp: utils.PointerTo[uint64](0), }, }, ), @@ -240,13 +240,13 @@ func initializeForks() { IstanbulBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ShanghaiTime: utils.NewUint64(0), - CancunTime: utils.NewUint64(0), + ShanghaiTime: utils.PointerTo[uint64](0), + CancunTime: utils.PointerTo[uint64](0), }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: utils.NewUint64(0), - DurangoTimestamp: utils.NewUint64(0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), + DurangoTimestamp: utils.PointerTo[uint64](0), }, }, ), From 7eb6a030938bdcbbf7ebd2fa6a05b198907bdb3e Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Mon, 15 Dec 2025 18:12:18 -0500 Subject: [PATCH 03/16] refactor: remove additional pointer helper --- vms/evm/metrics/prometheus/prometheus.go | 37 ++++++++++++------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/vms/evm/metrics/prometheus/prometheus.go b/vms/evm/metrics/prometheus/prometheus.go index f96ae3ae25ef..8f36741fdd75 100644 --- a/vms/evm/metrics/prometheus/prometheus.go +++ b/vms/evm/metrics/prometheus/prometheus.go @@ -12,6 +12,7 @@ import ( "github.com/ava-labs/libevm/metrics" "github.com/prometheus/client_golang/prometheus" + "github.com/ava-labs/avalanchego/graft/evm/utils" dto "github.com/prometheus/client_model/go" ) @@ -82,7 +83,7 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err Type: dto.MetricType_COUNTER.Enum(), Metric: []*dto.Metric{{ Counter: &dto.Counter{ - Value: ptrTo(float64(m.Snapshot().Count())), + Value: utils.PointerTo(float64(m.Snapshot().Count())), }, }}, }, nil @@ -93,7 +94,7 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err Type: dto.MetricType_COUNTER.Enum(), Metric: []*dto.Metric{{ Counter: &dto.Counter{ - Value: ptrTo(m.Snapshot().Count()), + Value: utils.PointerTo(m.Snapshot().Count()), }, }}, }, nil @@ -104,7 +105,7 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err Type: dto.MetricType_GAUGE.Enum(), Metric: []*dto.Metric{{ Gauge: &dto.Gauge{ - Value: ptrTo(float64(m.Snapshot().Value())), + Value: utils.PointerTo(float64(m.Snapshot().Value())), }, }}, }, nil @@ -115,7 +116,7 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err Type: dto.MetricType_GAUGE.Enum(), Metric: []*dto.Metric{{ Gauge: &dto.Gauge{ - Value: ptrTo(m.Snapshot().Value()), + Value: utils.PointerTo(m.Snapshot().Value()), }, }}, }, nil @@ -127,8 +128,8 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err dtoQuantiles := make([]*dto.Quantile, len(quantiles)) for i := range thresholds { dtoQuantiles[i] = &dto.Quantile{ - Quantile: ptrTo(quantiles[i]), - Value: ptrTo(thresholds[i]), + Quantile: utils.PointerTo(quantiles[i]), + Value: utils.PointerTo(thresholds[i]), } } return &dto.MetricFamily{ @@ -137,8 +138,8 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err Type: dto.MetricType_SUMMARY.Enum(), Metric: []*dto.Metric{{ Summary: &dto.Summary{ - SampleCount: ptrTo(uint64(snapshot.Count())), - SampleSum: ptrTo(float64(snapshot.Sum())), + SampleCount: utils.PointerTo(uint64(snapshot.Count())), + SampleSum: utils.PointerTo(float64(snapshot.Sum())), Quantile: dtoQuantiles, }, }}, @@ -150,7 +151,7 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err Type: dto.MetricType_GAUGE.Enum(), Metric: []*dto.Metric{{ Gauge: &dto.Gauge{ - Value: ptrTo(float64(m.Snapshot().Count())), + Value: utils.PointerTo(float64(m.Snapshot().Count())), }, }}, }, nil @@ -160,8 +161,8 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err dtoQuantiles := make([]*dto.Quantile, len(quantiles)) for i := range thresholds { dtoQuantiles[i] = &dto.Quantile{ - Quantile: ptrTo(quantiles[i]), - Value: ptrTo(thresholds[i]), + Quantile: utils.PointerTo(quantiles[i]), + Value: utils.PointerTo(thresholds[i]), } } return &dto.MetricFamily{ @@ -170,8 +171,8 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err Type: dto.MetricType_SUMMARY.Enum(), Metric: []*dto.Metric{{ Summary: &dto.Summary{ - SampleCount: ptrTo(uint64(snapshot.Count())), - SampleSum: ptrTo(float64(snapshot.Sum())), + SampleCount: utils.PointerTo(uint64(snapshot.Count())), + SampleSum: utils.PointerTo(float64(snapshot.Sum())), Quantile: dtoQuantiles, }, }}, @@ -182,8 +183,8 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err dtoQuantiles := make([]*dto.Quantile, len(pvShortPercent)) for i := range pvShortPercent { dtoQuantiles[i] = &dto.Quantile{ - Quantile: ptrTo(pvShortPercent[i]), - Value: ptrTo(thresholds[i]), + Quantile: utils.PointerTo(pvShortPercent[i]), + Value: utils.PointerTo(thresholds[i]), } } count := snapshot.Count() @@ -193,8 +194,8 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err Type: dto.MetricType_SUMMARY.Enum(), Metric: []*dto.Metric{{ Summary: &dto.Summary{ - SampleCount: ptrTo(uint64(count)), - SampleSum: ptrTo(float64(count) * snapshot.Mean()), + SampleCount: utils.PointerTo(uint64(count)), + SampleSum: utils.PointerTo(float64(count) * snapshot.Mean()), Quantile: dtoQuantiles, }, }}, @@ -203,5 +204,3 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err return nil, fmt.Errorf("%w: metric %q type %T", errMetricTypeNotSupported, name, metric) } } - -func ptrTo[T any](x T) *T { return &x } From dd0c87401e48e04b014aa014c1329a57b067492b Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Mon, 15 Dec 2025 18:14:12 -0500 Subject: [PATCH 04/16] chore: lint --- go.mod | 2 +- graft/subnet-evm/plugin/evm/customheader/time_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cef9828a89a2..c01cd95cb83d 100644 --- a/go.mod +++ b/go.mod @@ -87,7 +87,7 @@ require ( k8s.io/utils v0.0.0-20230726121419-3b25d923346b ) -require github.com/ava-labs/avalanchego/graft/evm v0.0.0-00010101000000-000000000000 // indirect +require github.com/ava-labs/avalanchego/graft/evm v0.0.0-00010101000000-000000000000 require ( github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/graft/subnet-evm/plugin/evm/customheader/time_test.go b/graft/subnet-evm/plugin/evm/customheader/time_test.go index b232195d9a0d..6d37fc102ce3 100644 --- a/graft/subnet-evm/plugin/evm/customheader/time_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/time_test.go @@ -213,7 +213,7 @@ func TestVerifyTime(t *testing.T) { parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis-1), // 1ms delay, meets zero requirement - utils.PointerTo[uint64](0), // Parent has zero delay excess + utils.PointerTo[uint64](0), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, }, @@ -227,7 +227,7 @@ func TestVerifyTime(t *testing.T) { parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), // Same timestamp, zero delay - utils.PointerTo[uint64](0), // Parent has zero delay excess + utils.PointerTo[uint64](0), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrMinDelayNotMet, From 52f5f6501a3d247f32ac41b52e48f5be79a8a01b Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Mon, 15 Dec 2025 18:21:05 -0500 Subject: [PATCH 05/16] chore: lint --- graft/coreth/plugin/evm/customheader/time_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graft/coreth/plugin/evm/customheader/time_test.go b/graft/coreth/plugin/evm/customheader/time_test.go index 9b0eee16d5aa..770201700b5a 100644 --- a/graft/coreth/plugin/evm/customheader/time_test.go +++ b/graft/coreth/plugin/evm/customheader/time_test.go @@ -213,7 +213,7 @@ func TestVerifyTime(t *testing.T) { parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis-1), // 1ms delay, meets zero requirement - utils.PointerTo[uint64](0), // Parent has zero delay excess + utils.PointerTo[uint64](0), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, }, @@ -227,7 +227,7 @@ func TestVerifyTime(t *testing.T) { parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), // Same timestamp, zero delay - utils.PointerTo[uint64](0), // Parent has zero delay excess + utils.PointerTo[uint64](0), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrMinDelayNotMet, From 27bd7df9328c879400b7ca35668e603ca7429741 Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Mon, 15 Dec 2025 18:44:06 -0500 Subject: [PATCH 06/16] chore: lint --- vms/evm/metrics/prometheus/prometheus.go | 1 + 1 file changed, 1 insertion(+) diff --git a/vms/evm/metrics/prometheus/prometheus.go b/vms/evm/metrics/prometheus/prometheus.go index 8f36741fdd75..44cc1e278177 100644 --- a/vms/evm/metrics/prometheus/prometheus.go +++ b/vms/evm/metrics/prometheus/prometheus.go @@ -13,6 +13,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/ava-labs/avalanchego/graft/evm/utils" + dto "github.com/prometheus/client_model/go" ) From b3ca14cf5c8289ce1d2255af51fd7307c8c05b16 Mon Sep 17 00:00:00 2001 From: Austin Larson Date: Wed, 17 Dec 2025 15:23:23 -0500 Subject: [PATCH 07/16] fix: nit --- graft/evm/utils/utilstest/snow.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/graft/evm/utils/utilstest/snow.go b/graft/evm/utils/utilstest/snow.go index b006fa96518b..530b77eca85d 100644 --- a/graft/evm/utils/utilstest/snow.go +++ b/graft/evm/utils/utilstest/snow.go @@ -19,6 +19,8 @@ import ( // SubnetEVMTestChainID is a subnet-evm specific chain ID for testing var SubnetEVMTestChainID = ids.GenerateTestID() +// @TODO: This should eventually be replaced by a more robust solution, or alternatively, the presence of nil +// validator states shouldn't be depended upon by tests func NewTestValidatorState() *validatorstest.State { return &validatorstest.State{ GetCurrentHeightF: func(context.Context) (uint64, error) { @@ -36,18 +38,18 @@ func NewTestValidatorState() *validatorstest.State { } return subnetID, nil }, - GetValidatorSetF: func(context.Context, uint64, ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error) { - return map[ids.NodeID]*validators.GetValidatorOutput{}, nil - }, - GetCurrentValidatorSetF: func(context.Context, ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { - return map[ids.ID]*validators.GetCurrentValidatorOutput{}, 0, nil - }, GetWarpValidatorSetsF: func(context.Context, uint64) (map[ids.ID]validators.WarpSet, error) { return nil, nil }, GetWarpValidatorSetF: func(context.Context, uint64, ids.ID) (validators.WarpSet, error) { return validators.WarpSet{}, nil }, + GetValidatorSetF: func(context.Context, uint64, ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error) { + return map[ids.NodeID]*validators.GetValidatorOutput{}, nil + }, + GetCurrentValidatorSetF: func(context.Context, ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { + return map[ids.ID]*validators.GetCurrentValidatorOutput{}, 0, nil + }, } } From 8ab7b072437c1fdc5316810bb4fdf1317fdd2add Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Thu, 18 Dec 2025 16:39:31 -0500 Subject: [PATCH 08/16] fix: remove other evm helper --- graft/subnet-evm/params/extras/config_test.go | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/graft/subnet-evm/params/extras/config_test.go b/graft/subnet-evm/params/extras/config_test.go index 0cc55379f004..f316dcdcce04 100644 --- a/graft/subnet-evm/params/extras/config_test.go +++ b/graft/subnet-evm/params/extras/config_test.go @@ -11,14 +11,13 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/upgrade" ) -func pointer[T any](v T) *T { return &v } - func TestChainConfigDescription(t *testing.T) { t.Parallel() @@ -40,10 +39,10 @@ $`, "set": { config: &ChainConfig{ NetworkUpgrades: NetworkUpgrades{ - SubnetEVMTimestamp: pointer(uint64(1)), - DurangoTimestamp: pointer(uint64(2)), - EtnaTimestamp: pointer(uint64(3)), - FortunaTimestamp: pointer(uint64(4)), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), + EtnaTimestamp: utils.PointerTo[uint64](3), + FortunaTimestamp: utils.PointerTo[uint64](4), }, FeeConfig: commontype.FeeConfig{ GasLimit: big.NewInt(5), @@ -58,11 +57,11 @@ $`, AllowFeeRecipients: true, UpgradeConfig: UpgradeConfig{ NetworkUpgradeOverrides: &NetworkUpgrades{ - SubnetEVMTimestamp: pointer(uint64(13)), + SubnetEVMTimestamp: utils.PointerTo[uint64](13), }, StateUpgrades: []StateUpgrade{ { - BlockTimestamp: pointer(uint64(14)), + BlockTimestamp: utils.PointerTo[uint64](14), StateUpgradeAccounts: map[common.Address]StateUpgradeAccount{ {15}: { Code: []byte{16}, @@ -123,8 +122,8 @@ func TestChainConfigVerify(t *testing.T) { UpgradeConfig: UpgradeConfig{ PrecompileUpgrades: []PrecompileUpgrade{ // same precompile cannot be configured twice for the same timestamp - {Config: txallowlist.NewDisableConfig(pointer(uint64(1)))}, - {Config: txallowlist.NewDisableConfig(pointer(uint64(1)))}, + {Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](1))}, + {Config: txallowlist.NewDisableConfig(utils.PointerTo[uint64](1))}, }, }, }, @@ -155,10 +154,10 @@ func TestChainConfigVerify(t *testing.T) { config: ChainConfig{ FeeConfig: validFeeConfig, NetworkUpgrades: NetworkUpgrades{ - SubnetEVMTimestamp: pointer(uint64(1)), - DurangoTimestamp: pointer(uint64(2)), - EtnaTimestamp: pointer(uint64(3)), - FortunaTimestamp: pointer(uint64(4)), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), + EtnaTimestamp: utils.PointerTo[uint64](3), + FortunaTimestamp: utils.PointerTo[uint64](4), }, AvalancheContext: AvalancheContext{SnowCtx: &snow.Context{ NetworkUpgrades: upgrade.Config{ From 98337b9ea1bda768a45303e77ba1b0de03d6932d Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Thu, 18 Dec 2025 17:05:36 -0500 Subject: [PATCH 09/16] refactor: move pointer function to avalanchego utils --- graft/coreth/core/genesis_extra_test.go | 6 +++--- graft/coreth/core/genesis_test.go | 2 +- graft/coreth/core/state_processor_test.go | 2 +- graft/coreth/internal/ethapi/api_test.go | 2 +- graft/coreth/params/config.go | 2 +- graft/coreth/params/config_extra.go | 2 +- graft/coreth/params/config_extra_test.go | 2 +- graft/coreth/params/config_test.go | 2 +- graft/coreth/params/extras/config.go | 2 +- graft/coreth/params/extras/config_extra_test.go | 2 +- graft/coreth/params/extras/precompile_upgrade.go | 2 +- graft/coreth/plugin/evm/config/config_test.go | 2 +- .../coreth/plugin/evm/customheader/base_fee_test.go | 2 +- graft/coreth/plugin/evm/customheader/extra_test.go | 2 +- .../plugin/evm/customheader/gas_limit_test.go | 2 +- .../evm/customheader/min_delay_excess_test.go | 2 +- graft/coreth/plugin/evm/customheader/time_test.go | 2 +- .../coreth/plugin/evm/customtypes/block_ext_test.go | 2 +- .../plugin/evm/customtypes/header_ext_test.go | 2 +- graft/coreth/plugin/evm/vm_test.go | 2 +- .../coreth/precompile/contracts/warp/config_test.go | 2 +- .../precompile/contracts/warp/predicate_test.go | 13 ++++++------- graft/coreth/tests/init.go | 2 +- 23 files changed, 30 insertions(+), 31 deletions(-) diff --git a/graft/coreth/core/genesis_extra_test.go b/graft/coreth/core/genesis_extra_test.go index ae53ff663f65..7f8260eba397 100644 --- a/graft/coreth/core/genesis_extra_test.go +++ b/graft/coreth/core/genesis_extra_test.go @@ -35,8 +35,8 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" "github.com/ava-labs/avalanchego/graft/coreth/params/paramstest" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade/upgradetest" + avalancheutils "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" @@ -68,8 +68,8 @@ func TestGenesisEthUpgrades(t *testing.T) { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), - ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase1BlockTimestamp: avalancheutils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: avalancheutils.PointerTo[uint64](0), }, }, ) diff --git a/graft/coreth/core/genesis_test.go b/graft/coreth/core/genesis_test.go index dd6e6b24df82..415dad783f27 100644 --- a/graft/coreth/core/genesis_test.go +++ b/graft/coreth/core/genesis_test.go @@ -42,7 +42,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/precompile/contracts/warp" "github.com/ava-labs/avalanchego/graft/coreth/triedb/firewood" "github.com/ava-labs/avalanchego/graft/coreth/triedb/pathdb" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" diff --git a/graft/coreth/core/state_processor_test.go b/graft/coreth/core/state_processor_test.go index 17e746622279..c3427d5c24da 100644 --- a/graft/coreth/core/state_processor_test.go +++ b/graft/coreth/core/state_processor_test.go @@ -41,8 +41,8 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap1" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap3" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/cortina" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/acp176" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/consensus/misc/eip4844" diff --git a/graft/coreth/internal/ethapi/api_test.go b/graft/coreth/internal/ethapi/api_test.go index 9d4f28d3664a..d09daab5ef7b 100644 --- a/graft/coreth/internal/ethapi/api_test.go +++ b/graft/coreth/internal/ethapi/api_test.go @@ -49,7 +49,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap3" "github.com/ava-labs/avalanchego/graft/coreth/rpc" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/accounts" "github.com/ava-labs/libevm/accounts/keystore" "github.com/ava-labs/libevm/common" diff --git a/graft/coreth/params/config.go b/graft/coreth/params/config.go index 0a829ff70df1..d31e7233b5ba 100644 --- a/graft/coreth/params/config.go +++ b/graft/coreth/params/config.go @@ -31,7 +31,7 @@ import ( "math/big" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/libevm" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/coreth/params/config_extra.go b/graft/coreth/params/config_extra.go index 78f7b73fb436..3a60460bee8f 100644 --- a/graft/coreth/params/config_extra.go +++ b/graft/coreth/params/config_extra.go @@ -10,8 +10,8 @@ import ( "math/big" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade" + "github.com/ava-labs/avalanchego/utils" ) const ( diff --git a/graft/coreth/params/config_extra_test.go b/graft/coreth/params/config_extra_test.go index 8dfb0fdcdac7..45e9d19197dd 100644 --- a/graft/coreth/params/config_extra_test.go +++ b/graft/coreth/params/config_extra_test.go @@ -11,8 +11,8 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade/upgradetest" + "github.com/ava-labs/avalanchego/utils" ) func TestMain(m *testing.M) { diff --git a/graft/coreth/params/config_test.go b/graft/coreth/params/config_test.go index 14aec6b39e83..b18ab2088068 100644 --- a/graft/coreth/params/config_test.go +++ b/graft/coreth/params/config_test.go @@ -35,7 +35,7 @@ import ( "time" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/coreth/params/extras/config.go b/graft/coreth/params/extras/config.go index 68f39b7c5554..14c17fcaeb2b 100644 --- a/graft/coreth/params/extras/config.go +++ b/graft/coreth/params/extras/config.go @@ -10,8 +10,8 @@ import ( "github.com/ava-labs/libevm/common" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/utils" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/coreth/params/extras/config_extra_test.go b/graft/coreth/params/extras/config_extra_test.go index bee75618a8c2..311547182606 100644 --- a/graft/coreth/params/extras/config_extra_test.go +++ b/graft/coreth/params/extras/config_extra_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" ) func TestIsTimestampForked(t *testing.T) { diff --git a/graft/coreth/params/extras/precompile_upgrade.go b/graft/coreth/params/extras/precompile_upgrade.go index 6a36d4172ee5..f289097e30dd 100644 --- a/graft/coreth/params/extras/precompile_upgrade.go +++ b/graft/coreth/params/extras/precompile_upgrade.go @@ -12,7 +12,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/precompile/modules" "github.com/ava-labs/avalanchego/graft/coreth/precompile/precompileconfig" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/coreth/plugin/evm/config/config_test.go b/graft/coreth/plugin/evm/config/config_test.go index bb887da55b80..636180940ae6 100644 --- a/graft/coreth/plugin/evm/config/config_test.go +++ b/graft/coreth/plugin/evm/config/config_test.go @@ -12,7 +12,7 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" ) diff --git a/graft/coreth/plugin/evm/customheader/base_fee_test.go b/graft/coreth/plugin/evm/customheader/base_fee_test.go index 7337a1674f67..ab66955b66d4 100644 --- a/graft/coreth/plugin/evm/customheader/base_fee_test.go +++ b/graft/coreth/plugin/evm/customheader/base_fee_test.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap4" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap5" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/etna" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/components/gas" "github.com/ava-labs/avalanchego/vms/evm/acp176" ) diff --git a/graft/coreth/plugin/evm/customheader/extra_test.go b/graft/coreth/plugin/evm/customheader/extra_test.go index f6a0e956d3a7..706113e67bf3 100644 --- a/graft/coreth/plugin/evm/customheader/extra_test.go +++ b/graft/coreth/plugin/evm/customheader/extra_test.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap3" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap4" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap5" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/components/gas" "github.com/ava-labs/avalanchego/vms/evm/acp176" ) diff --git a/graft/coreth/plugin/evm/customheader/gas_limit_test.go b/graft/coreth/plugin/evm/customheader/gas_limit_test.go index 1f6c45d0bc3c..002fbff46b09 100644 --- a/graft/coreth/plugin/evm/customheader/gas_limit_test.go +++ b/graft/coreth/plugin/evm/customheader/gas_limit_test.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap1" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap5" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/cortina" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/math" "github.com/ava-labs/avalanchego/vms/components/gas" "github.com/ava-labs/avalanchego/vms/evm/acp176" diff --git a/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go b/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go index a18cc3b338c4..72e40eda44de 100644 --- a/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go +++ b/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go @@ -11,7 +11,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params/extras" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/customtypes" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/coreth/plugin/evm/customheader/time_test.go b/graft/coreth/plugin/evm/customheader/time_test.go index 770201700b5a..f1febcdcdc05 100644 --- a/graft/coreth/plugin/evm/customheader/time_test.go +++ b/graft/coreth/plugin/evm/customheader/time_test.go @@ -12,7 +12,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params/extras" "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/customtypes" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/coreth/plugin/evm/customtypes/block_ext_test.go b/graft/coreth/plugin/evm/customtypes/block_ext_test.go index 5a2ff0e258d8..13026ad5e745 100644 --- a/graft/coreth/plugin/evm/customtypes/block_ext_test.go +++ b/graft/coreth/plugin/evm/customtypes/block_ext_test.go @@ -16,7 +16,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/coreth/plugin/evm/customtypes/header_ext_test.go b/graft/coreth/plugin/evm/customtypes/header_ext_test.go index 4d8de5fc9342..cb6bd49b5f69 100644 --- a/graft/coreth/plugin/evm/customtypes/header_ext_test.go +++ b/graft/coreth/plugin/evm/customtypes/header_ext_test.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/libevm/rlp" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/coreth/plugin/evm/vm_test.go b/graft/coreth/plugin/evm/vm_test.go index 555f6cb3fe24..d6ec9003527d 100644 --- a/graft/coreth/plugin/evm/vm_test.go +++ b/graft/coreth/plugin/evm/vm_test.go @@ -43,11 +43,11 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmtest" "github.com/ava-labs/avalanchego/graft/coreth/rpc" "github.com/ava-labs/avalanchego/graft/evm/constants" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/upgrade/upgradetest" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/vms/components/chain" diff --git a/graft/coreth/precompile/contracts/warp/config_test.go b/graft/coreth/precompile/contracts/warp/config_test.go index cfe27b404711..559f362a227a 100644 --- a/graft/coreth/precompile/contracts/warp/config_test.go +++ b/graft/coreth/precompile/contracts/warp/config_test.go @@ -10,7 +10,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/coreth/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/coreth/precompile/contracts/warp/predicate_test.go b/graft/coreth/precompile/contracts/warp/predicate_test.go index d6f3ba9013cd..3dbdb1666817 100644 --- a/graft/coreth/precompile/contracts/warp/predicate_test.go +++ b/graft/coreth/precompile/contracts/warp/predicate_test.go @@ -16,7 +16,6 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params/extras/extrastest" "github.com/ava-labs/avalanchego/graft/coreth/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/coreth/precompile/precompiletest" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" @@ -24,6 +23,7 @@ import ( "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/snow/validators/validatorstest" "github.com/ava-labs/avalanchego/upgrade/upgradetest" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/crypto/bls/signer/localsigner" @@ -31,13 +31,12 @@ import ( "github.com/ava-labs/avalanchego/vms/evm/predicate" "github.com/ava-labs/avalanchego/vms/platformvm/warp/payload" - agoUtils "github.com/ava-labs/avalanchego/utils" safemath "github.com/ava-labs/avalanchego/utils/math" avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp" ) var ( - _ agoUtils.Sortable[*testValidator] = (*testValidator)(nil) + _ utils.Sortable[*testValidator] = (*testValidator)(nil) sourceChainID = ids.GenerateTestID() sourceSubnetID = ids.GenerateTestID() @@ -62,7 +61,7 @@ func init() { for i := 0; i < numTestVdrs; i++ { testVdrs = append(testVdrs, newTestValidator()) } - agoUtils.Sort(testVdrs) + utils.Sort(testVdrs) vdrs = map[ids.NodeID]*validators.GetValidatorOutput{ testVdrs[0].nodeID: { @@ -269,7 +268,7 @@ func testWarpMessageFromPrimaryNetwork(t *testing.T, requirePrimaryNetworkSigner require := require.New(t) numKeys := 10 cChainID := ids.GenerateTestID() - addressedCall, err := payload.NewAddressedCall(agoUtils.RandomBytes(20), agoUtils.RandomBytes(100)) + addressedCall, err := payload.NewAddressedCall(utils.RandomBytes(20), utils.RandomBytes(100)) require.NoError(err) unsignedMsg, err := avalancheWarp.NewUnsignedMessage(constants.UnitTestID, cChainID, addressedCall.Bytes()) require.NoError(err) @@ -295,7 +294,7 @@ func testWarpMessageFromPrimaryNetwork(t *testing.T, requirePrimaryNetworkSigner NodeIDs: []ids.NodeID{vdr.nodeID}, }) } - agoUtils.Sort(warpValidators.Validators) + utils.Sort(warpValidators.Validators) aggregateSignature, err := bls.AggregateSignatures(blsSignatures) require.NoError(err) @@ -456,7 +455,7 @@ func TestInvalidAddressedPayload(t *testing.T) { } func TestInvalidBitSet(t *testing.T) { - addressedCall, err := payload.NewAddressedCall(agoUtils.RandomBytes(20), agoUtils.RandomBytes(100)) + addressedCall, err := payload.NewAddressedCall(utils.RandomBytes(20), utils.RandomBytes(100)) require.NoError(t, err) unsignedMsg, err := avalancheWarp.NewUnsignedMessage( constants.UnitTestID, diff --git a/graft/coreth/tests/init.go b/graft/coreth/tests/init.go index c58ff3060d15..132932fe61af 100644 --- a/graft/coreth/tests/init.go +++ b/graft/coreth/tests/init.go @@ -36,7 +36,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params" "github.com/ava-labs/avalanchego/graft/coreth/params/extras" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/libevm" ) From 8a0b2a98eee6743ee9ae22688cd660be55b2a3a6 Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Thu, 18 Dec 2025 17:05:45 -0500 Subject: [PATCH 10/16] refactor: move pointer function to avalanchego utils --- go.mod | 2 +- graft/evm/utils/numbers.go | 7 +- .../precompile_config_test_template.go | 17 +-- graft/subnet-evm/core/blockchain_ext_test.go | 2 +- graft/subnet-evm/core/genesis_extra_test.go | 2 +- graft/subnet-evm/core/genesis_test.go | 2 +- .../core/state_processor_ext_test.go | 2 +- graft/subnet-evm/core/state_processor_test.go | 2 +- graft/subnet-evm/internal/ethapi/api_test.go | 2 +- graft/subnet-evm/params/config.go | 2 +- graft/subnet-evm/params/config_extra.go | 2 +- graft/subnet-evm/params/config_extra_test.go | 2 +- graft/subnet-evm/params/config_test.go | 2 +- graft/subnet-evm/params/extras/config.go | 2 +- .../params/extras/config_extra_test.go | 2 +- graft/subnet-evm/params/extras/config_test.go | 2 +- .../params/extras/network_upgrades.go | 3 +- .../params/extras/network_upgrades_test.go | 110 +++++++++--------- .../params/extras/precompile_config_test.go | 2 +- .../params/extras/precompile_upgrade.go | 2 +- .../params/extras/precompile_upgrade_test.go | 2 +- .../params/extras/state_upgrade_test.go | 2 +- .../plugin/evm/customheader/base_fee_test.go | 4 +- .../plugin/evm/customheader/extra_test.go | 2 +- .../evm/customheader/min_delay_excess_test.go | 2 +- .../plugin/evm/customheader/time_test.go | 2 +- .../plugin/evm/customtypes/block_ext_test.go | 2 +- .../plugin/evm/customtypes/header_ext_test.go | 2 +- graft/subnet-evm/plugin/evm/vm_test.go | 35 +++--- .../plugin/evm/vm_upgrade_bytes_test.go | 5 +- .../allowlisttest/test_allowlist_config.go | 2 +- .../deployerallowlist/config_test.go | 2 +- .../deployerallowlist/simulated_test.go | 2 +- .../contracts/feemanager/config_test.go | 2 +- .../contracts/feemanager/simulated_test.go | 2 +- .../contracts/nativeminter/config_test.go | 2 +- .../contracts/nativeminter/simulated_test.go | 2 +- .../contracts/rewardmanager/config_test.go | 2 +- .../contracts/rewardmanager/simulated_test.go | 2 +- .../contracts/txallowlist/config_test.go | 2 +- .../contracts/txallowlist/simulated_test.go | 2 +- .../precompile/contracts/warp/config_test.go | 2 +- .../contracts/warp/predicate_test.go | 13 +-- graft/subnet-evm/tests/init.go | 2 +- utils/zero.go | 5 + vms/evm/metrics/prometheus/prometheus.go | 2 +- 46 files changed, 142 insertions(+), 131 deletions(-) diff --git a/go.mod b/go.mod index c01cd95cb83d..cef9828a89a2 100644 --- a/go.mod +++ b/go.mod @@ -87,7 +87,7 @@ require ( k8s.io/utils v0.0.0-20230726121419-3b25d923346b ) -require github.com/ava-labs/avalanchego/graft/evm v0.0.0-00010101000000-000000000000 +require github.com/ava-labs/avalanchego/graft/evm v0.0.0-00010101000000-000000000000 // indirect require ( github.com/Microsoft/go-winio v0.6.1 // indirect diff --git a/graft/evm/utils/numbers.go b/graft/evm/utils/numbers.go index 1361f011db4b..5926080a0ead 100644 --- a/graft/evm/utils/numbers.go +++ b/graft/evm/utils/numbers.go @@ -6,13 +6,12 @@ package utils import ( "math/big" "time" -) -func PointerTo[T any](x T) *T { return &x } + "github.com/ava-labs/avalanchego/utils" +) func TimeToNewUint64(time time.Time) *uint64 { - unix := uint64(time.Unix()) - return PointerTo(unix) + return utils.PointerTo(uint64(time.Unix())) } func Uint64ToTime(val *uint64) time.Time { diff --git a/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go b/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go index fe4e4277b1f2..8dab27e0b1e5 100644 --- a/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go +++ b/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go @@ -16,6 +16,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" + avaulancheutils "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/graft/evm/utils" {{- if .Contract.AllowList}} "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" @@ -34,7 +35,7 @@ func TestVerify(t *testing.T) { {{- end}} tests := map[string]precompiletest.ConfigVerifyTest{ "valid config": { - Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() @@ -45,7 +46,7 @@ func TestVerify(t *testing.T) { // CUSTOM CODE STARTS HERE // Add your own Verify tests here, e.g.: // "your custom test name": { - // Config: NewConfig(utils.PointerTo[uint64](3), {{- if .Contract.AllowList}} admins, enableds, managers{{- end}}), + // Config: NewConfig(avalancheutils.PointerTo[uint64](3), {{- if .Contract.AllowList}} admins, enableds, managers{{- end}}), // ExpectedError: ErrYourCustomError, // }, } @@ -71,23 +72,23 @@ func TestEqual(t *testing.T) { {{- end}} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds,managers{{- end}}), + Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds,managers{{- end}}), Other: nil, Expected: false, }, "different type": { - Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), - Other: NewConfig(utils.PointerTo[uint64](4){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Other: NewConfig(avalancheutils.PointerTo[uint64](4){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Expected: false, }, "same config": { - Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), - Other: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Other: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Expected: true, }, // CUSTOM CODE STARTS HERE diff --git a/graft/subnet-evm/core/blockchain_ext_test.go b/graft/subnet-evm/core/blockchain_ext_test.go index 2150317a1077..22fb8a8d8a3d 100644 --- a/graft/subnet-evm/core/blockchain_ext_test.go +++ b/graft/subnet-evm/core/blockchain_ext_test.go @@ -20,7 +20,6 @@ import ( "github.com/holiman/uint256" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" @@ -29,6 +28,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/feemanager" + "github.com/ava-labs/avalanchego/utils" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/subnet-evm/core/genesis_extra_test.go b/graft/subnet-evm/core/genesis_extra_test.go index 64f3d3b19dd4..be98853501cf 100644 --- a/graft/subnet-evm/core/genesis_extra_test.go +++ b/graft/subnet-evm/core/genesis_extra_test.go @@ -14,12 +14,12 @@ import ( "github.com/ava-labs/libevm/triedb" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/paramstest" "github.com/ava-labs/avalanchego/upgrade/upgradetest" + "github.com/ava-labs/avalanchego/utils" ) func TestGenesisEthUpgrades(t *testing.T) { diff --git a/graft/subnet-evm/core/genesis_test.go b/graft/subnet-evm/core/genesis_test.go index 2ccd59e17a4d..28dda6bb8e25 100644 --- a/graft/subnet-evm/core/genesis_test.go +++ b/graft/subnet-evm/core/genesis_test.go @@ -35,7 +35,6 @@ import ( "reflect" "testing" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" @@ -45,6 +44,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/triedb/firewood" "github.com/ava-labs/avalanchego/graft/subnet-evm/triedb/pathdb" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/state" diff --git a/graft/subnet-evm/core/state_processor_ext_test.go b/graft/subnet-evm/core/state_processor_ext_test.go index 9424ec92f757..72bb3dcd18e8 100644 --- a/graft/subnet-evm/core/state_processor_ext_test.go +++ b/graft/subnet-evm/core/state_processor_ext_test.go @@ -14,12 +14,12 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/vmerrors" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" + "github.com/ava-labs/avalanchego/utils" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/subnet-evm/core/state_processor_test.go b/graft/subnet-evm/core/state_processor_test.go index e05b36d546f7..d4f306da59f2 100644 --- a/graft/subnet-evm/core/state_processor_test.go +++ b/graft/subnet-evm/core/state_processor_test.go @@ -32,7 +32,6 @@ import ( "math/big" "testing" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" @@ -41,6 +40,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/upgrade/legacy" "github.com/ava-labs/avalanchego/upgrade" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/consensus/misc/eip4844" "github.com/ava-labs/libevm/core/rawdb" diff --git a/graft/subnet-evm/internal/ethapi/api_test.go b/graft/subnet-evm/internal/ethapi/api_test.go index a434a9e9ee06..eb360d6d198a 100644 --- a/graft/subnet-evm/internal/ethapi/api_test.go +++ b/graft/subnet-evm/internal/ethapi/api_test.go @@ -42,7 +42,6 @@ import ( "testing" "time" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" @@ -52,6 +51,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/upgrade/legacy" "github.com/ava-labs/avalanchego/graft/subnet-evm/rpc" "github.com/ava-labs/avalanchego/upgrade" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/accounts" "github.com/ava-labs/libevm/accounts/keystore" "github.com/ava-labs/libevm/common" diff --git a/graft/subnet-evm/params/config.go b/graft/subnet-evm/params/config.go index 1910061f6b67..e7b1b0670819 100644 --- a/graft/subnet-evm/params/config.go +++ b/graft/subnet-evm/params/config.go @@ -30,8 +30,8 @@ package params import ( "math/big" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/libevm" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/subnet-evm/params/config_extra.go b/graft/subnet-evm/params/config_extra.go index c808193226d8..8c1d10775992 100644 --- a/graft/subnet-evm/params/config_extra.go +++ b/graft/subnet-evm/params/config_extra.go @@ -8,9 +8,9 @@ import ( "errors" "math/big" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/upgrade" + "github.com/ava-labs/avalanchego/utils" ) const ( diff --git a/graft/subnet-evm/params/config_extra_test.go b/graft/subnet-evm/params/config_extra_test.go index cf345a40fe6b..dffe2a471e8b 100644 --- a/graft/subnet-evm/params/config_extra_test.go +++ b/graft/subnet-evm/params/config_extra_test.go @@ -10,9 +10,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/upgrade/upgradetest" + "github.com/ava-labs/avalanchego/utils" ) func TestMain(m *testing.M) { diff --git a/graft/subnet-evm/params/config_test.go b/graft/subnet-evm/params/config_test.go index 5915b52c3166..d2abe646f9da 100644 --- a/graft/subnet-evm/params/config_test.go +++ b/graft/subnet-evm/params/config_test.go @@ -35,11 +35,11 @@ import ( "testing" "time" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/common" ethparams "github.com/ava-labs/libevm/params" "github.com/stretchr/testify/require" diff --git a/graft/subnet-evm/params/extras/config.go b/graft/subnet-evm/params/extras/config.go index 5e47c1d4abfc..98ab63182835 100644 --- a/graft/subnet-evm/params/extras/config.go +++ b/graft/subnet-evm/params/extras/config.go @@ -10,10 +10,10 @@ import ( "github.com/ava-labs/libevm/common" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/upgrade" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" ethparams "github.com/ava-labs/libevm/params" diff --git a/graft/subnet-evm/params/extras/config_extra_test.go b/graft/subnet-evm/params/extras/config_extra_test.go index bee75618a8c2..311547182606 100644 --- a/graft/subnet-evm/params/extras/config_extra_test.go +++ b/graft/subnet-evm/params/extras/config_extra_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" ) func TestIsTimestampForked(t *testing.T) { diff --git a/graft/subnet-evm/params/extras/config_test.go b/graft/subnet-evm/params/extras/config_test.go index f316dcdcce04..e5cf49c0a036 100644 --- a/graft/subnet-evm/params/extras/config_test.go +++ b/graft/subnet-evm/params/extras/config_test.go @@ -11,11 +11,11 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/upgrade" + "github.com/ava-labs/avalanchego/utils" ) func TestChainConfigDescription(t *testing.T) { diff --git a/graft/subnet-evm/params/extras/network_upgrades.go b/graft/subnet-evm/params/extras/network_upgrades.go index a1476857b08c..b2090dd2dbfb 100644 --- a/graft/subnet-evm/params/extras/network_upgrades.go +++ b/graft/subnet-evm/params/extras/network_upgrades.go @@ -12,6 +12,7 @@ import ( "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/upgrade" + avalancheutils "github.com/ava-labs/avalanchego/utils" ethparams "github.com/ava-labs/libevm/params" ) @@ -237,7 +238,7 @@ func (n *NetworkUpgrades) GetAvalancheRules(time uint64) AvalancheRules { // Nil values are used to indicate optional upgrades. func GetNetworkUpgrades(agoUpgrade upgrade.Config) NetworkUpgrades { return NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(agoUpgrade.DurangoTime), EtnaTimestamp: utils.TimeToNewUint64(agoUpgrade.EtnaTime), FortunaTimestamp: nil, // Fortuna is optional and has no effect on Subnet-EVM diff --git a/graft/subnet-evm/params/extras/network_upgrades_test.go b/graft/subnet-evm/params/extras/network_upgrades_test.go index 1d4986f560c0..463c35944636 100644 --- a/graft/subnet-evm/params/extras/network_upgrades_test.go +++ b/graft/subnet-evm/params/extras/network_upgrades_test.go @@ -12,6 +12,8 @@ import ( "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/upgrade/upgradetest" "github.com/ava-labs/avalanchego/utils/constants" + + avalancheutils "github.com/ava-labs/avalanchego/utils" ) func TestNetworkUpgradesEqual(t *testing.T) { @@ -24,32 +26,32 @@ func TestNetworkUpgradesEqual(t *testing.T) { { name: "EqualNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, expected: true, }, { name: "NotEqualNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](3), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](3), }, expected: false, }, { name: "NilNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: nil, expected: false, @@ -57,11 +59,11 @@ func TestNetworkUpgradesEqual(t *testing.T) { { name: "NilNetworkUpgrade", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), DurangoTimestamp: nil, }, expected: false, @@ -85,12 +87,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_same_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, time: 1, valid: true, @@ -98,12 +100,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_different_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](3), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](3), }, time: 1, valid: true, @@ -111,11 +113,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_nil_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), DurangoTimestamp: nil, }, time: 1, @@ -124,12 +126,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_rewinded_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](1), }, time: 1, valid: false, @@ -137,12 +139,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_fastforward_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](3), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](3), }, time: 4, valid: false, @@ -150,11 +152,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_nil_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), DurangoTimestamp: nil, }, time: 2, @@ -211,7 +213,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Durango_nil_upgrade", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), DurangoTimestamp: nil, }, avagoUpgrades: upgrade.Mainnet, @@ -220,8 +222,8 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Subnet-EVM_non-zero", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, avagoUpgrades: upgrade.Mainnet, wantError: errTimestampTooEarly, @@ -229,8 +231,8 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Durango_before_default_upgrade", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), - DurangoTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), + DurangoTimestamp: avalancheutils.PointerTo[uint64](1), }, avagoUpgrades: upgrade.Mainnet, wantError: errTimestampTooEarly, @@ -238,7 +240,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Mainnet_Durango_reconfigured_to_Fuji", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.GetConfig(constants.FujiID).DurangoTime), }, avagoUpgrades: upgrade.Mainnet, @@ -247,7 +249,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Valid_Fuji_Durango_reconfigured_to_Mainnet", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.GetConfig(constants.MainnetID).DurangoTime), }, avagoUpgrades: upgrade.Fuji, @@ -256,7 +258,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Etna_nil", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime), EtnaTimestamp: nil, }, @@ -266,7 +268,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Etna_before_Durango", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime), EtnaTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime.Add(-1)), }, @@ -276,7 +278,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Valid_Granite_After_nil_Fortuna", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Fuji.DurangoTime), EtnaTimestamp: utils.TimeToNewUint64(upgrade.Fuji.EtnaTime), FortunaTimestamp: nil, @@ -303,16 +305,16 @@ func TestForkOrder(t *testing.T) { { name: "ValidNetworkUpgrades", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, wantError: nil, }, { name: "Invalid order", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](0), }, wantError: errUnsupportedForkOrdering, }, @@ -327,12 +329,12 @@ func TestForkOrder(t *testing.T) { func TestSetDefaultsTreatsZeroAsUnset(t *testing.T) { upgrades := &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), - DurangoTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), + DurangoTimestamp: avalancheutils.PointerTo[uint64](0), EtnaTimestamp: nil, - FortunaTimestamp: utils.PointerTo[uint64](0), - GraniteTimestamp: utils.PointerTo[uint64](0), - HeliconTimestamp: utils.PointerTo[uint64](0), + FortunaTimestamp: avalancheutils.PointerTo[uint64](0), + GraniteTimestamp: avalancheutils.PointerTo[uint64](0), + HeliconTimestamp: avalancheutils.PointerTo[uint64](0), } agoUpgrades := upgradetest.GetConfig(upgradetest.Latest) upgrades.SetDefaults(agoUpgrades) diff --git a/graft/subnet-evm/params/extras/precompile_config_test.go b/graft/subnet-evm/params/extras/precompile_config_test.go index 0d8d8f8a2b03..93e4d421fcc3 100644 --- a/graft/subnet-evm/params/extras/precompile_config_test.go +++ b/graft/subnet-evm/params/extras/precompile_config_test.go @@ -11,7 +11,6 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist" @@ -20,6 +19,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" + "github.com/ava-labs/avalanchego/utils" ) func TestVerifyWithChainConfig(t *testing.T) { diff --git a/graft/subnet-evm/params/extras/precompile_upgrade.go b/graft/subnet-evm/params/extras/precompile_upgrade.go index eb69cae2f3a8..34d1c7716c18 100644 --- a/graft/subnet-evm/params/extras/precompile_upgrade.go +++ b/graft/subnet-evm/params/extras/precompile_upgrade.go @@ -10,9 +10,9 @@ import ( "github.com/ava-labs/libevm/common" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/modules" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" + "github.com/ava-labs/avalanchego/utils" ethparams "github.com/ava-labs/libevm/params" ) diff --git a/graft/subnet-evm/params/extras/precompile_upgrade_test.go b/graft/subnet-evm/params/extras/precompile_upgrade_test.go index 1d4daee011c9..72bcb4117fbb 100644 --- a/graft/subnet-evm/params/extras/precompile_upgrade_test.go +++ b/graft/subnet-evm/params/extras/precompile_upgrade_test.go @@ -10,9 +10,9 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" + "github.com/ava-labs/avalanchego/utils" ) func TestVerifyUpgradeConfig(t *testing.T) { diff --git a/graft/subnet-evm/params/extras/state_upgrade_test.go b/graft/subnet-evm/params/extras/state_upgrade_test.go index 6a0e43f712b4..fdd68ed89b08 100644 --- a/graft/subnet-evm/params/extras/state_upgrade_test.go +++ b/graft/subnet-evm/params/extras/state_upgrade_test.go @@ -12,8 +12,8 @@ import ( "github.com/ava-labs/libevm/common/math" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" + "github.com/ava-labs/avalanchego/utils" ) func TestVerifyStateUpgrades(t *testing.T) { diff --git a/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go b/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go index 850cac1c2790..f0b3f0c03d9a 100644 --- a/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go @@ -15,6 +15,8 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/upgrade/subnetevm" + + avalancheutils "github.com/ava-labs/avalanchego/utils" ) const ( @@ -48,7 +50,7 @@ func BaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) { { name: "subnet_evm_first_block", upgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), }, parent: &types.Header{ Number: big.NewInt(1), diff --git a/graft/subnet-evm/plugin/evm/customheader/extra_test.go b/graft/subnet-evm/plugin/evm/customheader/extra_test.go index a0826688c666..606c8af96b1a 100644 --- a/graft/subnet-evm/plugin/evm/customheader/extra_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/extra_test.go @@ -11,10 +11,10 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/upgrade/subnetevm" + "github.com/ava-labs/avalanchego/utils" ) func TestMain(m *testing.M) { diff --git a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go index 6cc4104f431d..eff8f68598f3 100644 --- a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go @@ -9,9 +9,9 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/subnet-evm/plugin/evm/customheader/time_test.go b/graft/subnet-evm/plugin/evm/customheader/time_test.go index 6d37fc102ce3..f3bd77b121b3 100644 --- a/graft/subnet-evm/plugin/evm/customheader/time_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/time_test.go @@ -10,9 +10,9 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go b/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go index 94a913906b85..f3fb776693ff 100644 --- a/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go +++ b/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go @@ -12,8 +12,8 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/internal/blocktest" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go b/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go index f2a6d18299c4..14a150308838 100644 --- a/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go +++ b/graft/subnet-evm/plugin/evm/customtypes/header_ext_test.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/libevm/rlp" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" ) diff --git a/graft/subnet-evm/plugin/evm/vm_test.go b/graft/subnet-evm/plugin/evm/vm_test.go index 9b3e8cf823a4..fe0551ca4c1d 100644 --- a/graft/subnet-evm/plugin/evm/vm_test.go +++ b/graft/subnet-evm/plugin/evm/vm_test.go @@ -69,6 +69,7 @@ import ( warpcontract "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/warp" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" + avalancheutils "github.com/ava-labs/avalanchego/utils" avagoconstants "github.com/ava-labs/avalanchego/utils/constants" avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp" ) @@ -1479,13 +1480,13 @@ func TestTimeSemanticVerify(t *testing.T) { name: "Granite with TimeMilliseconds", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli())), + timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.UnixMilli())), }, { name: "Fortuna with TimeMilliseconds", fork: upgradetest.Fortuna, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli())), + timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.UnixMilli())), expectedError: customheader.ErrTimeMillisecondsBeforeGranite, }, { @@ -1499,14 +1500,14 @@ func TestTimeSemanticVerify(t *testing.T) { name: "Granite with mismatched TimeMilliseconds", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli()) + 1000), + timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.UnixMilli()) + 1000), expectedError: customheader.ErrTimeMillisecondsMismatched, }, { name: "Block too far in the future", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Add(2 * time.Hour).Unix()), - timeMilliseconds: utils.PointerTo(uint64(timestamp.Add(2 * time.Hour).UnixMilli())), + timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.Add(2 * time.Hour).UnixMilli())), expectedError: customheader.ErrBlockTooFarInFuture, }, } @@ -1582,7 +1583,7 @@ func TestBuildTimeMilliseconds(t *testing.T) { { name: "granite_should_have_timestamp_milliseconds", fork: upgradetest.Granite, - expectedTimeMilliseconds: utils.PointerTo(uint64(buildTime.UnixMilli())), + expectedTimeMilliseconds: avalancheutils.PointerTo(uint64(buildTime.UnixMilli())), }, } @@ -1742,7 +1743,7 @@ func TestTxAllowListSuccessfulTx(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(toGenesisJSON(paramstest.ForkToChainConfig[upgradetest.Durango])))) // this manager role should not be activated because DurangoTimestamp is in the future params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil), + txallowlist.ConfigKey: txallowlist.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil), } durangoTime := time.Now().Add(10 * time.Hour) params.GetExtra(genesis.Config).DurangoTimestamp = utils.TimeToNewUint64(durangoTime) @@ -1885,7 +1886,7 @@ func TestVerifyManagerConfig(t *testing.T) { params.GetExtra(genesis.Config).DurangoTimestamp = utils.TimeToNewUint64(durangoTimestamp) // this manager role should not be activated because DurangoTimestamp is in the future params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, []common.Address{testEthAddrs[1]}), + txallowlist.ConfigKey: txallowlist.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, []common.Address{testEthAddrs[1]}), } genesisJSON, err := genesis.MarshalJSON() @@ -2037,7 +2038,7 @@ func TestFeeManagerChangeFee(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) configExtra := params.GetExtra(genesis.Config) configExtra.GenesisPrecompiles = extras.Precompiles{ - feemanager.ConfigKey: feemanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), + feemanager.ConfigKey: feemanager.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } // set a lower fee config now @@ -2253,7 +2254,7 @@ func TestRewardManagerPrecompileSetRewardAddress(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - rewardmanager.ConfigKey: rewardmanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), + rewardmanager.ConfigKey: rewardmanager.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } params.GetExtra(genesis.Config).AllowFeeRecipients = true // enable this in genesis to test if this is recognized by the reward manager genesisJSON, err := genesis.MarshalJSON() @@ -2397,7 +2398,7 @@ func TestRewardManagerPrecompileAllowFeeRecipients(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - rewardmanager.ConfigKey: rewardmanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), + rewardmanager.ConfigKey: rewardmanager.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } params.GetExtra(genesis.Config).AllowFeeRecipients = false // disable this in genesis genesisJSON, err := genesis.MarshalJSON() @@ -2733,7 +2734,7 @@ func TestFeeManagerRegressionMempoolMinFeeAfterRestart(t *testing.T) { // Setup chain params genesis := &core.Genesis{} require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) - precompileActivationTime := utils.PointerTo(genesis.Timestamp + 5) // 5 seconds after genesis + precompileActivationTime := avalancheutils.PointerTo(genesis.Timestamp + 5) // 5 seconds after genesis configExtra := params.GetExtra(genesis.Config) configExtra.GenesisPrecompiles = extras.Precompiles{ feemanager.ConfigKey: feemanager.NewConfig(precompileActivationTime, testEthAddrs[0:1], nil, nil, nil), @@ -3582,26 +3583,26 @@ func TestMinDelayExcessInHeader(t *testing.T) { { name: "pre_granite_min_delay_excess", fork: upgradetest.Fortuna, - desiredMinDelay: utils.PointerTo[uint64](1000), + desiredMinDelay: avalancheutils.PointerTo[uint64](1000), expectedMinDelayExcess: nil, }, { name: "granite_first_block_initial_delay_excess", fork: upgradetest.Granite, desiredMinDelay: nil, - expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), + expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), }, { name: "granite_with_excessive_desired_min_delay_excess", fork: upgradetest.Granite, - desiredMinDelay: utils.PointerTo[uint64](4000), - expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), + desiredMinDelay: avalancheutils.PointerTo[uint64](4000), + expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), }, { name: "granite_with_zero_desired_min_delay_excess", fork: upgradetest.Granite, - desiredMinDelay: utils.PointerTo[uint64](0), - expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), + desiredMinDelay: avalancheutils.PointerTo[uint64](0), + expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), }, } diff --git a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go index f9e40e0a2e44..c5da6574c9dd 100644 --- a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go +++ b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go @@ -32,6 +32,7 @@ import ( "github.com/ava-labs/avalanchego/vms/components/chain" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" + avalancheutils "github.com/ava-labs/avalanchego/utils" ) func TestVMUpgradeBytesPrecompile(t *testing.T) { @@ -142,7 +143,7 @@ func TestNetworkUpgradesOverridden(t *testing.T) { fork := upgradetest.Granite chainConfig := paramstest.ForkToChainConfig[fork] extraConfig := params.GetExtra(chainConfig) - extraConfig.NetworkUpgrades.GraniteTimestamp = utils.PointerTo(uint64(upgrade.InitiallyActiveTime.Unix())) + extraConfig.NetworkUpgrades.GraniteTimestamp = avalancheutils.PointerTo(uint64(upgrade.InitiallyActiveTime.Unix())) genesis := &core.Genesis{} require.NoError(t, json.Unmarshal([]byte(toGenesisJSON(chainConfig)), genesis)) // Set the genesis timestamp to before the Granite activation time @@ -351,7 +352,7 @@ func TestVMEtnaActivatesCancun(t *testing.T) { upgradeJSON: func() string { upgrade := &extras.UpgradeConfig{ NetworkUpgradeOverrides: &extras.NetworkUpgrades{ - EtnaTimestamp: utils.PointerTo(defaultEtnaTime + 2), + EtnaTimestamp: avalancheutils.PointerTo(defaultEtnaTime + 2), }, } b, err := json.Marshal(upgrade) diff --git a/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go b/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go index 13572d1e7176..e4e2e9ecad50 100644 --- a/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go +++ b/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go @@ -11,11 +11,11 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/modules" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" + "github.com/ava-labs/avalanchego/utils" ) // mkConfigWithAllowList creates a new config with the correct type for [module] diff --git a/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go b/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go index 95779e07154d..45e372ec6c95 100644 --- a/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go +++ b/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go @@ -9,11 +9,11 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" + "github.com/ava-labs/avalanchego/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go b/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go index 6de5231d8249..20da25ae2c34 100644 --- a/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go @@ -11,7 +11,6 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" @@ -20,6 +19,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/utilstest" + "github.com/ava-labs/avalanchego/utils" sim "github.com/ava-labs/avalanchego/graft/subnet-evm/ethclient/simulated" allowlistbindings "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest/bindings" diff --git a/graft/subnet-evm/precompile/contracts/feemanager/config_test.go b/graft/subnet-evm/precompile/contracts/feemanager/config_test.go index a02a8a9e6232..ab84645e80fe 100644 --- a/graft/subnet-evm/precompile/contracts/feemanager/config_test.go +++ b/graft/subnet-evm/precompile/contracts/feemanager/config_test.go @@ -10,12 +10,12 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/feemanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" + "github.com/ava-labs/avalanchego/utils" ) var validFeeConfig = commontype.FeeConfig{ diff --git a/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go b/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go index cfbf107298df..bc310876a8ec 100644 --- a/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go @@ -13,7 +13,6 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" @@ -24,6 +23,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/feemanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/utilstest" + "github.com/ava-labs/avalanchego/utils" sim "github.com/ava-labs/avalanchego/graft/subnet-evm/ethclient/simulated" feemanagerbindings "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/feemanager/feemanagertest/bindings" diff --git a/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go b/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go index b97f55927a56..dba4a1cb0a95 100644 --- a/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go +++ b/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go @@ -10,12 +10,12 @@ import ( "github.com/ava-labs/libevm/common/math" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" + "github.com/ava-labs/avalanchego/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go b/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go index a87e52d83839..4982b53e3f85 100644 --- a/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go @@ -12,7 +12,6 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" @@ -21,6 +20,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/utilstest" + "github.com/ava-labs/avalanchego/utils" sim "github.com/ava-labs/avalanchego/graft/subnet-evm/ethclient/simulated" nativeminterbindings "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter/nativemintertest/bindings" diff --git a/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go b/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go index dca4badf6b4a..3894db716620 100644 --- a/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go +++ b/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go @@ -9,11 +9,11 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" + "github.com/ava-labs/avalanchego/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go b/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go index 8a81af42f987..3cfd9c6a0f5a 100644 --- a/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go @@ -15,7 +15,6 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/graft/evm/constants" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/eth/ethconfig" @@ -26,6 +25,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/utilstest" + "github.com/ava-labs/avalanchego/utils" sim "github.com/ava-labs/avalanchego/graft/subnet-evm/ethclient/simulated" rewardmanagerbindings "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager/rewardmanagertest/bindings" diff --git a/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go b/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go index 28472e0775c0..59eaa4a53dea 100644 --- a/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go +++ b/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go @@ -9,11 +9,11 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" + "github.com/ava-labs/avalanchego/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go b/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go index 840b1e21bdf5..98a854768312 100644 --- a/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go @@ -11,7 +11,6 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" @@ -21,6 +20,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/utilstest" + "github.com/ava-labs/avalanchego/utils" sim "github.com/ava-labs/avalanchego/graft/subnet-evm/ethclient/simulated" allowlistbindings "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest/bindings" diff --git a/graft/subnet-evm/precompile/contracts/warp/config_test.go b/graft/subnet-evm/precompile/contracts/warp/config_test.go index cda6b39c51a4..ea486698d073 100644 --- a/graft/subnet-evm/precompile/contracts/warp/config_test.go +++ b/graft/subnet-evm/precompile/contracts/warp/config_test.go @@ -8,9 +8,9 @@ import ( "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" + "github.com/ava-labs/avalanchego/utils" ) func TestVerify(t *testing.T) { diff --git a/graft/subnet-evm/precompile/contracts/warp/predicate_test.go b/graft/subnet-evm/precompile/contracts/warp/predicate_test.go index 30055cf24c16..9d1e8a97070c 100644 --- a/graft/subnet-evm/precompile/contracts/warp/predicate_test.go +++ b/graft/subnet-evm/precompile/contracts/warp/predicate_test.go @@ -12,7 +12,6 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras/extrastest" @@ -25,6 +24,7 @@ import ( "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/snow/validators/validatorstest" "github.com/ava-labs/avalanchego/upgrade/upgradetest" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/crypto/bls/signer/localsigner" @@ -32,13 +32,12 @@ import ( "github.com/ava-labs/avalanchego/vms/evm/predicate" "github.com/ava-labs/avalanchego/vms/platformvm/warp/payload" - agoUtils "github.com/ava-labs/avalanchego/utils" safemath "github.com/ava-labs/avalanchego/utils/math" avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp" ) var ( - _ agoUtils.Sortable[*testValidator] = (*testValidator)(nil) + _ utils.Sortable[*testValidator] = (*testValidator)(nil) sourceChainID = ids.GenerateTestID() sourceSubnetID = ids.GenerateTestID() @@ -63,7 +62,7 @@ func init() { for i := 0; i < numTestVdrs; i++ { testVdrs = append(testVdrs, newTestValidator()) } - agoUtils.Sort(testVdrs) + utils.Sort(testVdrs) vdrs = map[ids.NodeID]*validators.GetValidatorOutput{ testVdrs[0].nodeID: { @@ -271,7 +270,7 @@ func testWarpMessageFromPrimaryNetwork(t *testing.T, requirePrimaryNetworkSigner require := require.New(t) numKeys := 10 cChainID := ids.GenerateTestID() - addressedCall, err := payload.NewAddressedCall(agoUtils.RandomBytes(20), agoUtils.RandomBytes(100)) + addressedCall, err := payload.NewAddressedCall(utils.RandomBytes(20), utils.RandomBytes(100)) require.NoError(err) unsignedMsg, err := avalancheWarp.NewUnsignedMessage(constants.UnitTestID, cChainID, addressedCall.Bytes()) require.NoError(err) @@ -297,7 +296,7 @@ func testWarpMessageFromPrimaryNetwork(t *testing.T, requirePrimaryNetworkSigner NodeIDs: []ids.NodeID{vdr.nodeID}, }) } - agoUtils.Sort(warpValidators.Validators) + utils.Sort(warpValidators.Validators) aggregateSignature, err := bls.AggregateSignatures(blsSignatures) require.NoError(err) @@ -459,7 +458,7 @@ func TestInvalidAddressedPayload(t *testing.T) { } func TestInvalidBitSet(t *testing.T) { - addressedCall, err := payload.NewAddressedCall(agoUtils.RandomBytes(20), agoUtils.RandomBytes(100)) + addressedCall, err := payload.NewAddressedCall(utils.RandomBytes(20), utils.RandomBytes(100)) require.NoError(t, err) unsignedMsg, err := avalancheWarp.NewUnsignedMessage( constants.UnitTestID, diff --git a/graft/subnet-evm/tests/init.go b/graft/subnet-evm/tests/init.go index d8f516075b3b..c7e64a59b3ea 100644 --- a/graft/subnet-evm/tests/init.go +++ b/graft/subnet-evm/tests/init.go @@ -34,9 +34,9 @@ import ( "sort" "strings" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/libevm" ) diff --git a/utils/zero.go b/utils/zero.go index 0cd0ef01eabe..2ab2423b71e6 100644 --- a/utils/zero.go +++ b/utils/zero.go @@ -7,3 +7,8 @@ package utils func Zero[T any]() (_ T) { return } + +// PointerTo returns a pointer to the provided value. +func PointerTo[T any](v T) *T { + return &v +} diff --git a/vms/evm/metrics/prometheus/prometheus.go b/vms/evm/metrics/prometheus/prometheus.go index 44cc1e278177..8232d8e173cf 100644 --- a/vms/evm/metrics/prometheus/prometheus.go +++ b/vms/evm/metrics/prometheus/prometheus.go @@ -12,7 +12,7 @@ import ( "github.com/ava-labs/libevm/metrics" "github.com/prometheus/client_golang/prometheus" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" dto "github.com/prometheus/client_model/go" ) From 4899b18bc4ccb49decd988083c722c662ae82ba8 Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Thu, 18 Dec 2025 17:21:07 -0500 Subject: [PATCH 11/16] refactor: remove avalanche pointer functions --- graft/coreth/core/genesis_extra_test.go | 6 +- graft/coreth/plugin/evm/atomic/export_tx.go | 5 +- .../plugin/evm/atomic/vm/export_tx_test.go | 4 +- .../plugin/evm/atomic/vm/import_tx_test.go | 6 +- .../precompile_config_test_template.go | 16 +-- .../params/extras/network_upgrades_test.go | 110 +++++++++--------- .../plugin/evm/customheader/base_fee_test.go | 4 +- graft/subnet-evm/plugin/evm/vm_test.go | 36 +++--- .../plugin/evm/vm_upgrade_bytes_test.go | 6 +- utils/timer/eta_test.go | 15 +-- x/blockdb/helpers_test.go | 5 - x/blockdb/recovery_test.go | 9 +- 12 files changed, 107 insertions(+), 115 deletions(-) diff --git a/graft/coreth/core/genesis_extra_test.go b/graft/coreth/core/genesis_extra_test.go index 7f8260eba397..49383df0722a 100644 --- a/graft/coreth/core/genesis_extra_test.go +++ b/graft/coreth/core/genesis_extra_test.go @@ -36,7 +36,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/params/extras" "github.com/ava-labs/avalanchego/graft/coreth/params/paramstest" "github.com/ava-labs/avalanchego/upgrade/upgradetest" - avalancheutils "github.com/ava-labs/avalanchego/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" "github.com/ava-labs/libevm/core/types" @@ -68,8 +68,8 @@ func TestGenesisEthUpgrades(t *testing.T) { }, &extras.ChainConfig{ NetworkUpgrades: extras.NetworkUpgrades{ - ApricotPhase1BlockTimestamp: avalancheutils.PointerTo[uint64](0), - ApricotPhase2BlockTimestamp: avalancheutils.PointerTo[uint64](0), + ApricotPhase1BlockTimestamp: utils.PointerTo[uint64](0), + ApricotPhase2BlockTimestamp: utils.PointerTo[uint64](0), }, }, ) diff --git a/graft/coreth/plugin/evm/atomic/export_tx.go b/graft/coreth/plugin/evm/atomic/export_tx.go index ce0cf9ae4282..7a9a3fef48e9 100644 --- a/graft/coreth/plugin/evm/atomic/export_tx.go +++ b/graft/coreth/plugin/evm/atomic/export_tx.go @@ -19,6 +19,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/upgrade/ap5" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/math" @@ -27,8 +28,6 @@ import ( "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/components/verify" "github.com/ava-labs/avalanchego/vms/secp256k1fx" - - avalancheutils "github.com/ava-labs/avalanchego/utils" ) var ( @@ -125,7 +124,7 @@ func (utx *UnsignedExportTx) Verify( if !avax.IsSortedTransferableOutputs(utx.ExportedOutputs, Codec) { return ErrOutputsNotSorted } - if rules.IsApricotPhase1 && !avalancheutils.IsSortedAndUnique(utx.Ins) { + if rules.IsApricotPhase1 && !utils.IsSortedAndUnique(utx.Ins) { return ErrInputsNotSortedUnique } diff --git a/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go b/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go index 8023f68fe4e2..e61eaca41588 100644 --- a/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go +++ b/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go @@ -27,7 +27,7 @@ import ( avalancheatomic "github.com/ava-labs/avalanchego/chains/atomic" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" - avalancheutils "github.com/ava-labs/avalanchego/utils" + "github.com/ava-labs/avalanchego/utils" ) // createExportTxOptions adds funds to shared memory, imports them, and returns a list of export transactions @@ -466,7 +466,7 @@ func TestExportTxSemanticVerify(t *testing.T) { }, }, } - avalancheutils.Sort(validExportTx.Ins) + utils.Sort(validExportTx.Ins) validAVAXExportTx := &atomic.UnsignedExportTx{ NetworkID: vm.Ctx.NetworkID, diff --git a/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go b/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go index 719e9d6fda97..3738531830b2 100644 --- a/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go +++ b/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go @@ -28,7 +28,7 @@ import ( avalancheatomic "github.com/ava-labs/avalanchego/chains/atomic" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" - avalancheutils "github.com/ava-labs/avalanchego/utils" + "github.com/ava-labs/avalanchego/utils" ) // createImportTxOptions adds a UTXO to shared memory and generates a list of import transactions sending this UTXO @@ -99,8 +99,8 @@ func TestImportTxVerify(t *testing.T) { } // Sort the inputs and outputs to ensure the transaction is canonical - avalancheutils.Sort(importTx.ImportedInputs) - avalancheutils.Sort(importTx.Outs) + utils.Sort(importTx.ImportedInputs) + utils.Sort(importTx.Outs) tests := map[string]atomicTxVerifyTest{ "nil tx": { diff --git a/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go b/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go index 8dab27e0b1e5..7a6c40da30a7 100644 --- a/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go +++ b/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go @@ -35,7 +35,7 @@ func TestVerify(t *testing.T) { {{- end}} tests := map[string]precompiletest.ConfigVerifyTest{ "valid config": { - Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() @@ -46,7 +46,7 @@ func TestVerify(t *testing.T) { // CUSTOM CODE STARTS HERE // Add your own Verify tests here, e.g.: // "your custom test name": { - // Config: NewConfig(avalancheutils.PointerTo[uint64](3), {{- if .Contract.AllowList}} admins, enableds, managers{{- end}}), + // Config: NewConfig(utils.PointerTo[uint64](3), {{- if .Contract.AllowList}} admins, enableds, managers{{- end}}), // ExpectedError: ErrYourCustomError, // }, } @@ -72,23 +72,23 @@ func TestEqual(t *testing.T) { {{- end}} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds,managers{{- end}}), + Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds,managers{{- end}}), Other: nil, Expected: false, }, "different type": { - Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), - Other: NewConfig(avalancheutils.PointerTo[uint64](4){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Other: NewConfig(utils.PointerTo[uint64](4){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Expected: false, }, "same config": { - Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), - Other: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Other: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Expected: true, }, // CUSTOM CODE STARTS HERE diff --git a/graft/subnet-evm/params/extras/network_upgrades_test.go b/graft/subnet-evm/params/extras/network_upgrades_test.go index 463c35944636..1ec9b45141bd 100644 --- a/graft/subnet-evm/params/extras/network_upgrades_test.go +++ b/graft/subnet-evm/params/extras/network_upgrades_test.go @@ -13,7 +13,7 @@ import ( "github.com/ava-labs/avalanchego/upgrade/upgradetest" "github.com/ava-labs/avalanchego/utils/constants" - avalancheutils "github.com/ava-labs/avalanchego/utils" + "github.com/ava-labs/avalanchego/utils" ) func TestNetworkUpgradesEqual(t *testing.T) { @@ -26,32 +26,32 @@ func TestNetworkUpgradesEqual(t *testing.T) { { name: "EqualNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, expected: true, }, { name: "NotEqualNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](3), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](3), }, expected: false, }, { name: "NilNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: nil, expected: false, @@ -59,11 +59,11 @@ func TestNetworkUpgradesEqual(t *testing.T) { { name: "NilNetworkUpgrade", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), DurangoTimestamp: nil, }, expected: false, @@ -87,12 +87,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_same_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, time: 1, valid: true, @@ -100,12 +100,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_different_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](3), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](3), }, time: 1, valid: true, @@ -113,11 +113,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_nil_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), DurangoTimestamp: nil, }, time: 1, @@ -126,12 +126,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_rewinded_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](1), }, time: 1, valid: false, @@ -139,12 +139,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_fastforward_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](3), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](3), }, time: 4, valid: false, @@ -152,11 +152,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_nil_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), DurangoTimestamp: nil, }, time: 2, @@ -213,7 +213,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Durango_nil_upgrade", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), DurangoTimestamp: nil, }, avagoUpgrades: upgrade.Mainnet, @@ -222,8 +222,8 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Subnet-EVM_non-zero", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](2), }, avagoUpgrades: upgrade.Mainnet, wantError: errTimestampTooEarly, @@ -231,8 +231,8 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Durango_before_default_upgrade", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), - DurangoTimestamp: avalancheutils.PointerTo[uint64](1), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), + DurangoTimestamp: utils.PointerTo[uint64](1), }, avagoUpgrades: upgrade.Mainnet, wantError: errTimestampTooEarly, @@ -240,7 +240,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Mainnet_Durango_reconfigured_to_Fuji", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.GetConfig(constants.FujiID).DurangoTime), }, avagoUpgrades: upgrade.Mainnet, @@ -249,7 +249,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Valid_Fuji_Durango_reconfigured_to_Mainnet", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.GetConfig(constants.MainnetID).DurangoTime), }, avagoUpgrades: upgrade.Fuji, @@ -258,7 +258,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Etna_nil", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime), EtnaTimestamp: nil, }, @@ -268,7 +268,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Etna_before_Durango", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime), EtnaTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime.Add(-1)), }, @@ -278,7 +278,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Valid_Granite_After_nil_Fortuna", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Fuji.DurangoTime), EtnaTimestamp: utils.TimeToNewUint64(upgrade.Fuji.EtnaTime), FortunaTimestamp: nil, @@ -305,16 +305,16 @@ func TestForkOrder(t *testing.T) { { name: "ValidNetworkUpgrades", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), - DurangoTimestamp: avalancheutils.PointerTo[uint64](2), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), + DurangoTimestamp: utils.PointerTo[uint64](2), }, wantError: nil, }, { name: "Invalid order", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), - DurangoTimestamp: avalancheutils.PointerTo[uint64](0), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), + DurangoTimestamp: utils.PointerTo[uint64](0), }, wantError: errUnsupportedForkOrdering, }, @@ -329,12 +329,12 @@ func TestForkOrder(t *testing.T) { func TestSetDefaultsTreatsZeroAsUnset(t *testing.T) { upgrades := &NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), - DurangoTimestamp: avalancheutils.PointerTo[uint64](0), + SubnetEVMTimestamp: utils.PointerTo[uint64](0), + DurangoTimestamp: utils.PointerTo[uint64](0), EtnaTimestamp: nil, - FortunaTimestamp: avalancheutils.PointerTo[uint64](0), - GraniteTimestamp: avalancheutils.PointerTo[uint64](0), - HeliconTimestamp: avalancheutils.PointerTo[uint64](0), + FortunaTimestamp: utils.PointerTo[uint64](0), + GraniteTimestamp: utils.PointerTo[uint64](0), + HeliconTimestamp: utils.PointerTo[uint64](0), } agoUpgrades := upgradetest.GetConfig(upgradetest.Latest) upgrades.SetDefaults(agoUpgrades) diff --git a/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go b/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go index f0b3f0c03d9a..9a6abff31d41 100644 --- a/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/upgrade/subnetevm" - avalancheutils "github.com/ava-labs/avalanchego/utils" + "github.com/ava-labs/avalanchego/utils" ) const ( @@ -50,7 +50,7 @@ func BaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) { { name: "subnet_evm_first_block", upgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + SubnetEVMTimestamp: utils.PointerTo[uint64](1), }, parent: &types.Header{ Number: big.NewInt(1), diff --git a/graft/subnet-evm/plugin/evm/vm_test.go b/graft/subnet-evm/plugin/evm/vm_test.go index fe0551ca4c1d..8003c0a4334f 100644 --- a/graft/subnet-evm/plugin/evm/vm_test.go +++ b/graft/subnet-evm/plugin/evm/vm_test.go @@ -69,7 +69,7 @@ import ( warpcontract "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/warp" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" - avalancheutils "github.com/ava-labs/avalanchego/utils" + "github.com/ava-labs/avalanchego/utils" avagoconstants "github.com/ava-labs/avalanchego/utils/constants" avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp" ) @@ -1480,13 +1480,13 @@ func TestTimeSemanticVerify(t *testing.T) { name: "Granite with TimeMilliseconds", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.UnixMilli())), + timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli())), }, { name: "Fortuna with TimeMilliseconds", fork: upgradetest.Fortuna, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.UnixMilli())), + timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli())), expectedError: customheader.ErrTimeMillisecondsBeforeGranite, }, { @@ -1500,14 +1500,14 @@ func TestTimeSemanticVerify(t *testing.T) { name: "Granite with mismatched TimeMilliseconds", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.UnixMilli()) + 1000), + timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli()) + 1000), expectedError: customheader.ErrTimeMillisecondsMismatched, }, { name: "Block too far in the future", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Add(2 * time.Hour).Unix()), - timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.Add(2 * time.Hour).UnixMilli())), + timeMilliseconds: utils.PointerTo(uint64(timestamp.Add(2 * time.Hour).UnixMilli())), expectedError: customheader.ErrBlockTooFarInFuture, }, } @@ -1583,7 +1583,7 @@ func TestBuildTimeMilliseconds(t *testing.T) { { name: "granite_should_have_timestamp_milliseconds", fork: upgradetest.Granite, - expectedTimeMilliseconds: avalancheutils.PointerTo(uint64(buildTime.UnixMilli())), + expectedTimeMilliseconds: utils.PointerTo(uint64(buildTime.UnixMilli())), }, } @@ -1743,7 +1743,7 @@ func TestTxAllowListSuccessfulTx(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(toGenesisJSON(paramstest.ForkToChainConfig[upgradetest.Durango])))) // this manager role should not be activated because DurangoTimestamp is in the future params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil), + txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil), } durangoTime := time.Now().Add(10 * time.Hour) params.GetExtra(genesis.Config).DurangoTimestamp = utils.TimeToNewUint64(durangoTime) @@ -1886,7 +1886,7 @@ func TestVerifyManagerConfig(t *testing.T) { params.GetExtra(genesis.Config).DurangoTimestamp = utils.TimeToNewUint64(durangoTimestamp) // this manager role should not be activated because DurangoTimestamp is in the future params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, []common.Address{testEthAddrs[1]}), + txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, []common.Address{testEthAddrs[1]}), } genesisJSON, err := genesis.MarshalJSON() @@ -2038,7 +2038,7 @@ func TestFeeManagerChangeFee(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) configExtra := params.GetExtra(genesis.Config) configExtra.GenesisPrecompiles = extras.Precompiles{ - feemanager.ConfigKey: feemanager.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), + feemanager.ConfigKey: feemanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } // set a lower fee config now @@ -2254,7 +2254,7 @@ func TestRewardManagerPrecompileSetRewardAddress(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - rewardmanager.ConfigKey: rewardmanager.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), + rewardmanager.ConfigKey: rewardmanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } params.GetExtra(genesis.Config).AllowFeeRecipients = true // enable this in genesis to test if this is recognized by the reward manager genesisJSON, err := genesis.MarshalJSON() @@ -2398,7 +2398,7 @@ func TestRewardManagerPrecompileAllowFeeRecipients(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - rewardmanager.ConfigKey: rewardmanager.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), + rewardmanager.ConfigKey: rewardmanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } params.GetExtra(genesis.Config).AllowFeeRecipients = false // disable this in genesis genesisJSON, err := genesis.MarshalJSON() @@ -2734,7 +2734,7 @@ func TestFeeManagerRegressionMempoolMinFeeAfterRestart(t *testing.T) { // Setup chain params genesis := &core.Genesis{} require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) - precompileActivationTime := avalancheutils.PointerTo(genesis.Timestamp + 5) // 5 seconds after genesis + precompileActivationTime := utils.PointerTo(genesis.Timestamp + 5) // 5 seconds after genesis configExtra := params.GetExtra(genesis.Config) configExtra.GenesisPrecompiles = extras.Precompiles{ feemanager.ConfigKey: feemanager.NewConfig(precompileActivationTime, testEthAddrs[0:1], nil, nil, nil), @@ -3583,26 +3583,26 @@ func TestMinDelayExcessInHeader(t *testing.T) { { name: "pre_granite_min_delay_excess", fork: upgradetest.Fortuna, - desiredMinDelay: avalancheutils.PointerTo[uint64](1000), + desiredMinDelay: utils.PointerTo[uint64](1000), expectedMinDelayExcess: nil, }, { name: "granite_first_block_initial_delay_excess", fork: upgradetest.Granite, desiredMinDelay: nil, - expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), + expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), }, { name: "granite_with_excessive_desired_min_delay_excess", fork: upgradetest.Granite, - desiredMinDelay: avalancheutils.PointerTo[uint64](4000), - expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), + desiredMinDelay: utils.PointerTo[uint64](4000), + expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), }, { name: "granite_with_zero_desired_min_delay_excess", fork: upgradetest.Granite, - desiredMinDelay: avalancheutils.PointerTo[uint64](0), - expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), + desiredMinDelay: utils.PointerTo[uint64](0), + expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), }, } diff --git a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go index c5da6574c9dd..09304087e0ec 100644 --- a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go +++ b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go @@ -32,7 +32,7 @@ import ( "github.com/ava-labs/avalanchego/vms/components/chain" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" - avalancheutils "github.com/ava-labs/avalanchego/utils" + "github.com/ava-labs/avalanchego/utils" ) func TestVMUpgradeBytesPrecompile(t *testing.T) { @@ -143,7 +143,7 @@ func TestNetworkUpgradesOverridden(t *testing.T) { fork := upgradetest.Granite chainConfig := paramstest.ForkToChainConfig[fork] extraConfig := params.GetExtra(chainConfig) - extraConfig.NetworkUpgrades.GraniteTimestamp = avalancheutils.PointerTo(uint64(upgrade.InitiallyActiveTime.Unix())) + extraConfig.NetworkUpgrades.GraniteTimestamp = utils.PointerTo(uint64(upgrade.InitiallyActiveTime.Unix())) genesis := &core.Genesis{} require.NoError(t, json.Unmarshal([]byte(toGenesisJSON(chainConfig)), genesis)) // Set the genesis timestamp to before the Granite activation time @@ -352,7 +352,7 @@ func TestVMEtnaActivatesCancun(t *testing.T) { upgradeJSON: func() string { upgrade := &extras.UpgradeConfig{ NetworkUpgradeOverrides: &extras.NetworkUpgrades{ - EtnaTimestamp: avalancheutils.PointerTo(defaultEtnaTime + 2), + EtnaTimestamp: utils.PointerTo(defaultEtnaTime + 2), }, } b, err := json.Marshal(upgrade) diff --git a/utils/timer/eta_test.go b/utils/timer/eta_test.go index e0c4530e8fd4..e8aafe27d4af 100644 --- a/utils/timer/eta_test.go +++ b/utils/timer/eta_test.go @@ -8,12 +8,9 @@ import ( "time" "github.com/stretchr/testify/require" -) -// timePtr is a helper function to convert a time.Duration to a pointer -func timePtr(d time.Duration) *time.Duration { - return &d -} + "github.com/ava-labs/avalanchego/utils" +) func TestEtaTracker(t *testing.T) { tracker := NewEtaTracker(3, 1.0) @@ -48,7 +45,7 @@ func TestEtaTracker(t *testing.T) { name: "sample 3: sufficient data for ETA", completed: 200, timestamp: now.Add(20 * time.Second), - expectedEta: timePtr(80 * time.Second), + expectedEta: utils.PointerTo(80 * time.Second), expectedPercent: 20.0, }, { @@ -56,7 +53,7 @@ func TestEtaTracker(t *testing.T) { name: "sample 4: non linear since we sped up", completed: 600, timestamp: now.Add(40 * time.Second), - expectedEta: timePtr(24 * time.Second), + expectedEta: utils.PointerTo(24 * time.Second), expectedPercent: 60.0, }, { @@ -64,7 +61,7 @@ func TestEtaTracker(t *testing.T) { name: "sample 5: at the end", completed: 1000, timestamp: now.Add(1 * time.Second), - expectedEta: timePtr(0), + expectedEta: utils.PointerTo[time.Duration](0), expectedPercent: 100.0, }, { @@ -72,7 +69,7 @@ func TestEtaTracker(t *testing.T) { name: "sample 6: past the end", completed: 2000, timestamp: now.Add(1 * time.Second), - expectedEta: timePtr(0), + expectedEta: utils.PointerTo[time.Duration](0), expectedPercent: 100.0, }, { diff --git a/x/blockdb/helpers_test.go b/x/blockdb/helpers_test.go index 32e1f49e9380..3683e51d04e1 100644 --- a/x/blockdb/helpers_test.go +++ b/x/blockdb/helpers_test.go @@ -76,8 +76,3 @@ func checkDatabaseState(t *testing.T, db *Database, maxHeight uint64) { actualMaxHeight := db.maxBlockHeight.Load() require.Equal(t, maxHeight, actualMaxHeight, "maxBlockHeight mismatch") } - -// Helper function to create a pointer to uint64 -func uint64Ptr(v uint64) *uint64 { - return &v -} diff --git a/x/blockdb/recovery_test.go b/x/blockdb/recovery_test.go index 0925d5ad2270..2ad21c556226 100644 --- a/x/blockdb/recovery_test.go +++ b/x/blockdb/recovery_test.go @@ -12,6 +12,7 @@ import ( "github.com/DataDog/zstd" "github.com/stretchr/testify/require" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/compression" ) @@ -417,8 +418,8 @@ func TestRecovery_CorruptionDetection(t *testing.T) { name: "missing data file at index 1", blockHeights: []uint64{0, 1, 2, 3, 4, 5}, disableCompression: true, - maxDataFileSize: uint64Ptr(1024), // 1KB per file to force multiple files - blockSize: 512, // 512 bytes per block + maxDataFileSize: utils.PointerTo[uint64](1024), // 1KB per file to force multiple files + blockSize: 512, // 512 bytes per block setupCorruption: func(store *Database, _ [][]byte) error { // Delete the second data file (index 1) dataFilePath := store.dataFilePath(1) @@ -430,8 +431,8 @@ func TestRecovery_CorruptionDetection(t *testing.T) { { name: "unexpected multiple data files when MaxDataFileSize is max uint64", blockHeights: []uint64{0, 1, 2}, - maxDataFileSize: uint64Ptr(math.MaxUint64), // Single file mode - blockSize: 512, // 512 bytes per block + maxDataFileSize: utils.PointerTo(uint64(math.MaxUint64)), // Single file mode + blockSize: 512, // 512 bytes per block setupCorruption: func(store *Database, _ [][]byte) error { // Manually create a second data file to simulate corruption secondDataFilePath := store.dataFilePath(1) From 3ea19c327757e4454069261986acc2153c77e3db Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Thu, 18 Dec 2025 17:38:28 -0500 Subject: [PATCH 12/16] refactor: retype delay excess --- .../plugin/evm/atomic/vm/export_tx_test.go | 4 +- .../plugin/evm/atomic/vm/import_tx_test.go | 7 +- .../plugin/evm/customheader/time_test.go | 34 +++--- .../params/extras/network_upgrades_test.go | 110 +++++++++--------- .../plugin/evm/customheader/base_fee_test.go | 4 +- .../plugin/evm/customheader/time_test.go | 34 +++--- graft/subnet-evm/plugin/evm/vm_test.go | 36 +++--- .../plugin/evm/vm_upgrade_bytes_test.go | 7 +- vms/evm/acp226/acp226.go | 6 +- 9 files changed, 122 insertions(+), 120 deletions(-) diff --git a/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go b/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go index e61eaca41588..8023f68fe4e2 100644 --- a/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go +++ b/graft/coreth/plugin/evm/atomic/vm/export_tx_test.go @@ -27,7 +27,7 @@ import ( avalancheatomic "github.com/ava-labs/avalanchego/chains/atomic" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" - "github.com/ava-labs/avalanchego/utils" + avalancheutils "github.com/ava-labs/avalanchego/utils" ) // createExportTxOptions adds funds to shared memory, imports them, and returns a list of export transactions @@ -466,7 +466,7 @@ func TestExportTxSemanticVerify(t *testing.T) { }, }, } - utils.Sort(validExportTx.Ins) + avalancheutils.Sort(validExportTx.Ins) validAVAXExportTx := &atomic.UnsignedExportTx{ NetworkID: vm.Ctx.NetworkID, diff --git a/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go b/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go index 3738531830b2..08d2c77f9186 100644 --- a/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go +++ b/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go @@ -21,6 +21,7 @@ import ( "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/upgrade/upgradetest" "github.com/ava-labs/avalanchego/utils/constants" + "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/vms/components/avax" @@ -28,7 +29,7 @@ import ( avalancheatomic "github.com/ava-labs/avalanchego/chains/atomic" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" - "github.com/ava-labs/avalanchego/utils" + avalancheutils "github.com/ava-labs/avalanchego/utils" ) // createImportTxOptions adds a UTXO to shared memory and generates a list of import transactions sending this UTXO @@ -99,8 +100,8 @@ func TestImportTxVerify(t *testing.T) { } // Sort the inputs and outputs to ensure the transaction is canonical - utils.Sort(importTx.ImportedInputs) - utils.Sort(importTx.Outs) + avalancheutils.Sort(importTx.ImportedInputs) + avalancheutils.Sort(importTx.Outs) tests := map[string]atomicTxVerifyTest{ "nil tx": { diff --git a/graft/coreth/plugin/evm/customheader/time_test.go b/graft/coreth/plugin/evm/customheader/time_test.go index f1febcdcdc05..15bf7e5421a9 100644 --- a/graft/coreth/plugin/evm/customheader/time_test.go +++ b/graft/coreth/plugin/evm/customheader/time_test.go @@ -140,7 +140,7 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), parentHeader: generateHeader(timeSeconds-1, nil), // Pre-Granite parent extraConfig: extras.TestGraniteChainConfig, @@ -150,12 +150,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, utils.PointerTo(timeMillis-2000), // 2000 ms is the exact initial delay - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, }, @@ -164,12 +164,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, utils.PointerTo(timeMillis-1999), // 1 ms less than required - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrMinDelayNotMet, @@ -179,12 +179,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds+5, // 5 seconds in future utils.PointerTo(timeMillis+5000), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, utils.PointerTo(timeMillis-2000), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, }, @@ -193,12 +193,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds+15, // 15 seconds in future, exceeds MaxFutureBlockTime utils.PointerTo(timeMillis+15000), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, utils.PointerTo(timeMillis-2000), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrBlockTooFarInFuture, @@ -208,12 +208,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), - utils.PointerTo[uint64](0), + utils.PointerTo(acp226.DelayExcess(0)), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.PointerTo(timeMillis-1), // 1ms delay, meets zero requirement - utils.PointerTo[uint64](0), // Parent has zero delay excess + utils.PointerTo(timeMillis-1), // 1ms delay, meets zero requirement + utils.PointerTo(acp226.DelayExcess(0)), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, }, @@ -222,12 +222,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), - utils.PointerTo[uint64](0), + utils.PointerTo(acp226.DelayExcess(0)), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.PointerTo(timeMillis), // Same timestamp, zero delay - utils.PointerTo[uint64](0), // Parent has zero delay excess + utils.PointerTo(timeMillis), // Same timestamp, zero delay + utils.PointerTo(acp226.DelayExcess(0)), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrMinDelayNotMet, @@ -338,14 +338,14 @@ func generateHeader(timeSeconds uint64, timeMilliseconds *uint64) *types.Header ) } -func generateHeaderWithMinDelayExcessAndTime(timeSeconds uint64, timeMilliseconds *uint64, minDelayExcess *uint64) *types.Header { +func generateHeaderWithMinDelayExcessAndTime(timeSeconds uint64, timeMilliseconds *uint64, minDelayExcess *acp226.DelayExcess) *types.Header { return customtypes.WithHeaderExtra( &types.Header{ Time: timeSeconds, }, &customtypes.HeaderExtra{ TimeMilliseconds: timeMilliseconds, - MinDelayExcess: (*acp226.DelayExcess)(minDelayExcess), + MinDelayExcess: minDelayExcess, }, ) } diff --git a/graft/subnet-evm/params/extras/network_upgrades_test.go b/graft/subnet-evm/params/extras/network_upgrades_test.go index 1ec9b45141bd..463c35944636 100644 --- a/graft/subnet-evm/params/extras/network_upgrades_test.go +++ b/graft/subnet-evm/params/extras/network_upgrades_test.go @@ -13,7 +13,7 @@ import ( "github.com/ava-labs/avalanchego/upgrade/upgradetest" "github.com/ava-labs/avalanchego/utils/constants" - "github.com/ava-labs/avalanchego/utils" + avalancheutils "github.com/ava-labs/avalanchego/utils" ) func TestNetworkUpgradesEqual(t *testing.T) { @@ -26,32 +26,32 @@ func TestNetworkUpgradesEqual(t *testing.T) { { name: "EqualNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, expected: true, }, { name: "NotEqualNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](3), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](3), }, expected: false, }, { name: "NilNetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: nil, expected: false, @@ -59,11 +59,11 @@ func TestNetworkUpgradesEqual(t *testing.T) { { name: "NilNetworkUpgrade", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), DurangoTimestamp: nil, }, expected: false, @@ -87,12 +87,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_same_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, time: 1, valid: true, @@ -100,12 +100,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_different_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](3), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](3), }, time: 1, valid: true, @@ -113,11 +113,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Compatible_nil_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), DurangoTimestamp: nil, }, time: 1, @@ -126,12 +126,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_rewinded_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](1), }, time: 1, valid: false, @@ -139,12 +139,12 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_fastforward_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](3), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](3), }, time: 4, valid: false, @@ -152,11 +152,11 @@ func TestCheckNetworkUpgradesCompatible(t *testing.T) { { name: "Incompatible_nil_NetworkUpgrades", upgrades1: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, upgrades2: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), DurangoTimestamp: nil, }, time: 2, @@ -213,7 +213,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Durango_nil_upgrade", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), DurangoTimestamp: nil, }, avagoUpgrades: upgrade.Mainnet, @@ -222,8 +222,8 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Subnet-EVM_non-zero", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, avagoUpgrades: upgrade.Mainnet, wantError: errTimestampTooEarly, @@ -231,8 +231,8 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Durango_before_default_upgrade", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), - DurangoTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), + DurangoTimestamp: avalancheutils.PointerTo[uint64](1), }, avagoUpgrades: upgrade.Mainnet, wantError: errTimestampTooEarly, @@ -240,7 +240,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Mainnet_Durango_reconfigured_to_Fuji", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.GetConfig(constants.FujiID).DurangoTime), }, avagoUpgrades: upgrade.Mainnet, @@ -249,7 +249,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Valid_Fuji_Durango_reconfigured_to_Mainnet", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.GetConfig(constants.MainnetID).DurangoTime), }, avagoUpgrades: upgrade.Fuji, @@ -258,7 +258,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Etna_nil", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime), EtnaTimestamp: nil, }, @@ -268,7 +268,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Invalid_Etna_before_Durango", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime), EtnaTimestamp: utils.TimeToNewUint64(upgrade.Mainnet.DurangoTime.Add(-1)), }, @@ -278,7 +278,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) { { name: "Valid_Granite_After_nil_Fortuna", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), DurangoTimestamp: utils.TimeToNewUint64(upgrade.Fuji.DurangoTime), EtnaTimestamp: utils.TimeToNewUint64(upgrade.Fuji.EtnaTime), FortunaTimestamp: nil, @@ -305,16 +305,16 @@ func TestForkOrder(t *testing.T) { { name: "ValidNetworkUpgrades", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), - DurangoTimestamp: utils.PointerTo[uint64](2), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), + DurangoTimestamp: avalancheutils.PointerTo[uint64](2), }, wantError: nil, }, { name: "Invalid order", upgrades: &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), - DurangoTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), + DurangoTimestamp: avalancheutils.PointerTo[uint64](0), }, wantError: errUnsupportedForkOrdering, }, @@ -329,12 +329,12 @@ func TestForkOrder(t *testing.T) { func TestSetDefaultsTreatsZeroAsUnset(t *testing.T) { upgrades := &NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](0), - DurangoTimestamp: utils.PointerTo[uint64](0), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](0), + DurangoTimestamp: avalancheutils.PointerTo[uint64](0), EtnaTimestamp: nil, - FortunaTimestamp: utils.PointerTo[uint64](0), - GraniteTimestamp: utils.PointerTo[uint64](0), - HeliconTimestamp: utils.PointerTo[uint64](0), + FortunaTimestamp: avalancheutils.PointerTo[uint64](0), + GraniteTimestamp: avalancheutils.PointerTo[uint64](0), + HeliconTimestamp: avalancheutils.PointerTo[uint64](0), } agoUpgrades := upgradetest.GetConfig(upgradetest.Latest) upgrades.SetDefaults(agoUpgrades) diff --git a/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go b/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go index 9a6abff31d41..f0b3f0c03d9a 100644 --- a/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/base_fee_test.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/upgrade/subnetevm" - "github.com/ava-labs/avalanchego/utils" + avalancheutils "github.com/ava-labs/avalanchego/utils" ) const ( @@ -50,7 +50,7 @@ func BaseFeeTest(t *testing.T, feeConfig commontype.FeeConfig) { { name: "subnet_evm_first_block", upgrades: extras.NetworkUpgrades{ - SubnetEVMTimestamp: utils.PointerTo[uint64](1), + SubnetEVMTimestamp: avalancheutils.PointerTo[uint64](1), }, parent: &types.Header{ Number: big.NewInt(1), diff --git a/graft/subnet-evm/plugin/evm/customheader/time_test.go b/graft/subnet-evm/plugin/evm/customheader/time_test.go index f3bd77b121b3..ac75431dfdba 100644 --- a/graft/subnet-evm/plugin/evm/customheader/time_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/time_test.go @@ -140,7 +140,7 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), parentHeader: generateHeader(timeSeconds-1, nil), // Pre-Granite parent extraConfig: extras.TestGraniteChainConfig, @@ -150,12 +150,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, utils.PointerTo(timeMillis-2000), // 2000 ms is the exact initial delay - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, }, @@ -164,12 +164,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, utils.PointerTo(timeMillis-1999), // 1 ms less than required - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrMinDelayNotMet, @@ -179,12 +179,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds+5, // 5 seconds in future utils.PointerTo(timeMillis+5000), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, utils.PointerTo(timeMillis-2000), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, }, @@ -193,12 +193,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds+15, // 15 seconds in future, exceeds MaxFutureBlockTime utils.PointerTo(timeMillis+15000), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds-1, utils.PointerTo(timeMillis-2000), - utils.PointerTo[uint64](acp226.InitialDelayExcess), + utils.PointerTo(acp226.InitialDelayExcess), ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrBlockTooFarInFuture, @@ -208,12 +208,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), - utils.PointerTo[uint64](0), + utils.PointerTo(acp226.DelayExcess(0)), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.PointerTo(timeMillis-1), // 1ms delay, meets zero requirement - utils.PointerTo[uint64](0), // Parent has zero delay excess + utils.PointerTo(timeMillis-1), // 1ms delay, meets zero requirement + utils.PointerTo(acp226.DelayExcess(0)), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, }, @@ -222,12 +222,12 @@ func TestVerifyTime(t *testing.T) { header: generateHeaderWithMinDelayExcessAndTime( timeSeconds, utils.PointerTo(timeMillis), - utils.PointerTo[uint64](0), + utils.PointerTo(acp226.DelayExcess(0)), ), parentHeader: generateHeaderWithMinDelayExcessAndTime( timeSeconds, - utils.PointerTo(timeMillis), // Same timestamp, zero delay - utils.PointerTo[uint64](0), // Parent has zero delay excess + utils.PointerTo(timeMillis), // Same timestamp, zero delay + utils.PointerTo(acp226.DelayExcess(0)), // Parent has zero delay excess ), extraConfig: extras.TestGraniteChainConfig, expectedErr: ErrMinDelayNotMet, @@ -338,14 +338,14 @@ func generateHeader(timeSeconds uint64, timeMilliseconds *uint64) *types.Header ) } -func generateHeaderWithMinDelayExcessAndTime(timeSeconds uint64, timeMilliseconds *uint64, minDelayExcess *uint64) *types.Header { +func generateHeaderWithMinDelayExcessAndTime(timeSeconds uint64, timeMilliseconds *uint64, minDelayExcess *acp226.DelayExcess) *types.Header { return customtypes.WithHeaderExtra( &types.Header{ Time: timeSeconds, }, &customtypes.HeaderExtra{ TimeMilliseconds: timeMilliseconds, - MinDelayExcess: (*acp226.DelayExcess)(minDelayExcess), + MinDelayExcess: minDelayExcess, }, ) } diff --git a/graft/subnet-evm/plugin/evm/vm_test.go b/graft/subnet-evm/plugin/evm/vm_test.go index 8003c0a4334f..fe0551ca4c1d 100644 --- a/graft/subnet-evm/plugin/evm/vm_test.go +++ b/graft/subnet-evm/plugin/evm/vm_test.go @@ -69,7 +69,7 @@ import ( warpcontract "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/warp" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" - "github.com/ava-labs/avalanchego/utils" + avalancheutils "github.com/ava-labs/avalanchego/utils" avagoconstants "github.com/ava-labs/avalanchego/utils/constants" avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp" ) @@ -1480,13 +1480,13 @@ func TestTimeSemanticVerify(t *testing.T) { name: "Granite with TimeMilliseconds", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli())), + timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.UnixMilli())), }, { name: "Fortuna with TimeMilliseconds", fork: upgradetest.Fortuna, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli())), + timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.UnixMilli())), expectedError: customheader.ErrTimeMillisecondsBeforeGranite, }, { @@ -1500,14 +1500,14 @@ func TestTimeSemanticVerify(t *testing.T) { name: "Granite with mismatched TimeMilliseconds", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Unix()), - timeMilliseconds: utils.PointerTo(uint64(timestamp.UnixMilli()) + 1000), + timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.UnixMilli()) + 1000), expectedError: customheader.ErrTimeMillisecondsMismatched, }, { name: "Block too far in the future", fork: upgradetest.Granite, timeSeconds: uint64(timestamp.Add(2 * time.Hour).Unix()), - timeMilliseconds: utils.PointerTo(uint64(timestamp.Add(2 * time.Hour).UnixMilli())), + timeMilliseconds: avalancheutils.PointerTo(uint64(timestamp.Add(2 * time.Hour).UnixMilli())), expectedError: customheader.ErrBlockTooFarInFuture, }, } @@ -1583,7 +1583,7 @@ func TestBuildTimeMilliseconds(t *testing.T) { { name: "granite_should_have_timestamp_milliseconds", fork: upgradetest.Granite, - expectedTimeMilliseconds: utils.PointerTo(uint64(buildTime.UnixMilli())), + expectedTimeMilliseconds: avalancheutils.PointerTo(uint64(buildTime.UnixMilli())), }, } @@ -1743,7 +1743,7 @@ func TestTxAllowListSuccessfulTx(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(toGenesisJSON(paramstest.ForkToChainConfig[upgradetest.Durango])))) // this manager role should not be activated because DurangoTimestamp is in the future params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil), + txallowlist.ConfigKey: txallowlist.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil), } durangoTime := time.Now().Add(10 * time.Hour) params.GetExtra(genesis.Config).DurangoTimestamp = utils.TimeToNewUint64(durangoTime) @@ -1886,7 +1886,7 @@ func TestVerifyManagerConfig(t *testing.T) { params.GetExtra(genesis.Config).DurangoTimestamp = utils.TimeToNewUint64(durangoTimestamp) // this manager role should not be activated because DurangoTimestamp is in the future params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - txallowlist.ConfigKey: txallowlist.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, []common.Address{testEthAddrs[1]}), + txallowlist.ConfigKey: txallowlist.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, []common.Address{testEthAddrs[1]}), } genesisJSON, err := genesis.MarshalJSON() @@ -2038,7 +2038,7 @@ func TestFeeManagerChangeFee(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) configExtra := params.GetExtra(genesis.Config) configExtra.GenesisPrecompiles = extras.Precompiles{ - feemanager.ConfigKey: feemanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), + feemanager.ConfigKey: feemanager.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } // set a lower fee config now @@ -2254,7 +2254,7 @@ func TestRewardManagerPrecompileSetRewardAddress(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - rewardmanager.ConfigKey: rewardmanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), + rewardmanager.ConfigKey: rewardmanager.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } params.GetExtra(genesis.Config).AllowFeeRecipients = true // enable this in genesis to test if this is recognized by the reward manager genesisJSON, err := genesis.MarshalJSON() @@ -2398,7 +2398,7 @@ func TestRewardManagerPrecompileAllowFeeRecipients(t *testing.T) { require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) params.GetExtra(genesis.Config).GenesisPrecompiles = extras.Precompiles{ - rewardmanager.ConfigKey: rewardmanager.NewConfig(utils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), + rewardmanager.ConfigKey: rewardmanager.NewConfig(avalancheutils.PointerTo[uint64](0), testEthAddrs[0:1], nil, nil, nil), } params.GetExtra(genesis.Config).AllowFeeRecipients = false // disable this in genesis genesisJSON, err := genesis.MarshalJSON() @@ -2734,7 +2734,7 @@ func TestFeeManagerRegressionMempoolMinFeeAfterRestart(t *testing.T) { // Setup chain params genesis := &core.Genesis{} require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONSubnetEVM))) - precompileActivationTime := utils.PointerTo(genesis.Timestamp + 5) // 5 seconds after genesis + precompileActivationTime := avalancheutils.PointerTo(genesis.Timestamp + 5) // 5 seconds after genesis configExtra := params.GetExtra(genesis.Config) configExtra.GenesisPrecompiles = extras.Precompiles{ feemanager.ConfigKey: feemanager.NewConfig(precompileActivationTime, testEthAddrs[0:1], nil, nil, nil), @@ -3583,26 +3583,26 @@ func TestMinDelayExcessInHeader(t *testing.T) { { name: "pre_granite_min_delay_excess", fork: upgradetest.Fortuna, - desiredMinDelay: utils.PointerTo[uint64](1000), + desiredMinDelay: avalancheutils.PointerTo[uint64](1000), expectedMinDelayExcess: nil, }, { name: "granite_first_block_initial_delay_excess", fork: upgradetest.Granite, desiredMinDelay: nil, - expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), + expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), }, { name: "granite_with_excessive_desired_min_delay_excess", fork: upgradetest.Granite, - desiredMinDelay: utils.PointerTo[uint64](4000), - expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), + desiredMinDelay: avalancheutils.PointerTo[uint64](4000), + expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), }, { name: "granite_with_zero_desired_min_delay_excess", fork: upgradetest.Granite, - desiredMinDelay: utils.PointerTo[uint64](0), - expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), + desiredMinDelay: avalancheutils.PointerTo[uint64](0), + expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), }, } diff --git a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go index 09304087e0ec..0f4dd2a9959e 100644 --- a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go +++ b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go @@ -29,10 +29,11 @@ import ( "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/upgrade/upgradetest" + "github.com/ava-labs/avalanchego/vms/components/chain" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" - "github.com/ava-labs/avalanchego/utils" + avalancheutils "github.com/ava-labs/avalanchego/utils" ) func TestVMUpgradeBytesPrecompile(t *testing.T) { @@ -143,7 +144,7 @@ func TestNetworkUpgradesOverridden(t *testing.T) { fork := upgradetest.Granite chainConfig := paramstest.ForkToChainConfig[fork] extraConfig := params.GetExtra(chainConfig) - extraConfig.NetworkUpgrades.GraniteTimestamp = utils.PointerTo(uint64(upgrade.InitiallyActiveTime.Unix())) + extraConfig.NetworkUpgrades.GraniteTimestamp = avalancheutils.PointerTo(uint64(upgrade.InitiallyActiveTime.Unix())) genesis := &core.Genesis{} require.NoError(t, json.Unmarshal([]byte(toGenesisJSON(chainConfig)), genesis)) // Set the genesis timestamp to before the Granite activation time @@ -352,7 +353,7 @@ func TestVMEtnaActivatesCancun(t *testing.T) { upgradeJSON: func() string { upgrade := &extras.UpgradeConfig{ NetworkUpgradeOverrides: &extras.NetworkUpgrades{ - EtnaTimestamp: utils.PointerTo(defaultEtnaTime + 2), + EtnaTimestamp: avalancheutils.PointerTo(defaultEtnaTime + 2), }, } b, err := json.Marshal(upgrade) diff --git a/vms/evm/acp226/acp226.go b/vms/evm/acp226/acp226.go index bb36dfc99667..6266daca6f49 100644 --- a/vms/evm/acp226/acp226.go +++ b/vms/evm/acp226/acp226.go @@ -23,9 +23,9 @@ const ( // InitialDelayExcess represents the initial (≈2000ms) delay excess. // Formula: ConversionRate (2^20) * ln(2000) + 1 - InitialDelayExcess = 7_970_124 + InitialDelayExcess DelayExcess = 7_970_124 - maxDelayExcess = 46_516_320 // ConversionRate * ln(MaxUint64 / MinDelayMilliseconds) + 1 + maxDelayExcess DelayExcess = 46_516_320 // ConversionRate * ln(MaxUint64 / MinDelayMilliseconds) + 1 ) // DelayExcess represents the excess for delay calculation in the dynamic @@ -55,7 +55,7 @@ func DesiredDelayExcess(desiredDelay uint64) DelayExcess { // This could be solved directly by calculating D * ln(desired / M) // using floating point math. However, it introduces inaccuracies. So, we // use a binary search to find the closest integer solution. - return DelayExcess(sort.Search(maxDelayExcess, func(delayExcessGuess int) bool { + return DelayExcess(sort.Search(int(maxDelayExcess), func(delayExcessGuess int) bool { excess := DelayExcess(delayExcessGuess) return excess.Delay() >= desiredDelay })) From 8d3342ae73dbe2802414844b6ab990920438551e Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Thu, 18 Dec 2025 17:51:25 -0500 Subject: [PATCH 13/16] chore: lint --- graft/coreth/core/genesis_test.go | 2 +- graft/coreth/plugin/evm/atomic/vm/import_tx_test.go | 1 - graft/coreth/plugin/evm/customheader/min_delay_excess.go | 2 +- .../coreth/plugin/evm/customheader/min_delay_excess_test.go | 2 +- graft/coreth/plugin/evm/vm_test.go | 6 +++--- graft/subnet-evm/core/genesis_test.go | 1 - .../subnet-evm/plugin/evm/customheader/min_delay_excess.go | 2 +- .../plugin/evm/customheader/min_delay_excess_test.go | 2 +- graft/subnet-evm/plugin/evm/vm_test.go | 6 +++--- graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go | 1 - 10 files changed, 11 insertions(+), 14 deletions(-) diff --git a/graft/coreth/core/genesis_test.go b/graft/coreth/core/genesis_test.go index 0599ad72b0cc..546c1ec44179 100644 --- a/graft/coreth/core/genesis_test.go +++ b/graft/coreth/core/genesis_test.go @@ -42,7 +42,7 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/precompile/contracts/warp" "github.com/ava-labs/avalanchego/graft/coreth/triedb/pathdb" "github.com/ava-labs/avalanchego/graft/evm/firewood" - "github.com/ava-labs/avalanchego/graft/evm/utils" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/rawdb" diff --git a/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go b/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go index 08d2c77f9186..719e9d6fda97 100644 --- a/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go +++ b/graft/coreth/plugin/evm/atomic/vm/import_tx_test.go @@ -21,7 +21,6 @@ import ( "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/upgrade/upgradetest" "github.com/ava-labs/avalanchego/utils/constants" - "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/vms/components/avax" diff --git a/graft/coreth/plugin/evm/customheader/min_delay_excess.go b/graft/coreth/plugin/evm/customheader/min_delay_excess.go index 5e02aef9636e..cca21c3f4712 100644 --- a/graft/coreth/plugin/evm/customheader/min_delay_excess.go +++ b/graft/coreth/plugin/evm/customheader/min_delay_excess.go @@ -95,7 +95,7 @@ func minDelayExcess( parent *types.Header, desiredMinDelayExcess *acp226.DelayExcess, ) (acp226.DelayExcess, error) { - minDelayExcess := acp226.DelayExcess(acp226.InitialDelayExcess) + minDelayExcess := acp226.InitialDelayExcess if config.IsGranite(parent.Time) { // If the parent block was running with ACP-226, we start with the // resulting min delay excess from the parent block. diff --git a/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go b/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go index 72e40eda44de..4fcd575bac67 100644 --- a/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go +++ b/graft/coreth/plugin/evm/customheader/min_delay_excess_test.go @@ -64,7 +64,7 @@ func TestMinDelayExcess(t *testing.T) { Time: activatingGraniteTimestamp + 1, }, desiredMinDelayExcess: nil, - expectedDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), + expectedDelayExcess: utils.PointerTo(acp226.InitialDelayExcess), }, { name: "granite_no_parent_min_delay_error", diff --git a/graft/coreth/plugin/evm/vm_test.go b/graft/coreth/plugin/evm/vm_test.go index d6ec9003527d..9967fcdfa5f5 100644 --- a/graft/coreth/plugin/evm/vm_test.go +++ b/graft/coreth/plugin/evm/vm_test.go @@ -2150,19 +2150,19 @@ func TestMinDelayExcessInHeader(t *testing.T) { name: "granite_first_block_initial_delay_excess", fork: upgradetest.Granite, desiredMinDelay: nil, - expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), + expectedMinDelayExcess: utils.PointerTo(acp226.InitialDelayExcess), }, { name: "granite_with_excessive_desired_min_delay_excess", fork: upgradetest.Granite, desiredMinDelay: utils.PointerTo[uint64](4000), - expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), + expectedMinDelayExcess: utils.PointerTo(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff), }, { name: "granite_with_zero_desired_min_delay_excess", fork: upgradetest.Granite, desiredMinDelay: utils.PointerTo[uint64](0), - expectedMinDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), + expectedMinDelayExcess: utils.PointerTo(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff), }, } diff --git a/graft/subnet-evm/core/genesis_test.go b/graft/subnet-evm/core/genesis_test.go index 12779cd80178..005fa7d1f717 100644 --- a/graft/subnet-evm/core/genesis_test.go +++ b/graft/subnet-evm/core/genesis_test.go @@ -36,7 +36,6 @@ import ( "testing" "github.com/ava-labs/avalanchego/graft/evm/firewood" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" diff --git a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess.go b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess.go index 7fb84fe67d4f..1dd88e1874c2 100644 --- a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess.go +++ b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess.go @@ -95,7 +95,7 @@ func minDelayExcess( parent *types.Header, desiredMinDelayExcess *acp226.DelayExcess, ) (acp226.DelayExcess, error) { - minDelayExcess := acp226.DelayExcess(acp226.InitialDelayExcess) + minDelayExcess := acp226.InitialDelayExcess if config.IsGranite(parent.Time) { // If the parent block was running with ACP-226, we start with the // resulting min delay excess from the parent block. diff --git a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go index eff8f68598f3..d173488ab1ef 100644 --- a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go @@ -64,7 +64,7 @@ func TestMinDelayExcess(t *testing.T) { Time: activatingGraniteTimestamp + 1, }, desiredMinDelayExcess: nil, - expectedDelayExcess: utils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), + expectedDelayExcess: utils.PointerTo(acp226.InitialDelayExcess), }, { name: "granite_no_parent_min_delay_error", diff --git a/graft/subnet-evm/plugin/evm/vm_test.go b/graft/subnet-evm/plugin/evm/vm_test.go index fe0551ca4c1d..0369339216f9 100644 --- a/graft/subnet-evm/plugin/evm/vm_test.go +++ b/graft/subnet-evm/plugin/evm/vm_test.go @@ -3590,19 +3590,19 @@ func TestMinDelayExcessInHeader(t *testing.T) { name: "granite_first_block_initial_delay_excess", fork: upgradetest.Granite, desiredMinDelay: nil, - expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess)), + expectedMinDelayExcess: avalancheutils.PointerTo(acp226.InitialDelayExcess), }, { name: "granite_with_excessive_desired_min_delay_excess", fork: upgradetest.Granite, desiredMinDelay: avalancheutils.PointerTo[uint64](4000), - expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff)), + expectedMinDelayExcess: avalancheutils.PointerTo(acp226.InitialDelayExcess + acp226.MaxDelayExcessDiff), }, { name: "granite_with_zero_desired_min_delay_excess", fork: upgradetest.Granite, desiredMinDelay: avalancheutils.PointerTo[uint64](0), - expectedMinDelayExcess: avalancheutils.PointerTo(acp226.DelayExcess(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff)), + expectedMinDelayExcess: avalancheutils.PointerTo(acp226.InitialDelayExcess - acp226.MaxDelayExcessDiff), }, } diff --git a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go index 0f4dd2a9959e..c5da6574c9dd 100644 --- a/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go +++ b/graft/subnet-evm/plugin/evm/vm_upgrade_bytes_test.go @@ -29,7 +29,6 @@ import ( "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/upgrade/upgradetest" - "github.com/ava-labs/avalanchego/vms/components/chain" commonEng "github.com/ava-labs/avalanchego/snow/engine/common" From 9e161cefbb325ca6ebe89d01fdc97f7eb5c9cde5 Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Thu, 18 Dec 2025 18:19:32 -0500 Subject: [PATCH 14/16] fix: fix precompilebind test --- graft/evm/utils/numbers.go | 4 ++-- .../precompilebind/precompile_bind_test.go | 5 +++++ .../precompile_config_test_template.go | 20 +++++++++---------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/graft/evm/utils/numbers.go b/graft/evm/utils/numbers.go index 5926080a0ead..09e68faf2ff3 100644 --- a/graft/evm/utils/numbers.go +++ b/graft/evm/utils/numbers.go @@ -7,11 +7,11 @@ import ( "math/big" "time" - "github.com/ava-labs/avalanchego/utils" + avalancheutils "github.com/ava-labs/avalanchego/utils" ) func TimeToNewUint64(time time.Time) *uint64 { - return utils.PointerTo(uint64(time.Unix())) + return avalancheutils.PointerTo(uint64(time.Unix())) } func Uint64ToTime(val *uint64) time.Time { diff --git a/graft/subnet-evm/accounts/abi/bind/precompilebind/precompile_bind_test.go b/graft/subnet-evm/accounts/abi/bind/precompilebind/precompile_bind_test.go index ffa511e96995..06dcfe69c97a 100644 --- a/graft/subnet-evm/accounts/abi/bind/precompilebind/precompile_bind_test.go +++ b/graft/subnet-evm/accounts/abi/bind/precompilebind/precompile_bind_test.go @@ -694,6 +694,11 @@ func TestPrecompileBind(t *testing.T) { out, err = replacer.CombinedOutput() require.NoError(t, err, "failed to replace binding test dependency to current source tree: %v\n%s", err, out) + replacer = exec.Command(gocmd, "mod", "edit", "-x", "-require", "github.com/ava-labs/avalanchego@v0.0.0", "-replace", "github.com/ava-labs/avalanchego="+filepath.Join(pwd, "..", "..", "..", "..", "..", "..")) + replacer.Dir = pkg + out, err = replacer.CombinedOutput() + require.NoError(t, err, "failed to replace binding test dependency to current source tree: %v\n%s", err, out) + tidier := exec.Command(gocmd, "mod", "tidy", "-compat=1.24") tidier.Dir = pkg out, err = tidier.CombinedOutput() diff --git a/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go b/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go index 7a6c40da30a7..e2167eb460b1 100644 --- a/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go +++ b/graft/subnet-evm/accounts/abi/bind/precompilebind/templatetest/precompile_config_test_template.go @@ -16,8 +16,8 @@ import ( "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" - avaulancheutils "github.com/ava-labs/avalanchego/utils" - "github.com/ava-labs/avalanchego/graft/evm/utils" + + avalancheutils "github.com/ava-labs/avalanchego/utils" {{- if .Contract.AllowList}} "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" @@ -35,7 +35,7 @@ func TestVerify(t *testing.T) { {{- end}} tests := map[string]precompiletest.ConfigVerifyTest{ "valid config": { - Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() @@ -46,7 +46,7 @@ func TestVerify(t *testing.T) { // CUSTOM CODE STARTS HERE // Add your own Verify tests here, e.g.: // "your custom test name": { - // Config: NewConfig(utils.PointerTo[uint64](3), {{- if .Contract.AllowList}} admins, enableds, managers{{- end}}), + // Config: NewConfig(avalancheutils.PointerTo[uint64](3), {{- if .Contract.AllowList}} admins, enableds, managers{{- end}}), // ExpectedError: ErrYourCustomError, // }, } @@ -72,23 +72,23 @@ func TestEqual(t *testing.T) { {{- end}} tests := map[string]precompiletest.ConfigEqualTest{ "non-nil config and nil other": { - Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds,managers{{- end}}), + Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Other: nil, Expected: false, }, "different type": { - Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Other: precompileconfig.NewMockConfig(gomock.NewController(t)), Expected: false, }, "different timestamp": { - Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), - Other: NewConfig(utils.PointerTo[uint64](4){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Other: NewConfig(avalancheutils.PointerTo[uint64](4){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Expected: false, }, "same config": { - Config: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), - Other: NewConfig(utils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Config: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), + Other: NewConfig(avalancheutils.PointerTo[uint64](3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), Expected: true, }, // CUSTOM CODE STARTS HERE From 30996ca04744beedcc624e2ef656bc135da05710 Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Tue, 6 Jan 2026 12:00:50 -0500 Subject: [PATCH 15/16] fix: imports --- go.sum | 4 ++-- graft/coreth/go.sum | 4 ++-- graft/coreth/plugin/evm/vm_test.go | 2 -- graft/evm/go.sum | 1 - graft/subnet-evm/core/blockchain_ext_test.go | 1 - graft/subnet-evm/core/genesis_extra_test.go | 1 - graft/subnet-evm/core/genesis_test.go | 1 - graft/subnet-evm/core/state_processor_ext_test.go | 1 - graft/subnet-evm/core/state_processor_test.go | 1 - graft/subnet-evm/internal/ethapi/api_test.go | 1 - graft/subnet-evm/params/config.go | 1 - graft/subnet-evm/params/config_extra.go | 1 - graft/subnet-evm/params/config_extra_test.go | 1 - graft/subnet-evm/params/config_test.go | 1 - graft/subnet-evm/params/extras/config.go | 1 - graft/subnet-evm/params/extras/precompile_upgrade.go | 1 - graft/subnet-evm/params/extras/precompile_upgrade_test.go | 1 - graft/subnet-evm/plugin/evm/customheader/extra_test.go | 1 - .../plugin/evm/customheader/min_delay_excess_test.go | 1 - graft/subnet-evm/plugin/evm/customheader/time_test.go | 1 - graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go | 1 - .../allowlist/allowlisttest/test_allowlist_config.go | 1 - .../precompile/contracts/deployerallowlist/config_test.go | 1 - .../precompile/contracts/deployerallowlist/simulated_test.go | 1 - .../subnet-evm/precompile/contracts/feemanager/config_test.go | 1 - .../precompile/contracts/feemanager/simulated_test.go | 1 - .../precompile/contracts/nativeminter/config_test.go | 1 - .../precompile/contracts/nativeminter/simulated_test.go | 1 - .../precompile/contracts/rewardmanager/config_test.go | 1 - .../precompile/contracts/rewardmanager/simulated_test.go | 1 - .../precompile/contracts/txallowlist/config_test.go | 1 - .../precompile/contracts/txallowlist/simulated_test.go | 1 - graft/subnet-evm/precompile/contracts/warp/config_test.go | 1 - 33 files changed, 4 insertions(+), 36 deletions(-) diff --git a/go.sum b/go.sum index b21d00702b92..611ee4aa6ad2 100644 --- a/go.sum +++ b/go.sum @@ -43,8 +43,8 @@ connectrpc.com/grpcreflect v1.3.0/go.mod h1:nfloOtCS8VUQOQ1+GTdFzVg2CJo4ZGaat8JI dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= +github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= diff --git a/graft/coreth/go.sum b/graft/coreth/go.sum index 4b7f1f589721..b54aff1c3889 100644 --- a/graft/coreth/go.sum +++ b/graft/coreth/go.sum @@ -5,8 +5,8 @@ connectrpc.com/grpcreflect v1.3.0 h1:Y4V+ACf8/vOb1XOc251Qun7jMB75gCUNw6llvB9csXc connectrpc.com/grpcreflect v1.3.0/go.mod h1:nfloOtCS8VUQOQ1+GTdFzVg2CJo4ZGaat8JIovCtDYs= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= +github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= diff --git a/graft/coreth/plugin/evm/vm_test.go b/graft/coreth/plugin/evm/vm_test.go index 908a55b74600..520299982134 100644 --- a/graft/coreth/plugin/evm/vm_test.go +++ b/graft/coreth/plugin/evm/vm_test.go @@ -43,8 +43,6 @@ import ( "github.com/ava-labs/avalanchego/graft/coreth/plugin/evm/vmtest" "github.com/ava-labs/avalanchego/graft/coreth/rpc" "github.com/ava-labs/avalanchego/graft/evm/constants" - "github.com/ava-labs/avalanchego/graft/evm/utils" - "github.com/ava-labs/avalanchego/graft/evm/utils/utilstest" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/upgrade" diff --git a/graft/evm/go.sum b/graft/evm/go.sum index 505e62c71e03..4f6a669b66b6 100644 --- a/graft/evm/go.sum +++ b/graft/evm/go.sum @@ -1,6 +1,5 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= diff --git a/graft/subnet-evm/core/blockchain_ext_test.go b/graft/subnet-evm/core/blockchain_ext_test.go index ccf3577d0717..ae9a26099cb7 100644 --- a/graft/subnet-evm/core/blockchain_ext_test.go +++ b/graft/subnet-evm/core/blockchain_ext_test.go @@ -20,7 +20,6 @@ import ( "github.com/holiman/uint256" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" diff --git a/graft/subnet-evm/core/genesis_extra_test.go b/graft/subnet-evm/core/genesis_extra_test.go index 0ed37bb83773..8103c3861e8b 100644 --- a/graft/subnet-evm/core/genesis_extra_test.go +++ b/graft/subnet-evm/core/genesis_extra_test.go @@ -14,7 +14,6 @@ import ( "github.com/ava-labs/libevm/triedb" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" diff --git a/graft/subnet-evm/core/genesis_test.go b/graft/subnet-evm/core/genesis_test.go index c67766e18fed..dc43033f0a4f 100644 --- a/graft/subnet-evm/core/genesis_test.go +++ b/graft/subnet-evm/core/genesis_test.go @@ -36,7 +36,6 @@ import ( "testing" "github.com/ava-labs/avalanchego/graft/evm/firewood" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" diff --git a/graft/subnet-evm/core/state_processor_ext_test.go b/graft/subnet-evm/core/state_processor_ext_test.go index 3ea58065414f..7dec489c01ed 100644 --- a/graft/subnet-evm/core/state_processor_ext_test.go +++ b/graft/subnet-evm/core/state_processor_ext_test.go @@ -14,7 +14,6 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" diff --git a/graft/subnet-evm/core/state_processor_test.go b/graft/subnet-evm/core/state_processor_test.go index 1ea89820407f..60713d39e797 100644 --- a/graft/subnet-evm/core/state_processor_test.go +++ b/graft/subnet-evm/core/state_processor_test.go @@ -32,7 +32,6 @@ import ( "math/big" "testing" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" diff --git a/graft/subnet-evm/internal/ethapi/api_test.go b/graft/subnet-evm/internal/ethapi/api_test.go index 29a24555974a..f27c082034f4 100644 --- a/graft/subnet-evm/internal/ethapi/api_test.go +++ b/graft/subnet-evm/internal/ethapi/api_test.go @@ -42,7 +42,6 @@ import ( "testing" "time" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus" "github.com/ava-labs/avalanchego/graft/subnet-evm/consensus/dummy" diff --git a/graft/subnet-evm/params/config.go b/graft/subnet-evm/params/config.go index f1b56b3110df..56a3f9096a79 100644 --- a/graft/subnet-evm/params/config.go +++ b/graft/subnet-evm/params/config.go @@ -30,7 +30,6 @@ package params import ( "math/big" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/libevm/libevm" diff --git a/graft/subnet-evm/params/config_extra.go b/graft/subnet-evm/params/config_extra.go index 2f121723a7d8..705ed6aefc64 100644 --- a/graft/subnet-evm/params/config_extra.go +++ b/graft/subnet-evm/params/config_extra.go @@ -8,7 +8,6 @@ import ( "errors" "math/big" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils" diff --git a/graft/subnet-evm/params/config_extra_test.go b/graft/subnet-evm/params/config_extra_test.go index 2409faf89b7e..c2ce48c6bb34 100644 --- a/graft/subnet-evm/params/config_extra_test.go +++ b/graft/subnet-evm/params/config_extra_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/upgrade/upgradetest" "github.com/ava-labs/avalanchego/utils" diff --git a/graft/subnet-evm/params/config_test.go b/graft/subnet-evm/params/config_test.go index 29d6c30b6dd5..60e0b4638c16 100644 --- a/graft/subnet-evm/params/config_test.go +++ b/graft/subnet-evm/params/config_test.go @@ -35,7 +35,6 @@ import ( "testing" "time" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager" diff --git a/graft/subnet-evm/params/extras/config.go b/graft/subnet-evm/params/extras/config.go index ae01727fd4a2..b7ff955ee792 100644 --- a/graft/subnet-evm/params/extras/config.go +++ b/graft/subnet-evm/params/extras/config.go @@ -10,7 +10,6 @@ import ( "github.com/ava-labs/libevm/common" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/upgrade" diff --git a/graft/subnet-evm/params/extras/precompile_upgrade.go b/graft/subnet-evm/params/extras/precompile_upgrade.go index 83238bf0d112..0a90a86bf1a1 100644 --- a/graft/subnet-evm/params/extras/precompile_upgrade.go +++ b/graft/subnet-evm/params/extras/precompile_upgrade.go @@ -10,7 +10,6 @@ import ( "github.com/ava-labs/libevm/common" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/modules" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/utils" diff --git a/graft/subnet-evm/params/extras/precompile_upgrade_test.go b/graft/subnet-evm/params/extras/precompile_upgrade_test.go index a41faab11082..010ac9e127e1 100644 --- a/graft/subnet-evm/params/extras/precompile_upgrade_test.go +++ b/graft/subnet-evm/params/extras/precompile_upgrade_test.go @@ -10,7 +10,6 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" "github.com/ava-labs/avalanchego/utils" diff --git a/graft/subnet-evm/plugin/evm/customheader/extra_test.go b/graft/subnet-evm/plugin/evm/customheader/extra_test.go index bc9307a95805..8a80abbeb458 100644 --- a/graft/subnet-evm/plugin/evm/customheader/extra_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/extra_test.go @@ -11,7 +11,6 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/upgrade/subnetevm" diff --git a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go index ada0b81bb57f..dd7868520cb9 100644 --- a/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/min_delay_excess_test.go @@ -9,7 +9,6 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" "github.com/ava-labs/avalanchego/utils" diff --git a/graft/subnet-evm/plugin/evm/customheader/time_test.go b/graft/subnet-evm/plugin/evm/customheader/time_test.go index 2899f237d1b5..5a5200a814ce 100644 --- a/graft/subnet-evm/plugin/evm/customheader/time_test.go +++ b/graft/subnet-evm/plugin/evm/customheader/time_test.go @@ -10,7 +10,6 @@ import ( "github.com/ava-labs/libevm/core/types" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/params/extras" "github.com/ava-labs/avalanchego/graft/subnet-evm/plugin/evm/customtypes" "github.com/ava-labs/avalanchego/utils" diff --git a/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go b/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go index 16a9b631631f..214d5eec08a5 100644 --- a/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go +++ b/graft/subnet-evm/plugin/evm/customtypes/block_ext_test.go @@ -12,7 +12,6 @@ import ( "github.com/ava-labs/libevm/common" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/internal/blocktest" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/vms/evm/acp226" diff --git a/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go b/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go index ca1d193446d6..04d8d31f8b84 100644 --- a/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go +++ b/graft/subnet-evm/precompile/allowlist/allowlisttest/test_allowlist_config.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/modules" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" diff --git a/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go b/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go index 02505f14feb3..cf3f20263d0b 100644 --- a/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go +++ b/graft/subnet-evm/precompile/contracts/deployerallowlist/config_test.go @@ -9,7 +9,6 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/deployerallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" diff --git a/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go b/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go index 965c606f3ab5..a4eab2030112 100644 --- a/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/deployerallowlist/simulated_test.go @@ -11,7 +11,6 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" diff --git a/graft/subnet-evm/precompile/contracts/feemanager/config_test.go b/graft/subnet-evm/precompile/contracts/feemanager/config_test.go index ea9d668ccbf7..0afbc3640680 100644 --- a/graft/subnet-evm/precompile/contracts/feemanager/config_test.go +++ b/graft/subnet-evm/precompile/contracts/feemanager/config_test.go @@ -10,7 +10,6 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/feemanager" diff --git a/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go b/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go index daf332dcc4aa..b10bf6a6ea9e 100644 --- a/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/feemanager/simulated_test.go @@ -13,7 +13,6 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/commontype" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" diff --git a/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go b/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go index c60e5068cb0a..1955b1f5917c 100644 --- a/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go +++ b/graft/subnet-evm/precompile/contracts/nativeminter/config_test.go @@ -10,7 +10,6 @@ import ( "github.com/ava-labs/libevm/common/math" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/nativeminter" diff --git a/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go b/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go index 9af4bfc04c38..02559fb6f155 100644 --- a/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/nativeminter/simulated_test.go @@ -12,7 +12,6 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" diff --git a/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go b/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go index 695f83b03cdc..1bad13e4cd86 100644 --- a/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go +++ b/graft/subnet-evm/precompile/contracts/rewardmanager/config_test.go @@ -9,7 +9,6 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/rewardmanager" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" diff --git a/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go b/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go index ec4db9e7851a..7bf3a5175e5c 100644 --- a/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/rewardmanager/simulated_test.go @@ -15,7 +15,6 @@ import ( "github.com/stretchr/testify/require" "github.com/ava-labs/avalanchego/graft/evm/constants" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/eth/ethconfig" diff --git a/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go b/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go index 550b1f489eee..301dd7a927e8 100644 --- a/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go +++ b/graft/subnet-evm/precompile/contracts/txallowlist/config_test.go @@ -9,7 +9,6 @@ import ( "github.com/ava-labs/libevm/common" "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/allowlist/allowlisttest" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/contracts/txallowlist" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" diff --git a/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go b/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go index fa3bf5d53e1d..c7b3880355e7 100644 --- a/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go +++ b/graft/subnet-evm/precompile/contracts/txallowlist/simulated_test.go @@ -11,7 +11,6 @@ import ( "github.com/ava-labs/libevm/crypto" "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/accounts/abi/bind" "github.com/ava-labs/avalanchego/graft/subnet-evm/core" "github.com/ava-labs/avalanchego/graft/subnet-evm/params" diff --git a/graft/subnet-evm/precompile/contracts/warp/config_test.go b/graft/subnet-evm/precompile/contracts/warp/config_test.go index e960f33d332e..862661e2f274 100644 --- a/graft/subnet-evm/precompile/contracts/warp/config_test.go +++ b/graft/subnet-evm/precompile/contracts/warp/config_test.go @@ -8,7 +8,6 @@ import ( "go.uber.org/mock/gomock" - "github.com/ava-labs/avalanchego/graft/evm/utils" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/avalanchego/graft/subnet-evm/precompile/precompiletest" "github.com/ava-labs/avalanchego/utils" From 7f2844b447a8d34e151a2f123f26fc85cfe346d0 Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Tue, 6 Jan 2026 12:05:37 -0500 Subject: [PATCH 16/16] chore: correct header year --- graft/evm/utils/bytes.go | 2 +- graft/evm/utils/bytes_test.go | 2 +- graft/evm/utils/rand/rand.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/graft/evm/utils/bytes.go b/graft/evm/utils/bytes.go index 043d0b91bcb9..a22450d754f2 100644 --- a/graft/evm/utils/bytes.go +++ b/graft/evm/utils/bytes.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. +// Copyright (C) 2019-2026, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. package utils diff --git a/graft/evm/utils/bytes_test.go b/graft/evm/utils/bytes_test.go index f79dbfdbddee..b94b3fd62e90 100644 --- a/graft/evm/utils/bytes_test.go +++ b/graft/evm/utils/bytes_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. +// Copyright (C) 2019-2026, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. package utils diff --git a/graft/evm/utils/rand/rand.go b/graft/evm/utils/rand/rand.go index e0cc23c12661..e6c74a60a8ca 100644 --- a/graft/evm/utils/rand/rand.go +++ b/graft/evm/utils/rand/rand.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. +// Copyright (C) 2019-2026, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. package rand