fix: page the ACS snapshot for holdings reads - #8
Merged
Conversation
sdk.token.utxos.list was called with continueUntilCompletion, which makes core-acs-reader replay the whole update stream in 100-record pages instead of querying the active contract set once. Every balance read fired thousands of POST /v2/updates and tripped the validator ingress rate limit, which answered 503 and surfaced an nginx error page in the wallet. The client-side limit goes with it: it truncates the snapshot silently, while the participant's own http-list-max-elements-limit answers 413 instead.
sdk.token.utxos.list offers two shapes and neither answers "every holding": with continueUntilCompletion it replays the whole update stream in 100-record pages, and without it the read is a single response bounded by the participant's http-list-max-elements-limit. Read /v2/state/active-contracts-page directly instead, following nextPageToken against an offset pinned by the first request, which is complete regardless of that cap and costs one request per page rather than thousands per read.
Hoists the event format out of the read, drops a conditional spread that JSON.stringify already handles, and ends the loop on an empty page token as well as a missing one, which the participant documents as possible. A holding whose interface view is absent now fails the read rather than being skipped, since skipping it understates a balance. Grouping in summarizeHoldingUtxos pushes instead of rebuilding each group array, which matters now that this is the only balance path when Scan is unavailable.
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.
Summary
No related issue.
Every balance read replayed the whole ledger update stream, thousands of requests each time. That tripped the validator's rate limit, which answered with an nginx 503 page the wallet then showed to the user.
Changes
Deviations
Acceptance criteria
Test plan
Automated tests
pnpm installpnpm testManual verification
docker compose up --build -dgrep -c "POST /v2/updates" /var/log/nginx/access.logand note the numberBreaking changes
None.
Checklist
Screenshots
None.