Skip to content

Commit

Permalink
Cherry-pick PR #1374
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Nov 6, 2024
1 parent b42e3e2 commit 075906d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
4 changes: 4 additions & 0 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,10 @@ 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) {
Expand Down
3 changes: 2 additions & 1 deletion core/blockchain_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ 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
}
Expand Down
45 changes: 26 additions & 19 deletions core/state/intra_block_state_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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)
}
}
}

Expand All @@ -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
Expand Down

0 comments on commit 075906d

Please sign in to comment.