From 2bc0a1240d4517a1c65358858487cb7600cc7f9f Mon Sep 17 00:00:00 2001 From: buddho Date: Mon, 23 Dec 2024 16:34:26 +0800 Subject: [PATCH] eth: override chainconfig before create engine for testing (#2822) --- eth/backend.go | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/eth/backend.go b/eth/backend.go index 50c0ed0a37..d2115eca93 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -177,6 +177,32 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { if err != nil { return nil, err } + // Override the chain config with provided settings. + var overrides core.ChainOverrides + if config.OverridePassedForkTime != nil { + chainConfig.ShanghaiTime = config.OverridePassedForkTime + chainConfig.KeplerTime = config.OverridePassedForkTime + chainConfig.FeynmanTime = config.OverridePassedForkTime + chainConfig.FeynmanFixTime = config.OverridePassedForkTime + chainConfig.CancunTime = config.OverridePassedForkTime + chainConfig.HaberTime = config.OverridePassedForkTime + chainConfig.HaberFixTime = config.OverridePassedForkTime + chainConfig.BohrTime = config.OverridePassedForkTime + overrides.OverridePassedForkTime = config.OverridePassedForkTime + } + if config.OverridePascal != nil { + chainConfig.PascalTime = config.OverridePascal + overrides.OverridePascal = config.OverridePascal + } + if config.OverridePrague != nil { + chainConfig.PragueTime = config.OverridePrague + overrides.OverridePrague = config.OverridePrague + } + if config.OverrideVerkle != nil { + chainConfig.VerkleTime = config.OverrideVerkle + overrides.OverrideVerkle = config.OverrideVerkle + } + // startup ancient freeze freezeDb := chainDb if stack.CheckIfMultiDataBase() { @@ -278,31 +304,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { } vmConfig.Tracer = t } - // Override the chain config with provided settings. - var overrides core.ChainOverrides - if config.OverridePassedForkTime != nil { - chainConfig.ShanghaiTime = config.OverridePassedForkTime - chainConfig.KeplerTime = config.OverridePassedForkTime - chainConfig.FeynmanTime = config.OverridePassedForkTime - chainConfig.FeynmanFixTime = config.OverridePassedForkTime - chainConfig.CancunTime = config.OverridePassedForkTime - chainConfig.HaberTime = config.OverridePassedForkTime - chainConfig.HaberFixTime = config.OverridePassedForkTime - chainConfig.BohrTime = config.OverridePassedForkTime - overrides.OverridePassedForkTime = config.OverridePassedForkTime - } - if config.OverridePascal != nil { - chainConfig.PascalTime = config.OverridePascal - overrides.OverridePascal = config.OverridePascal - } - if config.OverridePrague != nil { - chainConfig.PragueTime = config.OverridePrague - overrides.OverridePrague = config.OverridePrague - } - if config.OverrideVerkle != nil { - chainConfig.VerkleTime = config.OverrideVerkle - overrides.OverrideVerkle = config.OverrideVerkle - } bcOps := make([]core.BlockChainOption, 0) if config.PersistDiff {