From 3e7508a0c66dcb45bf82d58cc8d7b31724a9a597 Mon Sep 17 00:00:00 2001 From: Jonathan Downing Date: Fri, 5 May 2023 15:03:45 -0500 Subject: [PATCH] Removed all references to Berlin from the codebase --- consensus/misc/eip1559_test.go | 1 - core/state/statedb.go | 2 +- core/state_processor_test.go | 1 - core/state_transition.go | 6 +++--- core/tx_pool.go | 2 +- core/vm/evm.go | 5 ++--- core/vm/runtime/runtime.go | 19 +++++++++---------- eth/ethconfig/config.go | 2 +- params/config.go | 27 +++++---------------------- tests/block_test.go | 2 +- tests/init.go | 11 ----------- 11 files changed, 23 insertions(+), 55 deletions(-) diff --git a/consensus/misc/eip1559_test.go b/consensus/misc/eip1559_test.go index 3e5dece508..615532cc46 100644 --- a/consensus/misc/eip1559_test.go +++ b/consensus/misc/eip1559_test.go @@ -30,7 +30,6 @@ import ( func copyConfig(original *params.ChainConfig) *params.ChainConfig { return ¶ms.ChainConfig{ ChainID: original.ChainID, - BerlinBlock: original.BerlinBlock, LondonBlock: original.LondonBlock, Blake3pow: original.Blake3pow, } diff --git a/core/state/statedb.go b/core/state/statedb.go index a619b47631..558a54af83 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -976,7 +976,7 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { // - Add precompiles to access list (2929) // - Add the contents of the optional tx access list (2930) // -// This method should only be called if Berlin/2929+2930 is applicable at the current number. +// This method should only be called if 2929+2930 is applicable at the current number. func (s *StateDB) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) { s.AddAddressToAccessList(sender) if dst != nil { diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 3c1583b6b4..2bea6e87a2 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -566,7 +566,6 @@ func TestStateProcessorErrors(t *testing.T) { var ( config = ¶ms.ChainConfig{ ChainID: big.NewInt(1), - BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), Blake3pow: new(params.Blake3powConfig), } diff --git a/core/state_transition.go b/core/state_transition.go index 1dfc430416..9ca00986a2 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -320,9 +320,9 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { } // Set up the initial access list. - if rules := st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber); rules.IsBerlin { - st.state.PrepareAccessList(msg.From(), msg.To(), vm.ActivePrecompiles(rules), msg.AccessList()) - } + rules := st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber) + st.state.PrepareAccessList(msg.From(), msg.To(), vm.ActivePrecompiles(rules), msg.AccessList()) + var ( ret []byte vmerr error // vm errors do not effect consensus and are therefore not assigned to err diff --git a/core/tx_pool.go b/core/tx_pool.go index e1a28068ab..ce6bb5b28e 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -1308,7 +1308,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) { // Update all fork indicator by next pending block number. next := new(big.Int).Add(newHead.Number(), big.NewInt(1)) - pool.eip2718 = pool.chainconfig.IsBerlin(next) + pool.eip2718 = true pool.eip1559 = pool.chainconfig.IsLondon(next) } diff --git a/core/vm/evm.go b/core/vm/evm.go index 3a02b3d07f..24c7ac75e8 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -421,9 +421,8 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, // We add this to the access list _before_ taking a snapshot. Even if the creation fails, // the access-list change should not be rolled back - if evm.chainRules.IsBerlin { - evm.StateDB.AddAddressToAccessList(address) - } + evm.StateDB.AddAddressToAccessList(address) + // Ensure there's no existing contract already at the designated address contractHash := evm.StateDB.GetCodeHash(internalContractAddr) if evm.StateDB.GetNonce(internalContractAddr) != 0 || (contractHash != (common.Hash{}) && contractHash != emptyCodeHash) { diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index cc9c48d00c..5400af827a 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -54,7 +54,6 @@ func setDefaults(cfg *Config) { if cfg.ChainConfig == nil { cfg.ChainConfig = ¶ms.ChainConfig{ ChainID: big.NewInt(1), - BerlinBlock: new(big.Int), LondonBlock: new(big.Int), } } @@ -110,9 +109,9 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) { if err != nil { return []byte{}, nil, err } - if rules := cfg.ChainConfig.Rules(vmenv.Context.BlockNumber); rules.IsBerlin { - cfg.State.PrepareAccessList(cfg.Origin, &address, vm.ActivePrecompiles(rules), nil) - } + rules := cfg.ChainConfig.Rules(vmenv.Context.BlockNumber) + cfg.State.PrepareAccessList(cfg.Origin, &address, vm.ActivePrecompiles(rules), nil) + cfg.State.CreateAccount(internal) // set the receiver's (the executing contract) code for execution. cfg.State.SetCode(internal, code) @@ -142,9 +141,9 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) { vmenv = NewEnv(cfg) sender = vm.AccountRef(cfg.Origin) ) - if rules := cfg.ChainConfig.Rules(vmenv.Context.BlockNumber); rules.IsBerlin { - cfg.State.PrepareAccessList(cfg.Origin, nil, vm.ActivePrecompiles(rules), nil) - } + rules := cfg.ChainConfig.Rules(vmenv.Context.BlockNumber) + cfg.State.PrepareAccessList(cfg.Origin, nil, vm.ActivePrecompiles(rules), nil) + // Call the code with the given configuration. code, address, leftOverGas, err := vmenv.Create( sender, @@ -171,9 +170,9 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, uint64, er statedb := cfg.State - if rules := cfg.ChainConfig.Rules(vmenv.Context.BlockNumber); rules.IsBerlin { - statedb.PrepareAccessList(cfg.Origin, &address, vm.ActivePrecompiles(rules), nil) - } + rules := cfg.ChainConfig.Rules(vmenv.Context.BlockNumber) + statedb.PrepareAccessList(cfg.Origin, &address, vm.ActivePrecompiles(rules), nil) + // Call the code with the given configuration. ret, leftOverGas, err := vmenv.Call( vm.AccountRef(cfg.Origin), diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 3baa386b0e..55edab7334 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -143,7 +143,7 @@ type Config struct { // send-transction variants. The unit is ether. RPCTxFeeCap float64 - // Berlin block override (TODO: remove after the fork) + // London block override (TODO: remove after the fork) OverrideLondon *big.Int `toml:",omitempty"` // Region location options diff --git a/params/config.go b/params/config.go index c7d6a5f1c0..205aec804c 100644 --- a/params/config.go +++ b/params/config.go @@ -36,7 +36,6 @@ var ( // ColosseumChainConfig is the chain parameters to run a node on the Colosseum network. ColosseumChainConfig = &ChainConfig{ ChainID: big.NewInt(9000), - BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), Blake3pow: new(Blake3powConfig), GenesisHash: ColosseumGenesisHash, @@ -45,7 +44,6 @@ var ( // GardenChainConfig contains the chain parameters to run a node on the Garden test network. GardenChainConfig = &ChainConfig{ ChainID: big.NewInt(12000), - BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), Blake3pow: new(Blake3powConfig), GenesisHash: GardenGenesisHash, @@ -54,7 +52,6 @@ var ( // OrchardChainConfig contains the chain parameters to run a node on the Orchard test network. OrchardChainConfig = &ChainConfig{ ChainID: big.NewInt(15000), - BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), Blake3pow: new(Blake3powConfig), GenesisHash: OrchardGenesisHash, @@ -63,7 +60,6 @@ var ( // GalenaChainConfig contains the chain parameters to run a node on the Galena test network. GalenaChainConfig = &ChainConfig{ ChainID: big.NewInt(17000), - BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), Blake3pow: new(Blake3powConfig), GenesisHash: GalenaGenesisHash, @@ -72,7 +68,6 @@ var ( // LocalChainConfig contains the chain parameters to run a node on the Local test network. LocalChainConfig = &ChainConfig{ ChainID: big.NewInt(1337), - BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), Blake3pow: new(Blake3powConfig), GenesisHash: LocalGenesisHash, @@ -83,9 +78,9 @@ var ( // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. - AllBlake3powProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), big.NewInt(0), new(Blake3powConfig), common.Hash{}} + AllBlake3powProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), new(Blake3powConfig), common.Hash{}} - TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), big.NewInt(0), new(Blake3powConfig), common.Hash{}} + TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), new(Blake3powConfig), common.Hash{}} TestRules = TestChainConfig.Rules(new(big.Int)) ) @@ -97,7 +92,6 @@ var ( type ChainConfig struct { ChainID *big.Int `json:"chainId"` // chainId identifies the current chain and is used for replay protection - BerlinBlock *big.Int `json:"berlinBlock,omitempty"` // Berlin switch block (nil = no fork, 0 = already on berlin) LondonBlock *big.Int `json:"londonBlock,omitempty"` // London switch block (nil = no fork, 0 = already on london) // Various consensus engines @@ -122,19 +116,13 @@ func (c *ChainConfig) String() string { default: engine = "unknown" } - return fmt.Sprintf("{ChainID: %v Berlin: %v, London: %v, Engine: %v}", + return fmt.Sprintf("{ChainID: %v London: %v, Engine: %v}", c.ChainID, - c.BerlinBlock, c.LondonBlock, engine, ) } -// IsBerlin returns whether num is either equal to the Berlin fork block or greater. -func (c *ChainConfig) IsBerlin(num *big.Int) bool { - return isForked(c.BerlinBlock, num) -} - // IsLondon returns whether num is either equal to the London fork block or greater. func (c *ChainConfig) IsLondon(num *big.Int) bool { return isForked(c.LondonBlock, num) @@ -168,7 +156,6 @@ func (c *ChainConfig) CheckConfigForkOrder() error { } var lastFork fork for _, cur := range []fork{ - {name: "berlinBlock", block: c.BerlinBlock}, {name: "londonBlock", block: c.LondonBlock}, } { if lastFork.name != "" { @@ -193,9 +180,6 @@ func (c *ChainConfig) CheckConfigForkOrder() error { } func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *ConfigCompatError { - if isForkIncompatible(c.BerlinBlock, newcfg.BerlinBlock, head) { - return newCompatError("Berlin fork block", c.BerlinBlock, newcfg.BerlinBlock) - } if isForkIncompatible(c.LondonBlock, newcfg.LondonBlock, head) { return newCompatError("London fork block", c.LondonBlock, newcfg.LondonBlock) } @@ -263,8 +247,8 @@ func (err *ConfigCompatError) Error() string { // Rules is a one time interface meaning that it shouldn't be used in between transition // phases. type Rules struct { - ChainID *big.Int - IsBerlin, IsLondon bool + ChainID *big.Int + IsLondon bool } // Rules ensures c's ChainID is not nil. @@ -275,7 +259,6 @@ func (c *ChainConfig) Rules(num *big.Int) Rules { } return Rules{ ChainID: new(big.Int).Set(chainID), - IsBerlin: c.IsBerlin(num), IsLondon: c.IsLondon(num), } } diff --git a/tests/block_test.go b/tests/block_test.go index cd6acd3d9c..3c2288dbdc 100644 --- a/tests/block_test.go +++ b/tests/block_test.go @@ -26,7 +26,7 @@ func TestBlockchain(t *testing.T) { bt := new(testMatcher) // General state tests are 'exported' as blockchain tests, but we can run them natively. // For speedier CI-runs, the line below can be uncommented, so those are skipped. - // For now, in hardfork-times (Berlin), we run the tests both as StateTests and + // For now, in hardfork-times we run the tests both as StateTests and // as blockchain tests, since the latter also covers things like receipt root bt.skipLoad(`^GeneralStateTests/`) diff --git a/tests/init.go b/tests/init.go index 006d68cb5b..97269b4520 100644 --- a/tests/init.go +++ b/tests/init.go @@ -26,23 +26,12 @@ import ( // Forks table defines supported forks and their chain config. var Forks = map[string]*params.ChainConfig{ - "Berlin": { - ChainID: big.NewInt(1), - BerlinBlock: big.NewInt(0), - }, - "BerlinToLondonAt5": { - ChainID: big.NewInt(1), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(5), - }, "London": { ChainID: big.NewInt(1), - BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), }, "Aleut": { ChainID: big.NewInt(1), - BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), }, }