diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index a6bfdf617df..77fa625b411 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -663,6 +663,9 @@ func AccumulateRewards(config *chain.Config, header *types.Header, uncles []*typ // accumulateRewards retrieves rewards for a block and applies them to the coinbase accounts for miner and uncle miners func accumulateRewards(config *chain.Config, state *state.IntraBlockState, header *types.Header, uncles []*types.Header) { + if config.IsNormalcy(header.Number.Uint64()) { + return + } minerReward, uncleRewards := AccumulateRewards(config, header, uncles) for i, uncle := range uncles { if i < len(uncleRewards) { diff --git a/core/blockchain_zkevm.go b/core/blockchain_zkevm.go index de39378f17b..10b61a2972a 100644 --- a/core/blockchain_zkevm.go +++ b/core/blockchain_zkevm.go @@ -134,7 +134,7 @@ func ExecuteBlockEphemerallyZk( receipts = append(receipts, receipt) } } - if !chainConfig.IsForkID7Etrog(block.NumberU64()) { + if !chainConfig.IsForkID7Etrog(block.NumberU64()) && !chainConfig.IsNormalcy(block.NumberU64()) { if err := ibs.ScalableSetSmtRootHash(roHermezDb); err != nil { return nil, err } diff --git a/core/state/intra_block_state_zkevm.go b/core/state/intra_block_state_zkevm.go index 22a44c769ac..36eb275f270 100644 --- a/core/state/intra_block_state_zkevm.go +++ b/core/state/intra_block_state_zkevm.go @@ -58,6 +58,10 @@ func (sdb *IntraBlockState) GetTxCount() (uint64, error) { } func (sdb *IntraBlockState) PostExecuteStateSet(chainConfig *chain.Config, blockNum uint64, blockInfoRoot *libcommon.Hash) { + if chainConfig.IsNormalcy(blockNum) { + return + } + //ETROG if chainConfig.IsForkID7Etrog(blockNum) { sdb.scalableSetBlockInfoRoot(blockInfoRoot) @@ -70,18 +74,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) + } } } @@ -99,18 +105,22 @@ func (sdb *IntraBlockState) SyncerPreExecuteStateSet( } //save block number - sdb.scalableSetBlockNum(blockNumber) + if !chainConfig.IsNormalcy(blockNumber) { + 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 diff --git a/smt/pkg/smt/entity_storage.go b/smt/pkg/smt/entity_storage.go index 261b27103cd..f115359a0e6 100644 --- a/smt/pkg/smt/entity_storage.go +++ b/smt/pkg/smt/entity_storage.go @@ -207,6 +207,10 @@ func (s *SMT) SetContractStorage(ethAddr string, storage map[string]string, prog } func (s *SMT) SetStorage(ctx context.Context, logPrefix string, accChanges map[libcommon.Address]*accounts.Account, codeChanges map[libcommon.Address]string, storageChanges map[libcommon.Address]map[string]string) ([]*utils.NodeKey, []*utils.NodeValue8, error) { + if len(storageChanges) == 0 && len(accChanges) == 0 && len(codeChanges) == 0 { + return nil, nil, nil + } + var isDelete bool var err error