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

Remove VerifyFinalizedBlkDescendant #12046

Merged
merged 7 commits into from
Feb 25, 2023
Merged

Conversation

potuz
Copy link
Contributor

@potuz potuz commented Feb 24, 2023

This PR removes the two helper functions VerifyFinalizedBlkDescendant and VerifyFinalizedConsistency.

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 call verifyBlockPreState, 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 fromverfyBlockPreState (and added a extra safety check directly on onBlock).

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 from verifyPreState since anyway this is checked in fillInMissingBlocksToForkchoice.

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.

@potuz potuz added Ready For Review A pull request ready for code review Cleanup Code health! labels Feb 24, 2023
@potuz potuz requested a review from a team as a code owner February 24, 2023 13:39
@@ -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
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

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

@potuz potuz merged commit ec13d52 into develop Feb 25, 2023
@delete-merged-branch delete-merged-branch bot deleted the verify-finalized-descendant branch February 25, 2023 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cleanup Code health! Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants