From 491ffc2b6f5464c625ce8156dd926a305c81ef9d Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Fri, 5 Jan 2024 00:24:07 +0300 Subject: [PATCH 1/3] bump min go version (#1032) * bump min go version * downgrade golangci --- .github/workflows/auto-generated-code-checker.yml | 2 +- .github/workflows/bench.yml | 2 +- .github/workflows/ci.yml | 6 +++--- .github/workflows/release.yml | 2 +- Dockerfile | 2 +- README.md | 2 +- scripts/build.sh | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/auto-generated-code-checker.yml b/.github/workflows/auto-generated-code-checker.yml index 39bd2c8434..a83c1f2990 100644 --- a/.github/workflows/auto-generated-code-checker.yml +++ b/.github/workflows/auto-generated-code-checker.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: '~1.20.10' + go-version: '~1.20.12' check-latest: true - shell: bash run: scripts/mock.gen.sh diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 12ce8eec47..500c9aaf7f 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: '~1.20.10' + go-version: '~1.20.12' check-latest: true - run: go mod download shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f932cbcb2..637aaf012e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: shell: bash - uses: actions/setup-go@v3 with: - go-version: '~1.20.10' + go-version: '~1.20.12' check-latest: true - name: golangci-lint uses: golangci/golangci-lint-action@v3 @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: '~1.20.10' + go-version: '~1.20.12' check-latest: true - run: go mod download shell: bash @@ -66,7 +66,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: '~1.20.10' + go-version: '~1.20.12' check-latest: true - name: Use Node.js uses: actions/setup-node@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index febc34fa75..285349835f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: '~1.20.10' + go-version: '~1.20.12' check-latest: true - name: Set up arm64 cross compiler run: | diff --git a/Dockerfile b/Dockerfile index 11784758dd..54e3274966 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ ARG AVALANCHE_VERSION # ============= Compilation Stage ================ -FROM golang:1.20.10-bullseye AS builder +FROM golang:1.20.12-bullseye AS builder WORKDIR /build diff --git a/README.md b/README.md index 193e209540..5f2fc45017 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ To support these changes, there have been a number of changes to the SubnetEVM b ### Clone Subnet-evm -First install Go 1.20.10 or later. Follow the instructions [here](https://go.dev/doc/install). You can verify by running `go version`. +First install Go 1.20.12 or later. Follow the instructions [here](https://go.dev/doc/install). You can verify by running `go version`. Set `$GOPATH` environment variable properly for Go to look for Go Workspaces. Please read [this](https://go.dev/doc/code) for details. You can verify by running `echo $GOPATH`. diff --git a/scripts/build.sh b/scripts/build.sh index c9b169bee9..a4941b99c4 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -4,7 +4,7 @@ set -o errexit set -o nounset set -o pipefail -go_version_minimum="1.20.10" +go_version_minimum="1.20.12" go_version() { go version | sed -nE -e 's/[^0-9.]+([0-9.]+).+/\1/p' From 36120e9acdbc06034c5b61b2fa93595469d4218d Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Fri, 5 Jan 2024 00:41:57 +0300 Subject: [PATCH 2/3] rename DUpgrade to Durango (#1029) * rename DUpgrade to Durango * Update core/evm.go Signed-off-by: Darioush Jalali * Update x/warp/contract.go Signed-off-by: Darioush Jalali * Update precompile/contracts/nativeminter/contract.go Signed-off-by: Darioush Jalali * Update predicate/predicate_bytes.go Signed-off-by: Darioush Jalali * Update precompile/precompileconfig/config.go Signed-off-by: Darioush Jalali * Update x/warp/config.go Signed-off-by: Darioush Jalali * Update x/warp/contract.go Signed-off-by: Darioush Jalali * Update x/warp/contract.go Signed-off-by: Darioush Jalali --------- Signed-off-by: Darioush Jalali Co-authored-by: Darioush Jalali --- .../precompile_config_test_template.go | 2 +- .../precompile_contract_template.go | 4 +- cmd/evm/internal/t8ntool/transaction.go | 2 +- consensus/dummy/consensus.go | 2 +- core/evm.go | 4 +- core/state/statedb.go | 4 +- core/state_processor_test.go | 4 +- core/state_transition.go | 4 +- core/txpool/txpool.go | 2 +- core/vm/interpreter.go | 4 +- core/vm/jump_table.go | 8 ++-- core/vm/jump_table_export.go | 4 +- core/vm/jump_table_test.go | 2 +- eth/tracers/api.go | 4 +- miner/worker.go | 4 +- params/config.go | 16 ++++---- params/config_test.go | 4 +- params/network_upgrades.go | 18 ++++----- plugin/evm/block.go | 6 +-- plugin/evm/block_verification.go | 2 +- plugin/evm/vm_test.go | 38 +++++++++---------- plugin/evm/vm_warp_test.go | 6 +-- precompile/allowlist/allowlist.go | 12 +++--- precompile/allowlist/config.go | 8 ++-- precompile/allowlist/role.go | 2 +- precompile/allowlist/test_allowlist.go | 34 ++++++++--------- precompile/allowlist/test_allowlist_config.go | 4 +- precompile/contract/utils.go | 4 +- precompile/contracts/feemanager/contract.go | 8 ++-- .../contracts/feemanager/contract_test.go | 20 +++++----- .../contracts/nativeminter/config_test.go | 2 +- precompile/contracts/nativeminter/contract.go | 6 +-- .../contracts/nativeminter/contract_test.go | 12 +++--- .../contracts/rewardmanager/contract.go | 10 ++--- .../contracts/rewardmanager/contract_test.go | 12 +++--- precompile/precompileconfig/config.go | 4 +- precompile/precompileconfig/mocks.go | 12 +++--- precompile/testutils/test_config.go | 2 +- precompile/testutils/test_precompile.go | 2 +- predicate/predicate_bytes.go | 4 +- predicate/predicate_bytes_test.go | 10 ++--- tests/init.go | 4 +- x/warp/config.go | 6 +-- x/warp/config_test.go | 4 +- x/warp/contract.go | 12 +++--- 45 files changed, 169 insertions(+), 169 deletions(-) diff --git a/accounts/abi/bind/precompilebind/precompile_config_test_template.go b/accounts/abi/bind/precompilebind/precompile_config_test_template.go index 9d09c8fb83..3c03732fd4 100644 --- a/accounts/abi/bind/precompilebind/precompile_config_test_template.go +++ b/accounts/abi/bind/precompilebind/precompile_config_test_template.go @@ -36,7 +36,7 @@ func TestVerify(t *testing.T) { Config: NewConfig(utils.NewUint64(3){{- if .Contract.AllowList}}, admins, enableds, managers{{- end}}), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }(), ExpectedError: "", diff --git a/accounts/abi/bind/precompilebind/precompile_contract_template.go b/accounts/abi/bind/precompilebind/precompile_contract_template.go index 297e848ea8..d1e06c9975 100644 --- a/accounts/abi/bind/precompilebind/precompile_contract_template.go +++ b/accounts/abi/bind/precompilebind/precompile_contract_template.go @@ -143,7 +143,7 @@ func Set{{.Contract.Type}}AllowListStatus(stateDB contract.StateDB, address comm // assumes that [input] does not include selector (omits first 4 func signature bytes) func Unpack{{capitalise .Normalized.Name}}Input(input []byte) ({{capitalise .Normalized.Name}}Input, error) { inputStruct := {{capitalise .Normalized.Name}}Input{} - // The strict mode in decoding is disabled after DUpgrade. You can re-enable by changing the last argument to true. + // The strict mode in decoding is disabled after Durango. You can re-enable by changing the last argument to true. err := {{$contract.Type}}ABI.UnpackInputIntoInterface(&inputStruct, "{{.Original.Name}}", input, false) return inputStruct, err @@ -160,7 +160,7 @@ func Pack{{.Normalized.Name}}(inputStruct {{capitalise .Normalized.Name}}Input) // Unpack{{capitalise .Normalized.Name}}Input attempts to unpack [input] into the {{$bindedType}} type argument // assumes that [input] does not include selector (omits first 4 func signature bytes) func Unpack{{capitalise .Normalized.Name}}Input(input []byte)({{$bindedType}}, error) { -// The strict mode in decoding is disabled after DUpgrade. You can re-enable by changing the last argument to true. +// The strict mode in decoding is disabled after Durango. You can re-enable by changing the last argument to true. res, err := {{$contract.Type}}ABI.UnpackInput("{{$method.Original.Name}}", input, false) if err != nil { return {{bindtypenew $input.Type $structs}}, err diff --git a/cmd/evm/internal/t8ntool/transaction.go b/cmd/evm/internal/t8ntool/transaction.go index ce6a6e9ef3..98ebc3e275 100644 --- a/cmd/evm/internal/t8ntool/transaction.go +++ b/cmd/evm/internal/t8ntool/transaction.go @@ -182,7 +182,7 @@ func Transaction(ctx *cli.Context) error { r.Error = errors.New("gas * maxFeePerGas exceeds 256 bits") } // Check whether the init code size has been exceeded. - if chainConfig.IsDUpgrade(0) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize { + if chainConfig.IsDurango(0) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize { r.Error = errors.New("max initcode size exceeded") } results = append(results, r) diff --git a/consensus/dummy/consensus.go b/consensus/dummy/consensus.go index 64fd27be83..173f1e8d53 100644 --- a/consensus/dummy/consensus.go +++ b/consensus/dummy/consensus.go @@ -198,7 +198,7 @@ func (self *DummyEngine) verifyHeader(chain consensus.ChainHeaderReader, header return errUnclesUnsupported } switch { - case config.IsDUpgrade(header.Time): + case config.IsDurango(header.Time): if len(header.Extra) < params.DynamicFeeExtraDataSize { return fmt.Errorf("expected extra-data field length >= %d, found %d", params.DynamicFeeExtraDataSize, len(header.Extra)) } diff --git a/core/evm.go b/core/evm.go index d13a9907ce..71da2dd4d4 100644 --- a/core/evm.go +++ b/core/evm.go @@ -54,8 +54,8 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common if !ok { return newEVMBlockContext(header, chain, author, nil) } - // Prior to the DUpgrade, the VM enforces the extra data is smaller than or - // equal to this size. After the DUpgrade, the VM pre-verifies the extra + // Prior to Durango, the VM enforces the extra data is smaller than or + // equal to this size. After Durango, the VM pre-verifies the extra // data past the dynamic fee rollup window is valid. predicateResults, err := predicate.ParseResults(predicateBytes) if err != nil { diff --git a/core/state/statedb.go b/core/state/statedb.go index 6c44427975..84ad766057 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -1169,7 +1169,7 @@ func (s *StateDB) commit(deleteEmptyObjects bool, snaps *snapshot.Tree, blockHas // // Potential EIPs: // - Reset access list (Berlin) -// - Add coinbase to access list (EIP-3651/DUpgrade) +// - Add coinbase to access list (EIP-3651/Durango) // - Reset transient storage (EIP-1153) func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) { if rules.IsSubnetEVM { @@ -1191,7 +1191,7 @@ func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, d al.AddSlot(el.Address, key) } } - if rules.IsDUpgrade { // EIP-3651: warm coinbase + if rules.IsDurango { // EIP-3651: warm coinbase al.AddAddress(coinbase) } diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 32a0d90731..d3776e7288 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -302,7 +302,7 @@ func TestStateProcessorErrors(t *testing.T) { } } - // ErrMaxInitCodeSizeExceeded, for this we need extra Shanghai (DUpgrade/EIP-3860) enabled. + // ErrMaxInitCodeSizeExceeded, for this we need extra Shanghai (Durango/EIP-3860) enabled. { var ( db = rawdb.NewMemoryDatabase() @@ -320,7 +320,7 @@ func TestStateProcessorErrors(t *testing.T) { MuirGlacierBlock: big.NewInt(0), MandatoryNetworkUpgrades: params.MandatoryNetworkUpgrades{ SubnetEVMTimestamp: utils.NewUint64(0), - DUpgradeTimestamp: utils.NewUint64(0), + DurangoTimestamp: utils.NewUint64(0), }, FeeConfig: params.DefaultFeeConfig, }, diff --git a/core/state_transition.go b/core/state_transition.go index 141a387a4e..ba2446fb15 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -111,7 +111,7 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation b } gas += z * params.TxDataZeroGas - if isContractCreation && rules.IsDUpgrade { + if isContractCreation && rules.IsDurango { lenWords := toWordSize(dataLen) if (math.MaxUint64-gas)/params.InitCodeWordGas < lenWords { return 0, ErrGasUintOverflow @@ -425,7 +425,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { } // Check whether the init code size has been exceeded. - if rules.IsDUpgrade && contractCreation && len(msg.Data) > params.MaxInitCodeSize { + if rules.IsDurango && contractCreation && len(msg.Data) > params.MaxInitCodeSize { return nil, fmt.Errorf("%w: code size %v limit %v", vmerrs.ErrMaxInitCodeSizeExceeded, len(msg.Data), params.MaxInitCodeSize) } diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index 4a662a7a10..46b687bb2d 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -1580,7 +1580,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) { pool.rules.Store(&rules) pool.eip2718.Store(rules.IsSubnetEVM) pool.eip1559.Store(rules.IsSubnetEVM) - pool.eip3860.Store(rules.IsDUpgrade) + pool.eip3860.Store(rules.IsDurango) } // promoteExecutables moves transactions that have become processable from the diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 22a64106c3..1752669d0d 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -70,8 +70,8 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter { // If jump table was not initialised we set the default one. var table *JumpTable switch { - case evm.chainRules.IsDUpgrade: - table = &dUpgradeInstructionSet + case evm.chainRules.IsDurango: + table = &durangoInstructionSet case evm.chainRules.IsSubnetEVM: table = &subnetEVMInstructionSet case evm.chainRules.IsIstanbul: diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 4ecfa265aa..a8c2089c4b 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -63,7 +63,7 @@ var ( constantinopleInstructionSet = newConstantinopleInstructionSet() istanbulInstructionSet = newIstanbulInstructionSet() subnetEVMInstructionSet = newSubnetEVMInstructionSet() - dUpgradeInstructionSet = newDUpgradeInstructionSet() + durangoInstructionSet = newDurangoInstructionSet() ) // JumpTable contains the EVM opcodes supported at a given fork. @@ -87,9 +87,9 @@ func validate(jt JumpTable) JumpTable { return jt } -// newDUpgradeInstructionSet returns the frontier, homestead, byzantium, -// constantinople, istanbul, petersburg, subnet-evm, d-upgrade instructions. -func newDUpgradeInstructionSet() JumpTable { +// newDurangoInstructionSet returns the frontier, homestead, byzantium, +// constantinople, istanbul, petersburg, subnet-evm, durango instructions. +func newDurangoInstructionSet() JumpTable { instructionSet := newSubnetEVMInstructionSet() enable3855(&instructionSet) // PUSH0 instruction enable3860(&instructionSet) // Limit and meter initcode diff --git a/core/vm/jump_table_export.go b/core/vm/jump_table_export.go index 63fd539e21..da095ce605 100644 --- a/core/vm/jump_table_export.go +++ b/core/vm/jump_table_export.go @@ -24,8 +24,8 @@ import ( // the rules. func LookupInstructionSet(rules params.Rules) (JumpTable, error) { switch { - case rules.IsDUpgrade: - return newDUpgradeInstructionSet(), nil + case rules.IsDurango: + return newDurangoInstructionSet(), nil case rules.IsSubnetEVM: return newSubnetEVMInstructionSet(), nil case rules.IsIstanbul: diff --git a/core/vm/jump_table_test.go b/core/vm/jump_table_test.go index 05c79d83ff..6e838337c1 100644 --- a/core/vm/jump_table_test.go +++ b/core/vm/jump_table_test.go @@ -34,7 +34,7 @@ import ( // TestJumpTableCopy tests that deep copy is necessery to prevent modify shared jump table func TestJumpTableCopy(t *testing.T) { - tbl := newDUpgradeInstructionSet() + tbl := newDurangoInstructionSet() require.Equal(t, uint64(0), tbl[SLOAD].constantGas) // a deep copy won't modify the shared jump table diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 6fad55c201..abc442ab64 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -1052,8 +1052,8 @@ func overrideConfig(original *params.ChainConfig, override *params.ChainConfig) copy.SubnetEVMTimestamp = timestamp canon = false } - if timestamp := override.DUpgradeTimestamp; timestamp != nil { - copy.DUpgradeTimestamp = timestamp + if timestamp := override.DurangoTimestamp; timestamp != nil { + copy.DurangoTimestamp = timestamp canon = false } if timestamp := override.CancunTime; timestamp != nil { diff --git a/miner/worker.go b/miner/worker.go index 00023d8607..ed87719108 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -252,7 +252,7 @@ func (w *worker) commitTransaction(env *environment, tx *types.Transaction, coin blockContext vm.BlockContext ) - if env.rules.IsDUpgrade { + if env.rules.IsDurango { results, err := core.CheckPredicates(env.rules, env.predicateContext, tx) if err != nil { log.Debug("Transaction predicate failed verification in miner", "tx", tx.Hash(), "err", err) @@ -337,7 +337,7 @@ func (w *worker) commitTransactions(env *environment, txs *types.TransactionsByP // commit runs any post-transaction state modifications, assembles the final block // and commits new work if consensus engine is running. func (w *worker) commit(env *environment) (*types.Block, error) { - if env.rules.IsDUpgrade { + if env.rules.IsDurango { predicateResultsBytes, err := env.predicateResults.Bytes() if err != nil { return nil, fmt.Errorf("failed to marshal predicate results: %w", err) diff --git a/params/config.go b/params/config.go index 991a4570dc..c027badfba 100644 --- a/params/config.go +++ b/params/config.go @@ -106,7 +106,7 @@ var ( MuirGlacierBlock: big.NewInt(0), MandatoryNetworkUpgrades: MandatoryNetworkUpgrades{ SubnetEVMTimestamp: utils.NewUint64(0), - DUpgradeTimestamp: utils.NewUint64(0), + DurangoTimestamp: utils.NewUint64(0), }, GenesisPrecompiles: Precompiles{}, UpgradeConfig: UpgradeConfig{}, @@ -279,7 +279,7 @@ func (c *ChainConfig) Description() string { } banner += "Mandatory Upgrades:\n" banner += fmt.Sprintf(" - SubnetEVM Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.10.0)\n", ptrToString(c.SubnetEVMTimestamp)) - banner += fmt.Sprintf(" - DUpgrade Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0)\n", ptrToString(c.DUpgradeTimestamp)) + banner += fmt.Sprintf(" - Durango Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0)\n", ptrToString(c.DurangoTimestamp)) banner += fmt.Sprintf(" - Cancun Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0)\n", ptrToString(c.CancunTime)) banner += "\n" @@ -370,10 +370,10 @@ func (c *ChainConfig) IsSubnetEVM(time uint64) bool { return utils.IsTimestampForked(c.SubnetEVMTimestamp, time) } -// IsDUpgrade returns whether [time] represents a block -// with a timestamp after the DUpgrade upgrade time. -func (c *ChainConfig) IsDUpgrade(time uint64) bool { - return utils.IsTimestampForked(c.DUpgradeTimestamp, time) +// IsDurango returns whether [time] represents a block +// with a timestamp after the Durango upgrade time. +func (c *ChainConfig) IsDurango(time uint64) bool { + return utils.IsTimestampForked(c.DurangoTimestamp, time) } // IsCancun returns whether [time] represents a block @@ -717,7 +717,7 @@ type Rules struct { // Rules for Avalanche releases IsSubnetEVM bool - IsDUpgrade bool + IsDurango bool // ActivePrecompiles maps addresses to stateful precompiled contracts that are enabled // for this rule set. @@ -764,7 +764,7 @@ func (c *ChainConfig) AvalancheRules(blockNum *big.Int, timestamp uint64) Rules rules := c.rules(blockNum, timestamp) rules.IsSubnetEVM = c.IsSubnetEVM(timestamp) - rules.IsDUpgrade = c.IsDUpgrade(timestamp) + rules.IsDurango = c.IsDurango(timestamp) // Initialize the stateful precompiles that should be enabled at [blockTimestamp]. rules.ActivePrecompiles = make(map[common.Address]precompileconfig.Config) diff --git a/params/config_test.go b/params/config_test.go index 71d9678cec..066cc21192 100644 --- a/params/config_test.go +++ b/params/config_test.go @@ -274,7 +274,7 @@ func TestChainConfigMarshalWithUpgrades(t *testing.T) { MuirGlacierBlock: big.NewInt(0), MandatoryNetworkUpgrades: MandatoryNetworkUpgrades{ SubnetEVMTimestamp: utils.NewUint64(0), - DUpgradeTimestamp: utils.NewUint64(0), + DurangoTimestamp: utils.NewUint64(0), }, GenesisPrecompiles: Precompiles{}, }, @@ -310,7 +310,7 @@ func TestChainConfigMarshalWithUpgrades(t *testing.T) { "istanbulBlock": 0, "muirGlacierBlock": 0, "subnetEVMTimestamp": 0, - "dUpgradeTimestamp": 0, + "durangoTimestamp": 0, "upgrades": { "precompileUpgrades": [ { diff --git a/params/network_upgrades.go b/params/network_upgrades.go index 9453d712c0..71a52f0a02 100644 --- a/params/network_upgrades.go +++ b/params/network_upgrades.go @@ -10,22 +10,22 @@ import ( var ( LocalNetworkUpgrades = MandatoryNetworkUpgrades{ SubnetEVMTimestamp: utils.NewUint64(0), - DUpgradeTimestamp: utils.NewUint64(0), + DurangoTimestamp: utils.NewUint64(0), } FujiNetworkUpgrades = MandatoryNetworkUpgrades{ SubnetEVMTimestamp: utils.NewUint64(0), - // DUpgradeTimestamp: utils.NewUint64(0), // TODO: Uncomment and set this to the correct value + // DurangoTimestamp: utils.NewUint64(0), // TODO: Uncomment and set this to the correct value } MainnetNetworkUpgrades = MandatoryNetworkUpgrades{ SubnetEVMTimestamp: utils.NewUint64(0), - // DUpgradeTimestamp: utils.NewUint64(0), // TODO: Uncomment and set this to the correct value + // DurangoTimestamp: utils.NewUint64(0), // TODO: Uncomment and set this to the correct value } UnitTestNetworkUpgrades = MandatoryNetworkUpgrades{ SubnetEVMTimestamp: utils.NewUint64(0), - DUpgradeTimestamp: utils.NewUint64(0), + DurangoTimestamp: utils.NewUint64(0), } ) @@ -36,10 +36,10 @@ var ( type MandatoryNetworkUpgrades struct { // SubnetEVMTimestamp is a placeholder that activates Avalanche Upgrades prior to ApricotPhase6 (nil = no fork, 0 = already activated) SubnetEVMTimestamp *uint64 `json:"subnetEVMTimestamp,omitempty"` - // DUpgrade activates the Shanghai Execution Spec Upgrade from Ethereum (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md#included-eips) + // Durango activates the Shanghai Execution Spec Upgrade from Ethereum (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md#included-eips) // and Avalanche Warp Messaging. (nil = no fork, 0 = already activated) // Note: EIP-4895 is excluded since withdrawals are not relevant to the Avalanche C-Chain or Subnets running the EVM. - DUpgradeTimestamp *uint64 `json:"dUpgradeTimestamp,omitempty"` + DurangoTimestamp *uint64 `json:"durangoTimestamp,omitempty"` // Cancun activates the Cancun upgrade from Ethereum. (nil = no fork, 0 = already activated) CancunTime *uint64 `json:"cancunTime,omitempty"` } @@ -48,8 +48,8 @@ func (m *MandatoryNetworkUpgrades) CheckMandatoryCompatible(newcfg *MandatoryNet if isForkTimestampIncompatible(m.SubnetEVMTimestamp, newcfg.SubnetEVMTimestamp, time) { return newTimestampCompatError("SubnetEVM fork block timestamp", m.SubnetEVMTimestamp, newcfg.SubnetEVMTimestamp) } - if isForkTimestampIncompatible(m.DUpgradeTimestamp, newcfg.DUpgradeTimestamp, time) { - return newTimestampCompatError("DUpgrade fork block timestamp", m.DUpgradeTimestamp, newcfg.DUpgradeTimestamp) + if isForkTimestampIncompatible(m.DurangoTimestamp, newcfg.DurangoTimestamp, time) { + return newTimestampCompatError("Durango fork block timestamp", m.DurangoTimestamp, newcfg.DurangoTimestamp) } if isForkTimestampIncompatible(m.CancunTime, newcfg.CancunTime, time) { return newTimestampCompatError("Cancun fork block timestamp", m.CancunTime, m.CancunTime) @@ -60,7 +60,7 @@ func (m *MandatoryNetworkUpgrades) CheckMandatoryCompatible(newcfg *MandatoryNet func (m *MandatoryNetworkUpgrades) mandatoryForkOrder() []fork { return []fork{ {name: "subnetEVMTimestamp", timestamp: m.SubnetEVMTimestamp}, - {name: "dUpgradeTimestamp", timestamp: m.DUpgradeTimestamp}, + {name: "durangoTimestamp", timestamp: m.DurangoTimestamp}, } } diff --git a/plugin/evm/block.go b/plugin/evm/block.go index df6062573b..87f9697fac 100644 --- a/plugin/evm/block.go +++ b/plugin/evm/block.go @@ -251,9 +251,9 @@ func (b *Block) verifyPredicates(predicateContext *precompileconfig.PredicateCon rules := b.vm.chainConfig.AvalancheRules(b.ethBlock.Number(), b.ethBlock.Timestamp()) switch { - case !rules.IsDUpgrade && rules.PredicatersExist(): - return errors.New("cannot enable predicates before DUpgrade activation") - case !rules.IsDUpgrade: + case !rules.IsDurango && rules.PredicatersExist(): + return errors.New("cannot enable predicates before Durango activation") + case !rules.IsDurango: return nil } diff --git a/plugin/evm/block_verification.go b/plugin/evm/block_verification.go index 09f04847b1..4599c48822 100644 --- a/plugin/evm/block_verification.go +++ b/plugin/evm/block_verification.go @@ -59,7 +59,7 @@ func (v blockValidator) SyntacticVerify(b *Block, rules params.Rules) error { } switch { - case rules.IsDUpgrade: + case rules.IsDurango: if len(ethHeader.Extra) < params.DynamicFeeExtraDataSize { return fmt.Errorf( "expected header ExtraData to be len >= %d but got %d", diff --git a/plugin/evm/vm_test.go b/plugin/evm/vm_test.go index 257bd9b675..0f2c4571c0 100644 --- a/plugin/evm/vm_test.go +++ b/plugin/evm/vm_test.go @@ -81,9 +81,9 @@ var ( // Use chainId: 43111, so that it does not overlap with any Avalanche ChainIDs, which may have their // config overridden in vm.Initialize. genesisJSONSubnetEVM = "{\"config\":{\"chainId\":43111,\"homesteadBlock\":0,\"eip150Block\":0,\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0,\"subnetEVMTimestamp\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x00\",\"gasLimit\":\"0x7A1200\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"0x71562b71999873DB5b286dF957af199Ec94617F7\": {\"balance\":\"0x4192927743b88000\"}, \"0x703c4b2bD70c169f5717101CaeE543299Fc946C7\": {\"balance\":\"0x4192927743b88000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\"}" - genesisJSONDUpgrade = "{\"config\":{\"chainId\":43111,\"homesteadBlock\":0,\"eip150Block\":0,\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0,\"subnetEVMTimestamp\":0,\"dUpgradeTimestamp\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x00\",\"gasLimit\":\"0x7A1200\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"0x71562b71999873DB5b286dF957af199Ec94617F7\": {\"balance\":\"0x4192927743b88000\"}, \"0x703c4b2bD70c169f5717101CaeE543299Fc946C7\": {\"balance\":\"0x4192927743b88000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\"}" + genesisJSONDurango = "{\"config\":{\"chainId\":43111,\"homesteadBlock\":0,\"eip150Block\":0,\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0,\"subnetEVMTimestamp\":0,\"durangoTimestamp\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x00\",\"gasLimit\":\"0x7A1200\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"0x71562b71999873DB5b286dF957af199Ec94617F7\": {\"balance\":\"0x4192927743b88000\"}, \"0x703c4b2bD70c169f5717101CaeE543299Fc946C7\": {\"balance\":\"0x4192927743b88000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\"}" genesisJSONPreSubnetEVM = "{\"config\":{\"chainId\":43111,\"homesteadBlock\":0,\"eip150Block\":0,\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x00\",\"gasLimit\":\"0x7A1200\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"0x71562b71999873DB5b286dF957af199Ec94617F7\": {\"balance\":\"0x4192927743b88000\"}, \"0x703c4b2bD70c169f5717101CaeE543299Fc946C7\": {\"balance\":\"0x4192927743b88000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\"}" - genesisJSONLatest = genesisJSONDUpgrade + genesisJSONLatest = genesisJSONDurango firstTxAmount = new(big.Int).Mul(big.NewInt(testMinGasPrice), big.NewInt(21000*100)) genesisBalance = new(big.Int).Mul(big.NewInt(testMinGasPrice), big.NewInt(21000*1000)) @@ -2190,29 +2190,29 @@ func TestTxAllowListSuccessfulTx(t *testing.T) { managerKey := testKeys[1] managerAddress := testEthAddrs[1] genesis := &core.Genesis{} - if err := genesis.UnmarshalJSON([]byte(genesisJSONDUpgrade)); err != nil { + if err := genesis.UnmarshalJSON([]byte(genesisJSONDurango)); err != nil { t.Fatal(err) } - // this manager role should not be activated because DUpgradeTimestamp is in the future + // this manager role should not be activated because DurangoTimestamp is in the future genesis.Config.GenesisPrecompiles = params.Precompiles{ txallowlist.ConfigKey: txallowlist.NewConfig(utils.NewUint64(0), testEthAddrs[0:1], nil, nil), } - dUpgradeTime := time.Now().Add(10 * time.Hour) - genesis.Config.DUpgradeTimestamp = utils.TimeToNewUint64(dUpgradeTime) + durangoTime := time.Now().Add(10 * time.Hour) + genesis.Config.DurangoTimestamp = utils.TimeToNewUint64(durangoTime) genesisJSON, err := genesis.MarshalJSON() if err != nil { t.Fatal(err) } // prepare the new upgrade bytes to disable the TxAllowList - disableAllowListTime := dUpgradeTime.Add(10 * time.Hour) + disableAllowListTime := durangoTime.Add(10 * time.Hour) reenableAllowlistTime := disableAllowListTime.Add(10 * time.Hour) upgradeConfig := ¶ms.UpgradeConfig{ PrecompileUpgrades: []params.PrecompileUpgrade{ { Config: txallowlist.NewDisableConfig(utils.TimeToNewUint64(disableAllowListTime)), }, - // re-enable the tx allowlist after DUpgrade to set the manager role + // re-enable the tx allowlist after Durango to set the manager role { Config: txallowlist.NewConfig(utils.TimeToNewUint64(reenableAllowlistTime), testEthAddrs[0:1], nil, []common.Address{managerAddress}), }, @@ -2245,7 +2245,7 @@ func TestTxAllowListSuccessfulTx(t *testing.T) { if role != allowlist.NoRole { t.Fatalf("Expected allow list status to be set to no role: %s, but found: %s", allowlist.NoRole, role) } - // Should not be a manager role because DUpgrade has not activated yet + // Should not be a manager role because Durango has not activated yet role = txallowlist.GetTxAllowListStatus(genesisState, managerAddress) require.Equal(t, allowlist.NoRole, role) @@ -2343,11 +2343,11 @@ func TestTxAllowListSuccessfulTx(t *testing.T) { func TestVerifyManagerConfig(t *testing.T) { genesis := &core.Genesis{} - require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONDUpgrade))) + require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONDurango))) - dUpgradeTimestamp := time.Now().Add(10 * time.Hour) - genesis.Config.DUpgradeTimestamp = utils.TimeToNewUint64(dUpgradeTimestamp) - // this manager role should not be activated because DUpgradeTimestamp is in the future + durangoTimestamp := time.Now().Add(10 * time.Hour) + genesis.Config.DurangoTimestamp = utils.TimeToNewUint64(durangoTimestamp) + // this manager role should not be activated because DurangoTimestamp is in the future genesis.Config.GenesisPrecompiles = params.Precompiles{ txallowlist.ConfigKey: txallowlist.NewConfig(utils.NewUint64(0), testEthAddrs[0:1], nil, []common.Address{testEthAddrs[1]}), } @@ -2368,18 +2368,18 @@ func TestVerifyManagerConfig(t *testing.T) { []*commonEng.Fx{}, nil, ) - require.ErrorIs(t, err, allowlist.ErrCannotAddManagersBeforeDUpgrade) + require.ErrorIs(t, err, allowlist.ErrCannotAddManagersBeforeDurango) genesis = &core.Genesis{} - require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONDUpgrade))) - genesis.Config.DUpgradeTimestamp = utils.TimeToNewUint64(dUpgradeTimestamp) + require.NoError(t, genesis.UnmarshalJSON([]byte(genesisJSONDurango))) + genesis.Config.DurangoTimestamp = utils.TimeToNewUint64(durangoTimestamp) genesisJSON, err = genesis.MarshalJSON() require.NoError(t, err) - // use an invalid upgrade now with managers set before DUpgrade + // use an invalid upgrade now with managers set before Durango upgradeConfig := ¶ms.UpgradeConfig{ PrecompileUpgrades: []params.PrecompileUpgrade{ { - Config: txallowlist.NewConfig(utils.TimeToNewUint64(dUpgradeTimestamp.Add(-time.Second)), nil, nil, []common.Address{testEthAddrs[1]}), + Config: txallowlist.NewConfig(utils.TimeToNewUint64(durangoTimestamp.Add(-time.Second)), nil, nil, []common.Address{testEthAddrs[1]}), }, }, } @@ -2399,7 +2399,7 @@ func TestVerifyManagerConfig(t *testing.T) { []*commonEng.Fx{}, nil, ) - require.ErrorIs(t, err, allowlist.ErrCannotAddManagersBeforeDUpgrade) + require.ErrorIs(t, err, allowlist.ErrCannotAddManagersBeforeDurango) } // Test that the tx allow list allows whitelisted transactions and blocks non-whitelisted addresses diff --git a/plugin/evm/vm_warp_test.go b/plugin/evm/vm_warp_test.go index 57ec319410..e88506b917 100644 --- a/plugin/evm/vm_warp_test.go +++ b/plugin/evm/vm_warp_test.go @@ -47,7 +47,7 @@ var ( func TestSendWarpMessage(t *testing.T) { require := require.New(t) genesis := &core.Genesis{} - require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDUpgrade))) + require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDurango))) genesis.Config.GenesisPrecompiles = params.Precompiles{ warp.ConfigKey: warp.NewDefaultConfig(subnetEVMUtils.NewUint64(0)), } @@ -247,7 +247,7 @@ func TestValidateInvalidWarpBlockHash(t *testing.T) { func testWarpVMTransaction(t *testing.T, unsignedMessage *avalancheWarp.UnsignedMessage, validSignature bool, txPayload []byte) { require := require.New(t) genesis := &core.Genesis{} - require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDUpgrade))) + require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDurango))) genesis.Config.GenesisPrecompiles = params.Precompiles{ warp.ConfigKey: warp.NewDefaultConfig(subnetEVMUtils.NewUint64(0)), } @@ -404,7 +404,7 @@ func testWarpVMTransaction(t *testing.T, unsignedMessage *avalancheWarp.Unsigned func TestReceiveWarpMessage(t *testing.T) { require := require.New(t) genesis := &core.Genesis{} - require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDUpgrade))) + require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDurango))) genesis.Config.GenesisPrecompiles = params.Precompiles{ warp.ConfigKey: warp.NewDefaultConfig(subnetEVMUtils.NewUint64(0)), } diff --git a/precompile/allowlist/allowlist.go b/precompile/allowlist/allowlist.go index 2c796648c7..6bc00aaf93 100644 --- a/precompile/allowlist/allowlist.go +++ b/precompile/allowlist/allowlist.go @@ -88,8 +88,8 @@ func createAllowListRoleSetter(precompileAddr common.Address, role Role) contrac return nil, 0, err } - // do not use strict mode after DUpgrade - useStrictMode := !contract.IsDUpgradeActivated(evm) + // do not use strict mode after Durango + useStrictMode := !contract.IsDurangoActivated(evm) modifyAddress, err := UnpackModifyAllowListInput(input, role, useStrictMode) if err != nil { @@ -109,7 +109,7 @@ func createAllowListRoleSetter(precompileAddr common.Address, role Role) contrac if !callerStatus.CanModify(modifyStatus, role) { return nil, remainingGas, fmt.Errorf("%w: modify address: %s, from role: %s, to role: %s", ErrCannotModifyAllowList, callerAddr, modifyStatus, role) } - if contract.IsDUpgradeActivated(evm) { + if contract.IsDurangoActivated(evm) { if remainingGas, err = contract.DeductGas(remainingGas, AllowListEventGasCost); err != nil { return nil, 0, err } @@ -159,8 +159,8 @@ func createReadAllowList(precompileAddr common.Address) contract.RunStatefulPrec return nil, 0, err } - // We skip the fixed length check with DUpgrade - useStrictMode := !contract.IsDUpgradeActivated(evm) + // We skip the fixed length check with Durango + useStrictMode := !contract.IsDurangoActivated(evm) readAddress, err := UnpackReadAllowListInput(input, useStrictMode) if err != nil { return nil, remainingGas, err @@ -200,7 +200,7 @@ func CreateAllowListFunctions(precompileAddr common.Address) []*contract.Statefu } else if noRoleFnName, _ := NoRole.GetSetterFunctionName(); name == noRoleFnName { fn = contract.NewStatefulPrecompileFunction(method.ID, createAllowListRoleSetter(precompileAddr, NoRole)) } else if managerFnName, _ := ManagerRole.GetSetterFunctionName(); name == managerFnName { - fn = contract.NewStatefulPrecompileFunctionWithActivator(method.ID, createAllowListRoleSetter(precompileAddr, ManagerRole), contract.IsDUpgradeActivated) + fn = contract.NewStatefulPrecompileFunctionWithActivator(method.ID, createAllowListRoleSetter(precompileAddr, ManagerRole), contract.IsDurangoActivated) } else { panic(fmt.Sprintf("unexpected method name: %s", name)) } diff --git a/precompile/allowlist/config.go b/precompile/allowlist/config.go index 33f312f052..520021f511 100644 --- a/precompile/allowlist/config.go +++ b/precompile/allowlist/config.go @@ -11,7 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" ) -var ErrCannotAddManagersBeforeDUpgrade = fmt.Errorf("cannot add managers before DUpgrade") +var ErrCannotAddManagersBeforeDurango = fmt.Errorf("cannot add managers before Durango") // AllowListConfig specifies the initial set of addresses with Admin or Enabled roles. type AllowListConfig struct { @@ -86,10 +86,10 @@ func (c *AllowListConfig) Verify(chainConfig precompileconfig.ChainConfig, upgra } if len(c.ManagerAddresses) != 0 && upgrade.Timestamp() != nil { - // If the config attempts to activate a manager before the DUpgrade, fail verification + // If the config attempts to activate a manager before the Durango, fail verification timestamp := *upgrade.Timestamp() - if !chainConfig.IsDUpgrade(timestamp) { - return ErrCannotAddManagersBeforeDUpgrade + if !chainConfig.IsDurango(timestamp) { + return ErrCannotAddManagersBeforeDurango } } diff --git a/precompile/allowlist/role.go b/precompile/allowlist/role.go index 7a9143fbc2..4cd55dcd3d 100644 --- a/precompile/allowlist/role.go +++ b/precompile/allowlist/role.go @@ -13,7 +13,7 @@ import ( // 1. NoRole - this is equivalent to common.Hash{} and deletes the key from the DB when set // 2. EnabledRole - allowed to call the precompile // 3. Admin - allowed to both modify the allowlist and call the precompile -// 4. Manager - allowed to add and remove only enabled addresses and also call the precompile. (only after DUpgrade) +// 4. Manager - allowed to add and remove only enabled addresses and also call the precompile. (only after Durango) var ( NoRole = Role(common.BigToHash(common.Big0)) EnabledRole = Role(common.BigToHash(common.Big1)) diff --git a/precompile/allowlist/test_allowlist.go b/precompile/allowlist/test_allowlist.go index 7df800cc3e..b558aa872a 100644 --- a/precompile/allowlist/test_allowlist.go +++ b/precompile/allowlist/test_allowlist.go @@ -164,12 +164,12 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr ReadOnly: false, ExpectedErr: ErrCannotModifyAllowList.Error(), }, - "no role set manager pre-DUpgrade": { + "no role set manager pre-Durango": { Caller: TestNoRoleAddr, BeforeHook: SetDefaultRoles(contractAddress), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { @@ -187,7 +187,7 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr BeforeHook: SetDefaultRoles(contractAddress), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { @@ -200,12 +200,12 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr ReadOnly: false, ExpectedErr: ErrCannotModifyAllowList.Error(), }, - "enabled role set manager pre-DUpgrade": { + "enabled role set manager pre-Durango": { Caller: TestEnabledAddr, BeforeHook: SetDefaultRoles(contractAddress), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { @@ -223,7 +223,7 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr BeforeHook: SetDefaultRoles(contractAddress), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { @@ -247,7 +247,7 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr }, ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, SuppliedGas: 0, @@ -266,7 +266,7 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr ExpectedRes: []byte{}, ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, SuppliedGas: ModifyAllowListGasCost + AllowListEventGasCost, @@ -327,7 +327,7 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr BeforeHook: SetDefaultRoles(contractAddress), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { @@ -371,7 +371,7 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr BeforeHook: SetDefaultRoles(contractAddress), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { @@ -436,7 +436,7 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr BeforeHook: SetDefaultRoles(contractAddress), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { @@ -579,12 +579,12 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr require.Equal(t, EnabledRole, GetAllowListStatus(state, contractAddress, TestNoRoleAddr)) }, }, - "admin set admin pre-DUpgrade": { + "admin set admin pre-Durango": { Caller: TestAdminAddr, BeforeHook: SetDefaultRoles(contractAddress), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { @@ -602,12 +602,12 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr require.Len(t, data, 0) }, }, - "admin set enabled pre-DUpgrade": { + "admin set enabled pre-Durango": { Caller: TestAdminAddr, BeforeHook: SetDefaultRoles(contractAddress), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { @@ -625,12 +625,12 @@ func AllowListTests(t testing.TB, module modules.Module) map[string]testutils.Pr require.Len(t, data, 0) }, }, - "admin set no role pre-DUpgrade": { + "admin set no role pre-Durango": { Caller: TestAdminAddr, BeforeHook: SetDefaultRoles(contractAddress), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { diff --git a/precompile/allowlist/test_allowlist_config.go b/precompile/allowlist/test_allowlist_config.go index 9594d71e89..27c649f520 100644 --- a/precompile/allowlist/test_allowlist_config.go +++ b/precompile/allowlist/test_allowlist_config.go @@ -106,10 +106,10 @@ func AllowListConfigVerifyTests(t testing.TB, module modules.Module) map[string] }), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false) + config.EXPECT().IsDurango(gomock.Any()).Return(false) return config }(), - ExpectedError: ErrCannotAddManagersBeforeDUpgrade.Error(), + ExpectedError: ErrCannotAddManagersBeforeDurango.Error(), }, "nil member allow list config in allowlist": { Config: mkConfigWithAllowList(module, &AllowListConfig{ diff --git a/precompile/contract/utils.go b/precompile/contract/utils.go index f0a760dfbc..4b7eff94bb 100644 --- a/precompile/contract/utils.go +++ b/precompile/contract/utils.go @@ -59,6 +59,6 @@ func ParseABI(rawABI string) abi.ABI { return parsed } -func IsDUpgradeActivated(evm AccessibleState) bool { - return evm.GetChainConfig().IsDUpgrade(evm.GetBlockContext().Timestamp()) +func IsDurangoActivated(evm AccessibleState) bool { + return evm.GetChainConfig().IsDurango(evm.GetBlockContext().Timestamp()) } diff --git a/precompile/contracts/feemanager/contract.go b/precompile/contracts/feemanager/contract.go index 5451d3373d..2e7cad7ec5 100644 --- a/precompile/contracts/feemanager/contract.go +++ b/precompile/contracts/feemanager/contract.go @@ -178,7 +178,7 @@ func UnpackSetFeeConfigInput(input []byte, useStrictMode bool) (commontype.FeeCo // Initially we had this check to ensure that the input was the correct length. // However solidity does not always pack the input to the correct length, and allows // for extra padding bytes to be added to the end of the input. Therefore, we have removed - // this check with the DUpgrade. We still need to keep this check for backwards compatibility. + // this check with the Durango. We still need to keep this check for backwards compatibility. if useStrictMode && len(input) != feeConfigInputLen { return commontype.FeeConfig{}, fmt.Errorf("%w: %d", ErrInvalidLen, len(input)) } @@ -213,8 +213,8 @@ func setFeeConfig(accessibleState contract.AccessibleState, caller common.Addres return nil, remainingGas, vmerrs.ErrWriteProtection } - // do not use strict mode after DUpgrade - useStrictMode := !contract.IsDUpgradeActivated(accessibleState) + // do not use strict mode after Durango + useStrictMode := !contract.IsDurangoActivated(accessibleState) feeConfig, err := UnpackSetFeeConfigInput(input, useStrictMode) if err != nil { return nil, remainingGas, err @@ -227,7 +227,7 @@ func setFeeConfig(accessibleState contract.AccessibleState, caller common.Addres return nil, remainingGas, fmt.Errorf("%w: %s", ErrCannotChangeFee, caller) } - if contract.IsDUpgradeActivated(accessibleState) { + if contract.IsDurangoActivated(accessibleState) { if remainingGas, err = contract.DeductGas(remainingGas, FeeConfigChangedEventGasCost); err != nil { return nil, 0, err } diff --git a/precompile/contracts/feemanager/contract_test.go b/precompile/contracts/feemanager/contract_test.go index 5ad497342f..68801ff98b 100644 --- a/precompile/contracts/feemanager/contract_test.go +++ b/precompile/contracts/feemanager/contract_test.go @@ -301,7 +301,7 @@ var ( ReadOnly: false, ExpectedErr: vmerrs.ErrOutOfGas.Error(), }, - "set config with extra padded bytes should fail before DUpgrade": { + "set config with extra padded bytes should fail before Durango": { Caller: allowlist.TestEnabledAddr, BeforeHook: allowlist.SetDefaultRoles(Module.Address), InputFn: func(t testing.TB) []byte { @@ -313,7 +313,7 @@ var ( }, ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, SuppliedGas: SetFeeConfigGasCost, @@ -324,7 +324,7 @@ var ( mbc.EXPECT().Timestamp().Return(uint64(0)).AnyTimes() }, }, - "set config with extra padded bytes should succeed with DUpgrade": { + "set config with extra padded bytes should succeed with Durango": { Caller: allowlist.TestEnabledAddr, BeforeHook: allowlist.SetDefaultRoles(Module.Address), InputFn: func(t testing.TB) []byte { @@ -336,7 +336,7 @@ var ( }, ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, SuppliedGas: SetFeeConfigGasCost + FeeConfigChangedEventGasCost, @@ -357,13 +357,13 @@ var ( }, }, // from https://github.com/ava-labs/subnet-evm/issues/487 - "setFeeConfig regression test should fail before DUpgrade": { + "setFeeConfig regression test should fail before Durango": { Caller: allowlist.TestEnabledAddr, BeforeHook: allowlist.SetDefaultRoles(Module.Address), Input: common.Hex2Bytes(regressionBytes), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, SuppliedGas: SetFeeConfigGasCost, @@ -374,13 +374,13 @@ var ( mbc.EXPECT().Timestamp().Return(uint64(0)).AnyTimes() }, }, - "setFeeConfig regression test should succeed after DUpgrade": { + "setFeeConfig regression test should succeed after Durango": { Caller: allowlist.TestEnabledAddr, BeforeHook: allowlist.SetDefaultRoles(Module.Address), Input: common.Hex2Bytes(regressionBytes), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, SuppliedGas: SetFeeConfigGasCost + FeeConfigChangedEventGasCost, @@ -400,12 +400,12 @@ var ( assertFeeEvent(t, logsTopics, logsData, allowlist.TestEnabledAddr, zeroFeeConfig, regressionFeeConfig) }, }, - "set config should not emit event before DUpgrade": { + "set config should not emit event before Durango": { Caller: allowlist.TestEnabledAddr, BeforeHook: allowlist.SetDefaultRoles(Module.Address), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { diff --git a/precompile/contracts/nativeminter/config_test.go b/precompile/contracts/nativeminter/config_test.go index 91a6784e0b..ca0a63ce4a 100644 --- a/precompile/contracts/nativeminter/config_test.go +++ b/precompile/contracts/nativeminter/config_test.go @@ -24,7 +24,7 @@ func TestVerify(t *testing.T) { Config: NewConfig(utils.NewUint64(3), admins, enableds, managers, nil), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }(), ExpectedError: "", diff --git a/precompile/contracts/nativeminter/contract.go b/precompile/contracts/nativeminter/contract.go index 99f83209e1..2e578fe2cc 100644 --- a/precompile/contracts/nativeminter/contract.go +++ b/precompile/contracts/nativeminter/contract.go @@ -63,7 +63,7 @@ func UnpackMintNativeCoinInput(input []byte, useStrictMode bool) (common.Address // Initially we had this check to ensure that the input was the correct length. // However solidity does not always pack the input to the correct length, and allows // for extra padding bytes to be added to the end of the input. Therefore, we have removed - // this check with the DUpgrade. We still need to keep this check for backwards compatibility. + // this check with Durango. We still need to keep this check for backwards compatibility. if useStrictMode && len(input) != mintInputLen { return common.Address{}, nil, fmt.Errorf("%w: %d", ErrInvalidLen, len(input)) } @@ -84,7 +84,7 @@ func mintNativeCoin(accessibleState contract.AccessibleState, caller common.Addr return nil, remainingGas, vmerrs.ErrWriteProtection } - useStrictMode := !contract.IsDUpgradeActivated(accessibleState) + useStrictMode := !contract.IsDurangoActivated(accessibleState) to, amount, err := UnpackMintNativeCoinInput(input, useStrictMode) if err != nil { return nil, remainingGas, err @@ -97,7 +97,7 @@ func mintNativeCoin(accessibleState contract.AccessibleState, caller common.Addr return nil, remainingGas, fmt.Errorf("%w: %s", ErrCannotMint, caller) } - if contract.IsDUpgradeActivated(accessibleState) { + if contract.IsDurangoActivated(accessibleState) { if remainingGas, err = contract.DeductGas(remainingGas, NativeCoinMintedEventGasCost); err != nil { return nil, 0, err } diff --git a/precompile/contracts/nativeminter/contract_test.go b/precompile/contracts/nativeminter/contract_test.go index 4200350490..47a754e5a3 100644 --- a/precompile/contracts/nativeminter/contract_test.go +++ b/precompile/contracts/nativeminter/contract_test.go @@ -174,12 +174,12 @@ var ( ReadOnly: false, ExpectedErr: vmerrs.ErrOutOfGas.Error(), }, - "mint doesn't log pre-DUpgrade": { + "mint doesn't log pre-Durango": { Caller: allowlist.TestEnabledAddr, BeforeHook: allowlist.SetDefaultRoles(Module.Address), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { @@ -197,12 +197,12 @@ var ( require.Len(t, logsData, 0) }, }, - "mint with extra padded bytes should fail pre-DUpgrade": { + "mint with extra padded bytes should fail pre-Durango": { Caller: allowlist.TestEnabledAddr, BeforeHook: allowlist.SetDefaultRoles(Module.Address), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(false).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { @@ -218,12 +218,12 @@ var ( ReadOnly: false, ExpectedErr: ErrInvalidLen.Error(), }, - "mint with extra padded bytes should succeed with DUpgrade": { + "mint with extra padded bytes should succeed with Durango": { Caller: allowlist.TestEnabledAddr, BeforeHook: allowlist.SetDefaultRoles(Module.Address), ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(ctrl) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(true).AnyTimes() + config.EXPECT().IsDurango(gomock.Any()).Return(true).AnyTimes() return config }, InputFn: func(t testing.TB) []byte { diff --git a/precompile/contracts/rewardmanager/contract.go b/precompile/contracts/rewardmanager/contract.go index 9a17ff7d9d..4a70a56eef 100644 --- a/precompile/contracts/rewardmanager/contract.go +++ b/precompile/contracts/rewardmanager/contract.go @@ -97,7 +97,7 @@ func allowFeeRecipients(accessibleState contract.AccessibleState, caller common. } // allow list code ends here. - if contract.IsDUpgradeActivated(accessibleState) { + if contract.IsDurangoActivated(accessibleState) { if remainingGas, err = contract.DeductGas(remainingGas, FeeRecipientsAllowedEventGasCost); err != nil { return nil, 0, err } @@ -200,8 +200,8 @@ func setRewardAddress(accessibleState contract.AccessibleState, caller common.Ad } // attempts to unpack [input] into the arguments to the SetRewardAddressInput. // Assumes that [input] does not include selector - // do not use strict mode after DUpgrade - useStrictMode := !contract.IsDUpgradeActivated(accessibleState) + // do not use strict mode after Durango + useStrictMode := !contract.IsDurangoActivated(accessibleState) rewardAddress, err := UnpackSetRewardAddressInput(input, useStrictMode) if err != nil { return nil, remainingGas, err @@ -224,7 +224,7 @@ func setRewardAddress(accessibleState contract.AccessibleState, caller common.Ad } // Add a log to be handled if this action is finalized. - if contract.IsDUpgradeActivated(accessibleState) { + if contract.IsDurangoActivated(accessibleState) { if remainingGas, err = contract.DeductGas(remainingGas, RewardAddressChangedEventGasCost); err != nil { return nil, 0, err } @@ -288,7 +288,7 @@ func disableRewards(accessibleState contract.AccessibleState, caller common.Addr } // allow list code ends here. - if contract.IsDUpgradeActivated(accessibleState) { + if contract.IsDurangoActivated(accessibleState) { if remainingGas, err = contract.DeductGas(remainingGas, RewardsDisabledEventGasCost); err != nil { return nil, 0, err } diff --git a/precompile/contracts/rewardmanager/contract_test.go b/precompile/contracts/rewardmanager/contract_test.go index d954a1a478..983ea10301 100644 --- a/precompile/contracts/rewardmanager/contract_test.go +++ b/precompile/contracts/rewardmanager/contract_test.go @@ -82,7 +82,7 @@ var ( assertFeeRecipientsAllowed(t, logsTopics, logsData, allowlist.TestEnabledAddr) }, }, - "set fee recipients should not emit events pre-DUpgrade": { + "set fee recipients should not emit events pre-Durango": { Caller: allowlist.TestEnabledAddr, BeforeHook: allowlist.SetDefaultRoles(Module.Address), InputFn: func(t testing.TB) []byte { @@ -95,7 +95,7 @@ var ( mockChainConfig := precompileconfig.NewMockChainConfig(ctrl) mockChainConfig.EXPECT().GetFeeConfig().AnyTimes().Return(commontype.ValidTestFeeConfig) mockChainConfig.EXPECT().AllowedFeeRecipients().AnyTimes().Return(false) - mockChainConfig.EXPECT().IsDUpgrade(gomock.Any()).AnyTimes().Return(false) + mockChainConfig.EXPECT().IsDurango(gomock.Any()).AnyTimes().Return(false) return mockChainConfig }, SuppliedGas: AllowFeeRecipientsGasCost, @@ -170,7 +170,7 @@ var ( assertRewardAddressChanged(t, logsTopics, logsData, allowlist.TestManagerAddr, common.Address{}, rewardAddress) }, }, - "change reward address should not emit events pre-DUpgrade": { + "change reward address should not emit events pre-Durango": { Caller: allowlist.TestManagerAddr, BeforeHook: allowlist.SetDefaultRoles(Module.Address), InputFn: func(t testing.TB) []byte { @@ -183,7 +183,7 @@ var ( mockChainConfig := precompileconfig.NewMockChainConfig(ctrl) mockChainConfig.EXPECT().GetFeeConfig().AnyTimes().Return(commontype.ValidTestFeeConfig) mockChainConfig.EXPECT().AllowedFeeRecipients().AnyTimes().Return(false) - mockChainConfig.EXPECT().IsDUpgrade(gomock.Any()).AnyTimes().Return(false) + mockChainConfig.EXPECT().IsDurango(gomock.Any()).AnyTimes().Return(false) return mockChainConfig }, SuppliedGas: SetRewardAddressGasCost, @@ -238,7 +238,7 @@ var ( assertRewardsDisabled(t, logsTopics, logsData, allowlist.TestEnabledAddr) }, }, - "disable rewards should not emit event pre-DUpgrade": { + "disable rewards should not emit event pre-Durango": { Caller: allowlist.TestManagerAddr, BeforeHook: allowlist.SetDefaultRoles(Module.Address), InputFn: func(t testing.TB) []byte { @@ -251,7 +251,7 @@ var ( mockChainConfig := precompileconfig.NewMockChainConfig(ctrl) mockChainConfig.EXPECT().GetFeeConfig().AnyTimes().Return(commontype.ValidTestFeeConfig) mockChainConfig.EXPECT().AllowedFeeRecipients().AnyTimes().Return(false) - mockChainConfig.EXPECT().IsDUpgrade(gomock.Any()).AnyTimes().Return(false) + mockChainConfig.EXPECT().IsDurango(gomock.Any()).AnyTimes().Return(false) return mockChainConfig }, SuppliedGas: SetRewardAddressGasCost, diff --git a/precompile/precompileconfig/config.go b/precompile/precompileconfig/config.go index be23f3570a..05d204de45 100644 --- a/precompile/precompileconfig/config.go +++ b/precompile/precompileconfig/config.go @@ -88,6 +88,6 @@ type ChainConfig interface { GetFeeConfig() commontype.FeeConfig // AllowedFeeRecipients returns true if fee recipients are allowed in the genesis. AllowedFeeRecipients() bool - // IsDUpgrade returns true if the time is after the DUpgrade. - IsDUpgrade(time uint64) bool + // IsDurango returns true if the time is after Durango. + IsDurango(time uint64) bool } diff --git a/precompile/precompileconfig/mocks.go b/precompile/precompileconfig/mocks.go index 6b19ce20b2..8d425daefa 100644 --- a/precompile/precompileconfig/mocks.go +++ b/precompile/precompileconfig/mocks.go @@ -208,18 +208,18 @@ func (mr *MockChainConfigMockRecorder) GetFeeConfig() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFeeConfig", reflect.TypeOf((*MockChainConfig)(nil).GetFeeConfig)) } -// IsDUpgrade mocks base method. -func (m *MockChainConfig) IsDUpgrade(arg0 uint64) bool { +// IsDurango mocks base method. +func (m *MockChainConfig) IsDurango(arg0 uint64) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsDUpgrade", arg0) + ret := m.ctrl.Call(m, "IsDurango", arg0) ret0, _ := ret[0].(bool) return ret0 } -// IsDUpgrade indicates an expected call of IsDUpgrade. -func (mr *MockChainConfigMockRecorder) IsDUpgrade(arg0 interface{}) *gomock.Call { +// IsDurango indicates an expected call of IsDurango. +func (mr *MockChainConfigMockRecorder) IsDurango(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDUpgrade", reflect.TypeOf((*MockChainConfig)(nil).IsDUpgrade), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDurango", reflect.TypeOf((*MockChainConfig)(nil).IsDurango), arg0) } // MockAccepter is a mock of Accepter interface. diff --git a/precompile/testutils/test_config.go b/precompile/testutils/test_config.go index 2ecf8a1e25..101d15113d 100644 --- a/precompile/testutils/test_config.go +++ b/precompile/testutils/test_config.go @@ -38,7 +38,7 @@ func RunVerifyTests(t *testing.T, tests map[string]ConfigVerifyTest) { mockChainConfig := precompileconfig.NewMockChainConfig(ctrl) mockChainConfig.EXPECT().GetFeeConfig().AnyTimes().Return(commontype.ValidTestFeeConfig) mockChainConfig.EXPECT().AllowedFeeRecipients().AnyTimes().Return(false) - mockChainConfig.EXPECT().IsDUpgrade(gomock.Any()).AnyTimes().Return(true) + mockChainConfig.EXPECT().IsDurango(gomock.Any()).AnyTimes().Return(true) chainConfig = mockChainConfig } err := test.Config.Verify(chainConfig) diff --git a/precompile/testutils/test_precompile.go b/precompile/testutils/test_precompile.go index 446ebd7179..c1a1eac813 100644 --- a/precompile/testutils/test_precompile.go +++ b/precompile/testutils/test_precompile.go @@ -95,7 +95,7 @@ func (test PrecompileTest) setup(t testing.TB, module modules.Module, state cont mockChainConfig := precompileconfig.NewMockChainConfig(ctrl) mockChainConfig.EXPECT().GetFeeConfig().AnyTimes().Return(commontype.ValidTestFeeConfig) mockChainConfig.EXPECT().AllowedFeeRecipients().AnyTimes().Return(false) - mockChainConfig.EXPECT().IsDUpgrade(gomock.Any()).AnyTimes().Return(true) + mockChainConfig.EXPECT().IsDurango(gomock.Any()).AnyTimes().Return(true) return mockChainConfig } } diff --git a/predicate/predicate_bytes.go b/predicate/predicate_bytes.go index 627adb2bb8..c31cc1f507 100644 --- a/predicate/predicate_bytes.go +++ b/predicate/predicate_bytes.go @@ -54,8 +54,8 @@ func UnpackPredicate(paddedPredicate []byte) ([]byte, error) { // GetPredicateResultBytes returns the predicate result bytes from the extra data and // true iff the predicate results bytes have non-zero length. func GetPredicateResultBytes(extraData []byte) ([]byte, bool) { - // Prior to the DUpgrade, the VM enforces the extra data is smaller than or equal to this size. - // After the DUpgrade, the VM pre-verifies the extra data past the dynamic fee rollup window is + // Prior to Durango, the VM enforces the extra data is smaller than or equal to this size. + // After Durango, the VM pre-verifies the extra data past the dynamic fee rollup window is // valid. if len(extraData) <= params.DynamicFeeExtraDataSize { return nil, false diff --git a/predicate/predicate_bytes_test.go b/predicate/predicate_bytes_test.go index d712fd11d5..af19a1ac96 100644 --- a/predicate/predicate_bytes_test.go +++ b/predicate/predicate_bytes_test.go @@ -56,11 +56,11 @@ func TestPredicateResultsBytes(t *testing.T) { _, ok := GetPredicateResultBytes(dataTooShort) require.False(ok) - preDUPgradeData := utils.RandomBytes(params.DynamicFeeExtraDataSize) - _, ok = GetPredicateResultBytes(preDUPgradeData) + preDurangoData := utils.RandomBytes(params.DynamicFeeExtraDataSize) + _, ok = GetPredicateResultBytes(preDurangoData) require.False(ok) - postDUpgradeData := utils.RandomBytes(params.DynamicFeeExtraDataSize + 2) - resultBytes, ok := GetPredicateResultBytes(postDUpgradeData) + postDurangoData := utils.RandomBytes(params.DynamicFeeExtraDataSize + 2) + resultBytes, ok := GetPredicateResultBytes(postDurangoData) require.True(ok) - require.Equal(resultBytes, postDUpgradeData[params.DynamicFeeExtraDataSize:]) + require.Equal(resultBytes, postDurangoData[params.DynamicFeeExtraDataSize:]) } diff --git a/tests/init.go b/tests/init.go index 7732bf9ea8..69ed834d6e 100644 --- a/tests/init.go +++ b/tests/init.go @@ -180,7 +180,7 @@ var Forks = map[string]*params.ChainConfig{ SubnetEVMTimestamp: utils.NewUint64(0), }, }, - "DUpgrade": { + "Durango": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), EIP150Block: big.NewInt(0), @@ -192,7 +192,7 @@ var Forks = map[string]*params.ChainConfig{ IstanbulBlock: big.NewInt(0), MandatoryNetworkUpgrades: params.MandatoryNetworkUpgrades{ SubnetEVMTimestamp: utils.NewUint64(0), - DUpgradeTimestamp: utils.NewUint64(0), + DurangoTimestamp: utils.NewUint64(0), }, }, } diff --git a/x/warp/config.go b/x/warp/config.go index cf70bbc9e2..d26c9a30db 100644 --- a/x/warp/config.go +++ b/x/warp/config.go @@ -34,7 +34,7 @@ var ( errInvalidAddressedPayload = errors.New("cannot unpack addressed payload") errInvalidBlockHashPayload = errors.New("cannot unpack block hash payload") errCannotGetNumSigners = errors.New("cannot fetch num signers from warp message") - errWarpCannotBeActivated = errors.New("warp cannot be activated before DUpgrade") + errWarpCannotBeActivated = errors.New("warp cannot be activated before Durango") errFailedVerification = errors.New("cannot verify warp signature") ) @@ -78,9 +78,9 @@ func (*Config) Key() string { return ConfigKey } // Verify tries to verify Config and returns an error accordingly. func (c *Config) Verify(chainConfig precompileconfig.ChainConfig) error { if c.Timestamp() != nil { - // If Warp attempts to activate before the DUpgrade, fail verification + // If Warp attempts to activate before Durango, fail verification timestamp := *c.Timestamp() - if !chainConfig.IsDUpgrade(timestamp) { + if !chainConfig.IsDurango(timestamp) { return errWarpCannotBeActivated } } diff --git a/x/warp/config_test.go b/x/warp/config_test.go index 89dedf55af..2372765871 100644 --- a/x/warp/config_test.go +++ b/x/warp/config_test.go @@ -33,11 +33,11 @@ func TestVerify(t *testing.T) { "valid quorum numerator 1 more than minimum": { Config: NewConfig(utils.NewUint64(3), params.WarpQuorumNumeratorMinimum+1), }, - "invalid cannot activated before DUpgrade activation": { + "invalid cannot activated before Durango activation": { Config: NewConfig(utils.NewUint64(3), 0), ChainConfig: func() precompileconfig.ChainConfig { config := precompileconfig.NewMockChainConfig(gomock.NewController(t)) - config.EXPECT().IsDUpgrade(gomock.Any()).Return(false) + config.EXPECT().IsDurango(gomock.Any()).Return(false) return config }(), ExpectedError: errWarpCannotBeActivated.Error(), diff --git a/x/warp/contract.go b/x/warp/contract.go index 8701b16015..b82c3a9065 100644 --- a/x/warp/contract.go +++ b/x/warp/contract.go @@ -109,8 +109,8 @@ func getBlockchainID(accessibleState contract.AccessibleState, caller common.Add // UnpackGetVerifiedWarpBlockHashInput attempts to unpack [input] into the uint32 type argument // assumes that [input] does not include selector (omits first 4 func signature bytes) func UnpackGetVerifiedWarpBlockHashInput(input []byte) (uint32, error) { - // We don't use strict mode here because it was disabled with the DUpgrade. - // Since Warp will be deployed after the DUpgrade, we don't need to use strict mode + // We don't use strict mode here because it was disabled with Durango. + // Since Warp will be deployed after Durango, we don't need to use strict mode res, err := WarpABI.UnpackInput("getVerifiedWarpBlockHash", input, false) if err != nil { return 0, err @@ -151,8 +151,8 @@ func getVerifiedWarpBlockHash(accessibleState contract.AccessibleState, caller c // UnpackGetVerifiedWarpMessageInput attempts to unpack [input] into the uint32 type argument // assumes that [input] does not include selector (omits first 4 func signature bytes) func UnpackGetVerifiedWarpMessageInput(input []byte) (uint32, error) { - // We don't use strict mode here because it was disabled with the DUpgrade. - // Since Warp will be deployed after the DUpgrade, we don't need to use strict mode. + // We don't use strict mode here because it was disabled with Durango. + // Since Warp will be deployed after Durango, we don't need to use strict mode. res, err := WarpABI.UnpackInput("getVerifiedWarpMessage", input, false) if err != nil { return 0, err @@ -195,8 +195,8 @@ func getVerifiedWarpMessage(accessibleState contract.AccessibleState, caller com // UnpackSendWarpMessageInput attempts to unpack [input] as []byte // assumes that [input] does not include selector (omits first 4 func signature bytes) func UnpackSendWarpMessageInput(input []byte) ([]byte, error) { - // We don't use strict mode here because it was disabled with the DUpgrade. - // Since Warp will be deployed after the DUpgrade, we don't need to use strict mode. + // We don't use strict mode here because it was disabled with Durango. + // Since Warp will be deployed after Durango, we don't need to use strict mode. res, err := WarpABI.UnpackInput("sendWarpMessage", input, false) if err != nil { return []byte{}, err From 84e86b4e284c898f9dff8043a93d181638f72d87 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Fri, 5 Jan 2024 01:08:03 +0300 Subject: [PATCH 3/3] move warp to precompiles package (#1034) * move warp to precompiles package * move warp params to warp package * use log gas cost from contract package --------- Co-authored-by: Darioush Jalali --- params/avalanche_params.go | 10 --------- plugin/evm/vm_warp_test.go | 16 +++++++------- {x => precompile/contracts}/warp/README.md | 0 {x => precompile/contracts}/warp/config.go | 21 ++++++++++++------- .../contracts}/warp/config_test.go | 21 +++++++++---------- {x => precompile/contracts}/warp/contract.abi | 0 {x => precompile/contracts}/warp/contract.go | 5 ++--- .../contracts}/warp/contract_test.go | 0 .../contracts}/warp/contract_warp_handler.go | 0 {x => precompile/contracts}/warp/module.go | 0 .../contracts}/warp/predicate_test.go | 21 +++++++++---------- .../warp/signature_verification_test.go | 0 precompile/registry/registry.go | 2 +- tests/warp/warp_test.go | 8 +++---- warp/aggregator/aggregator.go | 5 ++--- 15 files changed, 50 insertions(+), 59 deletions(-) delete mode 100644 params/avalanche_params.go rename {x => precompile/contracts}/warp/README.md (100%) rename {x => precompile/contracts}/warp/config.go (93%) rename {x => precompile/contracts}/warp/config_test.go (70%) rename {x => precompile/contracts}/warp/contract.abi (100%) rename {x => precompile/contracts}/warp/contract.go (98%) rename {x => precompile/contracts}/warp/contract_test.go (100%) rename {x => precompile/contracts}/warp/contract_warp_handler.go (100%) rename {x => precompile/contracts}/warp/module.go (100%) rename {x => precompile/contracts}/warp/predicate_test.go (97%) rename {x => precompile/contracts}/warp/signature_verification_test.go (100%) diff --git a/params/avalanche_params.go b/params/avalanche_params.go deleted file mode 100644 index fbda5b01c0..0000000000 --- a/params/avalanche_params.go +++ /dev/null @@ -1,10 +0,0 @@ -// (c) 2019-2020, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package params - -const ( - WarpDefaultQuorumNumerator uint64 = 67 - WarpQuorumNumeratorMinimum uint64 = 33 - WarpQuorumDenominator uint64 = 100 -) diff --git a/plugin/evm/vm_warp_test.go b/plugin/evm/vm_warp_test.go index e88506b917..2a212fef3c 100644 --- a/plugin/evm/vm_warp_test.go +++ b/plugin/evm/vm_warp_test.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/snow/validators" - "github.com/ava-labs/avalanchego/utils" + avagoUtils "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/vms/components/chain" @@ -29,9 +29,9 @@ import ( "github.com/ava-labs/subnet-evm/params" "github.com/ava-labs/subnet-evm/plugin/evm/message" "github.com/ava-labs/subnet-evm/precompile/contract" + "github.com/ava-labs/subnet-evm/precompile/contracts/warp" "github.com/ava-labs/subnet-evm/predicate" - subnetEVMUtils "github.com/ava-labs/subnet-evm/utils" - "github.com/ava-labs/subnet-evm/x/warp" + "github.com/ava-labs/subnet-evm/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" @@ -49,7 +49,7 @@ func TestSendWarpMessage(t *testing.T) { genesis := &core.Genesis{} require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDurango))) genesis.Config.GenesisPrecompiles = params.Precompiles{ - warp.ConfigKey: warp.NewDefaultConfig(subnetEVMUtils.NewUint64(0)), + warp.ConfigKey: warp.NewDefaultConfig(utils.NewUint64(0)), } genesisJSON, err := genesis.MarshalJSON() require.NoError(err) @@ -63,7 +63,7 @@ func TestSendWarpMessage(t *testing.T) { logsSub := vm.eth.APIBackend.SubscribeAcceptedLogsEvent(acceptedLogsChan) defer logsSub.Unsubscribe() - payloadData := utils.RandomBytes(100) + payloadData := avagoUtils.RandomBytes(100) warpSendMessageInput, err := warp.PackSendWarpMessage(payloadData) require.NoError(err) @@ -249,7 +249,7 @@ func testWarpVMTransaction(t *testing.T, unsignedMessage *avalancheWarp.Unsigned genesis := &core.Genesis{} require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDurango))) genesis.Config.GenesisPrecompiles = params.Precompiles{ - warp.ConfigKey: warp.NewDefaultConfig(subnetEVMUtils.NewUint64(0)), + warp.ConfigKey: warp.NewDefaultConfig(utils.NewUint64(0)), } genesisJSON, err := genesis.MarshalJSON() require.NoError(err) @@ -406,7 +406,7 @@ func TestReceiveWarpMessage(t *testing.T) { genesis := &core.Genesis{} require.NoError(genesis.UnmarshalJSON([]byte(genesisJSONDurango))) genesis.Config.GenesisPrecompiles = params.Precompiles{ - warp.ConfigKey: warp.NewDefaultConfig(subnetEVMUtils.NewUint64(0)), + warp.ConfigKey: warp.NewDefaultConfig(utils.NewUint64(0)), } genesisJSON, err := genesis.MarshalJSON() require.NoError(err) @@ -420,7 +420,7 @@ func TestReceiveWarpMessage(t *testing.T) { logsSub := vm.eth.APIBackend.SubscribeAcceptedLogsEvent(acceptedLogsChan) defer logsSub.Unsubscribe() - payloadData := utils.RandomBytes(100) + payloadData := avagoUtils.RandomBytes(100) addressedPayload, err := payload.NewAddressedCall( testEthAddrs[0].Bytes(), diff --git a/x/warp/README.md b/precompile/contracts/warp/README.md similarity index 100% rename from x/warp/README.md rename to precompile/contracts/warp/README.md diff --git a/x/warp/config.go b/precompile/contracts/warp/config.go similarity index 93% rename from x/warp/config.go rename to precompile/contracts/warp/config.go index d26c9a30db..5275671e6a 100644 --- a/x/warp/config.go +++ b/precompile/contracts/warp/config.go @@ -10,7 +10,6 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/warp" "github.com/ava-labs/avalanchego/vms/platformvm/warp/payload" - "github.com/ava-labs/subnet-evm/params" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/predicate" warpValidators "github.com/ava-labs/subnet-evm/warp/validators" @@ -19,6 +18,12 @@ import ( "github.com/ethereum/go-ethereum/log" ) +const ( + WarpDefaultQuorumNumerator uint64 = 67 + WarpQuorumNumeratorMinimum uint64 = 33 + WarpQuorumDenominator uint64 = 100 +) + var ( _ precompileconfig.Config = &Config{} _ precompileconfig.Predicater = &Config{} @@ -85,12 +90,12 @@ func (c *Config) Verify(chainConfig precompileconfig.ChainConfig) error { } } - if c.QuorumNumerator > params.WarpQuorumDenominator { - return fmt.Errorf("cannot specify quorum numerator (%d) > quorum denominator (%d)", c.QuorumNumerator, params.WarpQuorumDenominator) + if c.QuorumNumerator > WarpQuorumDenominator { + return fmt.Errorf("cannot specify quorum numerator (%d) > quorum denominator (%d)", c.QuorumNumerator, WarpQuorumDenominator) } // If a non-default quorum numerator is specified and it is less than the minimum, return an error - if c.QuorumNumerator != 0 && c.QuorumNumerator < params.WarpQuorumNumeratorMinimum { - return fmt.Errorf("cannot specify quorum numerator (%d) < min quorum numerator (%d)", c.QuorumNumerator, params.WarpQuorumNumeratorMinimum) + if c.QuorumNumerator != 0 && c.QuorumNumerator < WarpQuorumNumeratorMinimum { + return fmt.Errorf("cannot specify quorum numerator (%d) < min quorum numerator (%d)", c.QuorumNumerator, WarpQuorumNumeratorMinimum) } return nil } @@ -187,12 +192,12 @@ func (c *Config) VerifyPredicate(predicateContext *precompileconfig.PredicateCon return fmt.Errorf("%w: %w", errCannotParseWarpMsg, err) } - quorumNumerator := params.WarpDefaultQuorumNumerator + quorumNumerator := WarpDefaultQuorumNumerator if c.QuorumNumerator != 0 { quorumNumerator = c.QuorumNumerator } - log.Debug("verifying warp message", "warpMsg", warpMsg, "quorumNum", quorumNumerator, "quorumDenom", params.WarpQuorumDenominator) + log.Debug("verifying warp message", "warpMsg", warpMsg, "quorumNum", quorumNumerator, "quorumDenom", WarpQuorumDenominator) err = warpMsg.Signature.Verify( context.Background(), &warpMsg.UnsignedMessage, @@ -200,7 +205,7 @@ func (c *Config) VerifyPredicate(predicateContext *precompileconfig.PredicateCon warpValidators.NewState(predicateContext.SnowCtx), // Wrap validators.State on the chain snow context to special case the Primary Network predicateContext.ProposerVMBlockCtx.PChainHeight, quorumNumerator, - params.WarpQuorumDenominator, + WarpQuorumDenominator, ) if err != nil { diff --git a/x/warp/config_test.go b/precompile/contracts/warp/config_test.go similarity index 70% rename from x/warp/config_test.go rename to precompile/contracts/warp/config_test.go index 2372765871..dc52f3a5df 100644 --- a/x/warp/config_test.go +++ b/precompile/contracts/warp/config_test.go @@ -7,7 +7,6 @@ import ( "fmt" "testing" - "github.com/ava-labs/subnet-evm/params" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/testutils" "github.com/ava-labs/subnet-evm/utils" @@ -17,21 +16,21 @@ import ( func TestVerify(t *testing.T) { tests := map[string]testutils.ConfigVerifyTest{ "quorum numerator less than minimum": { - Config: NewConfig(utils.NewUint64(3), params.WarpQuorumNumeratorMinimum-1), - ExpectedError: fmt.Sprintf("cannot specify quorum numerator (%d) < min quorum numerator (%d)", params.WarpQuorumNumeratorMinimum-1, params.WarpQuorumNumeratorMinimum), + Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum-1), + ExpectedError: fmt.Sprintf("cannot specify quorum numerator (%d) < min quorum numerator (%d)", WarpQuorumNumeratorMinimum-1, WarpQuorumNumeratorMinimum), }, "quorum numerator greater than quorum denominator": { - Config: NewConfig(utils.NewUint64(3), params.WarpQuorumDenominator+1), - ExpectedError: fmt.Sprintf("cannot specify quorum numerator (%d) > quorum denominator (%d)", params.WarpQuorumDenominator+1, params.WarpQuorumDenominator), + Config: NewConfig(utils.NewUint64(3), WarpQuorumDenominator+1), + ExpectedError: fmt.Sprintf("cannot specify quorum numerator (%d) > quorum denominator (%d)", WarpQuorumDenominator+1, WarpQuorumDenominator), }, "default quorum numerator": { Config: NewDefaultConfig(utils.NewUint64(3)), }, "valid quorum numerator 1 less than denominator": { - Config: NewConfig(utils.NewUint64(3), params.WarpQuorumDenominator-1), + Config: NewConfig(utils.NewUint64(3), WarpQuorumDenominator-1), }, "valid quorum numerator 1 more than minimum": { - Config: NewConfig(utils.NewUint64(3), params.WarpQuorumNumeratorMinimum+1), + Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+1), }, "invalid cannot activated before Durango activation": { Config: NewConfig(utils.NewUint64(3), 0), @@ -67,8 +66,8 @@ func TestEqualWarpConfig(t *testing.T) { }, "different quorum numerator": { - Config: NewConfig(utils.NewUint64(3), params.WarpQuorumNumeratorMinimum+1), - Other: NewConfig(utils.NewUint64(3), params.WarpQuorumNumeratorMinimum+2), + Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+1), + Other: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+2), Expected: false, }, @@ -79,8 +78,8 @@ func TestEqualWarpConfig(t *testing.T) { }, "same non-default config": { - Config: NewConfig(utils.NewUint64(3), params.WarpQuorumNumeratorMinimum+5), - Other: NewConfig(utils.NewUint64(3), params.WarpQuorumNumeratorMinimum+5), + Config: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+5), + Other: NewConfig(utils.NewUint64(3), WarpQuorumNumeratorMinimum+5), Expected: true, }, } diff --git a/x/warp/contract.abi b/precompile/contracts/warp/contract.abi similarity index 100% rename from x/warp/contract.abi rename to precompile/contracts/warp/contract.abi diff --git a/x/warp/contract.go b/precompile/contracts/warp/contract.go similarity index 98% rename from x/warp/contract.go rename to precompile/contracts/warp/contract.go index b82c3a9065..96fcc48fbc 100644 --- a/x/warp/contract.go +++ b/precompile/contracts/warp/contract.go @@ -10,7 +10,6 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/warp" "github.com/ava-labs/avalanchego/vms/platformvm/warp/payload" "github.com/ava-labs/subnet-evm/accounts/abi" - "github.com/ava-labs/subnet-evm/params" "github.com/ava-labs/subnet-evm/precompile/contract" "github.com/ava-labs/subnet-evm/vmerrs" @@ -28,9 +27,9 @@ const ( // Note: using trie write for the gas cost results in a conservative overestimate since the message is stored in a // flat database that can be cleaned up after a period of time instead of the EVM trie. - SendWarpMessageGasCost uint64 = params.LogGas + 3*params.LogTopicGas + AddWarpMessageGasCost + contract.WriteGasCostPerSlot + SendWarpMessageGasCost uint64 = contract.LogGas + 3*contract.LogTopicGas + AddWarpMessageGasCost + contract.WriteGasCostPerSlot // SendWarpMessageGasCostPerByte cost accounts for producing a signed message of a given size - SendWarpMessageGasCostPerByte uint64 = params.LogDataGas + SendWarpMessageGasCostPerByte uint64 = contract.LogDataGas GasCostPerWarpSigner uint64 = 500 GasCostPerWarpMessageBytes uint64 = 100 diff --git a/x/warp/contract_test.go b/precompile/contracts/warp/contract_test.go similarity index 100% rename from x/warp/contract_test.go rename to precompile/contracts/warp/contract_test.go diff --git a/x/warp/contract_warp_handler.go b/precompile/contracts/warp/contract_warp_handler.go similarity index 100% rename from x/warp/contract_warp_handler.go rename to precompile/contracts/warp/contract_warp_handler.go diff --git a/x/warp/module.go b/precompile/contracts/warp/module.go similarity index 100% rename from x/warp/module.go rename to precompile/contracts/warp/module.go diff --git a/x/warp/predicate_test.go b/precompile/contracts/warp/predicate_test.go similarity index 97% rename from x/warp/predicate_test.go rename to precompile/contracts/warp/predicate_test.go index f72782cede..d2542976ff 100644 --- a/x/warp/predicate_test.go +++ b/precompile/contracts/warp/predicate_test.go @@ -19,7 +19,6 @@ import ( "github.com/ava-labs/avalanchego/utils/set" avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp" "github.com/ava-labs/avalanchego/vms/platformvm/warp/payload" - "github.com/ava-labs/subnet-evm/params" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/testutils" "github.com/ava-labs/subnet-evm/predicate" @@ -457,17 +456,17 @@ func TestWarpSignatureWeightsDefaultQuorumNumerator(t *testing.T) { tests := make(map[string]testutils.PredicateTest) for _, numSigners := range []int{ 1, - int(params.WarpDefaultQuorumNumerator) - 1, - int(params.WarpDefaultQuorumNumerator), - int(params.WarpDefaultQuorumNumerator) + 1, - int(params.WarpQuorumDenominator) - 1, - int(params.WarpQuorumDenominator), - int(params.WarpQuorumDenominator) + 1, + int(WarpDefaultQuorumNumerator) - 1, + int(WarpDefaultQuorumNumerator), + int(WarpDefaultQuorumNumerator) + 1, + int(WarpQuorumDenominator) - 1, + int(WarpQuorumDenominator), + int(WarpQuorumDenominator) + 1, } { predicateBytes := createPredicate(numSigners) // The predicate is valid iff the number of signers is >= the required numerator and does not exceed the denominator. var expectedErr error - if numSigners >= int(params.WarpDefaultQuorumNumerator) && numSigners <= int(params.WarpQuorumDenominator) { + if numSigners >= int(WarpDefaultQuorumNumerator) && numSigners <= int(WarpQuorumDenominator) { expectedErr = nil } else { expectedErr = errFailedVerification @@ -510,7 +509,7 @@ func TestWarpMultiplePredicates(t *testing.T) { {true, true}, } { var ( - numSigners = int(params.WarpQuorumDenominator) + numSigners = int(WarpQuorumDenominator) invalidPredicateBytes = createPredicate(1) validPredicateBytes = createPredicate(numSigners) ) @@ -562,13 +561,13 @@ func TestWarpSignatureWeightsNonDefaultQuorumNumerator(t *testing.T) { tests := make(map[string]testutils.PredicateTest) nonDefaultQuorumNumerator := 50 // Ensure this test fails if the DefaultQuroumNumerator is changed to an unexpected value during development - require.NotEqual(t, nonDefaultQuorumNumerator, int(params.WarpDefaultQuorumNumerator)) + require.NotEqual(t, nonDefaultQuorumNumerator, int(WarpDefaultQuorumNumerator)) // Add cases with default quorum for _, numSigners := range []int{nonDefaultQuorumNumerator, nonDefaultQuorumNumerator + 1, 99, 100, 101} { predicateBytes := createPredicate(numSigners) // The predicate is valid iff the number of signers is >= the required numerator and does not exceed the denominator. var expectedErr error - if numSigners >= nonDefaultQuorumNumerator && numSigners <= int(params.WarpQuorumDenominator) { + if numSigners >= nonDefaultQuorumNumerator && numSigners <= int(WarpQuorumDenominator) { expectedErr = nil } else { expectedErr = errFailedVerification diff --git a/x/warp/signature_verification_test.go b/precompile/contracts/warp/signature_verification_test.go similarity index 100% rename from x/warp/signature_verification_test.go rename to precompile/contracts/warp/signature_verification_test.go diff --git a/precompile/registry/registry.go b/precompile/registry/registry.go index 2b318ee998..490694d669 100644 --- a/precompile/registry/registry.go +++ b/precompile/registry/registry.go @@ -17,7 +17,7 @@ import ( _ "github.com/ava-labs/subnet-evm/precompile/contracts/rewardmanager" - _ "github.com/ava-labs/subnet-evm/x/warp" + _ "github.com/ava-labs/subnet-evm/precompile/contracts/warp" // ADD YOUR PRECOMPILE HERE // _ "github.com/ava-labs/subnet-evm/precompile/contracts/yourprecompile" ) diff --git a/tests/warp/warp_test.go b/tests/warp/warp_test.go index fd0fc032ce..a783dab59d 100644 --- a/tests/warp/warp_test.go +++ b/tests/warp/warp_test.go @@ -32,12 +32,12 @@ import ( "github.com/ava-labs/subnet-evm/interfaces" "github.com/ava-labs/subnet-evm/params" "github.com/ava-labs/subnet-evm/plugin/evm" + "github.com/ava-labs/subnet-evm/precompile/contracts/warp" "github.com/ava-labs/subnet-evm/predicate" "github.com/ava-labs/subnet-evm/tests/utils" "github.com/ava-labs/subnet-evm/tests/utils/runner" warpBackend "github.com/ava-labs/subnet-evm/warp" "github.com/ava-labs/subnet-evm/warp/aggregator" - "github.com/ava-labs/subnet-evm/x/warp" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" @@ -452,12 +452,12 @@ func (w *warpTest) aggregateSignatures() { if w.sendingSubnet.SubnetID == constants.PrimaryNetworkID { subnetIDStr = w.receivingSubnet.SubnetID.String() } - signedWarpMessageBytes, err := client.GetMessageAggregateSignature(ctx, w.addressedCallSignedMessage.ID(), params.WarpQuorumDenominator, subnetIDStr) + signedWarpMessageBytes, err := client.GetMessageAggregateSignature(ctx, w.addressedCallSignedMessage.ID(), warp.WarpQuorumDenominator, subnetIDStr) require.NoError(err) require.Equal(w.addressedCallSignedMessage.Bytes(), signedWarpMessageBytes) log.Info("Fetching block payload aggregate signature via p2p API") - signedWarpBlockBytes, err := client.GetBlockAggregateSignature(ctx, w.blockID, params.WarpQuorumDenominator, subnetIDStr) + signedWarpBlockBytes, err := client.GetBlockAggregateSignature(ctx, w.blockID, warp.WarpQuorumDenominator, subnetIDStr) require.NoError(err) require.Equal(w.blockPayloadSignedMessage.Bytes(), signedWarpBlockBytes) } @@ -697,7 +697,7 @@ func (w *warpTest) warpLoad() { } log.Info("Fetching addressed call aggregate signature via p2p API") - signedWarpMessageBytes, err := warpClient.GetMessageAggregateSignature(ctx, unsignedMessage.ID(), params.WarpDefaultQuorumNumerator, subnetIDStr) + signedWarpMessageBytes, err := warpClient.GetMessageAggregateSignature(ctx, unsignedMessage.ID(), warp.WarpDefaultQuorumNumerator, subnetIDStr) if err != nil { return nil, err } diff --git a/warp/aggregator/aggregator.go b/warp/aggregator/aggregator.go index 60a0279f1e..7c76f74820 100644 --- a/warp/aggregator/aggregator.go +++ b/warp/aggregator/aggregator.go @@ -7,13 +7,12 @@ import ( "context" "fmt" - "github.com/ava-labs/subnet-evm/params" - "github.com/ethereum/go-ethereum/log" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/set" avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp" + "github.com/ava-labs/subnet-evm/precompile/contracts/warp" ) type AggregateSignatureResult struct { @@ -130,7 +129,7 @@ func (a *Aggregator) AggregateSignatures(ctx context.Context, unsignedMessage *a ) // If the signature weight meets the requested threshold, cancel signature fetching - if err := avalancheWarp.VerifyWeight(signaturesWeight, a.totalWeight, quorumNum, params.WarpQuorumDenominator); err == nil { + if err := avalancheWarp.VerifyWeight(signaturesWeight, a.totalWeight, quorumNum, warp.WarpQuorumDenominator); err == nil { log.Debug("Verify weight passed, exiting aggregation early", "quorumNum", quorumNum, "totalWeight", a.totalWeight,