Skip to content

Commit 28ea27e

Browse files
committed
chore: ensure DIPs indexing rules in the reconciliation loop
1 parent 3427a3a commit 28ea27e

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

packages/indexer-agent/src/agent.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ export class Agent {
223223
{ logger, milliseconds: requestIntervalSmall },
224224
async () => {
225225
const { network, operator } = this.networkAndOperator
226+
if (network.specification.indexerOptions.enableDips) {
227+
// There should be a DipsManager in the operator
228+
if (!operator.dipsManager) {
229+
throw new Error('DipsManager is not available')
230+
}
231+
logger.trace('Ensuring indexing rules for DIPS', {
232+
protocolNetwork: network.specification.networkIdentifier,
233+
})
234+
await operator.dipsManager.ensureAgreementRules()
235+
}
226236
logger.trace('Fetching indexing rules', {
227237
protocolNetwork: network.specification.networkIdentifier,
228238
})

packages/indexer-common/src/indexer-management/client.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,11 @@ export interface IndexerManagementClientOptions {
454454
graphNode: GraphNode
455455
network: Network
456456
defaults: IndexerManagementDefaults
457+
actionManager?: ActionManager | undefined
457458
}
458459

459460
export class IndexerManagementClient extends Client {
461+
declare actionManager: ActionManager | undefined
460462
private logger?: Logger
461463
private models: IndexerManagementModels
462464

@@ -465,6 +467,7 @@ export class IndexerManagementClient extends Client {
465467

466468
this.logger = options.logger
467469
this.models = options.models
470+
this.actionManager = options.actionManager
468471
}
469472
}
470473

@@ -501,5 +504,8 @@ export const createIndexerManagementClient = async (
501504
context,
502505
})
503506

504-
return new IndexerManagementClient({ url: 'no-op', exchanges: [exchange] }, options)
507+
return new IndexerManagementClient(
508+
{ url: 'no-op', exchanges: [exchange] },
509+
{ ...options, actionManager },
510+
)
505511
}

packages/indexer-common/src/indexer-management/resolvers/allocations.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,13 @@ export default {
374374
amount: string
375375
protocolNetwork: string
376376
},
377-
{ network, graphNode, logger, models, actionManager }: IndexerManagementResolverContext,
377+
{
378+
network,
379+
graphNode,
380+
logger,
381+
models,
382+
actionManager,
383+
}: IndexerManagementResolverContext,
378384
): Promise<CreateAllocationResult> => {
379385
logger.debug('Execute createAllocation() mutation', {
380386
deployment,
@@ -735,9 +741,7 @@ export default {
735741
await models.IndexingRule.upsert(offchainIndexingRule)
736742

737743
if (actionManager?.allocationManager?.dipsManager) {
738-
await actionManager.allocationManager.dipsManager.tryCancelAgreement(
739-
allocation,
740-
)
744+
await actionManager.allocationManager.dipsManager.tryCancelAgreement(allocation)
741745
await actionManager.allocationManager.dipsManager.tryUpdateAgreementAllocation(
742746
allocationData.subgraphDeployment.id.toString(),
743747
allocation,

packages/indexer-common/src/operator.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
specification as spec,
1717
Action,
1818
POIDisputeAttributes,
19+
DipsManager,
1920
} from '@graphprotocol/indexer-common'
2021
import { Logger, formatGRT } from '@graphprotocol/common-ts'
2122
import { BigNumber, utils } from 'ethers'
@@ -82,6 +83,10 @@ export class Operator {
8283
this.specification = specification
8384
}
8485

86+
get dipsManager(): DipsManager | null {
87+
return this.indexerManagement.actionManager?.allocationManager?.dipsManager ?? null
88+
}
89+
8590
// --------------------------------------------------------------------------------
8691
// * Indexing Rules
8792
// --------------------------------------------------------------------------------

0 commit comments

Comments
 (0)