Skip to content

Commit 94b5427

Browse files
hopeyenhopeyen
authored andcommitted
indexer-agent,-service: remove index-node configs
1 parent 4c31f45 commit 94b5427

File tree

18 files changed

+13
-269
lines changed

18 files changed

+13
-269
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,6 @@ Indexer Infrastructure
146146
--indexer-geo-coordinates Coordinates describing the Indexer's
147147
location using latitude and longitude
148148
[array] [default: ["31.780715","-41.179504"]]
149-
--index-node-ids Node IDs of Graph nodes to use for
150-
indexing (separated by commas)
151-
[array] [required]
152149
--indexer-management-port Port to serve the indexer management API
153150
at [number] [default: 8000]
154151
--metrics-port Port to serve Prometheus metrics at

packages/indexer-agent/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ Indexer Infrastructure
2929
--indexer-geo-coordinates Coordinates describing the Indexer's location
3030
using latitude and longitude
3131
[array] [default: ["31.780715","-41.179504"]]
32-
--index-node-ids Node IDs of Graph nodes to use for indexing
33-
(separated by commas) [array] [required]
3432
--indexer-management-port Port to serve the indexer management API at
3533
[number] [default: 8000]
3634
--metrics-port Port to serve Prometheus metrics at [number]

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,11 @@ const setup = async () => {
138138
deployment: undefined,
139139
})
140140

