celestiaorg / go-header

Go library with all the services needed to request, sync and store blockchain headers.
Apache License 2.0
19 stars 18 forks source link

fix(p2p/exchange): set timeout if it was not provided for Head request #151

Closed vgonkivs closed 8 months ago

vgonkivs commented 8 months ago

Overview

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

Checklist

vgonkivs commented 8 months ago

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

vgonkivs commented 8 months ago

closed in favour of https://github.com/celestiaorg/go-header/pull/152