Skip to content

Commit 76a69a7

Browse files
committed
Merge branch 'horizon' of github.com:graphprotocol/indexer into horizon
2 parents db262bc + cc6bf44 commit 76a69a7

File tree

10 files changed

+50
-53
lines changed

10 files changed

+50
-53
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
MultiNetworks,
2222
loadTestYamlConfig,
2323
} from '@graphprotocol/indexer-common'
24-
import { BigNumber } from 'ethers'
2524
import { Sequelize } from 'sequelize'
2625

2726
const TEST_DISPUTE_1: POIDisputeAttributes = {
@@ -69,7 +68,7 @@ const TEST_DISPUTE_2: POIDisputeAttributes = {
6968

7069
const POI_DISPUTES_CONVERTERS_FROM_GRAPHQL: Record<
7170
keyof POIDisputeAttributes,
72-
(x: never) => string | BigNumber | number | undefined
71+
(x: never) => string | bigint | number | undefined
7372
> = {
7473
allocationID: x => x,
7574
subgraphDeploymentID: x => x,

packages/indexer-agent/src/agent.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,8 @@ export class Agent {
682682
currentEpochNumber: number,
683683
) =>
684684
currentEpochNumber -
685-
network.specification.indexerOptions.poiDisputableEpochs,
685+
(network.specification.indexerOptions
686+
.poiDisputableEpochs as number),
686687
)
687688

688689
// Find disputable allocations

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import { createSyncingServer } from '../syncing-server'
3131
import { injectCommonStartupOptions } from './common-options'
3232
import pMap from 'p-map'
3333
import { NetworkSpecification } from '@graphprotocol/indexer-common/dist/network-specification'
34-
import { BigNumber } from 'ethers'
3534
import { displayZodParsingError } from '@graphprotocol/indexer-common'
3635
import { readFileSync } from 'fs'
3736
import { AgentConfigs } from '../types'
@@ -601,7 +600,7 @@ export async function run(
601600
defaults: {
602601
globalIndexingRule: {
603602
// TODO: Update this, there will be defaults per network
604-
allocationAmount: BigNumber.from(100),
603+
allocationAmount: BigInt(100),
605604
parallelAllocations: 1,
606605
},
607606
},

packages/indexer-cli/src/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from '@graphprotocol/indexer-common'
1515
import { validatePOI, validateRequiredParams } from './command-helpers'
1616
import gql from 'graphql-tag'
17-
import { utils } from 'ethers'
17+
import { hexlify } from 'ethers'
1818
import { parseGRT } from '@graphprotocol/common-ts'
1919

2020
export interface GenericActionInputParams {
@@ -51,7 +51,7 @@ export async function buildActionInput(
5151
case ActionType.UNALLOCATE: {
5252
let poi = actionParams.param2
5353
if (poi == '0' || poi == '0x0') {
54-
poi = utils.hexlify(Array(32).fill(0))
54+
poi = hexlify(new Uint8Array(32).fill(0))
5555
}
5656
return {
5757
deploymentID: actionParams.targetDeployment,
@@ -69,7 +69,7 @@ export async function buildActionInput(
6969
case ActionType.REALLOCATE: {
7070
let poi = actionParams.param3
7171
if (poi == '0' || poi == '0x0') {
72-
poi = utils.hexlify(Array(32).fill(0))
72+
poi = hexlify(new Uint8Array(32).fill(0))
7373
}
7474
return {
7575
deploymentID: actionParams.targetDeployment,

packages/indexer-cli/src/allocations.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { SubgraphDeploymentID, formatGRT } from '@graphprotocol/common-ts'
1+
import { SubgraphDeploymentID, formatGRT, commify } from '@graphprotocol/common-ts'
22
import yaml from 'yaml'
33
import { GluegunPrint } from 'gluegun'
44
import { table, getBorderCharacters } from 'table'
5-
import { BigNumber, utils } from 'ethers'
65
import { OutputFormat, parseOutputFormat, pickFields } from './command-helpers'
76
import { IndexerManagementClient } from '@graphprotocol/indexer-common'
87
import gql from 'graphql-tag'
@@ -17,17 +16,17 @@ export interface IndexerAllocation {
1716
id: number
1817
indexer: string
1918
subgraphDeployment: string
20-
allocatedTokens: BigNumber
21-
signalledTokens: BigNumber
22-
stakedTokens: BigNumber
19+
allocatedTokens: bigint
20+
signalledTokens: bigint
21+
stakedTokens: bigint
2322
createdAtEpoch: number
2423
closedAtEpoch: number | null
2524
ageInEpochs: number
2625
closeDeadlineEpoch: number
2726
closeDeadlineBlocksRemaining: number
2827
closeDeadlineTimeRemaining: number
29-
indexingRewards: BigNumber
30-
queryFeesCollected: BigNumber
28+
indexingRewards: bigint
29+
queryFeesCollected: bigint
3130
status: string
3231
protocolNetwork: string
3332
}
@@ -41,17 +40,17 @@ const ALLOCATION_CONVERTERS_FROM_GRAPHQL: Record<
4140
indexer: x => x,
4241
subgraphDeployment: (d: SubgraphDeploymentID) =>
4342
typeof d === 'string' ? d : d.ipfsHash,
44-
allocatedTokens: nullPassThrough((x: string) => BigNumber.from(x)),
45-
signalledTokens: nullPassThrough((x: string) => BigNumber.from(x)),
46-
stakedTokens: nullPassThrough((x: string) => BigNumber.from(x)),
43+
allocatedTokens: nullPassThrough((x: string) => BigInt(x)),
44+
signalledTokens: nullPassThrough((x: string) => BigInt(x)),
45+
stakedTokens: nullPassThrough((x: string) => BigInt(x)),
4746
createdAtEpoch: nullPassThrough((x: string) => parseInt(x)),
4847
closedAtEpoch: nullPassThrough((x: string) => parseInt(x)),
4948
ageInEpochs: nullPassThrough((x: string) => parseInt(x)),
5049
closeDeadlineEpoch: nullPassThrough((x: string) => parseInt(x)),
5150
closeDeadlineBlocksRemaining: nullPassThrough((x: string) => parseInt(x)),
5251
closeDeadlineTimeRemaining: nullPassThrough((x: string) => parseInt(x)),
53-
indexingRewards: nullPassThrough((x: string) => BigNumber.from(x)),
54-
queryFeesCollected: nullPassThrough((x: string) => BigNumber.from(x)),
52+
indexingRewards: nullPassThrough((x: string) => BigInt(x)),
53+
queryFeesCollected: nullPassThrough((x: string) => BigInt(x)),
5554
status: x => x,
5655
protocolNetwork: x => x,
5756
}
@@ -64,17 +63,17 @@ const ALLOCATION_FORMATTERS: Record<
6463
indexer: nullPassThrough(x => x),
6564
subgraphDeployment: (d: SubgraphDeploymentID) =>
6665
typeof d === 'string' ? d : d.ipfsHash,
67-
allocatedTokens: x => utils.commify(formatGRT(x)),
68-
signalledTokens: x => utils.commify(formatGRT(x)),
69-
stakedTokens: x => utils.commify(formatGRT(x)),
66+
allocatedTokens: x => commify(formatGRT(x)),
67+
signalledTokens: x => commify(formatGRT(x)),
68+
stakedTokens: x => commify(formatGRT(x)),
7069
createdAtEpoch: x => x,
7170
closedAtEpoch: x => x,
7271
ageInEpochs: x => x,
7372
closeDeadlineEpoch: x => x,
7473
closeDeadlineBlocksRemaining: x => x,
7574
closeDeadlineTimeRemaining: x => x,
76-
indexingRewards: x => utils.commify(formatGRT(x)),
77-
queryFeesCollected: x => utils.commify(formatGRT(x)),
75+
indexingRewards: x => commify(formatGRT(x)),
76+
queryFeesCollected: x => commify(formatGRT(x)),
7877
status: x => x,
7978
protocolNetwork: resolveChainAlias,
8079
}
@@ -173,7 +172,7 @@ function nullPassThrough<T, U>(fn: (x: T) => U): (x: T | null) => U | null {
173172
export const createAllocation = async (
174173
client: IndexerManagementClient,
175174
deployment: string,
176-
amount: BigNumber,
175+
amount: bigint,
177176
indexNode: string | undefined,
178177
protocolNetwork: string,
179178
): Promise<CreateAllocationResult> => {
@@ -265,7 +264,7 @@ export const reallocateAllocation = async (
265264
client: IndexerManagementClient,
266265
allocationID: string,
267266
poi: string | undefined,
268-
amount: BigNumber,
267+
amount: bigint,
269268
force: boolean,
270269
protocolNetwork: string,
271270
): Promise<ReallocateAllocationResult> => {

packages/indexer-cli/src/command-helpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export enum OutputFormat {
3535
}
3636
import yaml from 'yaml'
3737
import { GluegunParameters, GluegunPrint } from 'gluegun'
38-
import { utils } from 'ethers'
3938
import { validateNetworkIdentifier } from '@graphprotocol/indexer-common'
39+
import { hexlify, isHexString } from 'ethers'
4040

4141
export const fixParameters = (
4242
parameters: GluegunParameters,
@@ -159,13 +159,13 @@ export async function validateRequiredParams(
159159
export function validatePOI(poi: string | undefined): string | undefined {
160160
if (poi !== undefined) {
161161
if (typeof poi == 'number' && poi == 0) {
162-
poi = utils.hexlify(Array(32).fill(0))
162+
poi = hexlify(new Uint8Array(32).fill(0))
163163
}
164164
if (typeof poi == 'string' && poi == '0') {
165-
poi = utils.hexlify(Array(32).fill(0))
165+
poi = hexlify(new Uint8Array(32).fill(0))
166166
}
167167
// Ensure user provided POI is formatted properly - '0x...' (32 bytes)
168-
const isHex = utils.isHexString(poi, 32)
168+
const isHex = isHexString(poi, 32)
169169
if (!isHex) {
170170
throw new Error(
171171
`Invalid POI provided ('${poi}'): Must be a 32 byte length hex string`,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import chalk from 'chalk'
33

44
import { loadValidatedConfig } from '../../../config'
55
import { createIndexerManagementClient } from '../../../client'
6-
import { BigNumber } from 'ethers'
76
import { createAllocation } from '../../../allocations'
87
import {
98
processIdentifier,
@@ -78,7 +77,7 @@ module.exports = {
7877
`Invalid 'deploymentID' provided (${deploymentID}), must be bytes32 or base58 formatted)`,
7978
)
8079
}
81-
const allocationAmount = BigNumber.from(amount)
80+
const allocationAmount = BigInt(amount)
8281

8382
const config = loadValidatedConfig()
8483
const client = await createIndexerManagementClient({ url: config.api })

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import gql from 'graphql-tag'
88
import { SubgraphDeploymentID } from '@graphprotocol/common-ts'
99
import { processIdentifier, SubgraphIdentifierType } from '@graphprotocol/indexer-common'
1010
import { IndexerAllocation, printIndexerAllocations } from '../../../allocations'
11-
import { utils } from 'ethers'
11+
import { isHexString } from 'ethers'
1212

1313
const HELP = `
1414
${chalk.bold('graph indexer allocations get')} [options]
@@ -59,7 +59,7 @@ module.exports = {
5959
}
6060

6161
if (allocation) {
62-
if (allocation !== 'all' && !utils.isHexString(allocation, 20)) {
62+
if (allocation !== 'all' && !isHexString(allocation, 20)) {
6363
throw Error(
6464
`Invalid 'allocation-id' provided ('${allocation}'), must be a bytes20 string or 'all'`,
6565
)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import chalk from 'chalk'
33

44
import { loadValidatedConfig } from '../../../config'
55
import { createIndexerManagementClient } from '../../../client'
6-
import { BigNumber } from 'ethers'
76
import { reallocateAllocation } from '../../../allocations'
87
import { printObjectOrArray, validatePOI } from '../../../command-helpers'
98

@@ -73,7 +72,7 @@ module.exports = {
7372

7473
try {
7574
validatePOI(poi)
76-
const allocationAmount = BigNumber.from(amount)
75+
const allocationAmount = BigInt(amount)
7776
const config = loadValidatedConfig()
7877
const client = await createIndexerManagementClient({ url: config.api })
7978

packages/indexer-cli/src/rules.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import {
88
IndexingDecisionBasis,
99
IndexingRuleIdentifier,
1010
resolveChainAlias,
11+
commify,
1112
} from '@graphprotocol/indexer-common'
1213
import gql from 'graphql-tag'
1314
import yaml from 'yaml'
1415
import { table, getBorderCharacters } from 'table'
15-
import { BigNumber, utils } from 'ethers'
16+
1617
import { OutputFormat, pickFields } from './command-helpers'
1718
import chalk from 'chalk'
1819

@@ -47,15 +48,15 @@ const INDEXING_RULE_FORMATTERS: Record<
4748
//deployment: (d: SubgraphDeploymentIDIsh) => (typeof d === 'string' ? d : d.ipfsHash),
4849
identifier: x => x,
4950
identifierType: x => x,
50-
allocationAmount: nullPassThrough(x => utils.commify(formatGRT(x))),
51+
allocationAmount: nullPassThrough(x => commify(formatGRT(x))),
5152
allocationLifetime: nullPassThrough((x: number) => x.toString()),
5253
autoRenewal: x => x,
5354
parallelAllocations: nullPassThrough((x: number) => x.toString()),
54-
maxSignal: nullPassThrough(x => utils.commify(formatGRT(x))),
55-
minSignal: nullPassThrough(x => utils.commify(formatGRT(x))),
56-
minStake: nullPassThrough(x => utils.commify(formatGRT(x))),
55+
maxSignal: nullPassThrough(x => commify(formatGRT(x))),
56+
minSignal: nullPassThrough(x => commify(formatGRT(x))),
57+
minStake: nullPassThrough(x => commify(formatGRT(x))),
5758
maxAllocationPercentage: nullPassThrough((x: number) => x.toPrecision(2)),
58-
minAverageQueryFees: nullPassThrough(x => utils.commify(formatGRT(x))),
59+
minAverageQueryFees: nullPassThrough(x => commify(formatGRT(x))),
5960
decisionBasis: x => x,
6061
custom: nullPassThrough(JSON.stringify),
6162
requireSupported: x => x,
@@ -71,15 +72,15 @@ const INDEXING_RULE_CONVERTERS_FROM_GRAPHQL: Record<
7172
id: x => x,
7273
identifier: x => x,
7374
identifierType: x => x,
74-
allocationAmount: nullPassThrough((x: string) => BigNumber.from(x)),
75+
allocationAmount: nullPassThrough((x: string) => BigInt(x)),
7576
allocationLifetime: nullPassThrough((x: string) => parseInt(x)),
7677
autoRenewal: x => x,
7778
parallelAllocations: nullPassThrough((x: string) => parseInt(x)),
78-
minSignal: nullPassThrough((x: string) => BigNumber.from(x)),
79-
maxSignal: nullPassThrough((x: string) => BigNumber.from(x)),
80-
minStake: nullPassThrough((x: string) => BigNumber.from(x)),
79+
minSignal: nullPassThrough((x: string) => BigInt(x)),
80+
maxSignal: nullPassThrough((x: string) => BigInt(x)),
81+
minStake: nullPassThrough((x: string) => BigInt(x)),
8182
maxAllocationPercentage: nullPassThrough((x: string) => parseFloat(x)),
82-
minAverageQueryFees: nullPassThrough((x: string) => BigNumber.from(x)),
83+
minAverageQueryFees: nullPassThrough((x: string) => BigInt(x)),
8384
decisionBasis: x => x,
8485
custom: nullPassThrough(JSON.stringify),
8586
requireSupported: x => x,
@@ -95,15 +96,15 @@ const INDEXING_RULE_CONVERTERS_TO_GRAPHQL: Record<
9596
id: x => x,
9697
identifier: x => x,
9798
identifierType: x => x,
98-
allocationAmount: nullPassThrough((x: BigNumber) => x.toString()),
99+
allocationAmount: nullPassThrough((x: bigint) => x.toString()),
99100
allocationLifetime: nullPassThrough((x: number) => x),
100101
autoRenewal: x => x,
101102
parallelAllocations: nullPassThrough((x: number) => x),
102-
minSignal: nullPassThrough((x: BigNumber) => x.toString()),
103-
maxSignal: nullPassThrough((x: BigNumber) => x.toString()),
104-
minStake: nullPassThrough((x: BigNumber) => x.toString()),
103+
minSignal: nullPassThrough((x: bigint) => x.toString()),
104+
maxSignal: nullPassThrough((x: bigint) => x.toString()),
105+
minStake: nullPassThrough((x: bigint) => x.toString()),
105106
maxAllocationPercentage: nullPassThrough((x: number) => x),
106-
minAverageQueryFees: nullPassThrough((x: BigNumber) => x.toString()),
107+
minAverageQueryFees: nullPassThrough((x: bigint) => x.toString()),
107108
decisionBasis: x => x,
108109
custom: nullPassThrough(JSON.stringify),
109110
requireSupported: x => x,

0 commit comments

Comments
 (0)