Skip to content

Commit 21ac384

Browse files
committed
common: improve auto-graft-sync error logging, docs
1 parent ddc4dbe commit 21ac384

File tree

5 files changed

+34
-28
lines changed

5 files changed

+34
-28
lines changed

packages/indexer-agent/src/commands/start.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ export const start = {
334334
})
335335
},
336336
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
337-
handler: (_argv: any) => { },
337+
handler: (_argv: any) => {},
338338
}
339339

340340
export async function createNetworkSpecification(
@@ -690,13 +690,14 @@ export function reviewArgumentsForWarnings(argv: AgentOptions, logger: Logger) {
690690
if (collectReceiptsEndpoint) {
691691
logger.warn(
692692
"The option '--collect-receipts-endpoint' is deprecated. " +
693-
"Please use the option '--gateway-endpoint' to inform the Gateway base URL.",
693+
"Please use the option '--gateway-endpoint' to inform the Gateway base URL.",
694694
)
695695
}
696696

697697
if (gasIncreaseTimeout < advisedGasIncreaseTimeout) {
698698
logger.warn(
699-
`Gas increase timeout is set to less than ${gasIncreaseTimeout / 1000
699+
`Gas increase timeout is set to less than ${
700+
gasIncreaseTimeout / 1000
700701
} seconds. This may lead to high gas usage`,
701702
{ gasIncreaseTimeout: gasIncreaseTimeout / 1000.0 },
702703
)
@@ -705,14 +706,14 @@ export function reviewArgumentsForWarnings(argv: AgentOptions, logger: Logger) {
705706
if (gasIncreaseFactor > advisedGasIncreaseTimeout) {
706707
logger.warn(
707708
`Gas increase factor is set to > ${advisedGasIncreaseFactor}. ` +
708-
'This may lead to high gas usage',
709+
'This may lead to high gas usage',
709710
{ gasIncreaseFactor: gasIncreaseFactor },
710711
)
711712
}
712713
if (rebateClaimThreshold < voucherRedemptionThreshold) {
713714
logger.warn(
714715
'Rebate single minimum claim value is less than voucher minimum redemption value, ' +
715-
'but claims depend on redemptions',
716+
'but claims depend on redemptions',
716717
{
717718
voucherRedemptionThreshold: formatGRT(voucherRedemptionThreshold),
718719
rebateClaimThreshold: formatGRT(rebateClaimThreshold),
@@ -729,7 +730,7 @@ export function reviewArgumentsForWarnings(argv: AgentOptions, logger: Logger) {
729730
if (rebateClaimMaxBatchSize > advisedRebateClaimMaxBatchSize) {
730731
logger.warn(
731732
`Setting the max batch size for rebate claims to more than ${advisedRebateClaimMaxBatchSize}` +
732-
'may result in batches that are too large to fit into a block',
733+
'may result in batches that are too large to fit into a block',
733734
{ rebateClaimMaxBatchSize: rebateClaimMaxBatchSize },
734735
)
735736
}
@@ -743,7 +744,7 @@ export function reviewArgumentsForWarnings(argv: AgentOptions, logger: Logger) {
743744
if (voucherRedemptionMaxBatchSize > advisedVoucherRedemptionMaxBatchSize) {
744745
logger.warn(
745746
`Setting the max batch size for voucher redemptions to more than ${advisedVoucherRedemptionMaxBatchSize} ` +
746-
'may result in batches that are too large to fit into a block',
747+
'may result in batches that are too large to fit into a block',
747748
{ voucherRedemptionMaxBatchSize: voucherRedemptionMaxBatchSize },
748749
)
749750
}

packages/indexer-common/src/__tests__/ipfs.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,16 @@ describe(SubgraphManifestResolver, () => {
9696
return res.send(err.message)
9797
}
9898

99-
// console.log(`got cid ${cid}`)
100-
10199
// Example: Respond with different data based on the CID
102100
if (manifestMap.has(cid)) {
103101
res.send(manifestMap.get(cid))
104102
} else {
105-
// console.log(`CID not found: ${cid}`)
106103
res.status(404).send('Not Found')
107104
}
108105
})
109106

110107
// Handler for all other routes
111108
app.use((req: Request, res: Response, next) => {
112-
// console.log(`404: ${req.url}, ${req.method}`)
113109
res.status(404).send('Not Found')
114110
next()
115111
})

packages/indexer-common/src/graph-node.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class SubgraphManifestResolver {
8787
this.ipfsBaseUrl = new URL(`/api/v0/`, ipfsEndpoint)
8888
this.ipfsClient = axios.create({})
8989
this.ipfsClient.interceptors.request.use((config) => {
90-
logger.info(`Subgraph Manifest IPFS request: ${config.url}`)
90+
logger.debug(`Subgraph Manifest IPFS request: ${config.url}`)
9191
return config
9292
})
9393
this.logger = logger
@@ -811,7 +811,10 @@ export class GraphNode {
811811
}
812812

813813
/**
814-
* wait for the block to be synced, polling indexing status until it is
814+
* Wait for the block to be synced, polling indexing status until it is
815+
* The Deployment should already be created and deployed to graph-node
816+
* This will resume a paused subgraph if the block height target is higher than the
817+
* current block height
815818
*/
816819
public async syncToBlockAndPause(
817820
blockHeight: number,
@@ -833,9 +836,12 @@ export class GraphNode {
833836
let deployed: SubgraphDeploymentAssignment[] = []
834837
let attempt = 0
835838

839+
const maxAttempts = 5
840+
const waitTimeMs = 3000
841+
836842
// wait and poll for the assignment to be created.
837-
while (attempt < 5) {
838-
await waitForMs(3000)
843+
while (attempt < maxAttempts) {
844+
await waitForMs(waitTimeMs)
839845
deployed = await this.subgraphDeploymentAssignmentsByDeploymentID(
840846
SubgraphStatus.ALL,
841847
[subgraphDeployment.ipfsHash],
@@ -853,13 +859,14 @@ export class GraphNode {
853859
deployed,
854860
})
855861
attempt += 1
856-
}
857-
858-
if (attempt >= 5) {
859-
this.logger.error(`Subgraph not deployed and active`, {
860-
subgraph: subgraphDeployment.ipfsHash,
861-
})
862-
throw new Error(`Subgraph not deployed and active, cannot sync to block`)
862+
if (attempt >= maxAttempts) {
863+
this.logger.error(`Subgraph not deployed and active`, {
864+
subgraph: subgraphDeployment.ipfsHash,
865+
})
866+
throw new Error(
867+
`Subgraph ${subgraphDeployment.ipfsHash} not deployed and active after ${maxAttempts} attempts, cannot sync to block ${blockHeight}`,
868+
)
869+
}
863870
}
864871

865872
const indexingStatus = await this.indexingStatus([subgraphDeployment])
@@ -927,7 +934,7 @@ export class GraphNode {
927934
indexingStatus,
928935
},
929936
)
930-
await waitForMs(3000)
937+
await waitForMs(waitTimeMs)
931938
}
932939

933940
this.logger.debug(`End syncing subgraph deployment synced to block`, {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ export class ActionManager {
329329
if (pendingActions.length > 0) {
330330
logger.warn(
331331
`${pendingActions} Actions found in PENDING state when execution began. Was there a crash?` +
332-
`These indicate that execution was interrupted while calling contracts, and will need to be cleared manually.`,
332+
`These indicate that execution was interrupted while calling contracts, and will need to be cleared manually.`,
333333
)
334334
}
335335

@@ -384,7 +384,7 @@ export class ActionManager {
384384
)
385385
}
386386
// This will return all results if successful, if failed it will return the failed actions
387-
results = await this.allocationManager.executeBatch(
387+
results = await allocationManager.executeBatch(
388388
prioritizedActions,
389389
onFinishedDeploying,
390390
)

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default {
127127
let lastId = ''
128128
// eslint-disable-next-line @typescript-eslint/no-explicit-any
129129
const allAllocations: any[] = []
130-
for (; ;) {
130+
for (;;) {
131131
const result = await network.networkSubgraph.checkedQuery(
132132
gql`
133133
query allocations($indexer: String!, $lastId: String!) {
@@ -275,7 +275,8 @@ async function endpointForNetwork(network: Network): Promise<Endpoints> {
275275
const response = await fetch(url)
276276
if (!response.ok) {
277277
throw new Error(
278-
`Returned status ${response.status}: ${response.body ? response.body.toString() : 'No data returned'
278+
`Returned status ${response.status}: ${
279+
response.body ? response.body.toString() : 'No data returned'
279280
}`,
280281
)
281282
}
@@ -310,7 +311,8 @@ async function endpointForNetwork(network: Network): Promise<Endpoints> {
310311
})
311312
if (!response.ok) {
312313
throw new Error(
313-
`Returned status ${response.status}: ${response.body ? response.body.toString() : 'No data returned'
314+
`Returned status ${response.status}: ${
315+
response.body ? response.body.toString() : 'No data returned'
314316
}`,
315317
)
316318
}

0 commit comments

Comments
 (0)