Skip to content

Conversation

@tmigone
Copy link
Member

@tmigone tmigone commented Dec 16, 2025

Problem

When an indexer is over-allocated (allocated tokens exceed provisioned stake + delegated stake), the unallocate operation fails the simulation with AllocationClosed (0x61b66e0d) error. This happens because:

  1. The indexer constructs a multicall: [collect(), stopService()] (stopService() is the new closeAllocation())
  2. During collect(), the contract presents POI, collects rewards and then checks for over allocated condition
  3. If over-allocated, it automatically calls _closeAllocation() closing the allocation
  4. Then stopService() executes and tries to close an already-closed allocation → reverts
"Failed to execute subgraph service transaction: execution reverted (unknown custom error) (action=\"estimateGas\", data=\"0x61b66e0d000000000000000000000000cf8e12d86245fdc7937ac38331cd41bcf06a1264000000000000000000000000000000000000000000000000000000006940768f\"

Solution

Before building the unallocate transaction, check SubgraphService.isOverAllocated(allocationId):

  • If over-allocated: Only call collect() — it will auto-close the allocation
  • If not over-allocated: Use normal multicall [collect(), stopService()]

Note that it's possible for the indexer to be over allocated when the agent checks for the condition, but under allocated once the transaction (consisting of just collect()) is confirmed on chain. In this case, on chain the indexer would have collected rewards but the allocation would remain open. The agent handles this well, it will expect an AllocationClosed event regardless of the calls being made, if it does not find one it will mark the action as failed. Retrying it later will result in the allocation being closed correctly (and potentially new rewards being collected as well).

Also fixed event detection for graph indexer allocation close command to look for AllocationClosed instead of ServiceStopped, since AllocationClosed is emitted in both paths.

Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
@github-project-automation github-project-automation bot moved this to 🗃️ Inbox in Indexer Dec 16, 2025
@tmigone tmigone requested review from Maikol and dwerner December 16, 2025 19:33
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
Copy link
Contributor

@dwerner dwerner left a comment

Choose a reason for hiding this comment

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

lgtm

@github-project-automation github-project-automation bot moved this from 🗃️ Inbox to ✅ Approved in Indexer Dec 16, 2025
@dwerner dwerner merged commit c5b8715 into main Dec 16, 2025
9 checks passed
@dwerner dwerner deleted the tmigone/handle-overallocation branch December 16, 2025 19:45
@github-project-automation github-project-automation bot moved this from ✅ Approved to 🚗 Merged in Indexer Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🚗 Merged

Development

Successfully merging this pull request may close these issues.

3 participants