Skip to content

Commit 7d29fff

Browse files
author
Darioush Jalali
authored
eth/tracers: more fork overrides in traceBlockToFile (#26655)
This change allows all post-Berlin forks to be specified as overrides for futureForkBlock in the config parameter for traceBlockToFile.
1 parent 2def62b commit 7d29fff

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

eth/tracers/api.go

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -772,17 +772,9 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
772772
// actual specified block, not any preceding blocks that we have to go through
773773
// in order to obtain the state.
774774
// Therefore, it's perfectly valid to specify `"futureForkBlock": 0`, to enable `futureFork`
775-
776775
if config != nil && config.Overrides != nil {
777-
// Copy the config, to not screw up the main config
778-
// Note: the Clique-part is _not_ deep copied
779-
chainConfigCopy := new(params.ChainConfig)
780-
*chainConfigCopy = *chainConfig
781-
chainConfig = chainConfigCopy
782-
if berlin := config.Config.Overrides.BerlinBlock; berlin != nil {
783-
chainConfig.BerlinBlock = berlin
784-
canon = false
785-
}
776+
// Note: This copies the config, to not screw up the main config
777+
chainConfig, canon = overrideConfig(chainConfig, config.Overrides)
786778
}
787779
for i, tx := range block.Transactions() {
788780
// Prepare the transaction for un-traced execution
@@ -1006,3 +998,48 @@ func APIs(backend Backend) []rpc.API {
1006998
},
1007999
}
10081000
}
1001+
1002+
// overrideConfig returns a copy of original with forks enabled by override enabled,
1003+
// along with a boolean that indicates whether the copy is canonical (equivalent to the original).
1004+
// Note: the Clique-part is _not_ deep copied
1005+
func overrideConfig(original *params.ChainConfig, override *params.ChainConfig) (*params.ChainConfig, bool) {
1006+
copy := new(params.ChainConfig)
1007+
*copy = *original
1008+
canon := true
1009+
1010+
// Apply forks (after Berlin) to the copy.
1011+
if block := override.BerlinBlock; block != nil {
1012+
copy.BerlinBlock = block
1013+
canon = false
1014+
}
1015+
if block := override.LondonBlock; block != nil {
1016+
copy.LondonBlock = block
1017+
canon = false
1018+
}
1019+
if block := override.ArrowGlacierBlock; block != nil {
1020+
copy.ArrowGlacierBlock = block
1021+
canon = false
1022+
}
1023+
if block := override.GrayGlacierBlock; block != nil {
1024+
copy.GrayGlacierBlock = block
1025+
canon = false
1026+
}
1027+
if block := override.MergeNetsplitBlock; block != nil {
1028+
copy.MergeNetsplitBlock = block
1029+
canon = false
1030+
}
1031+
if timestamp := override.ShanghaiTime; timestamp != nil {
1032+
copy.ShanghaiTime = timestamp
1033+
canon = false
1034+
}
1035+
if timestamp := override.CancunTime; timestamp != nil {
1036+
copy.CancunTime = timestamp
1037+
canon = false
1038+
}
1039+
if timestamp := override.PragueTime; timestamp != nil {
1040+
copy.PragueTime = timestamp
1041+
canon = false
1042+
}
1043+
1044+
return copy, canon
1045+
}

0 commit comments

Comments
 (0)