@@ -288,9 +288,7 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed
288
288
task .statedb .AddBalance (blockCtx .Coinbase , balance , tracing .BalanceChangeUnspecified )
289
289
}
290
290
291
- if api .backend .ChainConfig ().IsFeynman (task .block .Number (), task .block .Time ()) {
292
- systemcontracts .UpgradeBuildInSystemContract (api .backend .ChainConfig (), task .block .Number (), task .parent .Time (), task .block .Time (), task .statedb )
293
- }
291
+ systemcontracts .TryUpdateBuildInSystemContract (api .backend .ChainConfig (), task .block .Number (), task .parent .Time (), task .block .Time (), task .statedb , false )
294
292
beforeSystemTx = false
295
293
}
296
294
}
@@ -402,6 +400,10 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed
402
400
failed = err
403
401
break
404
402
}
403
+
404
+ // upgrade build-in system contract before normal txs if Feynman is not enabled
405
+ systemcontracts .TryUpdateBuildInSystemContract (api .backend .ChainConfig (), next .Number (), block .Time (), next .Time (), statedb , true )
406
+
405
407
// Insert block's parent beacon block root in the state
406
408
// as per EIP-4788.
407
409
if beaconRoot := next .BeaconRoot (); beaconRoot != nil {
@@ -421,11 +423,6 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed
421
423
// may fail if we release too early.
422
424
tracker .callReleases ()
423
425
424
- // upgrade build-in system contract before normal txs if Feynman is not enabled
425
- if ! api .backend .ChainConfig ().IsFeynman (next .Number (), next .Time ()) {
426
- systemcontracts .UpgradeBuildInSystemContract (api .backend .ChainConfig (), next .Number (), block .Time (), next .Time (), statedb )
427
- }
428
-
429
426
// Send the block over to the concurrent tracers (if not in the fast-forward phase)
430
427
txs := next .Transactions ()
431
428
select {
@@ -563,9 +560,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
563
560
defer release ()
564
561
565
562
// upgrade build-in system contract before normal txs if Feynman is not enabled
566
- if ! api .backend .ChainConfig ().IsFeynman (block .Number (), block .Time ()) {
567
- systemcontracts .UpgradeBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb )
568
- }
563
+ systemcontracts .TryUpdateBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb , true )
569
564
570
565
var (
571
566
roots []common.Hash
@@ -600,8 +595,8 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
600
595
statedb .AddBalance (vmctx .Coinbase , balance , tracing .BalanceChangeUnspecified )
601
596
}
602
597
603
- if beforeSystemTx && api . backend . ChainConfig (). IsFeynman ( block . Number (), block . Time ()) {
604
- systemcontracts .UpgradeBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb )
598
+ if beforeSystemTx {
599
+ systemcontracts .TryUpdateBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb , false )
605
600
beforeSystemTx = false
606
601
}
607
602
}
@@ -661,9 +656,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
661
656
defer release ()
662
657
663
658
// upgrade build-in system contract before normal txs if Feynman is not enabled
664
- if ! api .backend .ChainConfig ().IsFeynman (block .Number (), block .Time ()) {
665
- systemcontracts .UpgradeBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb )
666
- }
659
+ systemcontracts .TryUpdateBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb , true )
667
660
668
661
// JS tracers have high overhead. In this case run a parallel
669
662
// process that generates states in one thread and traces txes
@@ -702,9 +695,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
702
695
statedb .AddBalance (blockCtx .Coinbase , balance , tracing .BalanceChangeUnspecified )
703
696
}
704
697
705
- if api .backend .ChainConfig ().IsFeynman (block .Number (), block .Time ()) {
706
- systemcontracts .UpgradeBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb )
707
- }
698
+ systemcontracts .TryUpdateBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb , false )
708
699
beforeSystemTx = false
709
700
}
710
701
}
@@ -795,9 +786,7 @@ txloop:
795
786
statedb .AddBalance (block .Header ().Coinbase , balance , tracing .BalanceChangeUnspecified )
796
787
}
797
788
798
- if api .backend .ChainConfig ().IsFeynman (block .Number (), block .Time ()) {
799
- systemcontracts .UpgradeBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb )
800
- }
789
+ systemcontracts .TryUpdateBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb , false )
801
790
beforeSystemTx = false
802
791
}
803
792
}
@@ -863,9 +852,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
863
852
defer release ()
864
853
865
854
// upgrade build-in system contract before normal txs if Feynman is not enabled
866
- if ! api .backend .ChainConfig ().IsFeynman (block .Number (), block .Time ()) {
867
- systemcontracts .UpgradeBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb )
868
- }
855
+ systemcontracts .TryUpdateBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb , true )
869
856
870
857
// Retrieve the tracing configurations, or use default values
871
858
var (
@@ -915,9 +902,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
915
902
statedb .AddBalance (vmctx .Coinbase , balance , tracing .BalanceChangeUnspecified )
916
903
}
917
904
918
- if api .backend .ChainConfig ().IsFeynman (block .Number (), block .Time ()) {
919
- systemcontracts .UpgradeBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb )
920
- }
905
+ systemcontracts .TryUpdateBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb , false )
921
906
beforeSystemTx = false
922
907
}
923
908
}
@@ -1099,9 +1084,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
1099
1084
if err != nil {
1100
1085
return nil , err
1101
1086
}
1102
- if ! api .backend .ChainConfig ().IsFeynman (block .Number (), block .Time ()) {
1103
- systemcontracts .UpgradeBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb )
1104
- }
1087
+ systemcontracts .TryUpdateBuildInSystemContract (api .backend .ChainConfig (), block .Number (), parent .Time (), block .Time (), statedb , true )
1105
1088
}
1106
1089
1107
1090
vmctx := core .NewEVMBlockContext (block .Header (), api .chainContext (ctx ), nil )
0 commit comments