@@ -81,10 +81,9 @@ func (p *StateProcessor) Process(ctx context.Context, block *types.Block, stated
8181 if config .DAOForkSupport && config .DAOForkBlock != nil && config .DAOForkBlock .Cmp (block .Number ()) == 0 {
8282 misc .ApplyDAOHardFork (tracingStateDB )
8383 }
84- // EIP-7997: insert the deterministic deployment factory at the Amsterdam
85- // activation block via an irregular state transition.
86- if isEIP7997Transition (config , p .chain , header ) {
87- misc .ApplyEIP7997 (tracingStateDB )
84+ parent := p .chain .GetHeader (block .ParentHash (), block .NumberU64 ()- 1 )
85+ if parent == nil {
86+ return nil , fmt .Errorf ("missing parent %#x" , block .ParentHash ())
8887 }
8988 var (
9089 context = NewEVMBlockContext (header , p .chain , nil )
@@ -98,7 +97,7 @@ func (p *StateProcessor) Process(ctx context.Context, block *types.Block, stated
9897 evm .SetJumpDestCache (jumpDestCache )
9998 }
10099 // Run the pre-execution system calls
101- blockAccessList .Merge (PreExecution (ctx , block .BeaconRoot (), block . ParentHash () , config , evm , block .Number (), block .Time ()))
100+ blockAccessList .Merge (PreExecution (ctx , block .BeaconRoot (), parent , config , evm , block .Number (), block .Time ()))
102101
103102 // Iterate over and process the individual transactions
104103 for i , tx := range block .Transactions () {
@@ -142,35 +141,28 @@ func (p *StateProcessor) Process(ctx context.Context, block *types.Block, stated
142141 }, nil
143142}
144143
145- // isEIP7997Transition reports whether the given header belongs to the first block
146- // on which the Amsterdam fork is active.
147- func isEIP7997Transition (config * params.ChainConfig , chain ChainContext , header * types.Header ) bool {
148- if header .Number .Sign () == 0 || ! config .IsAmsterdam (header .Number , header .Time ) {
149- return false
150- }
151- parent := chain .GetHeader (header .ParentHash , header .Number .Uint64 ()- 1 )
152- if parent == nil {
153- return false
154- }
155- return ! config .IsAmsterdam (parent .Number , parent .Time )
156- }
157-
158- // PreExecution processes pre-execution system calls.
159- func PreExecution (ctx context.Context , beaconRoot * common.Hash , parent common.Hash , config * params.ChainConfig , evm * vm.EVM , number * big.Int , time uint64 ) * bal.ConstructionBlockAccessList {
144+ // PreExecution processes pre-execution state changes and system calls.
145+ func PreExecution (ctx context.Context , beaconRoot * common.Hash , parent * types.Header , config * params.ChainConfig , evm * vm.EVM , number * big.Int , time uint64 ) * bal.ConstructionBlockAccessList {
160146 _ , _ , spanEnd := telemetry .StartSpan (ctx , "core.preExecution" )
161147 defer spanEnd (nil )
162148
163149 var blockAccessList * bal.ConstructionBlockAccessList
164150 if config .IsAmsterdam (number , time ) {
165151 blockAccessList = bal .NewConstructionBlockAccessList ()
152+
153+ // EIP-7997: insert the deterministic deployment factory at the Amsterdam
154+ // activation block via an irregular state transition.
155+ if ! config .IsAmsterdam (parent .Number , parent .Time ) {
156+ misc .ApplyEIP7997 (evm .StateDB )
157+ }
166158 }
167159 // EIP-4788
168160 if beaconRoot != nil {
169161 ProcessBeaconBlockRoot (* beaconRoot , evm , blockAccessList )
170162 }
171163 // EIP-2935
172164 if config .IsPrague (number , time ) || config .IsUBT (number , time ) {
173- ProcessParentBlockHash (parent , evm , blockAccessList )
165+ ProcessParentBlockHash (parent . Hash () , evm , blockAccessList )
174166 }
175167 return blockAccessList
176168}
0 commit comments