-
Notifications
You must be signed in to change notification settings - Fork 16
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(p2p/exchange): set timeout if it was not provided for Head request #151
Conversation
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.
There should be a way for the caller to wait indefinitely until it gets the result(especially when #149 gets implemented). The caller decides whether he wants a deadline or not. This solution limits that by always setting a deadline. Instead, we should set a deadline on the caller side which is in sync_head.go where we request recent head if we have outdated. In that case its also acceptable to ignore context timeout error and proceed with outdated header we have
I have only one concern: we can request head from non-trusted peers, which means we don't guarantee that this particular peer will work as expected. Also, there is no punishment in the case when a peer does not respond at all and simply blocks the request. This malicious peer can hold 1-5-10-20 requests, so a lot of other "callers" will be blocked indefinitely. It also won't be fixed when #149 is done because we can have 2-3 malicious peers in the peer tracker. So, on the one hand, I agree with you that the caller should have the ability to not specify a timeout but from the other side, we are requesting 1 header that could not take more than even a minute + we are not requesting a particular height(which the node does not have). Every node has its own head and should serve it once it receives the request |
cancel context.CancelFunc | ||
|
||
reqCtx = ctx | ||
sub = time.Second * 5 |
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.
isn't this still too long?
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'm ok with setting even 1-2 seconds
closed in favour of #152 |
Overview
Setting a default timeout, if it wasn't set, allows us to avoid any cases when the Head request could stuck.
Checklist