-
Notifications
You must be signed in to change notification settings - Fork 649
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
Verify active witness before applying block - Issue #831 #884
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
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.
We need to check every block after last irreversible block, but not only those after head block.
However, for blocks those are before last maintenance interval, we aren't able to verify their witness, since we don't store the active witness list of that time in current state (not hard to change related code to store that info anyway).
That said, active witness list in current state can be different than in the fork that contains the new block, if the fork happened before last maintenance interval. Which means it's
incorrectless efficient (for switching to correct fork) if we drop the new block in this case.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.
Let me see if I am following your thought process correctly. I see 2 points here:
if
to look for blocks that came after the last maintenance interval instead of blocks> head_block_num()
Did I catch the meaning? Or am I off in the weeds?
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.
1
should be last irreversible block, not last maintenance interval.Need more discussion though. Perhaps @pmconrad will have some ideas.
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.
Tricky.
Let I be the last irreversible block, F the block after which the fork occurs (i. e. the last block common to both forks), M and M' the last maintenance blocks on the two forks, and W and W' the sets of active witnesses after M and M' respectively.
We know I <= F. If M = M' <= F then W=W' and we don't have a problem. So let's examine the case M != M' and W != W'.
Suppose we are on the M side of the fork, on block A=M+1. We have M' in the fork database. We receive A'=M'+1, signed by witness w'. w' is in W' but not in W. Then we receive B'=A'+1. That means (F,...,M',A',B') is a longer fork than (F,...,M,A), so we must switch over. We can only recognize the longer fork if we accept A' and B' into the fork database, despite the fact that we don't (as of today) know W'.
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.
Also note that in extreme situations we can have long-lived forks that span several maintenance intervals.
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.
Actually this discussion can lead to questioning about the correctness of "last irreversible block" mechanism. When forks are long enough, in extreme situations, each fork will have its own LIB.
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.
EOSIO/eos#2718 is related.