Skip to content

Commit

Permalink
miner: add totalDifficultyOverride flag
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden committed Oct 4, 2021
1 parent 00f3688 commit a094be5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
if ctx.GlobalIsSet(utils.OverrideLondonFlag.Name) {
cfg.Eth.OverrideLondon = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideLondonFlag.Name))
}
if ctx.GlobalIsSet(utils.OverrideTotalTerminalDifficulty.Name) {
cfg.Eth.Genesis.Config.TerminalTotalDifficulty = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideTotalTerminalDifficulty.Name))
}
backend, _ := utils.RegisterEthService(stack, &cfg.Eth, ctx.GlobalBool(utils.CatalystFlag.Name))

// Configure GraphQL if requested
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ var (
utils.USBFlag,
utils.SmartCardDaemonPathFlag,
utils.OverrideLondonFlag,
utils.OverrideTotalTerminalDifficulty,
utils.EthashCacheDirFlag,
utils.EthashCachesInMemoryFlag,
utils.EthashCachesOnDiskFlag,
Expand Down
4 changes: 4 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ var (
Name: "override.london",
Usage: "Manually specify London fork-block, overriding the bundled setting",
}
OverrideTotalTerminalDifficulty = cli.Uint64Flag{
Name: "override.totalterminaldifficulty",
Usage: "Manually specify TotalTerminalDifficulty, overriding the bundled setting",
}
// Light server and client settings
LightServeFlag = cli.IntFlag{
Name: "light.serve",
Expand Down
1 change: 1 addition & 0 deletions eth/catalyst/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ func (api *ConsensusAPI) setHead(newHead common.Hash) error {
if !merger.LeftPoW() {
merger.LeavePoW()
}
log.Info("Setting head", "head", newHead)
if api.light {
headHeader := api.les.BlockChain().CurrentHeader()
if headHeader.Hash() == newHead {
Expand Down
13 changes: 13 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package miner
import (
"bytes"
"errors"
"fmt"
"math/big"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -1024,6 +1025,18 @@ func (w *worker) commit(uncles []*types.Header, interval func(), update bool, st
if err != nil {
return err
}

// TODO (MariusVanDerWijden) remove this after eth2 interop
// ---
parent := w.chain.GetBlockByHash(block.ParentHash())
if parent == nil {
return fmt.Errorf("parent unavailable: %v", block.ParentHash())
}
td := w.chain.GetTdByHash(parent.Hash())
if td != nil && td.Cmp(w.chain.Config().TerminalTotalDifficulty) > 0 {
log.Warn("Total terminal difficulty reached, keeping on mining to test eth2 clients")
}
// ---
if w.isRunning() && !w.merger.LeftPoW() {
if interval != nil {
interval()
Expand Down

0 comments on commit a094be5

Please sign in to comment.