fix: collect high-value RAVs before dust and expose deferrals#1248
Merged
MoonBoi9001 merged 3 commits intoJul 17, 2026
Conversation
Query fee vouchers are collected 100 rows at a time, previously in no defined order, so more than 100 vouchers below the 1 GRT collection threshold could hide a newly closed high-value one forever. Take the highest value first, and expose the deferred count and value as metrics.
CI checks that prettier and eslint produce no diff, and this file was committed with 4 statements formatted wider than the repo's prettier settings allow.
MoonBoi9001
marked this pull request as ready for review
July 10, 2026 14:00
Each pass reconciles a capped batch of pending payment vouchers, and rows that can never settle could permanently fill a 100 row batch. Raising the cap to 1,000 requires chunking the allocation id filter sent to the subgraph, since larger request bodies have caused http 413.
tmigone
reviewed
Jul 13, 2026
tmigone
approved these changes
Jul 13, 2026
MoonBoi9001
deleted the
mb9/prioritise-high-value-ravs-in-collection-queue
branch
July 17, 2026 03:56
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.
This PR makes both TAP collectors reconcile their most valuable pending Receipt Aggregate Vouchers (RAVs) first, raises the per-pass batch from 100 to 1,000 rows, and makes deferred fees visible to operators.
Each pass, the collectors take a capped batch of pending RAVs and reconcile it against the chain: recording which were collected, finalizing settled ones, and clearing the rest for submission. The batch was 100 rows in unspecified database order, while RAVs below the redemption threshold (1 GRT by default) legitimately never leave the pending set, so permanently deferred rows could fill the batch and starve reconciliation for everything behind them. That matters more alongside #1247, which stops the agent from wrongly finalizing partially collected RAVs, so their below-threshold remainders now stay pending instead of being written off.
The parts:
6 Postgres-backed tests cover the ordering, the full-batch case, and the chunked, block-pinned subgraph queries.