Skip to content

Commit

Permalink
Add override.terminaltotaldifficulty flag (#4018)
Browse files Browse the repository at this point in the history
* cmd/utils: initialize f.Value before setting variable

* override.terminaltotaldifficulty flag

* Add OverrideTerminalTotalDifficulty to default_flags
  • Loading branch information
yperbasis authored Apr 28, 2022
1 parent 4b3eb0f commit f9858ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/utils/customflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)
})
}
Expand Down
8 changes: 8 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ var (
Name: "whitelist",
Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
}
OverrideTerminalTotalDifficulty = BigFlag{
Name: "override.terminaltotaldifficulty",
Usage: "Manually specify TerminalTotalDifficulty, overriding the bundled setting",
}
// Ethash settings
EthashCachesInMemoryFlag = cli.IntFlag{
Name: "ethash.cachesinmem",
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions turbo/cli/default_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ var DefaultFlags = []cli.Flag{
utils.HeimdallURLFlag,
utils.WithoutHeimdallFlag,
utils.EthStatsURLFlag,
utils.OverrideTerminalTotalDifficulty,
}

0 comments on commit f9858ff

Please sign in to comment.