141-
const indexNodeIDs = ['node_1']
142141
indexerManagementClient = await createIndexerManagementClient({
143142
models,
144143
address: toAddress(address),
145144
contracts: contracts,
146145
indexingStatusResolver,
147-
indexNodeIDs,
148146
deploymentManagementEndpoint: statusEndpoint,
149147
networkSubgraph,
150148
logger,
@@ -164,7 +162,6 @@ const setup = async () => {
164162
'test',
165163
indexingStatusResolver,
166164
indexerManagementClient,
167-
['test'],
168165
parseGRT('1000'),
169166
address,
170167
AllocationManagementMode.AUTO,

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,6 @@ export default {
171171
required: false,
172172
group: 'Protocol',
173173
})
174-
.option('index-node-ids', {
175-
description:
176-
'Node IDs of Graph nodes to use for indexing (separated by commas)',
177-
type: 'string',
178-
array: true,
179-
required: true,
180-
coerce: arg =>
181-
arg.reduce(
182-
(acc: string[], value: string) => [...acc, ...value.split(',')],
183-
[],
184-
),
185-
group: 'Indexer Infrastructure',
186-
})
187174
.option('default-allocation-amount', {
188175
description:
189176
'Default amount of GRT to allocate to a subgraph deployment',
@@ -786,7 +773,6 @@ export default {
786773
address: indexerAddress,
787774
contracts,
788775
indexingStatusResolver,
789-
indexNodeIDs: argv.indexNodeIds,
790776
deploymentManagementEndpoint: argv.graphNodeAdminEndpoint,
791777
networkSubgraph,
792778
logger,
@@ -818,7 +804,6 @@ export default {
818804
argv.graphNodeAdminEndpoint,
819805
indexingStatusResolver,
820806
indexerManagementClient,
821-
argv.indexNodeIds,
822807
argv.defaultAllocationAmount,
823808
indexerAddress,
824809
allocationManagementMode,

packages/indexer-agent/src/indexer.ts

Lines changed: 2 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,11 @@ const disputeFromGraphQL = (
7070
return obj as POIDisputeAttributes
7171
}
7272

73-
interface indexNode {
74-
id: string
75-
deployments: string[]
76-
}
77-
7873
export class Indexer {
7974
statusResolver: IndexingStatusResolver
8075
rpc: RpcClient
8176
indexerManagement: IndexerManagementClient
8277
logger: Logger
83-
indexNodeIDs: string[]
8478
defaultAllocationAmount: BigNumber
8579
indexerAddress: string
8680
allocationManagementMode: AllocationManagementMode
@@ -90,7 +84,6 @@ export class Indexer {
9084
adminEndpoint: string,
9185
statusResolver: IndexingStatusResolver,
9286
indexerManagement: IndexerManagementClient,
93-
indexNodeIDs: string[],
9487
defaultAllocationAmount: BigNumber,
9588
indexerAddress: string,
9689
allocationManagementMode: AllocationManagementMode,
@@ -108,7 +101,6 @@ export class Indexer {
108101
// eslint-disable-next-line @typescript-eslint/no-explicit-any
109102
this.rpc = jayson.Client.http(adminEndpoint as any)
110103
}
111-
this.indexNodeIDs = indexNodeIDs
112104
this.defaultAllocationAmount = defaultAllocationAmount
113105
}
114106

@@ -163,52 +155,6 @@ export class Indexer {
163155
}
164156
}
165157

166-
async indexNodes(): Promise<indexNode[]> {
167-
try {
168-
const result = await this.statusResolver.statuses
169-
.query(
170-
gql`
171-
{
172-
indexingStatuses {
173-
subgraphDeployment: subgraph
174-
node
175-
}
176-
}
177-
`,
178-
)
179-
.toPromise()
180-
181-
if (result.error) {
182-
throw result.error
183-
}
184-
185-
const indexNodes: indexNode[] = []
186-
result.data.indexingStatuses.map(
187-
(status: { subgraphDeployment: string; node: string }) => {
188-
const node = indexNodes.find(node => node.id === status.node)
189-
node
190-
? node.deployments.push(status.subgraphDeployment)
191-
: indexNodes.push({
192-
id: status.node,
193-
deployments: [status.subgraphDeployment],
194-
})
195-
},
196-
)
197-
198-
this.logger.trace(`Queried index nodes`, {
199-
indexNodes,
200-
})
201-
return indexNodes
202-
} catch (error) {
203-
const err = indexerError(IndexerErrorCode.IE018, error)
204-
this.logger.error(
205-
`Failed to query index nodes API (Should get a different IE?)`,
206-
{ err },
207-
)
208-
throw err
209-
}
210-
}
211-
212158
async indexingRules(merged: boolean): Promise<IndexingRuleAttributes[]> {
213159
try {
214160
const result = await this.indexerManagement
@@ -760,11 +706,7 @@ export class Indexer {
760706
}
761707
}
762708

763-
async deploy(
764-
name: string,
765-
deployment: SubgraphDeploymentID,
766-
node_id: string,
767-
): Promise<void> {
709+
async deploy(name: string, deployment: SubgraphDeploymentID): Promise<void> {
768710
try {
769711
this.logger.info(`Deploy subgraph deployment`, {
770712
name,
@@ -773,7 +715,6 @@ export class Indexer {
773715
const response = await this.rpc.request('subgraph_deploy', {
774716
name,
775717
ipfs_hash: deployment.ipfsHash,
776-
node_id: node_id,
777718
})
778719
if (response.error) {
779720
throw response.error
@@ -817,61 +758,10 @@ export class Indexer {
817758
}
818759
}
819760

820-
async reassign(
821-
deployment: SubgraphDeploymentID,
822-
node: string,
823-
): Promise<void> {
824-
try {
825-
this.logger.info(`Reassign subgraph deployment`, {
826-
deployment: deployment.display,
827-
node,
828-
})
829-
const response = await this.rpc.request('subgraph_reassign', {
830-
node_id: node,
831-
ipfs_hash: deployment.ipfsHash,
832-
})
833-
if (response.error) {
834-
throw response.error
835-
}
836-
} catch (error) {
837-
if (error.message.includes('unchanged')) {
838-
this.logger.debug(`Subgraph deployment assignment unchanged`, {
839-
deployment: deployment.display,
840-
node,
841-
})
842-
return
843-
}
844-
const err = indexerError(IndexerErrorCode.IE028, error)
845-
this.logger.error(`Failed to reassign subgraph deployment`, {
846-
deployment: deployment.display,
847-
err,
848-
})
849-
throw err
850-
}
851-
}
852-
853761
async ensure(name: string, deployment: SubgraphDeploymentID): Promise<void> {
854762
try {
855-
// Randomly assign to unused nodes if they exist,
856-
// otherwise use the node with lowest deployments assigned
857-
const indexNodes = (await this.indexNodes()).filter(
858-
(node: { id: string; deployments: Array<string> }) => {
859-
return node.id && node.id !== 'removed'
860-
},
861-
)
862-
const usedIndexNodeIDs = indexNodes.map(node => node.id)
863-
const unusedNodes = this.indexNodeIDs.filter(
864-
nodeID => !(nodeID in usedIndexNodeIDs),
865-
)
866-
867-
const targetNode = unusedNodes
868-
? unusedNodes[Math.floor(Math.random() * unusedNodes.length)]
869-
: indexNodes.sort((nodeA, nodeB) => {
870-
return nodeA.deployments.length - nodeB.deployments.length
871-
})[0].id
872763
await this.create(name)
873-
await this.deploy(name, deployment, targetNode)
874-
await this.reassign(deployment, targetNode)
764+
await this.deploy(name, deployment)
875765
} catch (error) {
876766
const err = indexerError(IndexerErrorCode.IE020, error)
877767
this.logger.error(`Failed to ensure subgraph deployment is indexing`, {

packages/indexer-cli/src/__tests__/util.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ export const setup = async () => {
6767
'https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-testnet',
6868
deployment: undefined,
6969
})
70-
const indexNodeIDs = ['node_1']
7170
indexerManagementClient = await createIndexerManagementClient({
7271
models,
7372
address: toAddress(address),
7473
contracts: contracts,
7574
indexingStatusResolver,
76-
indexNodeIDs,
7775
deploymentManagementEndpoint: statusEndpoint,
7876
networkSubgraph,
7977
logger,

packages/indexer-cli/src/allocations.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,21 +170,12 @@ export const createAllocation = async (
170170
client: IndexerManagementClient,
171171
deployment: string,
172172
amount: BigNumber,
173-
indexNode: string | undefined,
174173
): Promise<CreateAllocationResult> => {
175174
const result = await client
176175
.mutation(
177176
gql`
178-
mutation createAllocation(
179-
$deployment: String!
180-
$amount: String!
181-
$indexNode: String
182-
) {
183-
createAllocation(
184-
deployment: $deployment
185-
amount: $amount
186-
indexNode: $indexNode
187-
) {
177+
mutation createAllocation($deployment: String!, $amount: String!) {
178+
createAllocation(deployment: $deployment, amount: $amount) {
188179
allocation
189180
deployment
190181
allocatedTokens
@@ -194,7 +185,6 @@ export const createAllocation = async (
194185
{
195186
deployment,
196187
amount: amount.toString(),
197-
indexNode,
198188
},
199189
)
200190
.toPromise()

packages/indexer-cli/src/commands/indexer/allocations/create.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import { processIdentifier, SubgraphIdentifierType } from '@graphprotocol/indexe
99
import { printObjectOrArray } from '../../../command-helpers'
1010

1111
const HELP = `
12-
${chalk.bold(
13-
'graph indexer allocations create',
14-
)} [options] <deployment-id> <amount> <index-node>
12+
${chalk.bold('graph indexer allocations create')} [options] <deployment-id> <amount>
1513
1614
${chalk.dim('Options:')}
1715
@@ -45,7 +43,7 @@ module.exports = {
4543
return
4644
}
4745

48-
const [deploymentID, amount, indexNode] = parameters.array || []
46+
const [deploymentID, amount] = parameters.array || []
4947

5048
try {
5149
if (!deploymentID || !amount) {
@@ -72,7 +70,6 @@ module.exports = {
7270
client,
7371
deploymentString,
7472
allocationAmount,
75-
indexNode,
7673
)
7774

7875
spinner.succeed('Allocation created')

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ const invalidReallocateAction = {
223223
priority: 0,
224224
} as ActionInput
225225

226-
const indexNodeIDs = ['node_1']
227-
228226
let ethereum: ethers.providers.BaseProvider
229227
let sequelize: Sequelize
230228
let managementModels: IndexerManagementModels
@@ -313,7 +311,6 @@ const setup = async () => {
313311
address,
314312
contracts,
315313
indexingStatusResolver,
316-
indexNodeIDs,
317314
deploymentManagementEndpoint,
318315
networkSubgraph,
319316
receiptCollector,

packages/indexer-common/src/indexer-management/__tests__/resolvers/cost-models.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ let models: IndexerManagementModels
7070
let address: string
7171
let contracts: NetworkContracts
7272
let logger: Logger
73-
let indexNodeIDs: string[]
7473
let statusEndpoint: string
7574
let indexingStatusResolver: IndexingStatusResolver
7675
let networkSubgraph: NetworkSubgraph
@@ -95,7 +94,6 @@ const setupAll = async () => {
9594
async: false,
9695
level: __LOG_LEVEL__ ?? 'error',
9796
})
98-
indexNodeIDs = ['node_1']
9997
statusEndpoint = 'http://localhost:8030/graphql'
10098
indexingStatusResolver = new IndexingStatusResolver({
10199
logger: logger,
@@ -113,7 +111,6 @@ const setupAll = async () => {
113111
address,
114112
contracts,
115113
indexingStatusResolver,
116-
indexNodeIDs,
117114
deploymentManagementEndpoint: statusEndpoint,
118115
networkSubgraph,
119116
logger,
@@ -636,7 +633,6 @@ describe('Feature: Inject $DAI variable', () => {
636633
address,
637634
contracts,
638635
indexingStatusResolver,
639-
indexNodeIDs,
640636
deploymentManagementEndpoint: statusEndpoint,
641637
networkSubgraph,
642638
logger,

0 commit comments

Comments
 (0)