-
Notifications
You must be signed in to change notification settings - Fork 39
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
fix: Fix extra GetBlock
requests for validators
#27
fix: Fix extra GetBlock
requests for validators
#27
Conversation
@@ -139,6 +158,31 @@ impl PeerStates { | |||
} | |||
} | |||
|
|||
/// Cancels pending block retrieval for blocks that appear in the storage using other means | |||
/// (e.g., thanks to the consensus algorithm). This works at best-effort basis; it's not guaranteed | |||
/// that this method will timely cancel all block retrievals. |
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.
why do we need to compromise here?
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.
That's the most general approach I've come up with that doesn't make many assumptions as to what could update blocks externally and how these updates would look (e.g., whether it's consensus or some other actor). I guess with the knowledge of consensus we could do marginally better by cancelling not only the latest block produced by consensus, but all the preceding blocks as well; is this what you had in mind? If you have any suggestions, I'm happy to listen.
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 mean you are using watch to signal the received block from external source, which naturally will lead to NOT cancelling some blocks fetching tasks if multiple blocks are received from an external source at the same time. Also AFAICT there is a race condition between spawning a fetching routine for a block and receiving this block from an external source.
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. Just to be sure, this only cancels ongoing requests for the next block? It doesn't prevent validators from requesting non-existent blocks to begin with, correct?
@brunoffranca WDYM by non-existent blocks? |
I misremembered how sync_blocks works. I thought it would always try to fetch block N+1 if we had block N. But you just ask peers for their head number. My question doesn't apply then. |
What ❔
If the
SyncBlocks
actor runs on a validator node, the node previously produced unnecessaryGetBlock
requests to peers. This is becauseSyncBlocks
logic assumed that new blocks are only added within the actor. This PR lifts this assumption; it filtersGetBlock
requests and cancels pending requests reacting to new blocks being put in the storage.Why ❔
Extra
GetBlock
requests waste traffic and processing time of peers.