From 6e34cc4f2c212a849b2ed325633eafacaee9f7ec Mon Sep 17 00:00:00 2001 From: Pratik Patil Date: Fri, 2 May 2025 14:43:27 +0530 Subject: [PATCH] Revert "eth/downloader: move SyncMode to package eth/ethconfig (#30847)" This reverts commit 4afab7ef7614b6888abaf367a3a5852ecba9bee1. --- cmd/utils/flags.go | 7 ++-- eth/backend.go | 10 +++--- eth/catalyst/api.go | 6 ++-- eth/catalyst/api_test.go | 3 +- eth/catalyst/simulated_beacon_test.go | 3 +- eth/catalyst/tester.go | 4 +-- eth/downloader/beaconsync.go | 13 ++++--- eth/downloader/bor_downloader.go | 35 ++++++------------- .../syncmode.go => downloader/modes.go} | 2 +- eth/downloader/queue.go | 7 ++-- eth/ethconfig/config.go | 5 +-- eth/ethconfig/gen_config.go | 5 +-- eth/handler.go | 3 +- eth/handler_eth_test.go | 6 ++-- eth/handler_test.go | 4 +-- eth/sync_test.go | 4 +-- ethclient/simulated/backend.go | 3 +- 17 files changed, 55 insertions(+), 65 deletions(-) rename eth/{ethconfig/syncmode.go => downloader/modes.go} (99%) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 7d7d4b3649..fbbb48ba94 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -54,6 +54,7 @@ import ( "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth/catalyst" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/eth/gasprice" @@ -1722,7 +1723,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { godebug.SetGCPercent(int(gogc)) if ctx.IsSet(SyncTargetFlag.Name) { - cfg.SyncMode = ethconfig.FullSync // dev sync target forces full sync + cfg.SyncMode = downloader.FullSync // dev sync target forces full sync } else if ctx.IsSet(SyncModeFlag.Name) { value := ctx.String(SyncModeFlag.Name) if err = cfg.SyncMode.UnmarshalText([]byte(value)); err != nil { @@ -1825,7 +1826,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { } if !ctx.Bool(SnapshotFlag.Name) || cfg.SnapshotCache == 0 { // If snap-sync is requested, this flag is also required - if cfg.SyncMode == ethconfig.SnapSync { + if cfg.SyncMode == downloader.SnapSync { if !ctx.Bool(SnapshotFlag.Name) { log.Warn("Snap sync requested, enabling --snapshot") } @@ -1897,7 +1898,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if !ctx.IsSet(NetworkIdFlag.Name) { cfg.NetworkId = 1337 } - cfg.SyncMode = ethconfig.FullSync + cfg.SyncMode = downloader.FullSync // Create new developer account or reuse existing one var ( developer accounts.Account diff --git a/eth/backend.go b/eth/backend.go index b4e70da610..6a2fc6ef6a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -966,17 +966,17 @@ func (s *Ethereum) SetBlockchain(blockchain *core.BlockChain) { // SyncMode retrieves the current sync mode, either explicitly set, or derived // from the chain status. -func (s *Ethereum) SyncMode() ethconfig.SyncMode { +func (s *Ethereum) SyncMode() downloader.SyncMode { // If we're in snap sync mode, return that directly if s.handler.snapSync.Load() { - return ethconfig.SnapSync + return downloader.SnapSync } // We are probably in full sync, but we might have rewound to before the // snap sync pivot, check if we should re-enable snap sync. head := s.blockchain.CurrentBlock() if pivot := rawdb.ReadLastPivotNumber(s.chainDb); pivot != nil { if head.Number.Uint64() < *pivot { - return ethconfig.SnapSync + return downloader.SnapSync } } // We are in a full sync, but the associated head state is missing. To complete @@ -984,8 +984,8 @@ func (s *Ethereum) SyncMode() ethconfig.SyncMode { // persistent state is corrupted, just mismatch with the head block. if !s.blockchain.HasState(head.Root) { log.Info("Reenabled snap sync as chain is stateless") - return ethconfig.SnapSync + return downloader.SnapSync } // Nope, we're really full syncing - return ethconfig.FullSync + return downloader.FullSync } diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index ef5d9f0e02..8560fb4764 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -34,7 +34,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth" - "github.com/ethereum/go-ethereum/eth/ethconfig" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/internal/version" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/miner" @@ -925,7 +925,7 @@ func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashe // tries to make it import a block. That should be denied as pushing something // into the database directly will conflict with the assumptions of snap sync // that it has an empty db that it can fill itself. - if api.eth.SyncMode() != ethconfig.FullSync { + if api.eth.SyncMode() != downloader.FullSync { return api.delayPayloadImport(block), nil } if !api.eth.BlockChain().HasBlockAndState(block.ParentHash(), block.NumberU64()-1) { @@ -1038,7 +1038,7 @@ func (api *ConsensusAPI) delayPayloadImport(block *types.Block) engine.PayloadSt // payload as non-integratable on top of the existing sync. We'll just // have to rely on the beacon client to forcefully update the head with // a forkchoice update request. - if api.eth.SyncMode() == ethconfig.FullSync { + if api.eth.SyncMode() == downloader.FullSync { // In full sync mode, failure to import a well-formed block can only mean // that the parent state is missing and the syncer rejected extending the // current cycle with the new payload. diff --git a/eth/catalyst/api_test.go b/eth/catalyst/api_test.go index 8c9707e08c..d8449dde5e 100644 --- a/eth/catalyst/api_test.go +++ b/eth/catalyst/api_test.go @@ -40,6 +40,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/internal/version" "github.com/ethereum/go-ethereum/miner" @@ -453,7 +454,7 @@ func startEthService(t *testing.T, genesis *core.Genesis, blocks []*types.Block) mcfg := miner.DefaultConfig mcfg.Etherbase = testAddr - ethcfg := ðconfig.Config{Genesis: genesis, SyncMode: ethconfig.FullSync, TrieTimeout: time.Minute, TrieDirtyCache: 256, TrieCleanCache: 256, Miner: mcfg} + ethcfg := ðconfig.Config{Genesis: genesis, SyncMode: downloader.FullSync, TrieTimeout: time.Minute, TrieDirtyCache: 256, TrieCleanCache: 256, Miner: mcfg} ethservice, err := eth.New(n, ethcfg) if err != nil { t.Fatal("can't create eth service:", err) diff --git a/eth/catalyst/simulated_beacon_test.go b/eth/catalyst/simulated_beacon_test.go index e5f7384734..1a5fc27ecc 100644 --- a/eth/catalyst/simulated_beacon_test.go +++ b/eth/catalyst/simulated_beacon_test.go @@ -28,6 +28,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/node" @@ -49,7 +50,7 @@ func startSimulatedBeaconEthService(t *testing.T, genesis *core.Genesis, period t.Fatal("can't create node:", err) } - ethcfg := ðconfig.Config{Genesis: genesis, SyncMode: ethconfig.FullSync, TrieTimeout: time.Minute, TrieDirtyCache: 256, TrieCleanCache: 256, Miner: miner.DefaultConfig} + ethcfg := ðconfig.Config{Genesis: genesis, SyncMode: downloader.FullSync, TrieTimeout: time.Minute, TrieDirtyCache: 256, TrieCleanCache: 256, Miner: miner.DefaultConfig} ethservice, err := eth.New(n, ethcfg) if err != nil { t.Fatal("can't create eth service:", err) diff --git a/eth/catalyst/tester.go b/eth/catalyst/tester.go index 44d0e04392..9bce515513 100644 --- a/eth/catalyst/tester.go +++ b/eth/catalyst/tester.go @@ -22,7 +22,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/eth" - "github.com/ethereum/go-ethereum/eth/ethconfig" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" ) @@ -64,7 +64,7 @@ func (tester *FullSyncTester) Start() error { // Trigger beacon sync with the provided block hash as trusted // chain head. - err := tester.backend.Downloader().BeaconDevSync(ethconfig.FullSync, tester.target, tester.closed) + err := tester.backend.Downloader().BeaconDevSync(downloader.FullSync, tester.target, tester.closed) if err != nil { log.Info("Failed to trigger beacon sync", "err", err) } diff --git a/eth/downloader/beaconsync.go b/eth/downloader/beaconsync.go index 357f0306c4..da14542e27 100644 --- a/eth/downloader/beaconsync.go +++ b/eth/downloader/beaconsync.go @@ -24,7 +24,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/log" ) @@ -200,9 +199,9 @@ func (d *Downloader) findBeaconAncestor() (uint64, error) { var chainHead *types.Header switch d.getMode() { - case ethconfig.FullSync: + case FullSync: chainHead = d.blockchain.CurrentBlock() - case ethconfig.SnapSync: + case SnapSync: chainHead = d.blockchain.CurrentSnapBlock() default: chainHead = d.lightchain.CurrentHeader() @@ -222,9 +221,9 @@ func (d *Downloader) findBeaconAncestor() (uint64, error) { var linked bool switch d.getMode() { - case ethconfig.FullSync: + case FullSync: linked = d.blockchain.HasBlock(beaconTail.ParentHash, beaconTail.Number.Uint64()-1) - case ethconfig.SnapSync: + case SnapSync: linked = d.blockchain.HasFastBlock(beaconTail.ParentHash, beaconTail.Number.Uint64()-1) default: linked = d.blockchain.HasHeader(beaconTail.ParentHash, beaconTail.Number.Uint64()-1) @@ -260,9 +259,9 @@ func (d *Downloader) findBeaconAncestor() (uint64, error) { var known bool switch d.getMode() { - case ethconfig.FullSync: + case FullSync: known = d.blockchain.HasBlock(h.Hash(), n) - case ethconfig.SnapSync: + case SnapSync: known = d.blockchain.HasFastBlock(h.Hash(), n) default: known = d.lightchain.HasHeader(h.Hash(), n) diff --git a/eth/downloader/bor_downloader.go b/eth/downloader/bor_downloader.go index 09a82605c1..f5bc7fd434 100644 --- a/eth/downloader/bor_downloader.go +++ b/eth/downloader/bor_downloader.go @@ -31,7 +31,6 @@ import ( "github.com/ethereum/go-ethereum/core/state/snapshot" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/downloader/whitelist" - "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/eth/protocols/snap" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" @@ -84,17 +83,6 @@ var ( ErrMergeTransition = errors.New("legacy sync reached the merge") ) -// SyncMode defines the sync method of the downloader. -// Deprecated: use ethconfig.SyncMode instead -type SyncMode = ethconfig.SyncMode - -const ( - // Deprecated: use ethconfig.FullSync - FullSync = ethconfig.FullSync - // Deprecated: use ethconfig.SnapSync - SnapSync = ethconfig.SnapSync -) - // peerDropFn is a callback type for dropping a peer detected as malicious. type peerDropFn func(id string) @@ -279,11 +267,10 @@ func (d *Downloader) Progress() ethereum.SyncProgress { current := uint64(0) mode := d.getMode() - - switch { - case d.blockchain != nil && mode == ethconfig.FullSync: + switch mode { + case FullSync: current = d.blockchain.CurrentBlock().Number.Uint64() - case d.blockchain != nil && mode == ethconfig.SnapSync: + case SnapSync: current = d.blockchain.CurrentSnapBlock().Number.Uint64() case d.lightchain != nil: current = d.lightchain.CurrentHeader().Number.Uint64() @@ -431,7 +418,7 @@ func (d *Downloader) synchronise(id string, hash common.Hash, td, ttd *big.Int, if d.notified.CompareAndSwap(false, true) { log.Info("Block synchronisation started") } - if mode == ethconfig.SnapSync { + if mode == SnapSync { // Snap sync will directly modify the persistent state, making the entire // trie database unusable until the state is fully synced. To prevent any // subsequent state reads, explicitly disable the trie database and state @@ -569,7 +556,7 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td, ttd * // threshold (i.e. new chain). In that case we won't really fast sync // anyway, but still need a valid pivot block to avoid some code hitting // nil panics on access. - if mode == ethconfig.SnapSync && pivot == nil { + if mode == SnapSync && pivot == nil { pivot = d.blockchain.CurrentBlock() } @@ -599,7 +586,7 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td, ttd * d.syncStatsLock.Unlock() // Ensure our origin point is below any snap sync pivot point - if mode == ethconfig.SnapSync { + if mode == SnapSync { if height <= uint64(fsMinFullBlocks) { origin = 0 } else { @@ -614,10 +601,10 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td, ttd * } d.committed.Store(true) - if mode == ethconfig.SnapSync && pivot.Number.Uint64() != 0 { + if mode == SnapSync && pivot.Number.Uint64() != 0 { d.committed.Store(false) } - if mode == ethconfig.SnapSync { + if mode == SnapSync { // Set the ancient data limitation. If we are running snap sync, all block // data older than ancientLimit will be written to the ancient store. More // recent data will be written to the active database and will wait for the @@ -694,13 +681,13 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td, ttd * func() error { return d.processHeaders(origin+1, td, ttd, beaconMode) }, } - if mode == ethconfig.SnapSync { + if mode == SnapSync { d.pivotLock.Lock() d.pivotHeader = pivot d.pivotLock.Unlock() fetchers = append(fetchers, func() error { return d.processSnapSyncContent() }) - } else if mode == ethconfig.FullSync { + } else if mode == FullSync { fetchers = append(fetchers, func() error { return d.processFullSyncContent(ttd, beaconMode) }) } @@ -1453,7 +1440,7 @@ func (d *Downloader) processHeaders(origin uint64, td, ttd *big.Int, beaconMode chunkHashes := hashes[:limit] // In case of header only syncing, validate the chunk immediately - if mode == ethconfig.SnapSync { + if mode == SnapSync { // Although the received headers might be all valid, a legacy // PoW/PoA sync must not accept post-merge headers. Make sure // that any transition is rejected at this point. diff --git a/eth/ethconfig/syncmode.go b/eth/downloader/modes.go similarity index 99% rename from eth/ethconfig/syncmode.go rename to eth/downloader/modes.go index c402f13880..65e76f7996 100644 --- a/eth/ethconfig/syncmode.go +++ b/eth/downloader/modes.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see . -package ethconfig +package downloader import "fmt" diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index a5b8b63fbc..2caf1c1084 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -30,7 +30,6 @@ import ( "github.com/ethereum/go-ethereum/common/prque" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto/kzg4844" - "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/params" @@ -185,7 +184,7 @@ func (q *queue) Reset(blockCacheLimit int, thresholdInitialSize int) { defer q.lock.Unlock() q.closed = false - q.mode = ethconfig.FullSync + q.mode = FullSync q.headerHead = common.Hash{} q.headerPendPool = make(map[string]*fetchRequest) @@ -335,7 +334,7 @@ func (q *queue) Schedule(headers []*types.Header, hashes []common.Hash, from uin q.blockTaskQueue.Push(header, -int64(header.Number.Uint64())) } // Queue for receipt retrieval - if q.mode == ethconfig.SnapSync && !header.EmptyReceipts() { + if q.mode == SnapSync && !header.EmptyReceipts() { if _, ok := q.receiptTaskPool[hash]; ok { log.Warn("Header already scheduled for receipt fetch", "number", header.Number, "hash", hash) } else { @@ -541,7 +540,7 @@ func (q *queue) reserveHeaders(p *peerConnection, count int, taskPool map[common // we can ask the resultcache if this header is within the // "prioritized" segment of blocks. If it is not, we need to throttle - stale, throttle, item, err := q.resultCache.AddFetch(header, q.mode == ethconfig.SnapSync) + stale, throttle, item, err := q.resultCache.AddFetch(header, q.mode == SnapSync) if stale { // Don't put back in the task queue, this item has already been // delivered upstream diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index f361b946bd..9532e8f051 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -35,6 +35,7 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/txpool/blobpool" "github.com/ethereum/go-ethereum/core/txpool/legacypool" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/gasprice" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/internal/ethapi" @@ -55,7 +56,7 @@ var FullNodeGPO = gasprice.Config{ // Defaults contains default settings for use on the Ethereum main net. var Defaults = Config{ - SyncMode: FullSync, + SyncMode: downloader.SnapSync, NetworkId: 0, // enable auto configuration of networkID == chainID TxLookupLimit: 2350000, TransactionHistory: 2350000, @@ -87,7 +88,7 @@ type Config struct { // Network ID separates blockchains on the peer-to-peer networking level. When left // zero, the chain ID is used as network ID. NetworkId uint64 - SyncMode SyncMode + SyncMode downloader.SyncMode // HistoryMode configures chain history retention. HistoryMode HistoryMode diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index 7ee1f3cd9d..9cced8f89c 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/txpool/blobpool" "github.com/ethereum/go-ethereum/core/txpool/legacypool" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/gasprice" "github.com/ethereum/go-ethereum/miner" ) @@ -19,7 +20,7 @@ func (c Config) MarshalTOML() (interface{}, error) { type Config struct { Genesis *core.Genesis `toml:",omitempty"` NetworkId uint64 - SyncMode SyncMode + SyncMode downloader.SyncMode HistoryMode HistoryMode EthDiscoveryURLs []string SnapDiscoveryURLs []string @@ -137,7 +138,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { type Config struct { Genesis *core.Genesis `toml:",omitempty"` NetworkId *uint64 - SyncMode *SyncMode + SyncMode *downloader.SyncMode HistoryMode *HistoryMode EthDiscoveryURLs []string SnapDiscoveryURLs []string diff --git a/eth/handler.go b/eth/handler.go index e793844328..3798a2effb 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -33,7 +33,6 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth/downloader" - "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/eth/fetcher" "github.com/ethereum/go-ethereum/eth/protocols/eth" "github.com/ethereum/go-ethereum/eth/protocols/snap" @@ -169,7 +168,7 @@ func newHandler(config *handlerConfig) (*handler, error) { handlerDoneCh: make(chan struct{}), handlerStartCh: make(chan struct{}), } - if config.Sync == ethconfig.FullSync { + if config.Sync == downloader.FullSync { // The database seems empty as the current block is the genesis. Yet the snap // block is ahead, so snap sync was enabled for this node at a certain point. // The scenarios where this can happen is diff --git a/eth/handler_eth_test.go b/eth/handler_eth_test.go index d81ca8f347..48923d04df 100644 --- a/eth/handler_eth_test.go +++ b/eth/handler_eth_test.go @@ -29,7 +29,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/eth/ethconfig" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/protocols/eth" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/p2p" @@ -114,7 +114,7 @@ func testForkIDSplit(t *testing.T, protocol uint) { Chain: chainNoFork, TxPool: newTestTxPool(), Network: 1, - Sync: ethconfig.FullSync, + Sync: downloader.FullSync, BloomCache: 1, }) ethProFork, _ = newHandler(&handlerConfig{ @@ -122,7 +122,7 @@ func testForkIDSplit(t *testing.T, protocol uint) { Chain: chainProFork, TxPool: newTestTxPool(), Network: 1, - Sync: ethconfig.FullSync, + Sync: downloader.FullSync, BloomCache: 1, }) ) diff --git a/eth/handler_test.go b/eth/handler_test.go index 95b1eed285..1959fecd4c 100644 --- a/eth/handler_test.go +++ b/eth/handler_test.go @@ -29,7 +29,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/eth/ethconfig" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/params" @@ -181,7 +181,7 @@ func newTestHandlerWithBlocks(blocks int) *testHandler { Chain: chain, TxPool: txpool, Network: 1, - Sync: ethconfig.SnapSync, + Sync: downloader.SnapSync, BloomCache: 1, }) handler.Start(1000) diff --git a/eth/sync_test.go b/eth/sync_test.go index 6742f5aee2..5411fa1c49 100644 --- a/eth/sync_test.go +++ b/eth/sync_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/eth/ethconfig" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/protocols/eth" "github.com/ethereum/go-ethereum/eth/protocols/snap" "github.com/ethereum/go-ethereum/p2p" @@ -86,7 +86,7 @@ func testSnapSyncDisabling(t *testing.T, ethVer uint, snapVer uint) { time.Sleep(250 * time.Millisecond) // Check that snap sync was disabled - if err := empty.handler.downloader.BeaconSync(ethconfig.SnapSync, full.chain.CurrentBlock(), nil); err != nil { + if err := empty.handler.downloader.BeaconSync(downloader.SnapSync, full.chain.CurrentBlock(), nil); err != nil { t.Fatal("sync failed:", err) } time.Sleep(time.Second * 5) // Downloader internally has to wait a timer (3s) to be expired before exiting diff --git a/ethclient/simulated/backend.go b/ethclient/simulated/backend.go index 2744173203..af0b2fe2a4 100644 --- a/ethclient/simulated/backend.go +++ b/ethclient/simulated/backend.go @@ -26,6 +26,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth/catalyst" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/ethclient" @@ -84,7 +85,7 @@ func NewBackend(alloc types.GenesisAlloc, options ...func(nodeConf *node.Config, GasLimit: ethconfig.Defaults.Miner.GasCeil, Alloc: alloc, } - ethConf.SyncMode = ethconfig.FullSync + ethConf.SyncMode = downloader.FullSync ethConf.TxPool.NoLocals = true for _, option := range options {