Skip to content

Commit 70490e0

Browse files
authored
feat: update registration to support horizon flow, add provisioning flow at startup (#1120)
1 parent 9fbfacc commit 70490e0

File tree

11 files changed

+359
-49
lines changed

11 files changed

+359
-49
lines changed

packages/indexer-agent/src/agent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ export class Agent {
233233
try {
234234
await operator.ensureGlobalIndexingRule()
235235
await this.ensureAllSubgraphsIndexing(network)
236+
await network.provision()
236237
await network.register()
237238
} catch (err) {
238239
this.logger.critical(

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ export const start = {
111111
required: true,
112112
group: 'Ethereum',
113113
})
114+
.option('payments-destination', {
115+
description:
116+
'Address where payments are sent to. If not provided payments will be restaked.',
117+
type: 'string',
118+
group: 'Ethereum',
119+
})
114120
.option('public-indexer-url', {
115121
description: 'Indexer endpoint for receiving requests from the network',
116122
type: 'string',
@@ -272,6 +278,13 @@ export const start = {
272278
default: true,
273279
group: 'Protocol',
274280
})
281+
.option('max-provision-initial-size', {
282+
description:
283+
'The maximum number of tokens for the initial Subgraph Service provision',
284+
type: 'number',
285+
default: 0,
286+
group: 'Protocol',
287+
})
275288
.option('poi-disputable-epochs', {
276289
description:
277290
'The number of epochs in the past to look for potential POI disputes',
@@ -351,6 +364,7 @@ export async function createNetworkSpecification(
351364

352365
const indexerOptions = {
353366
address: argv.indexerAddress,
367+
paymentsDestination: argv.paymentsDestination,
354368
mnemonic: argv.mnemonic,
355369
url: argv.publicIndexerUrl,
356370
geoCoordinates: argv.indexerGeoCoordinates,
@@ -368,6 +382,7 @@ export async function createNetworkSpecification(
368382
autoAllocationMinBatchSize: argv.autoAllocationMinBatchSize,
369383
allocateOnNetworkSubgraph: argv.allocateOnNetworkSubgraph,
370384
register: argv.register,
385+
maxProvisionInitialSize: argv.maxProvisionInitialSize,
371386
finalityTime: argv.chainFinalizeTime,
372387
}
373388

packages/indexer-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"dependencies": {
2525
"@pinax/graph-networks-registry": "0.6.7",
2626
"@graphprotocol/common-ts": "3.0.1",
27-
"@graphprotocol/toolshed": "0.3.2",
27+
"@graphprotocol/toolshed": "0.4.2",
2828
"@semiotic-labs/tap-contracts-bindings": "2.0.0",
2929
"@thi.ng/heaps": "1.2.38",
3030
"@types/lodash.clonedeep": "^4.5.7",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
networkIdentifier: mainnet
2+
gateway:
3+
url: http://gateway
4+
indexerOptions:
5+
address: "0x4e8a4C63Df58bf59Fef513aB67a76319a9faf448"
6+
paymentsDestination: "0xclearlynotanaddress"
7+
mnemonic: word ivory whale diesel slab pelican voyage oxygen chat find tobacco sport
8+
url: http://indexer
9+
geoCoordinates: [25.1, -71.2]
10+
restakeRewards: true
11+
rebateClaimThreshold: 400
12+
rebateClaimBatchThreshold: 5000
13+
rebateClaimMaxBatchSize: 10
14+
poiDisputeMonitoring: false
15+
poiDisputableEpochs: 5
16+
defaultAllocationAmount: 0.05
17+
voucherRedemptionThreshold: 2
18+
voucherRedemptionBatchThreshold: 2000
19+
voucherRedemptionMaxBatchSize: 15
20+
allocationManagementMode: "auto"
21+
autoAllocationMinBatchSize: 20
22+
maxProvisionInitialSize: 100000
23+
transactionMonitoring:
24+
gasIncreaseTimeout: 10
25+
gasIncreaseFactor: 10
26+
baseFeePerGasMax: 10
27+
maxTransactionAttempts: 10
28+
subgraphs:
29+
networkSubgraph:
30+
deployment: QmPK1s3pNYLi9ERiq3BDxKa4XosgWwFRQUydHUtz4YgpqB
31+
epochSubgraph:
32+
url: http://subgraph
33+
tapSubgraph:
34+
url: http://subgraph
35+
networkProvider:
36+
url: http://provider
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
networkIdentifier: mainnet
2+
gateway:
3+
url: http://gateway
4+
indexerOptions:
5+
address: "0x4e8a4C63Df58bf59Fef513aB67a76319a9faf448"
6+
mnemonic: word ivory whale diesel slab pelican voyage oxygen chat find tobacco sport
7+
url: http://indexer
8+
geoCoordinates: [25.1, -71.2]
9+
restakeRewards: true
10+
rebateClaimThreshold: 400
11+
rebateClaimBatchThreshold: 5000
12+
rebateClaimMaxBatchSize: 10
13+
poiDisputeMonitoring: false
14+
poiDisputableEpochs: 5
15+
defaultAllocationAmount: 0.05
16+
voucherRedemptionThreshold: 2
17+
voucherRedemptionBatchThreshold: 2000
18+
voucherRedemptionMaxBatchSize: 15
19+
allocationManagementMode: "auto"
20+
autoAllocationMinBatchSize: 20
21+
maxProvisionInitialSize: 99999
22+
transactionMonitoring:
23+
gasIncreaseTimeout: 10
24+
gasIncreaseFactor: 10
25+
baseFeePerGasMax: 10
26+
maxTransactionAttempts: 10
27+
subgraphs:
28+
networkSubgraph:
29+
deployment: QmPK1s3pNYLi9ERiq3BDxKa4XosgWwFRQUydHUtz4YgpqB
30+
epochSubgraph:
31+
url: http://subgraph
32+
tapSubgraph:
33+
url: http://subgraph
34+
networkProvider:
35+
url: http://provider

packages/indexer-common/src/__tests__/network-specification-files/valid-missing.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ indexerOptions:
1919
voucherRedemptionMaxBatchSize: 15
2020
allocationManagementMode: "auto"
2121
autoAllocationMinBatchSize: 20
22+
maxProvisionInitialSize: 0
2223
subgraphs:
2324
networkSubgraph:
2425
deployment: QmPK1s3pNYLi9ERiq3BDxKa4XosgWwFRQUydHUtz4YgpqB

packages/indexer-common/src/__tests__/network-specification-files/valid.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ indexerOptions:
1818
voucherRedemptionMaxBatchSize: 15
1919
allocationManagementMode: "auto"
2020
autoAllocationMinBatchSize: 20
21+
maxProvisionInitialSize: 100000
2122
transactionMonitoring:
2223
gasIncreaseTimeout: 10
2324
gasIncreaseFactor: 10

packages/indexer-common/src/__tests__/network-specification.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ describe('Failed deserialization', () => {
7070
path: ['subgraphs', 'maxBlockDistance'],
7171
message: 'Number must be greater than or equal to 0',
7272
},
73+
{
74+
file: 'invalid-provision-size.yml',
75+
path: ['indexerOptions', 'maxProvisionInitialSize'],
76+
message: 'Must be greater or equal than 100000 GRT',
77+
},
78+
{
79+
file: 'invalid-payments-destination.yml',
80+
path: ['indexerOptions', 'paymentsDestination'],
81+
message: 'Invalid contract address',
82+
},
7383
]
7484

7585
test.each(failedTests)(

packages/indexer-common/src/network-specification.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ export const IndexerOptions = z
3939
mnemonic: z.string(),
4040
url: z.string().url(),
4141
geoCoordinates: z.number().array().length(2).default([31.780715, -41.179504]),
42+
paymentsDestination: z
43+
.string()
44+
.refine((val) => isAddress(val), {
45+
message: 'Invalid contract address',
46+
})
47+
.transform(toAddress)
48+
.optional(),
4249
restakeRewards: z.boolean().default(true),
4350
rebateClaimThreshold: GRT().default(1),
4451
rebateClaimBatchThreshold: GRT().default(5),
@@ -56,6 +63,11 @@ export const IndexerOptions = z
5663
autoAllocationMinBatchSize: positiveNumber().default(1),
5764
allocateOnNetworkSubgraph: z.boolean().default(false),
5865
register: z.boolean().default(true),
66+
maxProvisionInitialSize: GRT()
67+
.refine((x) => x >= parseGRT('100000') || x === 0n, {
68+
message: 'Must be greater or equal than 100000 GRT',
69+
})
70+
.default(0),
5971
finalityTime: positiveNumber().default(3600),
6072
})
6173
.strict()

0 commit comments

Comments
 (0)