Skip to content

Commit

Permalink
Removed all references to Berlin from the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning100 committed May 8, 2023
1 parent fe53495 commit 3e7508a
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 55 deletions.
1 change: 0 additions & 1 deletion consensus/misc/eip1559_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
func copyConfig(original *params.ChainConfig) *params.ChainConfig {
return &params.ChainConfig{
ChainID: original.ChainID,
BerlinBlock: original.BerlinBlock,
LondonBlock: original.LondonBlock,
Blake3pow: original.Blake3pow,
}
Expand Down
2 changes: 1 addition & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ func TestStateProcessorErrors(t *testing.T) {
var (
config = &params.ChainConfig{
ChainID: big.NewInt(1),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
Blake3pow: new(params.Blake3powConfig),
}
Expand Down
6 changes: 3 additions & 3 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
5 changes: 2 additions & 3 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 9 additions & 10 deletions core/vm/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func setDefaults(cfg *Config) {
if cfg.ChainConfig == nil {
cfg.ChainConfig = &params.ChainConfig{
ChainID: big.NewInt(1),
BerlinBlock: new(big.Int),
LondonBlock: new(big.Int),
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 5 additions & 22 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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))
)

Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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 != "" {
Expand All @@ -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)
}
Expand Down Expand Up @@ -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.
Expand All @@ -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),
}
}
2 changes: 1 addition & 1 deletion tests/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/`)

Expand Down
11 changes: 0 additions & 11 deletions tests/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
}
Expand Down

0 comments on commit 3e7508a

Please sign in to comment.