fix: use right slot number for future epoch of proposers duties - #6545
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## unstable #6545 +/- ##
=========================================
Coverage 61.46% 61.46%
=========================================
Files 556 556
Lines 58652 58652
Branches 1848 1848
=========================================
Hits 36051 36051
Misses 22561 22561
Partials 40 40 |
Performance Report鉁旓笍 no performance regression detected 馃殌馃殌 Significant benchmark improvement detected
Full benchmark results
|
| const clk = | ||
| clock === "real" | ||
| ? new Clock({config, genesisTime: 0, signal: new AbortController().signal}) | ||
| : { |
There was a problem hiding this comment.
Introducing a small utility function to create this dummy Clock would improve readability.
There was a problem hiding this comment.
we should probably look into reusing ClockMock from validator client
| currentSlotWithGossipDisparity: undefined, | ||
| isCurrentSlotGivenGossipDisparity: vi.fn(), | ||
| }, | ||
| clock: clk, |
There was a problem hiding this comment.
Nitpick: could we possibly rename clk to clock, and the previous clock to something else?
There was a problem hiding this comment.
Or maybe clock should be a parameter to this function, with a default value to the most common one.
| const pubkeys = getPubkeysForIndices(state.validators, indexes); | ||
|
|
||
| const startSlot = computeStartSlotAtEpoch(stateEpoch); | ||
| const startSlot = computeStartSlotAtEpoch(epoch); |
There was a problem hiding this comment.
This is the fix, right? Maybe it would be worth adding a comment clarifying what is done here?
There was a problem hiding this comment.
The previous code would have deserved a comment on why we use the stateEpoch instead of actual requested epoch which didn't make sense of course. But it makes sense now, shouldn't require a comment imo
| const pubkeys = getPubkeysForIndices(state.validators, indexes); | ||
|
|
||
| const startSlot = computeStartSlotAtEpoch(stateEpoch); | ||
| const startSlot = computeStartSlotAtEpoch(epoch); |
There was a problem hiding this comment.
The previous code would have deserved a comment on why we use the stateEpoch instead of actual requested epoch which didn't make sense of course. But it makes sense now, shouldn't require a comment imo
| const clk = | ||
| clock === "real" | ||
| ? new Clock({config, genesisTime: 0, signal: new AbortController().signal}) | ||
| : { |
There was a problem hiding this comment.
we should probably look into reusing ClockMock from validator client
|
馃帀 This PR is included in v1.18.0 馃帀 |
Motivation
Fix the block proper duties slot numbers.
Description
When the proposer duties API is called with future epoch, the wrong slot index was used. As given below we are calling for epoch 1, so the slot should start from 8, not for 0. (with minimal preset).
Steps to test or reproduce