diff --git a/eth/tracers/internal/tracetest/calltrace_test.go b/eth/tracers/internal/tracetest/calltrace_test.go index e3f1b1a0cc..582b5979a9 100644 --- a/eth/tracers/internal/tracetest/calltrace_test.go +++ b/eth/tracers/internal/tracetest/calltrace_test.go @@ -34,6 +34,8 @@ import ( "strings" "testing" + "github.com/ava-labs/avalanchego/upgrade" + "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/coreth/core" "github.com/ava-labs/coreth/core/rawdb" "github.com/ava-labs/coreth/core/types" @@ -275,6 +277,7 @@ func benchTracer(tracerName string, test *callTracerTest, b *testing.B) { func TestInternals(t *testing.T) { var ( + config = params.GetChainConfig(upgrade.GetConfig(constants.MainnetID), params.AvalancheMainnetChainID) to = common.HexToAddress("0x00000000000000000000000000000000deadbeef") origin = common.HexToAddress("0x00000000000000000000000000000000feed") txContext = vm.TxContext{ @@ -388,7 +391,7 @@ func TestInternals(t *testing.T) { }, false, rawdb.HashScheme) defer triedb.Close() - evm := vm.NewEVM(context, txContext, statedb, params.AvalancheMainnetChainConfig, vm.Config{Tracer: tc.tracer}) + evm := vm.NewEVM(context, txContext, statedb, config, vm.Config{Tracer: tc.tracer}) msg := &core.Message{ To: &to, From: origin, diff --git a/go.mod b/go.mod index 8cc4f6b425..88e24bafcf 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21.12 require ( github.com/VictoriaMetrics/fastcache v1.12.1 - github.com/ava-labs/avalanchego v1.11.11-0.20240813203340-ab83fb41528d + github.com/ava-labs/avalanchego v1.11.11-0.20240814145500-1ac532af76df github.com/cespare/cp v0.1.0 github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 github.com/davecgh/go-spew v1.1.1 diff --git a/go.sum b/go.sum index 2c359f6a24..c9447c5be7 100644 --- a/go.sum +++ b/go.sum @@ -56,6 +56,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/ava-labs/avalanchego v1.11.11-0.20240813203340-ab83fb41528d h1:LyrKJL9avIIxBY3uTcS2dFtUMBFmI2QpAgG6qYTdA6s= github.com/ava-labs/avalanchego v1.11.11-0.20240813203340-ab83fb41528d/go.mod h1:UkyrRDXK2E15Lq2abyae2Pt+JsWvgsg1pe0/AtoMyAM= +github.com/ava-labs/avalanchego v1.11.11-0.20240814145500-1ac532af76df h1:Yp9rCHpgEsPFzpx2MXxpb/T+/NbP2NpS1EDwFquffLQ= +github.com/ava-labs/avalanchego v1.11.11-0.20240814145500-1ac532af76df/go.mod h1:Kw2GKwTaCkLwq2z3zSVH4V2eiAmq2FohHmN3AIDWjvY= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= diff --git a/params/config.go b/params/config.go index 306a995df0..da47cf8282 100644 --- a/params/config.go +++ b/params/config.go @@ -32,8 +32,6 @@ import ( "fmt" "math/big" - "github.com/ava-labs/avalanchego/upgrade" - "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/coreth/precompile/modules" "github.com/ava-labs/coreth/precompile/precompileconfig" "github.com/ava-labs/coreth/utils" @@ -53,15 +51,6 @@ var ( ) var ( - // AvalancheMainnetChainConfig is the configuration for Avalanche Main Network - AvalancheMainnetChainConfig = GetChainConfig(upgrade.GetConfig(constants.MainnetID), AvalancheMainnetChainID) - - // AvalancheFujiChainConfig is the configuration for the Fuji Test Network - AvalancheFujiChainConfig = GetChainConfig(upgrade.GetConfig(constants.FujiID), AvalancheFujiChainID) - - // AvalancheLocalChainConfig is the configuration for the Avalanche Local Network - AvalancheLocalChainConfig = GetChainConfig(upgrade.GetConfig(constants.LocalID), AvalancheLocalChainID) - TestChainConfig = &ChainConfig{ AvalancheContext: AvalancheContext{utils.TestSnowContext()}, ChainID: big.NewInt(1), diff --git a/params/config_extra.go b/params/config_extra.go index 1b76ccd571..36fc2c98ba 100644 --- a/params/config_extra.go +++ b/params/config_extra.go @@ -171,20 +171,7 @@ func GetChainConfig(agoUpgrade upgrade.Config, chainID *big.Int) *ChainConfig { PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), - NetworkUpgrades: NetworkUpgrades{ - ApricotPhase1BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase1Time), - ApricotPhase2BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase2Time), - ApricotPhase3BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase3Time), - ApricotPhase4BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase4Time), - ApricotPhase5BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase5Time), - ApricotPhasePre6BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhasePre6Time), - ApricotPhase6BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase6Time), - ApricotPhasePost6BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhasePost6Time), - BanffBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.BanffTime), - CortinaBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.CortinaTime), - DurangoBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.DurangoTime), - EtnaTimestamp: utils.TimeToNewUint64(agoUpgrade.EtnaTime), - }, + NetworkUpgrades: getNetworkUpgrades(agoUpgrade), } } diff --git a/params/network_upgrades.go b/params/network_upgrades.go index 332119cfae..6af886b093 100644 --- a/params/network_upgrades.go +++ b/params/network_upgrades.go @@ -6,6 +6,9 @@ package params import ( "fmt" "reflect" + + "github.com/ava-labs/avalanchego/upgrade" + "github.com/ava-labs/coreth/utils" ) type NetworkUpgrades struct { @@ -191,6 +194,23 @@ func (n *NetworkUpgrades) Description() string { return banner } +func getNetworkUpgrades(agoUpgrade upgrade.Config) NetworkUpgrades { + return NetworkUpgrades{ + ApricotPhase1BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase1Time), + ApricotPhase2BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase2Time), + ApricotPhase3BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase3Time), + ApricotPhase4BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase4Time), + ApricotPhase5BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase5Time), + ApricotPhasePre6BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhasePre6Time), + ApricotPhase6BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase6Time), + ApricotPhasePost6BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhasePost6Time), + BanffBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.BanffTime), + CortinaBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.CortinaTime), + DurangoBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.DurangoTime), + EtnaTimestamp: utils.TimeToNewUint64(agoUpgrade.EtnaTime), + } +} + type AvalancheRules struct { IsApricotPhase1, IsApricotPhase2, IsApricotPhase3, IsApricotPhase4, IsApricotPhase5 bool IsApricotPhasePre6, IsApricotPhase6, IsApricotPhasePost6 bool diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 97fcfc7564..cb7cd9f1d6 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -19,6 +19,7 @@ import ( "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/network/p2p/gossip" + "github.com/ava-labs/avalanchego/upgrade" avalanchegoConstants "github.com/ava-labs/avalanchego/utils/constants" "github.com/prometheus/client_golang/prometheus" @@ -448,20 +449,27 @@ func (vm *VM) Initialize( } var extDataHashes map[common.Hash]common.Hash + var chainID *big.Int // Set the chain config for mainnet/fuji chain IDs switch chainCtx.NetworkID { case avalanchegoConstants.MainnetID: - config := *params.AvalancheMainnetChainConfig - g.Config = &config + chainID = params.AvalancheMainnetChainID extDataHashes = mainnetExtDataHashes case avalanchegoConstants.FujiID: - config := *params.AvalancheFujiChainConfig - g.Config = &config + chainID = params.AvalancheFujiChainID extDataHashes = fujiExtDataHashes case avalanchegoConstants.LocalID: - config := *params.AvalancheLocalChainConfig - g.Config = &config + chainID = params.AvalancheLocalChainID + default: + chainID = g.Config.ChainID + } + + // if the chainCtx.NetworkUpgrades is not empty, set the chain config + // normally it should not be empty, but some tests may not set it + if chainCtx.NetworkUpgrades != (upgrade.Config{}) { + g.Config = params.GetChainConfig(chainCtx.NetworkUpgrades, new(big.Int).Set(chainID)) } + // If the Durango is activated, activate the Warp Precompile at the same time if g.Config.DurangoBlockTimestamp != nil { g.Config.PrecompileUpgrades = append(g.Config.PrecompileUpgrades, params.PrecompileUpgrade{ diff --git a/scripts/versions.sh b/scripts/versions.sh index ebfd4dedc9..5bed52626d 100644 --- a/scripts/versions.sh +++ b/scripts/versions.sh @@ -6,4 +6,4 @@ set -euo pipefail # Don't export them as they're used in the context of other calls -AVALANCHE_VERSION=${AVALANCHE_VERSION:-'ab83fb41528de93c1790301cdd67a07dda9299f0'} +AVALANCHE_VERSION=${AVALANCHE_VERSION:-'1ac532af76df'}