Skip to content

Commit

Permalink
remove redundant start slot (#7991)
Browse files Browse the repository at this point in the history
Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
  • Loading branch information
farazdagi and rauljordan committed Dec 2, 2020
1 parent 387f7b2 commit c7f7a29
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
3 changes: 1 addition & 2 deletions beacon-chain/sync/initial-sync/blocks_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ type syncMode uint8
type blocksQueueConfig struct {
blocksFetcher *blocksFetcher
chain blockchainService
startSlot uint64
highestExpectedSlot uint64
p2p p2p.P2P
db db.ReadOnlyDatabase
Expand Down Expand Up @@ -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 {
Expand Down
30 changes: 0 additions & 30 deletions beacon-chain/sync/initial-sync/blocks_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c7f7a29

Please sign in to comment.