fix: indexer collects final payment after payer-side cancel#1216
Open
MoonBoi9001 wants to merge 4 commits into
Open
fix: indexer collects final payment after payer-side cancel#1216MoonBoi9001 wants to merge 4 commits into
MoonBoi9001 wants to merge 4 commits into
Conversation
When the payer cancels first via the on-chain contract, the agent's own opt-out rule from closing the allocation routes the agreement back through a second cancel. That cancel reverts, the function returns early, and the indexer is never paid for the active period. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI's format check rejected the previous commit because the new test assertions exceeded the line-length budget. No behaviour change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Existing comments in the file cap at 4 lines; the additions ran to 6-7. Trims both to two lines while keeping the why intact. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cross-link the two CanceledByPayer guards, document the return contract of cancelAgreement, and raise the lost-fees log to error with the deployment id attached. Consolidate the duplicate test block and add the failure-path coverage that was missing. 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.
TL;DR
Stops the indexer-agent from losing payment for honest work when the payer (via dipper) cancels an agreement on-chain before the agent has its own chance to cancel. Adds the missing final collect on the already-canceled path.
Motivation
When the payer cancels an indexing agreement on-chain (Studio shrinking the indexer set is the common case), the agent observes the resulting CanceledByPayer state, sweeps the deployment's DIPs rule, closes the allocation, and writes a NEVER rule so the deployment stays synced without being allocated to. The next collection tick is where the indexer loses money — the agent's "cancel blocklisted agreements" pass sees the NEVER rule and routes the already-canceled agreement back through the cancel function.
The cancel function tries a second on-chain cancel, the contract reverts because the agreement is already canceled, and the function returns early before reaching its own final-collection step. The indexer is never paid for the period the agreement was active, even though those funds are sitting in the payer's escrow and would have been collectable.
Summary
Generated with Claude Code