Skip to content

fix: collect remaining fees after a partial RAV collection#1247

Open
MoonBoi9001 wants to merge 1 commit into
mainfrom
mb9/collect-remaining-fees-after-partial-rav-collection
Open

fix: collect remaining fees after a partial RAV collection#1247
MoonBoi9001 wants to merge 1 commit into
mainfrom
mb9/collect-remaining-fees-after-partial-rav-collection

Conversation

@MoonBoi9001

@MoonBoi9001 MoonBoi9001 commented Jul 10, 2026

Copy link
Copy Markdown
Member

This PR stops the indexer-agent from permanently writing off query fees still owed on a Receipt Aggregate Voucher (RAV). In Graph Horizon a RAV's total keeps growing while its allocation is open, and the GraphTallyCollector contract pays out the difference from what it has already paid, so one RAV can be collected several times before the allocation closes; on Arbitrum One, 7 allocations have been collected repeatedly this way by the same payer, one of them 49 times. The agent's collection path already understands partial collection, but its settlement bookkeeping can only represent a single collection event: once the allocation closed, any earlier collection transaction older than 3,600 seconds caused the RAV to be marked final and dropped from collection forever, stranding everything earned between the last mid-allocation collection and the close.

The reviewer-relevant parts:

  • A RAV is marked final only when the contract's cumulative tokensCollected covers its current value, so final strictly means fully settled on-chain; the 3,600-second reorg buffer is kept.
  • redeemed_at now records settlement of the current value: it is stamped only once a RAV is fully paid out, and cleared on partially collected rows, which returns them to the submission list.
  • 2 adjacent defects are fixed: a reconciliation step that was not awaited, and collection ids rebuilt by zero-padding allocation ids.
  • The raw SQL on these paths is parameterized, and 10 Postgres-backed regression tests cover the partial-collection sequence.

The legacy pre-Horizon collector is unchanged; its escrow contract allows only 1 collection per allocation.

A query fee voucher can be paid out more than once as it grows, but the agent treated any past
payout as full settlement, so a voucher collected mid-allocation was frozen and the fees earned
afterwards were never claimed. Settlement is now judged against the amount actually paid out.
@github-project-automation github-project-automation Bot moved this to 🗃️ Inbox in Indexer Jul 10, 2026
@MoonBoi9001
MoonBoi9001 marked this pull request as ready for review July 10, 2026 14:00
@MoonBoi9001 MoonBoi9001 added the bug Something isn't working label Jul 13, 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: 🗃️ Inbox

Development

Successfully merging this pull request may close these issues.

1 participant