diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index b33f6ceff2..9693df65e3 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -747,7 +747,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.Downloader().GetSyncMode() == ethconfig.SnapSync { + if api.eth.Downloader().ConfigSyncMode() == ethconfig.SnapSync { return api.delayPayloadImport(block), nil } if !api.eth.BlockChain().HasBlockAndState(block.ParentHash(), block.NumberU64()-1) { @@ -804,7 +804,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.Downloader().GetSyncMode() == ethconfig.FullSync { + if api.eth.Downloader().ConfigSyncMode() == ethconfig.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/downloader/downloader.go b/eth/downloader/downloader.go index b84a0efddd..6b80a18539 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -424,8 +424,9 @@ func (d *Downloader) getMode() SyncMode { return SyncMode(d.mode.Load()) } -// GetSyncMode returns the suggested sync mode. -func (d *Downloader) GetSyncMode() SyncMode { +// ConfigSyncMode returns the sync mode configured for the node. +// The actual running sync mode can differ from this. +func (d *Downloader) ConfigSyncMode() SyncMode { return d.moder.getMode() } diff --git a/eth/handler.go b/eth/handler.go index 43f26ef663..4510dd32f0 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -163,7 +163,7 @@ func newHandler(config *handlerConfig) (*handler, error) { h.downloader = downloader.New(config.Database, config.Sync, h.eventMux, h.chain, h.removePeer, h.enableSyncedFeatures) // If snap sync is requested but snapshots are disabled, fail loudly - if h.downloader.GetSyncMode() == ethconfig.SnapSync && (config.Chain.Snapshots() == nil && config.Chain.TrieDB().Scheme() == rawdb.HashScheme) { + if h.downloader.ConfigSyncMode() == ethconfig.SnapSync && (config.Chain.Snapshots() == nil && config.Chain.TrieDB().Scheme() == rawdb.HashScheme) { return nil, errors.New("snap sync not supported with snapshots disabled") } fetchTx := func(peer string, hashes []common.Hash) error { @@ -238,7 +238,7 @@ func (h *handler) runEthPeer(peer *eth.Peer, handler eth.Handler) error { return err } reject := false // reserved peer slots - if h.downloader.GetSyncMode() == ethconfig.SnapSync { + if h.downloader.ConfigSyncMode() == ethconfig.SnapSync { if snap == nil { // If we are running snap-sync, we want to reserve roughly half the peer // slots for peers supporting the snap protocol. @@ -553,7 +553,7 @@ func (h *handler) blockRangeLoop(st *blockRangeState) { if ev == nil { continue } - if _, ok := ev.Data.(downloader.StartEvent); ok && h.downloader.GetSyncMode() == ethconfig.SnapSync { + if _, ok := ev.Data.(downloader.StartEvent); ok && h.downloader.ConfigSyncMode() == ethconfig.SnapSync { h.blockRangeWhileSnapSyncing(st) } case <-st.headCh: diff --git a/eth/sync_test.go b/eth/sync_test.go index 0fb54a5e14..509b836f82 100644 --- a/eth/sync_test.go +++ b/eth/sync_test.go @@ -90,7 +90,7 @@ func testSnapSyncDisabling(t *testing.T, ethVer uint, snapVer uint) { case <-timeout: t.Fatalf("snap sync not disabled after successful synchronisation") case <-time.After(100 * time.Millisecond): - if empty.handler.downloader.GetSyncMode() == ethconfig.FullSync { + if empty.handler.downloader.ConfigSyncMode() == ethconfig.FullSync { return } } diff --git a/eth/syncer/syncer.go b/eth/syncer/syncer.go index 416bd62ed1..537ece0a69 100644 --- a/eth/syncer/syncer.go +++ b/eth/syncer/syncer.go @@ -129,7 +129,7 @@ func (s *Syncer) run() { break } if resync { - if mode := s.backend.Downloader().GetSyncMode(); mode != ethconfig.FullSync { + if mode := s.backend.Downloader().ConfigSyncMode(); mode != ethconfig.FullSync { req.errc <- fmt.Errorf("unsupported syncmode %v, please relaunch geth with --syncmode full", mode) } else { req.errc <- s.backend.Downloader().BeaconDevSync(target)