Skip to content

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

Merged
tmigone merged 3 commits into
mainfrom
mb9/collect-remaining-fees-after-partial-rav-collection
Oct 20, 2026
Merged

tmigone merged 3 commits 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 from 🗃️ Inbox to ✅ Approved in Indexer Oct 20, 2026
@tmigone
tmigone merged commit 3593e53 into main Oct 20, 2026
11 checks passed
@tmigone
tmigone deleted the mb9/collect-remaining-fees-after-partial-rav-collection branch October 20, 2026 12:59
@github-project-automation github-project-automation Bot moved this from ✅ Approved to 🚗 Merged in Indexer Oct 20, 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