From 219f994dfabc78fa430a3a96b940a5265cdcbc6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Mon, 4 Nov 2024 15:51:20 +0100 Subject: [PATCH] Cherry-pick PR #1374 --- core/state/intra_block_state_zkevm.go | 45 ++++++++++++++++----------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/core/state/intra_block_state_zkevm.go b/core/state/intra_block_state_zkevm.go index 22a44c769ac..256026a7bbf 100644 --- a/core/state/intra_block_state_zkevm.go +++ b/core/state/intra_block_state_zkevm.go @@ -59,7 +59,7 @@ func (sdb *IntraBlockState) GetTxCount() (uint64, error) { func (sdb *IntraBlockState) PostExecuteStateSet(chainConfig *chain.Config, blockNum uint64, blockInfoRoot *libcommon.Hash) { //ETROG - if chainConfig.IsForkID7Etrog(blockNum) { + if chainConfig.IsForkID7Etrog(blockNum) && !chainConfig.IsNormalcy(blockNum) { sdb.scalableSetBlockInfoRoot(blockInfoRoot) } } @@ -70,18 +70,20 @@ func (sdb *IntraBlockState) PreExecuteStateSet(chainConfig *chain.Config, blockN sdb.CreateAccount(ADDRESS_SCALABLE_L2, true) } - //save block number - sdb.scalableSetBlockNum(blockNumber) + if !chainConfig.IsNormalcy(blockNumber) { + //save block number + sdb.scalableSetBlockNum(blockNumber) - //ETROG - if chainConfig.IsForkID7Etrog(blockNumber) { - currentTimestamp := sdb.ScalableGetTimestamp() - if blockTimestamp > currentTimestamp { - sdb.ScalableSetTimestamp(blockTimestamp) - } + //ETROG + if chainConfig.IsForkID7Etrog(blockNumber) { + currentTimestamp := sdb.ScalableGetTimestamp() + if blockTimestamp > currentTimestamp { + sdb.ScalableSetTimestamp(blockTimestamp) + } - //save prev block hash - sdb.scalableSetBlockHash(blockNumber-1, stateRoot) + //save prev block hash + sdb.scalableSetBlockHash(blockNumber-1, stateRoot) + } } } @@ -98,19 +100,24 @@ func (sdb *IntraBlockState) SyncerPreExecuteStateSet( sdb.CreateAccount(ADDRESS_SCALABLE_L2, true) } - //save block number - sdb.scalableSetBlockNum(blockNumber) + if !chainConfig.IsNormalcy(blockNumber) { + //save block number + sdb.scalableSetBlockNum(blockNumber) + } + emptyHash := libcommon.Hash{} //ETROG if chainConfig.IsForkID7Etrog(blockNumber) { - currentTimestamp := sdb.ScalableGetTimestamp() - if blockTimestamp > currentTimestamp { - sdb.ScalableSetTimestamp(blockTimestamp) - } + if !chainConfig.IsNormalcy(blockNumber) { + currentTimestamp := sdb.ScalableGetTimestamp() + if blockTimestamp > currentTimestamp { + sdb.ScalableSetTimestamp(blockTimestamp) + } - //save prev block hash - sdb.scalableSetBlockHash(blockNumber-1, prevBlockHash) + //save prev block hash + sdb.scalableSetBlockHash(blockNumber-1, prevBlockHash) + } //save ger with l1blockhash - but only in the case that the l1 info tree index hasn't been // re-used. If it has been re-used we never write this to the contract storage