Skip to content

feat: track on-chain RCA offers for dipper idempotency gate#6

Open
MoonBoi9001 wants to merge 2 commits intomainfrom
mb9/track-on-chain-rca-offers
Open

feat: track on-chain RCA offers for dipper idempotency gate#6
MoonBoi9001 wants to merge 2 commits intomainfrom
mb9/track-on-chain-rca-offers

Conversation

@MoonBoi9001
Copy link
Copy Markdown
Member

@MoonBoi9001 MoonBoi9001 commented Apr 23, 2026

Motivation

The indexing-payments-subgraph tracks the IndexingAgreement lifecycle from the point an indexer calls acceptIndexingAgreement on-chain -- the AgreementAccepted event creates the stateful entity and subsequent AgreementUpdated / AgreementCanceled / RCACollected events mutate it. What the subgraph does not currently index is the earlier pre-accept step where dipper calls RecurringCollector.offer() to post the RCA offer that indexers will later accept.

Dipper needs to know whether an offer for a given agreement already exists on-chain before submitting a new one. Without that check, a dipper crash between broadcasting offer() and persisting the result locally would cause the restart to resubmit, wasting gas on an already-successful on-chain transaction.

Summary

  • Adds a handleOfferStored mapping on the RecurringCollector data source that creates an Offer entity keyed by agreementId (bytes16) when the contract emits OfferStored.
  • Declares Offer immutable. Duplicate OfferStored events for the same agreementId are guaranteed by the contract's id derivation to carry the same offerHash, so the handler returns early on the second event rather than attempting an immutable rewrite (which would halt the subgraph).
  • Adds the OfferStored event to abis/RecurringCollector.json and binds it in subgraph.template.yaml.
  • Matchstick coverage for the handler: first-wins entity creation and duplicate-event no-op.

Generated with Claude Code

Adds a handleOfferStored mapping to the RecurringCollector data source
that creates an immutable Offer entity keyed by agreementId (bytes16) on
each OfferStored event.

Dipper queries this entity before calling RecurringCollector.offer() to
avoid re-submitting an offer after a crashed-mid-flight restart where the
on-chain transaction landed but dipper lost track of it. For a given
agreementId the RCA identifying fields (payer, dataService, serviceProvider,
deadline, nonce) are fixed by the id derivation, so duplicate OfferStored
events for the same id carry the same offerHash by construction -- the
entity is modelled as write-only and first-wins to reflect that. The
handler returns early if an Offer for the same id already exists, which
guards crash-recovery resubmissions and chain reorg re-emissions from
halting the subgraph on an immutable rewrite.

Includes matchstick coverage for handleOfferStored (first-wins and
duplicate-event guard).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MoonBoi9001 MoonBoi9001 force-pushed the mb9/track-on-chain-rca-offers branch from a788f72 to eb408d4 Compare April 23, 2026 04:32
Drop the branches: [main] filter so stacked PRs whose base is another
branch in the same repo (e.g. PR #7 stacked on this one) still get
build-and-test runs. Keep the push trigger narrow to main so CI does
not fire on every force-push across feature branches.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant