diff --git a/chain/chain_config.go b/chain/chain_config.go index 3b77208ede7..52d3b7a17d4 100644 --- a/chain/chain_config.go +++ b/chain/chain_config.go @@ -29,7 +29,7 @@ const ( ForkID5Dragonfruit = 5 ForkID6IncaBerry = 6 ForkID7Etrog = 7 - ForkID8 = 8 + ForkID88Elderberry = 8 ) // Config is the core config which determines the blockchain settings. @@ -88,7 +88,7 @@ type Config struct { ForkID5DragonfruitBlock *big.Int `json:"forkID5DragonfruitBlock,omitempty"` ForkID6IncaBerryBlock *big.Int `json:"forkID6IncaBerryBlock,omitempty"` ForkID7EtrogBlock *big.Int `json:"forkID7EtrogBlock,omitempty"` - ForkID8Block *big.Int `json:"forkID8EtrogBlock,omitempty"` + ForkID88ElderberryBlock *big.Int `json:"forkID88ElderberryBlock,omitempty"` } func (c *Config) String() string { @@ -235,8 +235,8 @@ func (c *Config) IsForkID7Etrog(num uint64) bool { return isForked(c.ForkID7EtrogBlock, num) } -func (c *Config) IsForkID8(num uint64) bool { - return isForked(c.ForkID8Block, num) +func (c *Config) IsForkID8Elderberry(num uint64) bool { + return isForked(c.ForkID88ElderberryBlock, num) } // CheckCompatible checks whether scheduled fork transitions have been imported @@ -408,12 +408,12 @@ func newCompatError(what string, storedblock, newblock *big.Int) *chain.ConfigCo // Rules is a one time interface meaning that it shouldn't be used in between transition // phases. type Rules struct { - ChainID *big.Int - IsHomestead, IsTangerineWhistle, IsSpuriousDragon bool - IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool - IsBerlin, IsLondon, IsShanghai, IsCancun, IsPrague bool - IsEip1559FeeCollector, IsAura bool - IsForkID4, IsForkID5Dragonfruit, IsForkID6IncaBerry, IsForkID7Etrog, IsForkID8 bool + ChainID *big.Int + IsHomestead, IsTangerineWhistle, IsSpuriousDragon bool + IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool + IsBerlin, IsLondon, IsShanghai, IsCancun, IsPrague bool + IsEip1559FeeCollector, IsAura bool + IsForkID4, IsForkID5Dragonfruit, IsForkID6IncaBerry, IsForkID7Etrog, IsForkID8Elderberry bool } // Rules ensures c's ChainID is not nil and returns a new Rules instance @@ -443,7 +443,7 @@ func (c *Config) Rules(num uint64, time uint64) *Rules { IsForkID5Dragonfruit: c.IsForkID5Dragonfruit(num), IsForkID6IncaBerry: c.IsForkID6IncaBerry(num), IsForkID7Etrog: c.IsForkID7Etrog(num), - IsForkID8: c.IsForkID8(num), + IsForkID8Elderberry: c.IsForkID8Elderberry(num), } } diff --git a/core/blockchain_zkevm.go b/core/blockchain_zkevm.go index 34afb3a557c..25a427dab5e 100644 --- a/core/blockchain_zkevm.go +++ b/core/blockchain_zkevm.go @@ -63,7 +63,7 @@ func ExecuteBlockEphemerallyZk( blockGasLimit := block.GasLimit() //[hack] - on forkid7 this gas limit was used for execution but rpc is now returning forkid8 gas limit - if !chainConfig.IsForkID8(block.NumberU64()) { + if !chainConfig.IsForkID8Elderberry(block.NumberU64()) { blockGasLimit = 18446744073709551615 } @@ -202,19 +202,21 @@ func ExecuteBlockEphemerallyZk( return nil, err } - // the stateroot in the transactions that comes from the datastream - // is the one after smart contract writes so it can't be used - // but since pre forkid7 blocks have 1 tx only, we can use the block root - if chainConfig.IsForkID7Etrog(blockNum) { - receipt.PostState = intermediateState.Bytes() - } else { - receipt.PostState = header.Root.Bytes() - } + // forkid8 tje poststate is empty + // forkid8 also fixed the bugs with logs and cumulative gas used + if !chainConfig.IsForkID8Elderberry(blockNum) { + // the stateroot in the transactions that comes from the datastream + // is the one after smart contract writes so it can't be used + // but since pre forkid7 blocks have 1 tx only, we can use the block root + if chainConfig.IsForkID7Etrog(blockNum) { + receipt.PostState = intermediateState.Bytes() + } else { + receipt.PostState = header.Root.Bytes() + } - //[hack] log0 pre forkid8 are not included in the rpc logs - // also pre forkid8 comulative gas used is same as gas used - var fixedLogs types.Logs - if !chainConfig.IsForkID8(blockNum) { + //[hack] log0 pre forkid8 are not included in the rpc logs + // also pre forkid8 comulative gas used is same as gas used + var fixedLogs types.Logs for _, l := range receipt.Logs { if len(l.Topics) == 0 && len(l.Data) == 0 { continue diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 19d467259cb..c99013537b7 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -111,13 +111,13 @@ var PrecompiledContractsBLS = map[libcommon.Address]PrecompiledContract{ } var ( - PrecompiledAddressesBerlin []libcommon.Address - PrecompiledAddressesIstanbul []libcommon.Address - PrecompiledAddressesByzantium []libcommon.Address - PrecompiledAddressesHomestead []libcommon.Address - PrecompiledAddressesEtrog []libcommon.Address - PrecompiledAddressesDragonfruit []libcommon.Address - PrecompiledAddressesForkId8 []libcommon.Address + PrecompiledAddressesBerlin []libcommon.Address + PrecompiledAddressesIstanbul []libcommon.Address + PrecompiledAddressesByzantium []libcommon.Address + PrecompiledAddressesHomestead []libcommon.Address + PrecompiledAddressesEtrog []libcommon.Address + PrecompiledAddressesDragonfruit []libcommon.Address + PrecompiledAddressesForkID88Elderberry []libcommon.Address ) func init() { @@ -139,16 +139,16 @@ func init() { for k := range PrecompiledContractForkID7Etrog { PrecompiledAddressesEtrog = append(PrecompiledAddressesEtrog, k) } - for k := range PrecompiledContractsForkID8 { - PrecompiledAddressesForkId8 = append(PrecompiledAddressesForkId8, k) + for k := range PrecompiledContractsForkID88Elderberry { + PrecompiledAddressesForkID88Elderberry = append(PrecompiledAddressesForkID88Elderberry, k) } } // ActivePrecompiles returns the precompiles enabled with the current configuration. func ActivePrecompiles(rules *chain.Rules) []libcommon.Address { switch { - case rules.IsForkID8: - return PrecompiledAddressesForkId8 + case rules.IsForkID8Elderberry: + return PrecompiledAddressesForkID88Elderberry case rules.IsForkID7Etrog: return PrecompiledAddressesEtrog case rules.IsForkID5Dragonfruit: diff --git a/core/vm/contracts_zkevm.go b/core/vm/contracts_zkevm.go index 1e7c1a82f76..f3e1b6021a3 100644 --- a/core/vm/contracts_zkevm.go +++ b/core/vm/contracts_zkevm.go @@ -62,7 +62,7 @@ var PrecompiledContractForkID7Etrog = map[libcommon.Address]PrecompiledContract{ } // PrecompiledContractsForkID8 contains the default set of pre-compiled ForkID8. -var PrecompiledContractsForkID8 = map[libcommon.Address]PrecompiledContract{ +var PrecompiledContractsForkID88Elderberry = map[libcommon.Address]PrecompiledContract{ libcommon.BytesToAddress([]byte{1}): &ecrecover_zkevm{enabled: true}, libcommon.BytesToAddress([]byte{2}): &sha256hash_zkevm{enabled: true}, libcommon.BytesToAddress([]byte{3}): &ripemd160hash_zkevm{enabled: false}, diff --git a/core/vm/evm_zkevm.go b/core/vm/evm_zkevm.go index f56de93714b..adeaed40d8f 100644 --- a/core/vm/evm_zkevm.go +++ b/core/vm/evm_zkevm.go @@ -27,8 +27,8 @@ import ( func (evm *EVM) precompile(addr libcommon.Address) (PrecompiledContract, bool) { var precompiles map[libcommon.Address]PrecompiledContract switch { - case evm.chainRules.IsForkID8: - precompiles = PrecompiledContractsForkID8 + case evm.chainRules.IsForkID8Elderberry: + precompiles = PrecompiledContractsForkID88Elderberry case evm.chainRules.IsForkID7Etrog: precompiles = PrecompiledContractForkID7Etrog default: diff --git a/core/vm/interpreter_zkevm.go b/core/vm/interpreter_zkevm.go index 09aa8f491ee..01df8d53bca 100644 --- a/core/vm/interpreter_zkevm.go +++ b/core/vm/interpreter_zkevm.go @@ -22,7 +22,7 @@ func NewZkConfig(config Config, counterCollector *CounterCollector) ZkConfig { func getJumpTable(cr *chain.Rules) *JumpTable { var jt *JumpTable switch { - case cr.IsForkID5Dragonfruit, cr.IsForkID6IncaBerry, cr.IsForkID7Etrog, cr.IsForkID8: + case cr.IsForkID5Dragonfruit, cr.IsForkID6IncaBerry, cr.IsForkID7Etrog, cr.IsForkID8Elderberry: jt = &forkID5DragonfruitInstructionSet case cr.IsBerlin: jt = &forkID4InstructionSet diff --git a/eth/stagedsync/stage_execute_zkevm.go b/eth/stagedsync/stage_execute_zkevm.go index 38419605594..df4757e6187 100644 --- a/eth/stagedsync/stage_execute_zkevm.go +++ b/eth/stagedsync/stage_execute_zkevm.go @@ -543,7 +543,7 @@ func updateZkEVMBlockCfg(cfg *ExecuteBlockCfg, hermezDb *hermez_db.HermezDb, log if err := update(chain.ForkID7Etrog, &cfg.chainConfig.ForkID7EtrogBlock); err != nil { return err } - if err := update(chain.ForkID8, &cfg.chainConfig.ForkID8Block); err != nil { + if err := update(chain.ForkID88Elderberry, &cfg.chainConfig.ForkID88ElderberryBlock); err != nil { return err } return nil