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.
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
network: discard unrequested or stale block messages #5431
network: discard unrequested or stale block messages #5431
Changes from 1 commit
3855d0e
cedd485
295e2ab
4ca9242
476f9e2
ba886fe
02fcb7f
b0da5a0
7dd930d
0668f22
d4502d4
215a19c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
this is a weak condition since
lastSentRequestTime
is never removed from the peer data map.I also traced the context all way up and do not see if it cancelled by timeout - could you point out? The only cancellation I found incatchup.innerFetch
iscase <-ledgerWaitCh
when the ledger received the block by other means.It appears the message the existence of a hash in
responseChannels
is a pretty good indication of "a request was sent" and an emptyresponseChannels
opposite and a good opportunity to drop.It will be more complex but more error proof if there would be a compliment data structure to
responseChannels
- like topic requests tags have been sent but this is complicated to manage and since there are lots of block requests on catchup.Edit: agreed on
lastSentRequestTime
importance but it needs to be cleared after some period of time.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.
Instead of clearing it out, added a synchronous check and disconnect if the response is more than a minute late.
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.
similarly maybe this is not important enough to be Warnf level? io.Discard.Write() can't fail but I guess reader.Read() could return err ...
oh I see, we seem to have a
wp.reportReadErr(err)
just for that, and has its own special handling of when and how to log read errors from peersThere 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, shouldn't you disconnect here? that's what happens for other reader Read errors?
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.
Agreed, made the change
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.
Warnf goes to telemetry by default, but this doesn't seem very important. Could we make this Infof
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.
Sure but it's nice to have a telemetry of how often this happened. Current behavior actually logs this case to telemetry but not until after it unmarshalls the message on line 581. This doesn't increase the number of telemetry messages we are expecting to receive but even so happy to downgrade if others agree and do the same for the other place where we log this
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.
Since you're doing all the work of taking the lock, could you isntead return the
len
directly, and let the caller decide to compare it with 0?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 think I have a slight preference for the way it is currently but happy to change if there's a +1 .
I just don't think that we will be checking the length of this outside of this use-case and to me this parses slightly easier in the conditional.