remove redundant start slot (#7991)

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
Victor Farazdagi 2020-12-02 20:47:39 +03:00 committed by GitHub
parent 387f7b28c1
commit c7f7a29d7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 32 deletions

View File

@ -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 {

View File

@ -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) {