mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
eth: remove usage of tdd
This commit is contained in:
parent
0aee8d9db7
commit
aa36b7dd9b
5 changed files with 23 additions and 55 deletions
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -77,28 +77,27 @@ func newTestBackendWithGenerator(blocks int, shanghai bool, generator func(int,
|
||||||
|
|
||||||
if shanghai {
|
if shanghai {
|
||||||
config = ¶ms.ChainConfig{
|
config = ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(1),
|
ChainID: big.NewInt(1),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: big.NewInt(0),
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: big.NewInt(0),
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: big.NewInt(0),
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: big.NewInt(0),
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: big.NewInt(0),
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
ConstantinopleBlock: big.NewInt(0),
|
||||||
PetersburgBlock: big.NewInt(0),
|
PetersburgBlock: big.NewInt(0),
|
||||||
IstanbulBlock: big.NewInt(0),
|
IstanbulBlock: big.NewInt(0),
|
||||||
MuirGlacierBlock: big.NewInt(0),
|
MuirGlacierBlock: big.NewInt(0),
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: big.NewInt(0),
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: big.NewInt(0),
|
||||||
ArrowGlacierBlock: big.NewInt(0),
|
ArrowGlacierBlock: big.NewInt(0),
|
||||||
GrayGlacierBlock: big.NewInt(0),
|
GrayGlacierBlock: big.NewInt(0),
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
engine = beacon.NewFaker()
|
engine = beacon.NewFaker()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
eth/sync.go
11
eth/sync.go
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue