Skip to content

perf(api): serve v1 stx_supply from the chain_tip supply counter - #2736

Merged
rafa-stacks merged 1 commit into
mainfrom
work/v1-stx-supply-counter-d67474
Oct 26, 2026
Merged

rafa-stacks merged 1 commit into
mainfrom
work/v1-stx-supply-counter-d67474

Conversation

@rafa-stacks

Copy link
Copy Markdown
Collaborator

Serves the /extended/v1/stx_supply routes from the materialized chain_tip.stx_supply counter when no height is requested or the height is at or above the chain tip, fixing mainnet timeouts. Historical ?height requests still use the aggregate query, and response shapes are unchanged.

@rafa-stacks
rafa-stacks requested a balanced review from Copilot October 26, 2026 22:58
@rafa-stacks
rafa-stacks marked this pull request as ready for review October 26, 2026 22:59
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI 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.

🟢 Approval recommended

The focused change uses the existing maintained counter, preserves historical behavior, and has no identified blocking issues.

No open issues 🎉

What changed in this PR

This PR reduces timeouts on /extended/v1/stx_supply by using the existing materialized supply counter for current supply requests, while preserving historical queries and response formats.

Changes:

  • Reads chain_tip.stx_supply when height is omitted or at or above the chain tip.
  • Retains aggregate queries for historical heights.
  • Updates tests to use block builders and verify supply calculations, tip-height requests, and historical responses.
File Description
tests/​api/​datastore/​other.test.ts Updates supply fixtures and adds tip-height and historical assertions.
src/​datastore/​pg-store.ts Adds and documents the counter-based fast path for supply queries.

Review effort: Balanced

@rafa-stacks
rafa-stacks merged commit 2a8245f into main Oct 26, 2026
26 checks passed
@rafa-stacks
rafa-stacks deleted the work/v1-stx-supply-counter-d67474 branch October 26, 2026 23:01
@github-project-automation github-project-automation Bot moved this to ✅ Done in API Board Oct 26, 2026

This branch was successfully deployed

1 active deployment
Production — 72951f73 Deployed Oct 26, 2026 by rafa-stacks via build-publish #3874
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants