Skip to content

fix: collect high-value RAVs before dust and expose deferrals#1248

Merged
MoonBoi9001 merged 3 commits into
mainfrom
mb9/prioritise-high-value-ravs-in-collection-queue
Jul 17, 2026
Merged

fix: collect high-value RAVs before dust and expose deferrals#1248
MoonBoi9001 merged 3 commits into
mainfrom
mb9/prioritise-high-value-ravs-in-collection-queue

Conversation

@MoonBoi9001

@MoonBoi9001 MoonBoi9001 commented Jul 10, 2026

Copy link
Copy Markdown
Member

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:

  • pendingRAVs orders by value descending, so dust sinks to the bottom of the batch, and warns when the batch comes back full.
  • The batch limit rises from 100 to 1,000. The allocation id filter sent to the subgraph is chunked into groups of 100 per request, keeping request bodies the size they are today (larger bodies have drawn http 413 rejections from this endpoint before).
  • New Prometheus gauges report the count of below-threshold RAVs deferred each pass and their total GRT; for Horizon (TAP v2) that value is what is still collectible, the RAV's total minus what the payer already collected. The existing info log gains the same remainder figure.

6 Postgres-backed tests cover the ordering, the full-batch case, and the chunked, block-pinned subgraph queries.

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.
@github-project-automation github-project-automation Bot moved this to 🗃️ Inbox in Indexer Jul 10, 2026
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
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.
@MoonBoi9001 MoonBoi9001 added the bug Something isn't working label Jul 13, 2026
Comment thread packages/indexer-common/src/allocations/graph-tally-collector.ts
@github-project-automation github-project-automation Bot moved this from 🗃️ Inbox to ✅ Approved in Indexer Jul 13, 2026
@MoonBoi9001
MoonBoi9001 merged commit d7d47ca into main Jul 17, 2026
11 of 15 checks passed
@MoonBoi9001
MoonBoi9001 deleted the mb9/prioritise-high-value-ravs-in-collection-queue branch July 17, 2026 03:56
@github-project-automation github-project-automation Bot moved this from ✅ Approved to 🚗 Merged in Indexer Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: 🚗 Merged

Development

Successfully merging this pull request may close these issues.

2 participants