-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Remove VerifyFinalizedBlkDescendant #12046
Conversation
@@ -107,6 +107,11 @@ func (s *Service) onBlock(ctx context.Context, signed interfaces.ReadOnlySignedB | |||
return err | |||
} | |||
|
|||
// Verify that the parent block is in forkchoice | |||
if !s.ForkChoicer().HasNode(b.ParentRoot()) { | |||
return ErrNotDescendantOfFinalized |
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.
A bit torn about this error message. It makes sense but there's some implementation details that may not be obvious for someone that's not in depth
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.
I am not sure how to change this, this error is exported and used in several places. Changing it on one side and not others seems odd, I can change it to "parent not in forkchoice" but that's even less info for someone not in depth, the only thing that can trigger this error is if the block does not connect to the finalized checkpoint
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.
Agree. I dont think it's a big deal but just wanted to point it out
This PR removes the two helper functions
VerifyFinalizedBlkDescendant
andVerifyFinalizedConsistency
.Both these helpers served the purpose of validate if a given root is a descendant of the finalized checkpoint. In all usages of the latter, a simlple check for forkchoice if it has the parentroot, would work. The former is a little trickier
There are two paths in block processing where we use
VerifyFinalizedBlkDescendant
, during regular block sync, and during init sync. Both paths currently callverifyBlockPreState
, which in turn verifies that the block is a descendant of the finalized checkpoint.During regular sync, the block's parent must be in forkchoice. So we removed this check from
verfyBlockPreState
(and added a extra safety check directly ononBlock
).During init sync however, we allow insertion of blocks to
onBlockBatch
whose parent are not in forkchoice, but that they connect to the finalized checkpoint with blocks on db. This is because we do not start with the full forkchoice loaded from disk. However we removed the check fromverifyPreState
since anyway this is checked infillInMissingBlocksToForkchoice
.In addition we add a helper
InForkChoice
to chaininfo. This is in preparation to the locking PRs for forkchoice: blockchain packages are already locked and need to call forkchoice directly. Packages relying on chain_info have to call the helper that will lock forkchoice.