Skip to content

Commit

Permalink
feat: ensure no requests are included in isthmus blocks (#498)
Browse files Browse the repository at this point in the history
* feat: ensure no requests are included in isthmus blocks

* Ensure cancun enabled in block encode decode test

---------

Co-authored-by: refcell <[email protected]>
  • Loading branch information
meyer9 and refcell authored Feb 13, 2025
1 parent 9111c8f commit acea125
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
core.ProcessConsolidationQueue(&requests, evm)
}

if chainConfig.IsIsthmus(vmContext.Time) {
requests = [][]byte{}
}

// Commit block
root, err := statedb.Commit(vmContext.BlockNumber.Uint64(), chainConfig.IsEIP158(vmContext.BlockNumber), chainConfig.IsCancun(vmContext.BlockNumber, vmContext.Time))
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ func (b *BlockGen) collectRequests(readonly bool) (requests [][]byte) {
// EIP-7251
ProcessConsolidationQueue(&requests, evm)
}

if b.cm.config.IsIsthmus(b.header.Time) {
requests = [][]byte{}
}

return requests
}

Expand Down
1 change: 1 addition & 0 deletions core/rlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ func TestBlockRlpEncodeDecode(t *testing.T) {
config := *params.OptimismTestConfig
config.ShanghaiTime = &zeroTime
config.IsthmusTime = &zeroTime
config.CancunTime = &zeroTime
require.True(t, config.IsOptimismIsthmus(zeroTime))

block := getBlock(&config, 10, 2, 50)
Expand Down
4 changes: 4 additions & 0 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
ProcessConsolidationQueue(&requests, evm)
}

if p.config.IsIsthmus(block.Time()) {
requests = [][]byte{}
}

// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
p.chain.engine.Finalize(p.chain, header, tracingStateDB, block.Body())

Expand Down
5 changes: 5 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo
// EIP-7251 consolidations
core.ProcessConsolidationQueue(&requests, work.evm)
}

if miner.chainConfig.IsIsthmus(work.header.Time) {
requests = [][]byte{}
}

if requests != nil {
reqHash := types.CalcRequestsHash(requests)
work.header.RequestsHash = &reqHash
Expand Down

0 comments on commit acea125

Please sign in to comment.