Skip to content

fix(p2p/server): reject range requests below the store tail - #406

Merged
renaynay merged 1 commit into
celestiaorg:mainfrom
renaynay:fix/range-request-below-tail
Aug 21, 2026
Merged

fix(p2p/server): reject range requests below the store tail#406
renaynay merged 1 commit into
celestiaorg:mainfrom
renaynay:fix/range-request-below-tail

Conversation

@renaynay

@renaynay renaynay commented Aug 18, 2026

Copy link
Copy Markdown
Member

Resolves PROTOCO-2383.

Rejects a GetRangeRequest whose from is below the store's tail with ErrNotFound up front, instead of loading headers until it runs into a pruned height.

WHY? A partial range must start at from (see interface.go partial-range contract), so a below-tail from can only be a NOT_FOUND.

Complements #405: the tail check guards the request bottom, #405's min(to, head+1) guards the top.

  • One atomic Tail() load (atomic.Pointer), no datastore hit.
  • Adds regression test TestExchangeServer_rangeBelowTail.

🤖 Generated with Claude Code

A range request whose `from` is below the store's tail can only be served
as a hard NOT_FOUND, since a partial range must start at `from`. Check the
tail up front and return ErrNotFound instead of walking into pruned heights.

Resolves PROTOCO-2383. Complements celestiaorg#405.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@renaynay
renaynay requested a review from a team as a code owner August 18, 2026 11:43
@mergify

mergify Bot commented Aug 18, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@ninabarbakadze
ninabarbakadze removed their request for review August 18, 2026 14:47
@renaynay
renaynay merged commit 34564d8 into celestiaorg:main Aug 21, 2026
3 checks passed
@loglapa

loglapa commented Aug 21, 2026

Copy link
Copy Markdown

The merged change currently makes the existing TestExchangeServer_partialRangeNotExpanded panic deterministically on main before either normal or race suites can complete. Reproduced on Go 1.26/darwin and Go 1.27/linux-arm64:

panic: nil pointer dereference
p2p.(*partialRangeStore).Tail
p2p/server.go:237
p2p/server_test.go:198

handleRangeRequest now always calls Tail, while partialRangeStore embeds a nil header.Store and does not implement Tail. The existing test needs a concrete tail at or below from plus a Tail method (so it continues exercising the partial-range path rather than the new below-tail rejection). There is no open follow-up PR/issue yet.

@loglapa

loglapa commented Aug 21, 2026

Copy link
Copy Markdown

I opened a minimal follow-up fix in #409. It adds an explicit tail to the existing test double, preserves the original partial-range path, and restores the full suite on Go 1.27.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants