eth: remove usage of tdd

This commit is contained in:
Manav Darji 2025-03-26 11:09:50 +05:30
parent 0aee8d9db7
commit aa36b7dd9b
No known key found for this signature in database
GPG key ID: A426F0124435F36E
5 changed files with 23 additions and 55 deletions

View file

@ -18,7 +18,6 @@
package ethconfig package ethconfig
import ( import (
"errors"
"math/big" "math/big"
"time" "time"
@ -238,11 +237,5 @@ func CreateConsensusEngine(chainConfig *params.ChainConfig, ethConfig *Config, d
return bor.New(chainConfig, db, blockchainAPI, spanner, heimdallClient, genesisContractsClient, false), nil return bor.New(chainConfig, db, blockchainAPI, spanner, heimdallClient, genesisContractsClient, false), nil
} }
} }
// If defaulting to proof-of-work, enforce an already merged network since
// we cannot run PoW algorithms anymore, so we cannot even follow a chain
// not coordinated by a beacon node.
if !chainConfig.TerminalTotalDifficultyPassed {
return nil, errors.New("ethash is only supported as a historical component of already merged networks")
}
return beacon.New(ethash.NewFaker()), nil return beacon.New(ethash.NewFaker()), nil
} }

View file

@ -576,7 +576,7 @@ func (f *BlockFetcher) loop() {
case res := <-resCh: case res := <-resCh:
res.Done <- nil res.Done <- nil
// Ignoring withdrawals here, since the block fetcher is not used post-merge. // Ignoring withdrawals here, since the block fetcher is not used post-merge.
txs, uncles, _, _ := res.Res.(*eth.BlockBodiesResponse).Unpack() txs, uncles, _ := res.Res.(*eth.BlockBodiesResponse).Unpack()
f.FilterBodies(peer, txs, uncles, time.Now(), announcedAt) f.FilterBodies(peer, txs, uncles, time.Now(), announcedAt)
case <-timeout.C: case <-timeout.C:

View file

@ -203,20 +203,7 @@ func newHandler(config *handlerConfig) (*handler, error) {
} }
// Construct the downloader (long sync) // Construct the downloader (long sync)
h.downloader = downloader.New(config.Database, h.eventMux, h.chain, nil, h.removePeer, h.enableSyncedFeatures, config.checker) h.downloader = downloader.New(config.Database, h.eventMux, h.chain, nil, h.removePeer, h.enableSyncedFeatures, config.checker)
if ttd := h.chain.Config().TerminalTotalDifficulty; ttd != nil {
if h.chain.Config().TerminalTotalDifficultyPassed {
log.Info("Chain post-merge, sync via beacon client")
} else {
head := h.chain.CurrentBlock()
if td := h.chain.GetTd(head.Hash(), head.Number.Uint64()); td.Cmp(ttd) >= 0 {
log.Info("Chain post-TTD, sync via beacon client")
} else {
log.Warn("Chain pre-merge, sync via PoW (ensure beacon client is ready)")
}
}
} else if h.chain.Config().TerminalTotalDifficultyPassed {
log.Error("Chain configured post-merge, but without TTD. Are you debugging sync?")
}
// Construct the fetcher (short sync) // Construct the fetcher (short sync)
validator := func(header *types.Header) error { validator := func(header *types.Header) error {
// Reject all the PoS style headers in the first place. No matter // Reject all the PoS style headers in the first place. No matter

View file

@ -96,7 +96,6 @@ func newTestBackendWithGenerator(blocks int, shanghai bool, generator func(int,
MergeNetsplitBlock: big.NewInt(0), MergeNetsplitBlock: big.NewInt(0),
ShanghaiBlock: big.NewInt(0), ShanghaiBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true,
Ethash: new(params.EthashConfig), Ethash: new(params.EthashConfig),
Bor: params.TestChainConfig.Bor, Bor: params.TestChainConfig.Bor,
} }

View file

@ -146,17 +146,6 @@ func (cs *chainSyncer) nextSyncOp() *chainSyncOp {
if cs.doneCh != nil { if cs.doneCh != nil {
return nil // Sync already running return nil // Sync already running
} }
// If a beacon client once took over control, disable the entire legacy sync
// path from here on end. Note, there is a slight "race" between reaching TTD
// and the beacon client taking over. The downloader will enforce that nothing
// above the first TTD will be delivered to the chain for import.
//
// An alternative would be to check the local chain for exceeding the TTD and
// avoid triggering a sync in that case, but that could also miss sibling or
// other family TTD block being accepted.
if cs.handler.chain.Config().TerminalTotalDifficultyPassed {
return nil
}
// Ensure we're at minimum peer count. // Ensure we're at minimum peer count.
minPeers := defaultMinSyncPeers minPeers := defaultMinSyncPeers
if cs.forced { if cs.forced {