diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 5a34d9d4a6ab..55c56b40c9f1 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -772,17 +772,9 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block // actual specified block, not any preceding blocks that we have to go through // in order to obtain the state. // Therefore, it's perfectly valid to specify `"futureForkBlock": 0`, to enable `futureFork` - if config != nil && config.Overrides != nil { - // Copy the config, to not screw up the main config - // Note: the Clique-part is _not_ deep copied - chainConfigCopy := new(params.ChainConfig) - *chainConfigCopy = *chainConfig - chainConfig = chainConfigCopy - if berlin := config.Config.Overrides.BerlinBlock; berlin != nil { - chainConfig.BerlinBlock = berlin - canon = false - } + // Note: This copies the config, to not screw up the main config + chainConfig, canon = overrideConfig(chainConfig, config.Overrides) } for i, tx := range block.Transactions() { // Prepare the transaction for un-traced execution @@ -1006,3 +998,48 @@ func APIs(backend Backend) []rpc.API { }, } } + +// overrideConfig returns a copy of original with forks enabled by override enabled, +// along with a boolean that indicates whether the copy is canonical (equivalent to the original). +// Note: the Clique-part is _not_ deep copied +func overrideConfig(original *params.ChainConfig, override *params.ChainConfig) (*params.ChainConfig, bool) { + copy := new(params.ChainConfig) + *copy = *original + canon := true + + // Apply forks (after Berlin) to the copy. + if block := override.BerlinBlock; block != nil { + copy.BerlinBlock = block + canon = false + } + if block := override.LondonBlock; block != nil { + copy.LondonBlock = block + canon = false + } + if block := override.ArrowGlacierBlock; block != nil { + copy.ArrowGlacierBlock = block + canon = false + } + if block := override.GrayGlacierBlock; block != nil { + copy.GrayGlacierBlock = block + canon = false + } + if block := override.MergeNetsplitBlock; block != nil { + copy.MergeNetsplitBlock = block + canon = false + } + if timestamp := override.ShanghaiTime; timestamp != nil { + copy.ShanghaiTime = timestamp + canon = false + } + if timestamp := override.CancunTime; timestamp != nil { + copy.CancunTime = timestamp + canon = false + } + if timestamp := override.PragueTime; timestamp != nil { + copy.PragueTime = timestamp + canon = false + } + + return copy, canon +}