-
Notifications
You must be signed in to change notification settings - Fork 291
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
netsync: Rework inventory announcement handling. #2548
Merged
davecgh
merged 2 commits into
decred:master
from
davecgh:netsync_rework_inv_announcement
Jan 15, 2021
Merged
netsync: Rework inventory announcement handling. #2548
davecgh
merged 2 commits into
decred:master
from
davecgh:netsync_rework_inv_announcement
Jan 15, 2021
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
davecgh
force-pushed
the
netsync_rework_inv_announcement
branch
from
January 11, 2021 00:50
1444559
to
6488fb9
Compare
rstaudt2
approved these changes
Jan 11, 2021
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 good, definitely simplifies the case for the recently confirmed transaction handling.
dnldd
reviewed
Jan 11, 2021
davecgh
force-pushed
the
netsync_rework_inv_announcement
branch
from
January 11, 2021 17:34
6488fb9
to
33c39f2
Compare
dnldd
approved these changes
Jan 12, 2021
This removes the error return from the LatestBlockLocator function since it can never fail and ends up causing unneeded error checking.
This modifies the way inventory announcements are handled to improve efficiency and readability. Specifically, it switches to a more explicit approach that handles the specific recognized types (blocks and transactions) independently and now determines if they are needed with unique logic for each type as opposed to the more generic inventory-only based approach. Next, and probably the most important change overall, is that recently confirmed transactions are now tracked by the server and the logic which determines if a transaction is needed now makes use of those tracked transactions as opposed to the previous rather expensive utxo-based query approach. The reasoning for this change is that the only time honest nodes notify others about transactions are when they view those transactions as unconfirmed and they consider themselves to be current. In practice this means the only duplicate announcements are for unconfirmed and recently confirmed transactions. In the case of malicious nodes, the transactions are rejected (either the transactions are actually invalid or they are old transactions that were valid in the past but will now fail due to trying to spend outputs they already spent). So, given the above discussion, there are 3 cases to handle: 1) Duplicate announcements for unconfirmed transactions 2) Duplicate announcements for txns that have already been rejected 3) Duplicate announcements for recently-confirmed transactions For the first case, the duplicate request is filtered by the mempool since it already knows the unconfirmed transaction. For the second case, rejected transactions are tracked separately and filtered. Thus, only the third case of recently confirmed transactions remains. Finally, the last block is now tracked by the hash instead of an index into the index which allows the relevant updates to take place after the main loop versus inside of it conditionally.
davecgh
force-pushed
the
netsync_rework_inv_announcement
branch
from
January 15, 2021 04:25
33c39f2
to
c93e1a0
Compare
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.
This is rebased on #2547.
This modifies the way inventory announcements are handled to improve efficiency and readability.
Specifically, it switches to a more explicit approach that handles the specific recognized types (blocks and transactions) independently and now determines if they are needed with unique logic for each type as opposed to the more generic inventory-only based approach.
Next, and probably the most important change overall, is that recently confirmed transactions are now tracked by the server and the logic which determines if a transaction is needed now makes use of those tracked transactions as opposed to the previous rather expensive utxo-based query approach.
The reasoning for this change is that the only time honest nodes notify others about transactions are when they view those transactions as unconfirmed and they consider themselves to be current. In practice this means the only duplicate announcements are for unconfirmed and recently confirmed transactions. In the case of malicious nodes, the transactions are rejected (either the transactions are actually invalid or they are old transactions that were valid in the past but will now fail due to trying to spend outputs they already spent).
So, given the above discussion, there are 3 cases to handle:
For the first case, the duplicate request is filtered by the mempool since it already knows the unconfirmed transaction. For the second case, rejected transactions are tracked separately and filtered. Thus, only the third case of recently confirmed transactions remains.