celestia-node icon indicating copy to clipboard operation
celestia-node copied to clipboard

Reconsider behaviour for `GetRangeByHeight`

Open renaynay opened this issue 2 years ago • 3 comments

Current behaviour: GetRangeByHeight goes from to-1 -> from, meaning for a request of [200:300] where the node only has [200:299], no headers would be returned an an err code ErrNotFound is returned.

Desired behaviour: GetRangeByHeight should go from from -> to-1 as far as it can (contiguously) and return partial headers as well as ErrNotFound if only a partial range is returned.

renaynay avatar Sep 26 '22 10:09 renaynay

Screenshot 2022-09-26 at 12 12 56 from https://github.com/celestiaorg/celestia-node/pull/1135

renaynay avatar Sep 26 '22 10:09 renaynay

Should we actually return an ErrNotFound in situation where partial data is returned? I think it might lead to confusion with situation when there is no data at all. Also usually in api design if error is return, response data is not considered, but only error is handled. Maybe add another statusCodePartial to keep status explicit in situations when partial data is returned?

walldiss avatar Oct 10 '22 14:10 walldiss

I agree with returning ErrNotFound instead of partial data, for the reason of partial data response being a very rare case that will complicate the implementation for very minimal gain. Currently, all peers have all the headers, in future with pruning, peers will have either peers with all headers or peers with headers for unboding window(3 weeks since head). If this changes it some point, we can reconsider making partial responses.

Wondertan avatar Oct 11 '22 06:10 Wondertan