From 62c676bc2b63c7611cb27c6e88f7b2742502d892 Mon Sep 17 00:00:00 2001 From: Nate Gentile Date: Thu, 18 Dec 2025 18:07:32 -0800 Subject: [PATCH] add --auto-allocation-max-batch-size indexer-agent option --- packages/indexer-agent/README.md | 7 +++++ packages/indexer-agent/src/commands/start.ts | 7 +++++ .../src/indexer-management/actions.ts | 28 ++++++++++++++----- .../src/network-specification.ts | 1 + 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/packages/indexer-agent/README.md b/packages/indexer-agent/README.md index dae674c8a..be27e2a6b 100644 --- a/packages/indexer-agent/README.md +++ b/packages/indexer-agent/README.md @@ -50,6 +50,13 @@ Indexer Infrastructure inside a batch for auto allocation management. No obvious upperbound, with default of 1 [number] [default: 1] + --auto-allocation-max-batch-size Maximum number of allocation transactions + inside a batch for auto allocation + management. Limits the number of actions + processed per batch to prevent multicall + failures when there are many allocations. + Remaining actions will be processed in + subsequent batches. [number] Postgres --postgres-host Postgres host [string] [required] diff --git a/packages/indexer-agent/src/commands/start.ts b/packages/indexer-agent/src/commands/start.ts index 0d197e927..4f2b62b0c 100644 --- a/packages/indexer-agent/src/commands/start.ts +++ b/packages/indexer-agent/src/commands/start.ts @@ -348,6 +348,12 @@ export const start = { default: 1, group: 'Indexer Infrastructure', }) + .option('auto-allocation-max-batch-size', { + description: `Maximum number of allocation transactions inside a batch for auto allocation management. Limits the number of actions processed per batch to prevent multicall failures when there are many allocations. Remaining actions will be processed in subsequent batches.`, + type: 'number', + required: false, + group: 'Indexer Infrastructure', + }) .check(argv => { if ( !argv['network-subgraph-endpoint'] && @@ -408,6 +414,7 @@ export async function createNetworkSpecification( voucherRedemptionMaxBatchSize: argv.voucherRedemptionMaxBatchSize, allocationManagementMode: argv.allocationManagement, autoAllocationMinBatchSize: argv.autoAllocationMinBatchSize, + autoAllocationMaxBatchSize: argv.autoAllocationMaxBatchSize, allocateOnNetworkSubgraph: argv.allocateOnNetworkSubgraph, register: argv.register, maxProvisionInitialSize: argv.maxProvisionInitialSize, diff --git a/packages/indexer-common/src/indexer-management/actions.ts b/packages/indexer-common/src/indexer-management/actions.ts index dc3df35c7..33d3080a9 100644 --- a/packages/indexer-common/src/indexer-management/actions.ts +++ b/packages/indexer-common/src/indexer-management/actions.ts @@ -355,13 +355,27 @@ export class ActionManager { logger.error('Failed to query approved actions for network', { error }) return [] } - // mark all approved actions as DEPLOYING, this serves as a lock on other processing of them - await this.markActions( - approvedAndDeployingActions, - transaction, - ActionStatus.DEPLOYING, - ) - return approvedAndDeployingActions + + // Limit batch size to prevent multicall failures when there are many allocations + const maxBatchSize = + network.specification.indexerOptions.autoAllocationMaxBatchSize + let actionsToExecute = approvedAndDeployingActions + if (maxBatchSize && approvedAndDeployingActions.length > maxBatchSize) { + actionsToExecute = approvedAndDeployingActions.slice(0, maxBatchSize) + logger.info( + `Limiting batch size to ${maxBatchSize} actions (${approvedAndDeployingActions.length} total approved). ` + + `Remaining ${approvedAndDeployingActions.length - maxBatchSize} actions will be processed in subsequent batches.`, + { + totalApproved: approvedAndDeployingActions.length, + maxBatchSize, + actionsInThisBatch: actionsToExecute.length, + }, + ) + } + + // mark actions to execute as DEPLOYING, this serves as a lock on other processing of them + await this.markActions(actionsToExecute, transaction, ActionStatus.DEPLOYING) + return actionsToExecute }, ) diff --git a/packages/indexer-common/src/network-specification.ts b/packages/indexer-common/src/network-specification.ts index 2e9391c87..956fd7591 100644 --- a/packages/indexer-common/src/network-specification.ts +++ b/packages/indexer-common/src/network-specification.ts @@ -61,6 +61,7 @@ export const IndexerOptions = z .default('auto') .transform((x) => x as AllocationManagementMode), autoAllocationMinBatchSize: positiveNumber().default(1), + autoAllocationMaxBatchSize: positiveNumber().optional(), allocateOnNetworkSubgraph: z.boolean().default(false), register: z.boolean().default(true), maxProvisionInitialSize: GRT()