-
Notifications
You must be signed in to change notification settings - Fork 704
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
Reduce usage of getBlock
in consensus
#3151
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
marun
approved these changes
Jun 26, 2024
aaronbuchwald
approved these changes
Jul 11, 2024
tsachiherman
approved these changes
Jul 12, 2024
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.
The change looks great. Two comments:
- The getProcessingAncestor, in the way being written, looks like it could get into a (theoretical) endless loop in case of a circle in the parents linked list. ( clearly, this would imply a serious issue elsewhere ).
- I find the field name
nonVerifiedCache
to be somewhat confusing. The description is :
// A block is put into this cache if it was not able to be issued. A block
// fails to be issued if verification on the block or one of its ancestors
// occurs.
- which implies it it should be called
verifiedBlocksCache
. alternatively, maybe "unissuedBlock" ? it might be a terminology issue, where we're using the terms (un)issued and verified synonymously ?
This is true.
The comment was incorrect. It should have referenced verification failing on either the block or one of its ancestors. I updated the comment. I also renamed a couple of the fields to be a bit more clear. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why this should be merged
getBlock
can result in DB reads due to it's usage of theVM.GetBlock
function. If the same behavior can be performed with in-memory checks rather than with usingVM.GetBlock
, we should.This also improves
TestGetProcessingAncestor
.How this works
From the
VM.GetBlock
specification:So, we can only rely on
VM.GetBlock
to returnAccepted
andVerified
but not yetDecided
blocks.Additionally,
pending
contains the set of blocks that are awaiting issuance due to a transitive network request. Meaning that there is a block that is not locally known between apending
block and aProcessing
orDecided
block.Start
,getBlock
can be removed to explicitly useVM.GetBlock
, aspending
andnonVerifiedCache
are both empty.getProcessingAncestor
there are 3 cases that we need to consider:a.
VM.GetBlock
would have returned aVerified
but not yetDecided
block. This case can never occur because, we already know that the provided block is not processing.b.
VM.GetBlock
would have previously returned anAccepted
block. If this was the case, then we would have immediately dropped it in the next check. So dropping the vote early results in the same behavior.c.
pending
contained the block that we are looking for. In this case, we may have been able to continue looking for aProcessing
ancestor. However, we know that we would have never found such an ancestor, because if we were able to locally iterate and find a processing ancestor, then this block shouldn't bepending
, it should have been attempted to be issued. Additionally, we know thatinitialVote
has already been eitherFulfilled
orAbandoned
, so we aren't running into a situation where thepending
block is currently in the process of being issued.How this was tested