fix(core): Return partial response for headers if one fails#4738
fix(core): Return partial response for headers if one fails#4738renaynay wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
walldiss
left a comment
There was a problem hiding this comment.
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.
|
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 ? |
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.