-
-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introducing a small utility function to create this dummy Clock
would improve readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably look into reusing ClockMock
from validator client
export class ClockMock implements IClock { |
currentSlotWithGossipDisparity: undefined, | ||
isCurrentSlotGivenGossipDisparity: vi.fn(), | ||
}, | ||
clock: clk, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: could we possibly rename clk
to clock
, and the previous clock
to something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe clock
should be a parameter to this function, with a default value to the most common one.
@@ -912,7 +912,7 @@ export function getValidatorApi({ | |||
// TODO: Add a flag to just send 0x00 as pubkeys since the Lodestar validator does not need them. | |||
const pubkeys = getPubkeysForIndices(state.validators, indexes); | |||
|
|||
const startSlot = computeStartSlotAtEpoch(stateEpoch); | |||
const startSlot = computeStartSlotAtEpoch(epoch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, could apply some refactoring in tests as suggested by @jeluard
@@ -912,7 +912,7 @@ export function getValidatorApi({ | |||
// TODO: Add a flag to just send 0x00 as pubkeys since the Lodestar validator does not need them. | |||
const pubkeys = getPubkeysForIndices(state.validators, indexes); | |||
|
|||
const startSlot = computeStartSlotAtEpoch(stateEpoch); | |||
const startSlot = computeStartSlotAtEpoch(epoch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably look into reusing ClockMock
from validator client
export class ClockMock implements IClock { |
🎉 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