Skip to content

feat: stop unpaid indexing after a DIPs agreement is canceled#1225

Merged
MoonBoi9001 merged 5 commits into
main-dipsfrom
mb9/close-dips-allocations-after-cancel-once-fees-drained
Jun 1, 2026
Merged

feat: stop unpaid indexing after a DIPs agreement is canceled#1225
MoonBoi9001 merged 5 commits into
main-dipsfrom
mb9/close-dips-allocations-after-cancel-once-fees-drained

Conversation

@MoonBoi9001
Copy link
Copy Markdown
Member

TL;DR

When a payer cancels a DIPs agreement, the indexer used to keep its allocation open indefinitely, indexing a subgraph it would no longer be paid for. This lets that allocation close once the agreement's final payment has been collected, so the indexer stops doing unpaid work and frees the stake. It waits for the final payment first, because the payment can only be collected while the allocation is still open.

Motivation

A DIPs agreement pays an indexer to index a particular subgraph, and while the agreement is live the indexer's allocation for it is protected from being closed. When the payer cancels the agreement, that protection used to stay in place forever, so the allocation never closed and the indexer carried on indexing — with its stake locked in place — for a subgraph nobody was paying for.

The allocation can't simply close on cancellation, though: the final payment for work already done can only be collected while the allocation is still open, so closing too early would forfeit it. This change keeps the allocation protected only until that final payment has been collected, then releases it so the indexer's normal housekeeping can close it and put the stake to use elsewhere.

Summary

  • A canceled agreement's allocation stays protected only until its final payment is collected.
  • Protection consults the payment contract, which reports fees as collectable until fully drained.
  • Once nothing is left to collect, the allocation is freed and normal housekeeping closes it.
  • An active, uncanceled agreement still protects its allocation exactly as before.
  • If the collectable amount can't be read, the allocation stays protected, to avoid losing fees.

@github-project-automation github-project-automation Bot moved this to 🗃️ Inbox in Indexer May 29, 2026
A payer-canceled agreement kept its allocation open forever, so the indexer kept indexing a
subgraph it would no longer be paid for. Now the allocation is freed to close once its final
fees have been collected; closing any earlier makes the final collection fail on-chain.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MoonBoi9001 MoonBoi9001 force-pushed the mb9/close-dips-allocations-after-cancel-once-fees-drained branch from 7837320 to 1a97e23 Compare May 29, 2026 07:47
@MoonBoi9001 MoonBoi9001 requested a review from Maikol May 29, 2026 08:13
// allocation to be open), so a canceled agreement must keep its allocation
// alive until its final fees have been collected. Two cases protect:
// - an Accepted agreement: still live, closing would cancel it on-chain;
// - a payer-canceled agreement whose fees aren't fully collected yet.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this entire comment feels out of place, maybe we can move to where hasActiveDipsAgreement is called.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in follow up commits, also tightened this block

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the changes to the implementation of this function I would rename this since it's no longer looking for active agreements but checking if the agreement is collectable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed in follow up commit

MoonBoi9001 and others added 4 commits June 1, 2026 18:05
The check protects an allocation from closing while a DIPS agreement can still collect fees;
closing early makes the on-chain collection revert and strands them. It now covers live
agreements and canceled ones that are not yet drained, which "active" no longer described.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The note explained why closing an allocation can strand DIPS fees, but it sat inside the
lookup that only answers whether fees are still collectable. Move it next to the unallocate
guard that actually decides whether to block the close, where that reasoning is needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Refusing to close an allocation that still has a DIPS agreement printed a message that
claimed closing would cancel the agreement on-chain. That is wrong for an agreement the
payer already canceled but whose fees are still draining; reword it to fit both cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A repo check flags any run of four or more consecutive comment lines. The allocation-close
protection note ran to six lines and a POI-validation note to four; condense both, keeping why
an early close strands fees and the zero-POI sentinel rule.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MoonBoi9001 MoonBoi9001 requested a review from Maikol June 1, 2026 11:06
@github-project-automation github-project-automation Bot moved this from 🗃️ Inbox to ✅ Approved in Indexer Jun 1, 2026
@MoonBoi9001 MoonBoi9001 merged commit 343af6e into main-dips Jun 1, 2026
3 checks passed
@MoonBoi9001 MoonBoi9001 deleted the mb9/close-dips-allocations-after-cancel-once-fees-drained branch June 1, 2026 19:19
@github-project-automation github-project-automation Bot moved this from ✅ Approved to 🚗 Merged in Indexer Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: 🚗 Merged

Development

Successfully merging this pull request may close these issues.

2 participants