Repository navigation
perf(api): serve v1 stx_supply from the chain_tip supply counter - #2736
Merged
Merged
Conversation
bgridley-stacks
approved these changes
Oct 26, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
🟢 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_supplywhen 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
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Serves the
/extended/v1/stx_supplyroutes from the materializedchain_tip.stx_supplycounter when no height is requested or the height is at or above the chain tip, fixing mainnet timeouts. Historical?heightrequests still use the aggregate query, and response shapes are unchanged.