feat: track on-chain RCA offers for dipper idempotency gate#6
Open
MoonBoi9001 wants to merge 2 commits intomainfrom
Open
feat: track on-chain RCA offers for dipper idempotency gate#6MoonBoi9001 wants to merge 2 commits intomainfrom
MoonBoi9001 wants to merge 2 commits intomainfrom
Conversation
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>
a788f72 to
eb408d4
Compare
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>
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.
Motivation
The indexing-payments-subgraph tracks the
IndexingAgreementlifecycle from the point an indexer callsacceptIndexingAgreementon-chain -- theAgreementAcceptedevent creates the stateful entity and subsequentAgreementUpdated/AgreementCanceled/RCACollectedevents mutate it. What the subgraph does not currently index is the earlier pre-accept step where dipper callsRecurringCollector.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
handleOfferStoredmapping on theRecurringCollectordata source that creates anOfferentity keyed byagreementId(bytes16) when the contract emitsOfferStored.Offerimmutable. DuplicateOfferStoredevents for the sameagreementIdare guaranteed by the contract's id derivation to carry the sameofferHash, so the handler returns early on the second event rather than attempting an immutable rewrite (which would halt the subgraph).OfferStoredevent toabis/RecurringCollector.jsonand binds it insubgraph.template.yaml.Generated with Claude Code