From c7f7a29d7e22f4f4ce47be0f9cc77fc604e6362a Mon Sep 17 00:00:00 2001 From: Victor Farazdagi Date: Wed, 2 Dec 2020 20:47:39 +0300 Subject: [PATCH] remove redundant start slot (#7991) Co-authored-by: Raul Jordan --- .../sync/initial-sync/blocks_queue.go | 3 +- .../sync/initial-sync/blocks_queue_test.go | 30 ------------------- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/beacon-chain/sync/initial-sync/blocks_queue.go b/beacon-chain/sync/initial-sync/blocks_queue.go index 57e42b5a9..e44970f01 100644 --- a/beacon-chain/sync/initial-sync/blocks_queue.go +++ b/beacon-chain/sync/initial-sync/blocks_queue.go @@ -62,7 +62,6 @@ type syncMode uint8 type blocksQueueConfig struct { blocksFetcher *blocksFetcher chain blockchainService - startSlot uint64 highestExpectedSlot uint64 p2p p2p.P2P db db.ReadOnlyDatabase @@ -106,7 +105,7 @@ func newBlocksQueue(ctx context.Context, cfg *blocksQueueConfig) *blocksQueue { }) } highestExpectedSlot := cfg.highestExpectedSlot - if highestExpectedSlot <= cfg.startSlot { + if highestExpectedSlot == 0 { if cfg.mode == modeStopOnFinalizedEpoch { highestExpectedSlot = blocksFetcher.bestFinalizedSlot() } else { diff --git a/beacon-chain/sync/initial-sync/blocks_queue_test.go b/beacon-chain/sync/initial-sync/blocks_queue_test.go index 534a8d42e..7ed70f92b 100644 --- a/beacon-chain/sync/initial-sync/blocks_queue_test.go +++ b/beacon-chain/sync/initial-sync/blocks_queue_test.go @@ -129,36 +129,6 @@ func TestBlocksQueue_InitStartStop(t *testing.T) { cancel() assert.NoError(t, queue.stop()) }) - - t.Run("start is higher than expected slot", func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - p := p2pt.NewTestP2P(t) - connectPeers(t, p, []*peerData{ - {blocks: makeSequence(500, 628), finalizedEpoch: 16, headSlot: 600}, - }, p.Peers()) - fetcher := newBlocksFetcher(ctx, &blocksFetcherConfig{ - chain: mc, - p2p: p, - }) - // Mode 1: stop on finalized. - queue := newBlocksQueue(ctx, &blocksQueueConfig{ - blocksFetcher: fetcher, - chain: mc, - highestExpectedSlot: blockBatchLimit, - startSlot: 128, - }) - assert.Equal(t, uint64(512), queue.highestExpectedSlot) - // Mode 2: unconstrained. - queue = newBlocksQueue(ctx, &blocksQueueConfig{ - blocksFetcher: fetcher, - chain: mc, - highestExpectedSlot: blockBatchLimit, - startSlot: 128, - mode: modeNonConstrained, - }) - assert.Equal(t, uint64(576), queue.highestExpectedSlot) - }) } func TestBlocksQueue_Loop(t *testing.T) {