Skip to content

fix: bound and make resumable the EVM, Solana and CKB announcement fetchers - #284

Open
Bolajiomo99 wants to merge 5 commits into
wraith-protocol:developfrom
Bolajiomo99:fix/271-bounded-announcement-fetchers
Open

Bolajiomo99 wants to merge 5 commits into
wraith-protocol:developfrom
Bolajiomo99:fix/271-bounded-announcement-fetchers

Conversation

@Bolajiomo99

Copy link
Copy Markdown

Closes #271

Summary

The EVM, Solana and CKB announcement fetchers could loop or allocate without limit: no request timeout, no cancellation, no page/item budget, no provider-error classification and no way to resume after a partial run. Only Stellar had bounded helpers.

This PR puts all three non-Stellar fetchers on one shared bounded-fetch foundation and keeps their pagination models honestly distinct instead of pretending they are the same.

Changes

Shared module — src/chains/announcementFetch.ts (new)

  • AnnouncementFetchOptions / AnnouncementPaginationOptions with finite defaults: maxPages 100, maxItems 10 000, 10 s connect timeout, 30 s request timeout, 2 retries, 250 ms base delay capped at 10 s, retryable statuses [429, 500, 502, 503, 504].
  • Abort-aware HTTP JSON transport: caller AbortSignal + per-request timeout raced against the fetch, so a hung provider cannot stall a scan.
  • Deterministic exponential backoff (no jitter) that honours Retry-After.
  • collectAnnouncementPages with cursor validation and a hard stop at the page/item budget; runBoundedOperation and mapWithConcurrency for bounded parallel work.
  • No fetch loop or allocation can start without a configured bound — the budgets always resolve to finite values.

Chain fetchers

  • EVM (src/chains/evm/announcements.ts): bounded skip pagination, GraphQL errors[] surfaced as provider errors, resumable decimal skip cursor, new fetchAnnouncementsPage.
  • Solana (src/chains/solana/announcements.ts): bounded signature pagination, opaque { v: 1, program, before } cursor, bounded transaction-fetch concurrency (concurrency option), rate-limit retries, new fetchAnnouncementsPage.
  • CKB (src/chains/ckb/announcements.ts): bounded indexer cursor pagination with repeated-cursor detection, JSON-RPC error mapping, new fetchStealthCellsPage.
  • Positional signatures (chain, optional URL) remain backward compatible; options may be passed as the second or third argument.

Typed errors (src/errors.ts)

All extend WraithNetworkError:

  • AnnouncementBudgetExceededError — carries partial results and the last good cursor so work is resumable.
  • AnnouncementCursorError — malformed | repeated | missing.
  • AnnouncementProviderError — HTTP/RPC/GraphQL failures with status/details.
  • AnnouncementResponseError — shape/decoding failures.

Exported from the root entry point and from chains/evm, chains/solana and chains/ckb.

Tests

33 new tests (test/chains/{evm,solana,ckb}/announcements.test.ts — 12 EVM, 9 Solana, 12 CKB) covering:

  • request timeout and caller abort
  • HTTP error and JSON-RPC/GraphQL provider error
  • rate limit (429) with Retry-After retry
  • malformed cursor and repeated cursor
  • maximum-page and maximum-item exhaustion (budget error carries partial results + cursor)
  • partial progress and resume from the returned cursor

Docs / generated artifacts

  • docs/errors.md — new error classes documented.
  • COMPAT.md — regenerated with pnpm compat:doc.
  • BUNDLE_SIZE.md and package.json size limits — budgets raised minimally to fit the new code.
  • etc/sdk*.api.md — API reports refreshed.

Verification

  • pnpm build
  • pnpm test (full suite, including companion packages)
  • pnpm format:check
  • pnpm test:types
  • pnpm api:check
  • pnpm size

Re-verified on the pushed commit c9cf236: 33/33 new tests pass, build and test:types succeed.

Notes for reviewers

  • Pagination models are intentionally not unified: EVM resumes on a decimal skip, Solana on a program/signature cursor, CKB on an opaque indexer cursor. The shared layer only carries what is genuinely common (bounds, deadlines, retries, error taxonomy).
  • Defaults are finite but generous; consumers can tighten them per call via the options object.

…tchers

The three non-Stellar fetchers had no shared timeout or AbortSignal, and their
pagination was unbounded, fixed to one provider page, or a serial transaction
walk. They now share one options shape and error set while keeping each
upstream's paging model: timeouts and caller cancellation, retry/backoff for
429/5xx and retryable RPC failures, page and item budgets with partial
progress, cursor validation/repetition guards, resumable cursors, and bounded
transaction concurrency for Solana. Budget exhaustion exposes the cursor for
resuming, and the EVM/Solana/CKB errors are consistent without pretending the
pagination models are identical.

Adds tests for timeout, abort, HTTP/RPC errors, rate limits, malformed and
repeated cursors, page exhaustion, partial progress and resume, plus error and
compatibility docs and refreshed API/size reports.
@drips-wave

drips-wave Bot commented Nov 19, 2026

Copy link
Copy Markdown

@Bolajiomo99 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@truthixify truthixify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Head 36cac7f screened clean for the known malware indicators; linked issue #271 is assigned to PR author @Bolajiomo99. Changes requested: when maxItems is exhausted mid-page, collectAnnouncementPages retains only a prefix but reports the provider cursor for the whole page. Resuming from that cursor skips the unconsumed suffix and loses announcements. Return a cursor at the exact consumed boundary or size page requests to the remaining item budget, with a regression proving stop/resume returns every record exactly once.

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.

[Wave 11] Bound, cancel, and page non-Stellar announcement fetchers

3 participants