Skip to content

fix(core): Return partial response for headers if one fails#4738

Draft
renaynay wants to merge 2 commits into
celestiaorg:mainfrom
renaynay:robus-core-ex
Draft

fix(core): Return partial response for headers if one fails#4738
renaynay wants to merge 2 commits into
celestiaorg:mainfrom
renaynay:robus-core-ex

Conversation

@renaynay

Copy link
Copy Markdown
Member

Fixes an issue where we would discard all headers in case one failed. Now we can at least return the ones we synced successfully (as long as they're contiguous from from) so we don't need to do duplicate work.

@renaynay renaynay self-assigned this Dec 12, 2025
@renaynay renaynay added area:core_and_app Relationship with Core node and Celestia-App kind:fix Attached to bug-fixing PRs labels Dec 12, 2025
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 36.00%. Comparing base (2469e7a) to head (4b30d03).
⚠️ Report is 633 commits behind head on main.

Files with missing lines Patch % Lines
core/exchange.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4738      +/-   ##
==========================================
- Coverage   44.83%   36.00%   -8.83%     
==========================================
  Files         265      307      +42     
  Lines       14620    20777    +6157     
==========================================
+ Hits         6555     7481     +926     
- Misses       7313    12326    +5013     
- Partials      752      970     +218     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@walldiss walldiss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few concerns:

Syncer assumes full range on nil error. In go-header's sync/syncer.go:373, requestHeaders does amount -= size (the requested size, not len(headers)) and advances fromHead to the last returned header. If this returns fewer headers with nil error, the syncer will silently skip the gap between what it got and what it thinks it got. There's also a panic if the partial result is empty (headers[len(headers)-1]).

Concurrent fill makes nil-scan unreliable. errgroup.WithContext cancels remaining goroutines on first error. Earlier slots may still be nil if those goroutines hadn't written yet. The contiguous prefix assumption only holds reliably when failures are at the tail (e.g. beyond chain tip), not for mid-range transient errors.

h.IsZero() is redundant — it's just eh == nil, same as the nil check before it.

Suggestion: either return the error alongside partial results (new sentinel like ErrPartialRange so callers can opt in), or fix the syncer in go-header to use amount -= uint64(len(headers)) before landing this.

@vgonkivs

Copy link
Copy Markdown
Member

Moving it to draft until go-header pr merged and tested. @renaynay do you want to finish it then or should I take it over ?

@vgonkivs
vgonkivs marked this pull request as draft June 11, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core_and_app Relationship with Core node and Celestia-App kind:fix Attached to bug-fixing PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants