Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -5,6 +5,7 @@ export enum ProposerPreferencesErrorCode {
INVALID_EPOCH = "PROPOSER_PREFERENCES_ERROR_INVALID_EPOCH",
PROPOSAL_SLOT_PASSED = "PROPOSER_PREFERENCES_ERROR_PROPOSAL_SLOT_PASSED",
UNKNOWN_DEPENDENT_ROOT = "PROPOSER_PREFERENCES_ERROR_UNKNOWN_DEPENDENT_ROOT",
INVALID_DEPENDENT_ROOT = "PROPOSER_PREFERENCES_ERROR_INVALID_DEPENDENT_ROOT",
INVALID_PROPOSER = "PROPOSER_PREFERENCES_ERROR_INVALID_PROPOSER",
ALREADY_KNOWN = "PROPOSER_PREFERENCES_ERROR_ALREADY_KNOWN",
INVALID_SIGNATURE = "PROPOSER_PREFERENCES_ERROR_INVALID_SIGNATURE",
Expand All @@ -26,6 +27,11 @@ export type ProposerPreferencesErrorType =
proposalSlot: Slot;
dependentRoot: RootHex;
}
| {
code: ProposerPreferencesErrorCode.INVALID_DEPENDENT_ROOT;
proposalSlot: Slot;
dependentRoot: RootHex;
}
| {
code: ProposerPreferencesErrorCode.INVALID_PROPOSER;
proposalSlot: Slot;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {SLOTS_PER_EPOCH} from "@lodestar/params";
import {GENESIS_SLOT, MIN_SEED_LOOKAHEAD, SLOTS_PER_EPOCH} from "@lodestar/params";
import {
computeEpochAtSlot,
computeStartSlotAtEpoch,
createSingleSignatureSetFromComponents,
getProposerPreferencesSigningRoot,
} from "@lodestar/state-transition";
Expand Down Expand Up @@ -70,6 +71,18 @@ export async function validateGossipProposerPreferences(
});
}

// [REJECT] Dependent block after the lookahead decision slot (clamped to `GENESIS_SLOT` so early epochs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jtraglia what's your plan for bringing new checks like this to the spec, my gut feeling is those should be separate PRs and not hidden in the large executable spec PR, but curious what are your thoughts

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.

Yeah I should add it in a separate PR to the existing natural language specs. I forget the details, but I must have added it here because it was necessary when testing or identified it while reviewing.

// don't underflow). Kept after the proposer-resolution IGNORE so state-unavailable roots stay IGNORE (`ignore_dependent_root_state_unavailable`).
const decisionSlot = Math.max(GENESIS_SLOT, computeStartSlotAtEpoch(proposalEpoch - MIN_SEED_LOOKAHEAD) - 1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we make the comment less verbose please

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.

Trimmed to 2 lines in bd6b61ac72 (kept the GENESIS_SLOT clamp + the after-IGNORE ordering note).

const dependentBlock = chain.forkChoice.getBlockHexDefaultStatus(dependentRootHex);
if (dependentBlock !== null && dependentBlock.slot > decisionSlot) {
throw new ProposerPreferencesError(GossipAction.REJECT, {
code: ProposerPreferencesErrorCode.INVALID_DEPENDENT_ROOT,
proposalSlot,
dependentRoot: dependentRootHex,
});
}

// [REJECT] `is_valid_proposal_slot(state, preferences)` returns True.
if (proposers[proposalSlot % SLOTS_PER_EPOCH] !== validatorIndex) {
throw new ProposerPreferencesError(GossipAction.REJECT, {
Expand Down
Loading