Skip to content

feat: add GET /api/sync-progress endpoint (COW-985)#74

Merged
lgahdl merged 3 commits into
developfrom
luizhatem/cow-985-feat-add-apisync-progress-endpoint-with-per-chain-completion
May 29, 2026
Merged

feat: add GET /api/sync-progress endpoint (COW-985)#74
lgahdl merged 3 commits into
developfrom
luizhatem/cow-985-feat-add-apisync-progress-endpoint-with-per-chain-completion

Conversation

@lgahdl
Copy link
Copy Markdown
Contributor

@lgahdl lgahdl commented May 28, 2026

Summary

Adds a GET /api/sync-progress endpoint that returns per-chain historical sync progress in clean JSON. Addresses the client ask: "nice to get a sense of how far we are from being ready".

Example response while backfilling:

{
  "mainnet": {
    "totalBlocks": 7313715,
    "processedBlocks": 2906029,
    "progressPct": 39.7,
    "isRealtime": false,
    "isComplete": false
  },
  "gnosis": {
    "totalBlocks": 17024177,
    "processedBlocks": 2399220,
    "progressPct": 14.1,
    "isRealtime": false,
    "isComplete": false
  }
}

Example response once fully synced:

{
  "mainnet": { "progressPct": 100.0, "isRealtime": true, "isComplete": true, ... },
  "gnosis":  { "progressPct": 100.0, "isRealtime": true, "isComplete": true, ... }
}

Implementation

Reads from Ponder's built-in GET /metrics Prometheus endpoint using the incoming request's origin (no hardcoded port). Parses ponder_historical_total_blocks, ponder_historical_completed_blocks, ponder_historical_cached_blocks, ponder_sync_is_realtime, and ponder_sync_is_complete. Degrades gracefully if /metrics is unreachable (returns {}).

Registered in the OpenAPI spec — visible in Swagger UI at /docs.

Test plan

  • pnpm typecheck && pnpm lint passes
  • 6 unit tests: 200 status, chain entries, processedBlocks math, progressPct rounding, flags, unreachable fallback
  • Verified live against running indexer — returns real block counts and percentages

Related Issues

COW-985

🤖 Generated with Claude Code

Returns per-chain historical sync progress as clean JSON:
totalBlocks, processedBlocks, progressPct (0-100), isRealtime,
isComplete. Reads from Ponder's Prometheus /metrics endpoint using
the request origin so it works on any port. Registered in OpenAPI/Swagger.

6 integration tests covering: status code, chain entries, processedBlocks
calculation, progressPct rounding, realtime/complete flags, and graceful
degradation when /metrics is unreachable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 28, 2026

COW-985

…W-985)

Add non-null assertions for Record<string, T> index access under noUncheckedIndexedAccess.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@jeffersonBastos jeffersonBastos left a comment

Choose a reason for hiding this comment

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

Did you add this new route to the documentation?
/sync-progress

@jeffersonBastos jeffersonBastos self-requested a review May 29, 2026 14:38
Copy link
Copy Markdown
Contributor

@jeffersonBastos jeffersonBastos left a comment

Choose a reason for hiding this comment

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

need doc

Add entry in REST endpoints section and a dedicated subsection with
example response and field descriptions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lgahdl lgahdl merged commit d534915 into develop May 29, 2026
4 checks passed
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.

2 participants