Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth/tracers: more fork overrides in traceBlockToFile #26655

Merged
merged 3 commits into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 47 additions & 10 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}