-
-
Notifications
You must be signed in to change notification settings - Fork 310
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 safe optimistic import #4340
Conversation
Performance Report✔️ no performance regression detected Full benchmark results
|
// It becomes optimistically safefor following blocks if a post-merge block is deemed fit | ||
// for import. If it would not have been safe verifyBlockExecutionPayload would throw error | ||
// and we would not be here. | ||
isOptimisticallySafe ||= executionStatus !== ExecutionStatus.PreMerge; |
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.
While the ||=
operand is pretty cool, can you use a regular if statement since it's more readable?
packages/beacon-node/src/chain/blocks/verifyBlocksExecutionPayloads.ts
Outdated
Show resolved
Hide resolved
// - we have transitioned to post-merge world or | ||
// - all the blocks are way behind the current slot | ||
// - or we have already imported a post-merge parent of first block of this chain in forkchoice | ||
const lastBlock = blocks[blocks.length - 1]; |
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.
Does this function ensure that there are more than 0 blocks?
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.
may be somewhere from where its called? because it didn't give any type issues, but will return early to be safe
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.
added a throw just to be safe
if (!isOptimisticallySafe) { | ||
const firstBlock = blocks[0]; | ||
const parentRoot = toHexString(firstBlock.message.parentRoot); | ||
const parentBlock = chain.forkChoice.getBlockHex(parentRoot); |
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.
You could return the parent block of the segment in sanity checks
return {relevantBlocks, parentSlots}; |
and re-use here
Co-authored-by: Lion - dapplion <[email protected]>
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 great! Beautifully documented too thank you!!! ❤️
Motivation
The safe optimistic import got broken with the PR to optimize the sync speed:
because in safe optimistic import, we used to check if are we syncing near head and the block's parent in forkchoice is not post merge then its not safe to import block with optimistic status.
But this was giving error (EL still syncing and spinned up the lodestar on kiln with weak subjectivity sync, so we are syncing near head), as the parent block would not be found in the forkchoice as we no longer verify then import block by block, now we verify a segment and then import
So updated verification to where the segment's safeness is evaluated and updated and based on that the block import is accepted if its safe.
Also removes the check for justified block being post-merge for safe import as it was a redundant check, as removed in this PR: ethereum/consensus-specs#2881