Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export async function validateGossipProposerPreferences(
});
}

// [IGNORE] `preferences.proposal_slot` has not already passed.
const currentSlot = chain.clock.currentSlot;
// [IGNORE] `preferences.proposal_slot` has not already passed, i.e. `proposal_slot > current_slot`,
// allowing for `MAXIMUM_GOSSIP_CLOCK_DISPARITY`.
const currentSlot = chain.clock.slotWithFutureTolerance(chain.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY / 1000);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of manually calculating the tolerance and calling slotWithFutureTolerance, we can use the existing currentSlotWithGossipDisparity property on the clock. This property is specifically designed to handle the MAXIMUM_GOSSIP_CLOCK_DISPARITY check at slot boundaries, making the code cleaner and more idiomatic.

Suggested change
const currentSlot = chain.clock.slotWithFutureTolerance(chain.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY / 1000);
const currentSlot = chain.clock.currentSlotWithGossipDisparity;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call — applied in e75f482a60. currentSlotWithGossipDisparity is behaviour-equivalent here (both resolve to currentSlot, or currentSlot + 1 when within MAXIMUM_GOSSIP_CLOCK_DISPARITY of the next slot start) and drops the manual ms→s conversion. Biome clean.

if (proposalSlot <= currentSlot) {
throw new ProposerPreferencesError(GossipAction.IGNORE, {
code: ProposerPreferencesErrorCode.PROPOSAL_SLOT_PASSED,
Expand Down