Skip to content

Commit 8e9bdb9

Browse files
dwernertmigone
andauthored
release-0.25 (#1158)
Co-authored-by: Tomás Migone <[email protected]>
1 parent 0036054 commit 8e9bdb9

File tree

8 files changed

+177
-26
lines changed

8 files changed

+177
-26
lines changed

docs/networks/arbitrum-sepolia.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ The Graph Network's testnet is on Arbitrum Sepolia (eip155:421614). Sepolia netw
77
| Component | Release |
88
| ------------------ | ------------------------------------------------------------------------------------ |
99
| contracts | [5.3.3](https://github.com/graphprotocol/contracts/releases/tag/v5.3.3) |
10-
| indexer-agent | [0.25.4](https://github.com/graphprotocol/indexer/releases/tag/v0.25.4) |
11-
| indexer-cli | [0.25.4](https://github.com/graphprotocol/indexer/releases/tag/v0.25.4) |
10+
| indexer-agent | [0.25.5](https://github.com/graphprotocol/indexer/releases/tag/v0.25.5) |
11+
| indexer-cli | [0.25.5](https://github.com/graphprotocol/indexer/releases/tag/v0.25.5) |
1212
| indexer-service-rs | [1.0.0](https://github.com/graphprotocol/indexer-rs/releases/tag/v1.0.0) |
1313
| tap-agent | [1.0.0](https://github.com/graphprotocol/indexer-rs/releases/tag/v1.0.0) |
1414
| graph-node | [0.35.1](https://github.com/graphprotocol/graph-node/releases/tag/v0.35.1) |

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
],
55
"npmClient": "yarn",
66
"useWorkspaces": true,
7-
"version": "0.25.4"
7+
"version": "0.25.5"
88
}

packages/indexer-agent/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@graphprotocol/indexer-agent",
3-
"version": "0.25.4",
3+
"version": "0.25.5",
44
"description": "Indexer agent",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",
@@ -30,7 +30,7 @@
3030
},
3131
"dependencies": {
3232
"@graphprotocol/common-ts": "3.0.1",
33-
"@graphprotocol/indexer-common": "0.25.4",
33+
"@graphprotocol/indexer-common": "0.25.5",
3434
"@thi.ng/heaps": "^1.3.1",
3535
"axios": "0.26.1",
3636
"bs58": "5.0.0",

packages/indexer-agent/src/__tests__/agent.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
convertSubgraphBasedRulesToDeploymentBased,
33
consolidateAllocationDecisions,
4+
resolveTargetDeployments,
45
} from '../agent'
56
import {
67
INDEXING_RULE_GLOBAL,
@@ -208,3 +209,122 @@ describe('consolidateAllocationDecisions function', () => {
208209
expect(result).not.toContain(a)
209210
})
210211
})
212+
213+
describe('resolveTargetDeployments function', () => {
214+
const alwaysDeployment = new SubgraphDeploymentID(
215+
'QmXZiV6S13ha6QXq4dmaM3TB4CHcDxBMvGexSNu9Kc28EH',
216+
)
217+
const offchainDeployment = new SubgraphDeploymentID(
218+
'QmRKs2ZfuwvmZA3QAWmCqrGUjV9pxtBUDP3wuc6iVGnjA2',
219+
)
220+
const allocationDeployment = new SubgraphDeploymentID(
221+
'QmULAfA3eS5yojxeSR2KmbyuiwCGYPjymsFcpa6uYsu6CJ',
222+
)
223+
const offchainArgDeployment = new SubgraphDeploymentID(
224+
'QmWmyoMoctfbAaiEs2G46gpeUmhqFRDW6KWo64y5r581Vz',
225+
)
226+
227+
it('includes OFFCHAIN rules when allocationDecisions is empty (manual mode)', () => {
228+
const rules = {
229+
'eip155:42161': [
230+
{
231+
identifier: offchainDeployment.ipfsHash,
232+
identifierType: SubgraphIdentifierType.DEPLOYMENT,
233+
decisionBasis: IndexingDecisionBasis.OFFCHAIN,
234+
} as IndexingRuleAttributes,
235+
],
236+
}
237+
238+
const result = resolveTargetDeployments({}, rules, [])
239+
240+
expect(result.size).toBe(1)
241+
expect([...result].map(d => d.ipfsHash)).toContain(
242+
offchainDeployment.ipfsHash,
243+
)
244+
})
245+
246+
it('includes offchainSubgraphs from startup args', () => {
247+
const result = resolveTargetDeployments({}, {}, [offchainArgDeployment])
248+
249+
expect(result.size).toBe(1)
250+
expect([...result].map(d => d.ipfsHash)).toContain(
251+
offchainArgDeployment.ipfsHash,
252+
)
253+
})
254+
255+
it('includes deployments from allocationDecisions', () => {
256+
const allocationDecisions = {
257+
'eip155:42161': [{ deployment: allocationDeployment, toAllocate: true }],
258+
}
259+
260+
const result = resolveTargetDeployments(allocationDecisions, {}, [])
261+
262+
expect(result.size).toBe(1)
263+
expect(result).toContain(allocationDeployment)
264+
})
265+
266+
/**
267+
* BUG TEST: In manual allocation mode, networkDeploymentAllocationDecisions is empty
268+
* because evaluateDeployments is skipped. This means decisionBasis: ALWAYS rules
269+
* are not included in targetDeployments, causing those subgraphs to be paused.
270+
*
271+
* This test should FAIL with the current buggy code and PASS after the fix.
272+
*/
273+
it('includes ALWAYS rules when allocationDecisions is empty (manual mode)', () => {
274+
const rules = {
275+
'eip155:42161': [
276+
{
277+
identifier: alwaysDeployment.ipfsHash,
278+
identifierType: SubgraphIdentifierType.DEPLOYMENT,
279+
decisionBasis: IndexingDecisionBasis.ALWAYS,
280+
} as IndexingRuleAttributes,
281+
],
282+
}
283+
284+
// In manual mode, allocationDecisions is empty because evaluateDeployments is skipped
285+
const result = resolveTargetDeployments({}, rules, [])
286+
287+
// ALWAYS rules should still be included in targetDeployments
288+
expect(result.size).toBe(1)
289+
expect([...result].map(d => d.ipfsHash)).toContain(
290+
alwaysDeployment.ipfsHash,
291+
)
292+
})
293+
294+
it('combines all sources correctly', () => {
295+
const allocationDecisions = {
296+
'eip155:42161': [{ deployment: allocationDeployment, toAllocate: true }],
297+
}
298+
const rules = {
299+
'eip155:42161': [
300+
{
301+
identifier: offchainDeployment.ipfsHash,
302+
identifierType: SubgraphIdentifierType.DEPLOYMENT,
303+
decisionBasis: IndexingDecisionBasis.OFFCHAIN,
304+
} as IndexingRuleAttributes,
305+
{
306+
identifier: alwaysDeployment.ipfsHash,
307+
identifierType: SubgraphIdentifierType.DEPLOYMENT,
308+
decisionBasis: IndexingDecisionBasis.ALWAYS,
309+
} as IndexingRuleAttributes,
310+
],
311+
}
312+
313+
const result = resolveTargetDeployments(allocationDecisions, rules, [
314+
offchainArgDeployment,
315+
])
316+
317+
// Should include: allocationDeployment, offchainDeployment, alwaysDeployment, offchainArgDeployment
318+
expect(result.size).toBe(4)
319+
expect(result).toContain(allocationDeployment)
320+
expect([...result].map(d => d.ipfsHash)).toContain(
321+
offchainDeployment.ipfsHash,
322+
)
323+
expect([...result].map(d => d.ipfsHash)).toContain(
324+
alwaysDeployment.ipfsHash,
325+
)
326+
expect([...result].map(d => d.ipfsHash)).toContain(
327+
offchainArgDeployment.ipfsHash,
328+
)
329+
})
330+
})

packages/indexer-agent/src/agent.ts

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -425,23 +425,13 @@ export class Agent {
425425
}).tryMap(
426426
async ({ indexingRules, networkDeploymentAllocationDecisions }) => {
427427
logger.trace('Resolving target deployments')
428-
const targetDeploymentIDs: Set<SubgraphDeploymentID> =
429-
consolidateAllocationDecisions(networkDeploymentAllocationDecisions)
430-
431-
// Add offchain subgraphs to the deployment list from rules
432-
Object.values(indexingRules)
433-
.flat()
434-
.filter(
435-
rule => rule?.decisionBasis === IndexingDecisionBasis.OFFCHAIN,
436-
)
437-
.forEach(rule => {
438-
targetDeploymentIDs.add(new SubgraphDeploymentID(rule.identifier))
439-
})
440-
// From startup args
441-
this.offchainSubgraphs.forEach(deployment => {
442-
targetDeploymentIDs.add(deployment)
443-
})
444-
return [...targetDeploymentIDs]
428+
return [
429+
...resolveTargetDeployments(
430+
networkDeploymentAllocationDecisions,
431+
indexingRules,
432+
this.offchainSubgraphs,
433+
),
434+
]
445435
},
446436
{
447437
onError: error =>
@@ -1231,3 +1221,44 @@ export function consolidateAllocationDecisions(
12311221
.map(decision => decision.deployment),
12321222
)
12331223
}
1224+
1225+
/**
1226+
* Resolves the set of target deployments that should be synced by graph-node.
1227+
* This combines:
1228+
* 1. Deployments from allocation decisions (where toAllocate=true)
1229+
* 2. Deployments with OFFCHAIN and ALWAYS decision basis from rules
1230+
* 3. Deployments from --offchain-subgraphs startup args
1231+
*/
1232+
export function resolveTargetDeployments(
1233+
networkDeploymentAllocationDecisions: Record<
1234+
string,
1235+
AllocationDecisionInterface[]
1236+
>,
1237+
indexingRules: Record<string, IndexingRuleAttributes[]>,
1238+
offchainSubgraphs: SubgraphDeploymentID[],
1239+
): Set<SubgraphDeploymentID> {
1240+
const targetDeploymentIDs: Set<SubgraphDeploymentID> =
1241+
consolidateAllocationDecisions(networkDeploymentAllocationDecisions)
1242+
1243+
// Add offchain and always subgraphs to the deployment list from rules.
1244+
// ALWAYS rules must be handled here because in manual allocation mode,
1245+
// evaluateDeployments is skipped, so ALWAYS rules would otherwise not
1246+
// be included in targetDeployments.
1247+
Object.values(indexingRules)
1248+
.flat()
1249+
.filter(
1250+
rule =>
1251+
rule?.decisionBasis === IndexingDecisionBasis.OFFCHAIN ||
1252+
rule?.decisionBasis === IndexingDecisionBasis.ALWAYS,
1253+
)
1254+
.forEach(rule => {
1255+
targetDeploymentIDs.add(new SubgraphDeploymentID(rule.identifier))
1256+
})
1257+
1258+
// From startup args
1259+
offchainSubgraphs.forEach(deployment => {
1260+
targetDeploymentIDs.add(deployment)
1261+
})
1262+
1263+
return targetDeploymentIDs
1264+
}

packages/indexer-cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@graphprotocol/indexer-cli",
3-
"version": "0.25.4",
3+
"version": "0.25.5",
44
"description": "Indexer CLI for The Graph Network",
55
"main": "./dist/cli.js",
66
"files": [
@@ -27,7 +27,7 @@
2727
},
2828
"dependencies": {
2929
"@graphprotocol/common-ts": "3.0.1",
30-
"@graphprotocol/indexer-common": "0.25.4",
30+
"@graphprotocol/indexer-common": "0.25.5",
3131
"@iarna/toml": "2.2.5",
3232
"@thi.ng/iterators": "5.1.74",
3333
"@urql/core": "3.1.0",

packages/indexer-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@graphprotocol/indexer-common",
3-
"version": "0.25.4",
3+
"version": "0.25.5",
44
"description": "Common library for Graph Protocol indexer components",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

scripts/run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ POSTGRES_TEST_DATABASE=indexer_tests \
4040
POSTGRES_TEST_USERNAME=testuser \
4141
POSTGRES_TEST_PASSWORD=testpass \
4242
NODE_OPTIONS="--dns-result-order=ipv4first" \
43-
yarn test:ci
43+
${TEST_CMD:-yarn test:ci}

0 commit comments

Comments
 (0)