From 20ee1b29ecc0469e6eb2a883618b053ee3f0dafc Mon Sep 17 00:00:00 2001 From: yperbasis Date: Thu, 28 Apr 2022 17:06:07 +0200 Subject: [PATCH 1/3] cmd/utils: initialize f.Value before setting variable --- cmd/utils/customflags.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/utils/customflags.go b/cmd/utils/customflags.go index 6db1f74be59..0fdb6f9e954 100644 --- a/cmd/utils/customflags.go +++ b/cmd/utils/customflags.go @@ -154,11 +154,11 @@ func (b *bigValue) String() string { } func (b *bigValue) Set(s string) error { - int, ok := math.ParseBig256(s) + intVal, ok := math.ParseBig256(s) if !ok { return errors.New("invalid integer syntax") } - *b = bigValue(*int) + *b = bigValue(*intVal) return nil } @@ -172,6 +172,7 @@ func (f BigFlag) String() string { func (f BigFlag) Apply(set *flag.FlagSet) { eachName(f.Name, func(name string) { + f.Value = new(big.Int) set.Var((*bigValue)(f.Value), f.Name, f.Usage) }) } From b0368704ac3445a626c53170af79a6f30bfd0c46 Mon Sep 17 00:00:00 2001 From: yperbasis Date: Thu, 28 Apr 2022 17:33:17 +0200 Subject: [PATCH 2/3] override.terminaltotaldifficulty flag --- cmd/utils/flags.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 171d7e812a6..4384401fb0d 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -134,6 +134,10 @@ var ( Name: "whitelist", Usage: "Comma separated block number-to-hash mappings to enforce (=)", } + OverrideTerminalTotalDifficulty = BigFlag{ + Name: "override.terminaltotaldifficulty", + Usage: "Manually specify TerminalTotalDifficulty, overriding the bundled setting", + } // Ethash settings EthashCachesInMemoryFlag = cli.IntFlag{ Name: "ethash.cachesinmem", @@ -1492,6 +1496,10 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *node.Config, cfg *ethconfig.Conf cfg.Miner.GasPrice = big.NewInt(1) } } + + if ctx.GlobalIsSet(OverrideTerminalTotalDifficulty.Name) { + cfg.Genesis.Config.TerminalTotalDifficulty = GlobalBig(ctx, OverrideTerminalTotalDifficulty.Name) + } } // SetDNSDiscoveryDefaults configures DNS discovery with the given URL if From b8fd873a06a3f755f3c8b9865d2eb9b8f96cd599 Mon Sep 17 00:00:00 2001 From: yperbasis Date: Thu, 28 Apr 2022 17:59:50 +0200 Subject: [PATCH 3/3] Add OverrideTerminalTotalDifficulty to default_flags --- turbo/cli/default_flags.go | 1 + 1 file changed, 1 insertion(+) diff --git a/turbo/cli/default_flags.go b/turbo/cli/default_flags.go index 276b7613708..f66bf3821b8 100644 --- a/turbo/cli/default_flags.go +++ b/turbo/cli/default_flags.go @@ -124,4 +124,5 @@ var DefaultFlags = []cli.Flag{ utils.HeimdallURLFlag, utils.WithoutHeimdallFlag, utils.EthStatsURLFlag, + utils.OverrideTerminalTotalDifficulty, }