Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

vgonkivs
Copy link
Member

Overview

Setting a default timeout, if it wasn't set, allows us to avoid any cases when the Head request could stuck.

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@vgonkivs vgonkivs added bug Something isn't working enhancement New feature or request p2p kind:fix labels Jan 29, 2024
@vgonkivs vgonkivs self-assigned this Jan 29, 2024
Copy link
Member

@Wondertan Wondertan left a 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

@vgonkivs
Copy link
Member Author

vgonkivs commented Jan 29, 2024

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
Copy link
Member

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?

Copy link
Member Author

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

@vgonkivs
Copy link
Member Author

closed in favour of #152

@vgonkivs vgonkivs closed this Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request kind:fix p2p
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants