Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions packages/beacon-node/test/spec/utils/specTestIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ export const defaultSkipOpts: SkipOpts = {
// TODO-GLOAS: re-enable after gloas light client is implemented
/\/gloas_fork$/,
/\/heze_fork$/,
// TODO GLOAS: Proposer-boost dependent-root gate uses stale cached head across epoch-boundary ticks;
// boost wrongly denied. Fails identically on every pre-gloas fork.
// Enable this after https://github.com/ChainSafe/lodestar/issues/9666 is resolved
// The case name embeds the generation seed, so it changes whenever comptests are regenerated.
/fork_choice_compliance\/block_tree_test\/pyspec_tests\/block_tree_test_17_381675768_1$/,
// TODO GLOAS: gloas/heze take ~23-24s on the mainnet preset (~7.5x pre-gloas) because every
// post-gloas slot writes into the SLOTS_PER_HISTORICAL_ROOT-wide executionPayloadAvailability
// bitvector, and this suite steps 8192 slots. That is 76-81% of the 30s sanity/slots timeout,
Expand Down
16 changes: 14 additions & 2 deletions packages/fork-choice/src/forkChoice/forkChoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1737,18 +1737,24 @@ export class ForkChoice implements IForkChoice {
justifiedCheckpoint: CheckpointWithHex,
finalizedCheckpoint: CheckpointWithHex,
getJustifiedBalances: () => JustifiedBalances
): void {
): boolean {
Comment thread
wemeetagain marked this conversation as resolved.
Resolved
let updated = false;

// Update justified checkpoint.
if (justifiedCheckpoint.epoch > this.fcStore.justified.checkpoint.epoch) {
this.fcStore.justified = {checkpoint: justifiedCheckpoint, balances: getJustifiedBalances()};
this.justifiedProposerBoostScore = null;
updated = true;
}

// Update finalized checkpoint.
if (finalizedCheckpoint.epoch > this.fcStore.finalizedCheckpoint.epoch) {
this.fcStore.finalizedCheckpoint = finalizedCheckpoint;
this.justifiedProposerBoostScore = null;
updated = true;
}

return updated;
}

/**
Expand Down Expand Up @@ -2060,11 +2066,17 @@ export class ForkChoice implements IForkChoice {
}

// If a new epoch, pull-up justification and finalization from previous epoch
this.updateCheckpoints(
const didUpdateCheckpoints = this.updateCheckpoints(
this.fcStore.unrealizedJustified.checkpoint,
this.fcStore.unrealizedFinalizedCheckpoint,
() => this.fcStore.unrealizedJustified.balances
);

// recompute head if we pull-up checkpoints because the head's dependent root could be changed
// this is to make sure isProposerBoostSameDependentRoot() correct on block 0 of the next epoch
if (didUpdateCheckpoints) {
this.updateHead();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid recomputing the head twice at epoch boundaries

When fast confirmation is enabled and not paused, an epoch-boundary checkpoint update calls the expensive updateHead() here, but updateTime() then immediately drains the attestation queue and invokes runFastConfirmation(), which calls updateHead() again. The first result cannot be observed between these synchronous operations and is already outdated once queued votes are applied, so this adds a redundant full proto-array score and head calculation to the slot-start critical path. Delay this recomputation until after the queue is processed or share it with the fast-confirmation calculation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks, fixed in the latest commit
moved the updateHead() to the last step, it's more precise because we applied previous slot attestations at that time

}
}

/**
Expand Down
Loading