Skip to content
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

chore: add get_proposer_head check in fork choice spec test #6814

Merged
merged 3 commits into from
May 24, 2024
Merged
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
14 changes: 14 additions & 0 deletions packages/beacon-node/test/spec/presets/fork_choice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,19 @@ const forkChoiceTest =
`Invalid finalized checkpoint at step ${i}`
);
}
if (step.checks.get_proposer_head) {
const currentSlot = Math.floor(tickTime / config.SECONDS_PER_SLOT);
const {proposerHead, notReorgedReason} = (chain.forkChoice as ForkChoice).getProposerHead(
head,
tickTime % config.SECONDS_PER_SLOT,
currentSlot
);
logger.debug(`Not reorged reason ${notReorgedReason} at step ${i}`);
expect(proposerHead.blockRoot).toEqualWithMessage(
step.checks.get_proposer_head,
`Invalid proposer head at step ${i}`
);
}
}

// None of the above
Expand Down Expand Up @@ -465,6 +478,7 @@ type Checks = {
justified_checkpoint?: SpecTestCheckpoint;
finalized_checkpoint?: SpecTestCheckpoint;
proposer_boost_root?: RootHex;
get_proposer_head?: string;
};
};

Expand Down
2 changes: 1 addition & 1 deletion packages/fork-choice/src/forkChoice/forkChoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export class ForkChoice implements IForkChoice {
const parentNode = this.protoArray.getNode(parentBlock.blockRoot);
// If parentNode is unavailable, give up reorg
if (parentNode === undefined || parentNode.weight <= parentThreshold) {
return {proposerHead, isHeadTimely, notReorgedReason: NotReorgedReason.ParentBlockIsStrong};
return {proposerHead, isHeadTimely, notReorgedReason: NotReorgedReason.ParentBlockNotStrong};
}

// Reorg if all above checks fail
Expand Down
2 changes: 1 addition & 1 deletion packages/fork-choice/src/forkChoice/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export enum NotReorgedReason {
ReorgMoreThanOneSlot,
ProposerBoostNotWornOff,
HeadBlockNotWeak,
ParentBlockIsStrong,
ParentBlockNotStrong,
NotProposingOnTime,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe("Forkchoice / GetProposerHead", function () {
parentBlock: {...baseParentHeadBlock, weight: 211},
headBlock: {...baseHeadBlock},
expectReorg: false,
expectedNotReorgedReason: NotReorgedReason.ParentBlockIsStrong,
expectedNotReorgedReason: NotReorgedReason.ParentBlockNotStrong,
},
{
id: "No reorg if not proposing on time",
Expand Down
Loading