diff --git a/packages/indexer-common/src/indexer-management/actions.ts b/packages/indexer-common/src/indexer-management/actions.ts index a6952affc..a9e7f8636 100644 --- a/packages/indexer-common/src/indexer-management/actions.ts +++ b/packages/indexer-common/src/indexer-management/actions.ts @@ -108,6 +108,7 @@ export class ActionManager { } private async updateActionStatuses( + action_ids: number[], results: AllocationResult[], transaction: Transaction, ): Promise { @@ -128,6 +129,27 @@ export class ActionManager { ) updatedActions = updatedActions.concat(updatedAction) } + // approved actions that did not have an allocation result + const resultedActionIDs = results.map((result) => result.actionID) + const unfoundActionIDs = action_ids.filter((id) => id in resultedActionIDs) + + // Assume they have failed + for (const id of unfoundActionIDs) { + const status = ActionStatus.FAILED + const [, updatedAction] = await this.models.Action.update( + { + status: status, + transaction: null, + failureReason: 'No correlating transaction', + }, + { + where: { id }, + returning: true, + transaction, + }, + ) + updatedActions = updatedActions.concat(updatedAction) + } return updatedActions } @@ -163,7 +185,15 @@ export class ActionManager { results, }) - updatedActions = await this.updateActionStatuses(results, transaction) + updatedActions = await this.updateActionStatuses( + approvedActions.map((action) => action.id), + results, + transaction, + ) + + this.logger.debug('Completed action statuses update', { + updatedActions, + }) } catch (error) { this.logger.error(`Failed to execute batch tx on staking contract: ${error}`) throw indexerError(IndexerErrorCode.IE072, error) diff --git a/packages/indexer-common/src/indexer-management/allocations.ts b/packages/indexer-common/src/indexer-management/allocations.ts index 9a34f3b3e..144400185 100644 --- a/packages/indexer-common/src/indexer-management/allocations.ts +++ b/packages/indexer-common/src/indexer-management/allocations.ts @@ -628,28 +628,28 @@ export class AllocationManager { indexingRewards: rewardsAssigned, }) - logger.info('Identifying receipts worth collecting', { - allocation: closeAllocationEventLogs.allocationID, - }) - const allocation = await this.networkMonitor.allocation(allocationID) - // Collect query fees for this allocation - const isCollectingQueryFees = await this.receiptCollector.collectReceipts( - actionID, - allocation, - ) - // Upsert a rule so the agent keeps the deployment synced but doesn't allocate to it logger.debug( `Updating indexing rules so indexer-agent keeps the deployment synced but doesn't reallocate to it`, ) const offchainIndexingRule = { - identifier: allocation.subgraphDeployment.id.ipfsHash, + identifier: subgraphDeploymentID.ipfsHash, identifierType: SubgraphIdentifierType.DEPLOYMENT, decisionBasis: IndexingDecisionBasis.OFFCHAIN, } as Partial await upsertIndexingRule(logger, this.models, offchainIndexingRule) + logger.info('Identifying receipts worth collecting', { + allocation: closeAllocationEventLogs.allocationID, + }) + const allocation = await this.networkMonitor.allocation(allocationID) + // Collect query fees for this allocation + const isCollectingQueryFees = await this.receiptCollector.collectReceipts( + actionID, + allocation, + ) + return { actionID, type: 'unallocate',