@@ -32,6 +32,7 @@ import (
3232 "github.com/scroll-tech/go-ethereum/common"
3333 "github.com/scroll-tech/go-ethereum/common/hexutil"
3434 "github.com/scroll-tech/go-ethereum/consensus"
35+ "github.com/scroll-tech/go-ethereum/consensus/misc"
3536 "github.com/scroll-tech/go-ethereum/core"
3637 "github.com/scroll-tech/go-ethereum/core/rawdb"
3738 "github.com/scroll-tech/go-ethereum/core/state"
@@ -202,10 +203,11 @@ type txTraceResult struct {
202203// blockTraceTask represents a single block trace task when an entire chain is
203204// being traced.
204205type blockTraceTask struct {
205- statedb * state.StateDB // Intermediate state prepped for tracing
206- block * types.Block // Block to trace the transactions from
207- rootref common.Hash // Trie root reference held for this task
208- results []* txTraceResult // Trace results procudes by the task
206+ statedb * state.StateDB // Intermediate state prepped for tracing
207+ block * types.Block // Block to trace the transactions from
208+ parentBlock * types.Block // Block to trace the transactions from
209+ rootref common.Hash // Trie root reference held for this task
210+ results []* txTraceResult // Trace results procudes by the task
209211}
210212
211213// blockTraceResult represets the results of tracing a single block when an entire
@@ -277,11 +279,16 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config
277279 for task := range tasks {
278280 signer := types .MakeSigner (api .backend .ChainConfig (), task .block .Number (), task .block .Time ())
279281 blockCtx := core .NewEVMBlockContext (task .block .Header (), api .chainContext (localctx ), api .backend .ChainConfig (), nil )
282+
283+ // Apply Scroll hard fork state transitions on state
284+ misc .ApplyForkStateTransitions (api .backend .ChainConfig (), task .statedb , task .block .NumberU64 (), task .block .Time (), task .parentBlock .Time ())
285+
280286 // EIP-2935: Insert parent hash in history contract.
281287 if api .backend .ChainConfig ().IsFeynman (task .block .Time ()) {
282288 evm := vm .NewEVM (blockCtx , vm.TxContext {}, task .statedb , api .backend .ChainConfig (), vm.Config {})
283289 core .ProcessParentBlockHash (task .block .ParentHash (), evm , task .statedb )
284290 }
291+
285292 // Trace all the transactions contained within
286293 for i , tx := range task .block .Transactions () {
287294 msg , _ := tx .AsMessage (signer , task .block .BaseFee ())
@@ -410,7 +417,7 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config
410417 // Send the block over to the concurrent tracers (if not in the fast-forward phase)
411418 txs := next .Transactions ()
412419 select {
413- case tasks <- & blockTraceTask {statedb : statedb .Copy (), block : next , rootref : block .Root (), results : make ([]* txTraceResult , len (txs ))}:
420+ case tasks <- & blockTraceTask {statedb : statedb .Copy (), block : next , parentBlock : block , rootref : block .Root (), results : make ([]* txTraceResult , len (txs ))}:
414421 case <- notifier .Closed ():
415422 return
416423 }
@@ -544,6 +551,10 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
544551 vmctx = core .NewEVMBlockContext (block .Header (), api .chainContext (ctx ), api .backend .ChainConfig (), nil )
545552 deleteEmptyObjects = chainConfig .IsEIP158 (block .Number ())
546553 )
554+
555+ // Apply Scroll hard fork state transitions on state
556+ misc .ApplyForkStateTransitions (api .backend .ChainConfig (), statedb , block .NumberU64 (), block .Time (), parent .Time ())
557+
547558 // EIP-2935: Insert parent hash in history contract.
548559 if api .backend .ChainConfig ().IsFeynman (block .Time ()) {
549560 vmenv := vm .NewEVM (vmctx , vm.TxContext {}, statedb , chainConfig , vm.Config {})
@@ -624,11 +635,16 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
624635 threads = len (txs )
625636 }
626637 blockCtx := core .NewEVMBlockContext (block .Header (), api .chainContext (ctx ), api .backend .ChainConfig (), nil )
638+
639+ // Apply Scroll hard fork state transitions on state
640+ misc .ApplyForkStateTransitions (api .backend .ChainConfig (), statedb , block .NumberU64 (), block .Time (), parent .Time ())
641+
627642 // EIP-2935: Insert parent hash in history contract.
628643 if api .backend .ChainConfig ().IsFeynman (block .Time ()) {
629644 evm := vm .NewEVM (blockCtx , vm.TxContext {}, statedb , api .backend .ChainConfig (), vm.Config {})
630645 core .ProcessParentBlockHash (block .ParentHash (), evm , statedb )
631646 }
647+
632648 blockHash := block .Hash ()
633649 blockNumber := block .NumberU64 ()
634650 for th := 0 ; th < threads ; th ++ {
@@ -764,6 +780,9 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
764780 }
765781 }
766782
783+ // Apply Scroll hard fork state transitions on state
784+ misc .ApplyForkStateTransitions (api .backend .ChainConfig (), statedb , block .NumberU64 (), block .Time (), parent .Time ())
785+
767786 // EIP-2935: Insert parent hash in history contract.
768787 if api .backend .ChainConfig ().IsFeynman (block .Time ()) {
769788 evm := vm .NewEVM (vmctx , vm.TxContext {}, statedb , api .backend .ChainConfig (), vm.Config {})
0 commit comments