From b663c65e55d82cc0ecaefc580add1a83b5735edf Mon Sep 17 00:00:00 2001 From: Daniel Werner Date: Mon, 18 Nov 2024 11:19:05 -0800 Subject: [PATCH 1/3] release version 0.21.8 bump --- docs/networks/arbitrum-sepolia.md | 4 ++-- lerna.json | 2 +- packages/indexer-agent/package.json | 4 ++-- packages/indexer-cli/package.json | 4 ++-- packages/indexer-common/package.json | 2 +- packages/indexer-service/package.json | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/networks/arbitrum-sepolia.md b/docs/networks/arbitrum-sepolia.md index b94159e72..0eb4c49d7 100644 --- a/docs/networks/arbitrum-sepolia.md +++ b/docs/networks/arbitrum-sepolia.md @@ -7,8 +7,8 @@ The Graph Network's testnet is on Arbitrum Sepolia (eip155:421614). Sepolia netw | Component | Release | | ------------------ | ------------------------------------------------------------------------------------ | | contracts | [5.3.3](https://github.com/graphprotocol/contracts/releases/tag/v5.3.3) | -| indexer-agent | [0.21.7](https://github.com/graphprotocol/indexer/releases/tag/v0.21.7) | -| indexer-cli | [0.21.7](https://github.com/graphprotocol/indexer/releases/tag/v0.21.7) | +| indexer-agent | [0.21.8](https://github.com/graphprotocol/indexer/releases/tag/v0.21.8) | +| indexer-cli | [0.21.8](https://github.com/graphprotocol/indexer/releases/tag/v0.21.8) | | indexer-service-rs | [1.0.0](https://github.com/graphprotocol/indexer-rs/releases/tag/v1.0.0) | | tap-agent | [1.0.0](https://github.com/graphprotocol/indexer-rs/releases/tag/v1.0.0) | | graph-node | [0.35.1](https://github.com/graphprotocol/graph-node/releases/tag/v0.35.1) | diff --git a/lerna.json b/lerna.json index 3b5ee92d5..035aa2491 100644 --- a/lerna.json +++ b/lerna.json @@ -4,5 +4,5 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "0.21.7" + "version": "0.21.8" } diff --git a/packages/indexer-agent/package.json b/packages/indexer-agent/package.json index acf7e1b53..69b3d9acc 100644 --- a/packages/indexer-agent/package.json +++ b/packages/indexer-agent/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/indexer-agent", - "version": "0.21.7", + "version": "0.21.8", "description": "Indexer agent", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -30,7 +30,7 @@ }, "dependencies": { "@graphprotocol/common-ts": "2.0.11", - "@graphprotocol/indexer-common": "^0.21.7", + "@graphprotocol/indexer-common": "^0.21.8", "@thi.ng/heaps": "^1.3.1", "@uniswap/sdk": "3.0.3", "axios": "0.26.1", diff --git a/packages/indexer-cli/package.json b/packages/indexer-cli/package.json index 61f989529..ab5930248 100644 --- a/packages/indexer-cli/package.json +++ b/packages/indexer-cli/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/indexer-cli", - "version": "0.21.7", + "version": "0.21.8", "description": "Indexer CLI for The Graph Network", "main": "./dist/cli.js", "files": [ @@ -27,7 +27,7 @@ }, "dependencies": { "@graphprotocol/common-ts": "2.0.11", - "@graphprotocol/indexer-common": "^0.21.7", + "@graphprotocol/indexer-common": "^0.21.8", "@iarna/toml": "2.2.5", "@thi.ng/iterators": "5.1.74", "@urql/core": "3.1.0", diff --git a/packages/indexer-common/package.json b/packages/indexer-common/package.json index f23c714cb..a56340ec6 100644 --- a/packages/indexer-common/package.json +++ b/packages/indexer-common/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/indexer-common", - "version": "0.21.7", + "version": "0.21.8", "description": "Common library for Graph Protocol indexer components", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/packages/indexer-service/package.json b/packages/indexer-service/package.json index b133c6c44..77ca566f5 100644 --- a/packages/indexer-service/package.json +++ b/packages/indexer-service/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/indexer-service", - "version": "0.21.7", + "version": "0.21.8", "description": "Indexer service", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -33,7 +33,7 @@ "dependencies": { "@google-cloud/profiler": "6.0.1", "@graphprotocol/common-ts": "2.0.11", - "@graphprotocol/indexer-common": "^0.21.7", + "@graphprotocol/indexer-common": "^0.21.8", "@graphprotocol/indexer-native": "0.21.6", "@graphql-tools/load": "8.0.0", "@graphql-tools/url-loader": "8.0.0", From 07c4aae43445e1888f0d6c505451cb6f00e84658 Mon Sep 17 00:00:00 2001 From: Daniel Werner Date: Mon, 18 Nov 2024 13:15:31 -0800 Subject: [PATCH 2/3] common: add pagination support to allocation queries --- .../__tests__/helpers.test.ts | 2 +- .../resolvers/allocations.ts | 79 ++++++++++++++----- .../resolvers/indexer-status.ts | 63 +++++++++------ 3 files changed, 100 insertions(+), 44 deletions(-) diff --git a/packages/indexer-common/src/indexer-management/__tests__/helpers.test.ts b/packages/indexer-common/src/indexer-management/__tests__/helpers.test.ts index a2358926e..402775edb 100644 --- a/packages/indexer-common/src/indexer-management/__tests__/helpers.test.ts +++ b/packages/indexer-common/src/indexer-management/__tests__/helpers.test.ts @@ -473,7 +473,7 @@ describe('Monitor: CI', () => { test('Fetch subgraph deployments (unconstrained block)', async () => { const deployments = await networkMonitor.subgraphDeployments() await expect(deployments.length).toBeGreaterThan(500) - }, 30000) + }, 40000) }) describe('Network layer detection', () => { diff --git a/packages/indexer-common/src/indexer-management/resolvers/allocations.ts b/packages/indexer-common/src/indexer-management/resolvers/allocations.ts index f5ad5da3a..385c9a424 100644 --- a/packages/indexer-common/src/indexer-management/resolvers/allocations.ts +++ b/packages/indexer-common/src/indexer-management/resolvers/allocations.ts @@ -66,8 +66,13 @@ interface AllocationInfo { const ALLOCATION_QUERIES = { [AllocationQuery.all]: gql` - query allocations($indexer: String!) { - allocations(where: { indexer: $indexer }, first: 1000) { + query allocations($indexer: String!, $lastId: String!) { + allocations( + where: { indexer: $indexer, id_gt: $lastId } + orderBy: id + orderDirection: asc + first: 1000 + ) { id subgraphDeployment { id @@ -87,8 +92,13 @@ const ALLOCATION_QUERIES = { } `, [AllocationQuery.active]: gql` - query allocations($indexer: String!) { - allocations(where: { indexer: $indexer, status: Active }, first: 1000) { + query allocations($indexer: String!, $lastId: String!) { + allocations( + where: { indexer: $indexer, id_gt: $lastId, status: Active } + orderBy: id + orderDirection: asc + first: 1000 + ) { id subgraphDeployment { id @@ -108,8 +118,13 @@ const ALLOCATION_QUERIES = { } `, [AllocationQuery.closed]: gql` - query allocations($indexer: String!) { - allocations(where: { indexer: $indexer, status: Closed }, first: 1000) { + query allocations($indexer: String!, $lastId: String!) { + allocations( + where: { indexer: $indexer, id_gt: $lastId, status: Closed } + orderBy: id + orderDirection: asc + first: 1000 + ) { id subgraphDeployment { id @@ -129,8 +144,13 @@ const ALLOCATION_QUERIES = { } `, [AllocationQuery.allocation]: gql` - query allocations($allocation: String!) { - allocations(where: { id: $allocation }, first: 1000) { + query allocations($allocation: String!, $lastId: String!) { + allocations( + where: { id: $allocation, id_gt: $lastId } + orderBy: id + orderDirection: asc + first: 1000 + ) { id subgraphDeployment { id @@ -203,27 +223,44 @@ async function queryAllocations( ) } - const result = await networkSubgraph.checkedQuery( - ALLOCATION_QUERIES[filterType], - filterVars, - ) + let lastId = '' + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const resultAllocations: any[] = [] + for (;;) { + const pageVars = { + ...filterVars, + lastId, + } + const result = await networkSubgraph.checkedQuery( + ALLOCATION_QUERIES[filterType], + pageVars, + ) + + if (result.error) { + logger.warning('Querying allocations failed', { + error: result.error, + lastId: lastId, + }) + throw result.error + } - if (result.data.allocations.length == 0) { + if (result.data.allocations.length == 0) { + break + } + // merge results + resultAllocations.push(...result.data.allocations) + lastId = result.data.allocations.slice(-1)[0].id + } + + if (resultAllocations.length == 0) { // TODO: Is 'Claimable' still the correct term here, after Exponential Rebates? logger.info(`No 'Claimable' allocations found`) return [] } - if (result.error) { - logger.warning('Query failed', { - error: result.error, - }) - throw result.error - } - // eslint-disable-next-line @typescript-eslint/no-explicit-any return pMap( - result.data.allocations, + resultAllocations, // eslint-disable-next-line @typescript-eslint/no-explicit-any async (allocation: any): Promise => { const deadlineEpoch = allocation.createdAtEpoch + context.maxAllocationEpochs diff --git a/packages/indexer-common/src/indexer-management/resolvers/indexer-status.ts b/packages/indexer-common/src/indexer-management/resolvers/indexer-status.ts index dad36df87..c040113a2 100644 --- a/packages/indexer-common/src/indexer-management/resolvers/indexer-status.ts +++ b/packages/indexer-common/src/indexer-management/resolvers/indexer-status.ts @@ -124,33 +124,52 @@ export default { const address = network.specification.indexerOptions.address try { - const result = await network.networkSubgraph.checkedQuery( - gql` - query allocations($indexer: String!) { - allocations( - where: { indexer: $indexer, status: Active } - first: 1000 - orderDirection: desc - ) { - id - allocatedTokens - createdAtEpoch - closedAtEpoch - subgraphDeployment { + let lastId = '' + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const allAllocations: any[] = [] + for (;;) { + const result = await network.networkSubgraph.checkedQuery( + gql` + query allocations($indexer: String!, $lastId: String!) { + allocations( + where: { indexer: $indexer, status: Active, id_gt: $lastId } + first: 1000 + orderBy: id + orderDirection: asc + ) { id - stakedTokens - signalledTokens + allocatedTokens + createdAtEpoch + closedAtEpoch + subgraphDeployment { + id + stakedTokens + signalledTokens + } } } - } - `, - { indexer: address.toLocaleLowerCase() }, - ) - if (result.error) { - throw result.error + `, + { indexer: address.toLocaleLowerCase(), lastId }, + ) + + if (result.error) { + logger.warning('Querying allocations failed', { + error: result.error, + lastId: lastId, + }) + throw result.error + } + + if (result.data.allocations.length === 0) { + break + } + + allAllocations.push(...result.data.allocations) + lastId = result.data.allocations.slice(-1)[0].id } + // eslint-disable-next-line @typescript-eslint/no-explicit-any - return result.data.allocations.map((allocation: any) => ({ + return allAllocations.map((allocation: any) => ({ ...allocation, subgraphDeployment: new SubgraphDeploymentID(allocation.subgraphDeployment.id) .ipfsHash, From cc1b1e97fa75ecf9b432441cf53c9149316d8d93 Mon Sep 17 00:00:00 2001 From: Daniel Werner Date: Tue, 19 Nov 2024 11:01:05 -0800 Subject: [PATCH 3/3] release-0.21.8-2 version bump --- docs/networks/arbitrum-sepolia.md | 4 ++-- lerna.json | 2 +- packages/indexer-agent/package.json | 4 ++-- packages/indexer-cli/package.json | 4 ++-- packages/indexer-common/package.json | 2 +- packages/indexer-service/package.json | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/networks/arbitrum-sepolia.md b/docs/networks/arbitrum-sepolia.md index 0eb4c49d7..7e578f185 100644 --- a/docs/networks/arbitrum-sepolia.md +++ b/docs/networks/arbitrum-sepolia.md @@ -7,8 +7,8 @@ The Graph Network's testnet is on Arbitrum Sepolia (eip155:421614). Sepolia netw | Component | Release | | ------------------ | ------------------------------------------------------------------------------------ | | contracts | [5.3.3](https://github.com/graphprotocol/contracts/releases/tag/v5.3.3) | -| indexer-agent | [0.21.8](https://github.com/graphprotocol/indexer/releases/tag/v0.21.8) | -| indexer-cli | [0.21.8](https://github.com/graphprotocol/indexer/releases/tag/v0.21.8) | +| indexer-agent | [0.21.8-2](https://github.com/graphprotocol/indexer/releases/tag/v0.21.8-2) | +| indexer-cli | [0.21.8-2](https://github.com/graphprotocol/indexer/releases/tag/v0.21.8-2) | | indexer-service-rs | [1.0.0](https://github.com/graphprotocol/indexer-rs/releases/tag/v1.0.0) | | tap-agent | [1.0.0](https://github.com/graphprotocol/indexer-rs/releases/tag/v1.0.0) | | graph-node | [0.35.1](https://github.com/graphprotocol/graph-node/releases/tag/v0.35.1) | diff --git a/lerna.json b/lerna.json index 035aa2491..7108b99f9 100644 --- a/lerna.json +++ b/lerna.json @@ -4,5 +4,5 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "0.21.8" + "version": "0.21.8-2" } diff --git a/packages/indexer-agent/package.json b/packages/indexer-agent/package.json index 69b3d9acc..8a94586a0 100644 --- a/packages/indexer-agent/package.json +++ b/packages/indexer-agent/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/indexer-agent", - "version": "0.21.8", + "version": "0.21.8-2", "description": "Indexer agent", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -30,7 +30,7 @@ }, "dependencies": { "@graphprotocol/common-ts": "2.0.11", - "@graphprotocol/indexer-common": "^0.21.8", + "@graphprotocol/indexer-common": "^0.21.8-2", "@thi.ng/heaps": "^1.3.1", "@uniswap/sdk": "3.0.3", "axios": "0.26.1", diff --git a/packages/indexer-cli/package.json b/packages/indexer-cli/package.json index ab5930248..33711e4d8 100644 --- a/packages/indexer-cli/package.json +++ b/packages/indexer-cli/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/indexer-cli", - "version": "0.21.8", + "version": "0.21.8-2", "description": "Indexer CLI for The Graph Network", "main": "./dist/cli.js", "files": [ @@ -27,7 +27,7 @@ }, "dependencies": { "@graphprotocol/common-ts": "2.0.11", - "@graphprotocol/indexer-common": "^0.21.8", + "@graphprotocol/indexer-common": "^0.21.8-2", "@iarna/toml": "2.2.5", "@thi.ng/iterators": "5.1.74", "@urql/core": "3.1.0", diff --git a/packages/indexer-common/package.json b/packages/indexer-common/package.json index a56340ec6..4c20dbfe4 100644 --- a/packages/indexer-common/package.json +++ b/packages/indexer-common/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/indexer-common", - "version": "0.21.8", + "version": "0.21.8-2", "description": "Common library for Graph Protocol indexer components", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/packages/indexer-service/package.json b/packages/indexer-service/package.json index 77ca566f5..dc7dc38f7 100644 --- a/packages/indexer-service/package.json +++ b/packages/indexer-service/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/indexer-service", - "version": "0.21.8", + "version": "0.21.8-2", "description": "Indexer service", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -33,7 +33,7 @@ "dependencies": { "@google-cloud/profiler": "6.0.1", "@graphprotocol/common-ts": "2.0.11", - "@graphprotocol/indexer-common": "^0.21.8", + "@graphprotocol/indexer-common": "^0.21.8-2", "@graphprotocol/indexer-native": "0.21.6", "@graphql-tools/load": "8.0.0", "@graphql-tools/url-loader": "8.0.0",