celestiaorg / go-header

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

p2p: ExchangeServer.handleRangeRequest should assert that from < to #224

Open odeke-em opened 3 weeks ago

odeke-em commented 3 weeks ago

https://github.com/celestiaorg/go-header/blob/18f0eb1c5d3aeab6476123da0dad57e82c067984/p2p/server.go#L200-L203

Should also include a check that from < to. Having worked on a bunch of networking, the pain of debugging simple coding errors like a mix up between ranges can be hell and not worth the time, hence insure future selves by simply returning an error when from >= to

Kindly cc-ing @Wondertan

walldiss commented 2 weeks ago

Hey, thanks for pointing that out!

I totally agree - adding a check to ensure from < to will help prevent any range mix-ups and make the code more robust.