Skip to content

Commit e4e4734

Browse files
committed
wip: more fixes
Signed-off-by: Tomás Migone <[email protected]>
1 parent 76a69a7 commit e4e4734

File tree

12 files changed

+73
-98
lines changed

12 files changed

+73
-98
lines changed

packages/indexer-agent/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
preset: 'ts-jest',
1212
testEnvironment: 'node',
1313
testPathIgnorePatterns: ['/node_modules/', '/dist/', '.yalc'],
14+
transformIgnorePatterns: ['!node_modules/'],
1415
globals: {
1516
__DATABASE__: {
1617
host:

packages/indexer-agent/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"graph-indexer-agent": "bin/graph-indexer-agent"
3030
},
3131
"dependencies": {
32-
"@graphprotocol/common-ts": "3.0.0",
32+
"@graphprotocol/common-ts": "3.0.1",
3333
"@graphprotocol/indexer-common": "^0.23.5",
3434
"@thi.ng/heaps": "^1.3.1",
3535
"axios": "0.26.1",

packages/indexer-agent/src/agent.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import mapValues from 'lodash.mapvalues'
4747
import zip from 'lodash.zip'
4848
import { AgentConfigs, NetworkAndOperator } from './types'
4949

50-
type ActionReconciliationContext = [AllocationDecision[], number, number]
50+
type ActionReconciliationContext = [AllocationDecision[], number, bigint]
5151

5252
const deploymentInList = (
5353
list: SubgraphDeploymentID[],
@@ -270,15 +270,15 @@ export class Agent {
270270
},
271271
)
272272

273-
const maxAllocationEpochs: Eventual<NetworkMapped<number>> =
273+
const maxAllocationEpochs: Eventual<NetworkMapped<bigint>> =
274274
sequentialTimerMap(
275275
{ logger, milliseconds: requestIntervalLarge },
276276
() =>
277277
this.multiNetworks.map(({ network }) => {
278278
logger.trace('Fetching max allocation epochs', {
279279
protocolNetwork: network.specification.networkIdentifier,
280280
})
281-
return network.contracts.staking.maxAllocationEpochs()
281+
return network.contracts.LegacyStaking.maxAllocationEpochs()
282282
}),
283283
{
284284
onError: error =>
@@ -304,9 +304,9 @@ export class Agent {
304304
await network.networkMonitor.subgraphs(subgraphRuleIds)
305305
if (subgraphsMatchingRules.length >= 1) {
306306
const epochLength =
307-
await network.contracts.epochManager.epochLength()
307+
await network.contracts.EpochManager.epochLength()
308308
const blockPeriod = 15
309-
const bufferPeriod = epochLength.toNumber() * blockPeriod * 100 // 100 epochs
309+
const bufferPeriod = Number(epochLength) * blockPeriod * 100 // 100 epochs
310310
rules = convertSubgraphBasedRulesToDeploymentBased(
311311
rules,
312312
subgraphsMatchingRules,
@@ -486,7 +486,7 @@ export class Agent {
486486
const matchingTransfer = eligibleTransferDeployments.find(
487487
deployment =>
488488
deployment.ipfsHash == decision.deployment.ipfsHash &&
489-
deployment.startedTransferToL2At.toNumber() > oneWeekAgo,
489+
Number(deployment.startedTransferToL2At) > oneWeekAgo,
490490
)
491491
if (matchingTransfer) {
492492
logger.debug('Found a matching subgraph transfer', {
@@ -822,22 +822,22 @@ export class Agent {
822822
await network.networkProvider.getBlock(
823823
pool.previousEpochStartBlockHash!,
824824
)
825-
pool.closedAtEpochStartBlockNumber = closedAtEpochStartBlock.number
825+
pool.closedAtEpochStartBlockNumber = closedAtEpochStartBlock!.number
826826
pool.referencePOI = await this.graphNode.proofOfIndexing(
827827
pool.subgraphDeployment,
828828
{
829-
number: closedAtEpochStartBlock.number,
830-
hash: closedAtEpochStartBlock.hash,
829+
number: closedAtEpochStartBlock!.number,
830+
hash: closedAtEpochStartBlock!.hash!,
831831
},
832832
pool.allocationIndexer,
833833
)
834-
pool.previousEpochStartBlockHash = previousEpochStartBlock.hash
835-
pool.previousEpochStartBlockNumber = previousEpochStartBlock.number
834+
pool.previousEpochStartBlockHash = previousEpochStartBlock!.hash!
835+
pool.previousEpochStartBlockNumber = previousEpochStartBlock!.number
836836
pool.referencePreviousPOI = await this.graphNode.proofOfIndexing(
837837
pool.subgraphDeployment,
838838
{
839-
number: previousEpochStartBlock.number,
840-
hash: previousEpochStartBlock.hash,
839+
number: previousEpochStartBlock!.number,
840+
hash: previousEpochStartBlock!.hash!,
841841
},
842842
pool.allocationIndexer,
843843
)
@@ -1007,13 +1007,13 @@ export class Agent {
10071007
activeAllocations: Allocation[],
10081008
deploymentAllocationDecision: AllocationDecision,
10091009
epoch: number,
1010-
maxAllocationEpochs: number,
1010+
maxAllocationEpochs: bigint,
10111011
network: Network,
10121012
): Promise<Allocation[]> {
10131013
const desiredAllocationLifetime = deploymentAllocationDecision.ruleMatch
10141014
.rule?.allocationLifetime
10151015
? deploymentAllocationDecision.ruleMatch.rule.allocationLifetime
1016-
: Math.max(1, maxAllocationEpochs - 1)
1016+
: Math.max(1, Number(maxAllocationEpochs) - 1)
10171017

10181018
// Identify expiring allocations
10191019
let expiredAllocations = activeAllocations.filter(
@@ -1029,8 +1029,8 @@ export class Agent {
10291029
async (allocation: Allocation) => {
10301030
try {
10311031
const onChainAllocation =
1032-
await network.contracts.staking.getAllocation(allocation.id)
1033-
return onChainAllocation.closedAtEpoch.eq('0')
1032+
await network.contracts.LegacyStaking.getAllocation(allocation.id)
1033+
return onChainAllocation.closedAtEpoch == 0n
10341034
} catch (err) {
10351035
this.logger.warn(
10361036
`Failed to cross-check allocation state with contracts; assuming it needs to be closed`,
@@ -1051,7 +1051,7 @@ export class Agent {
10511051
deploymentAllocationDecision: AllocationDecision,
10521052
activeAllocations: Allocation[],
10531053
epoch: number,
1054-
maxAllocationEpochs: number,
1054+
maxAllocationEpochs: bigint,
10551055
network: Network,
10561056
operator: Operator,
10571057
): Promise<void> {
@@ -1146,7 +1146,7 @@ export class Agent {
11461146
async reconcileActions(
11471147
networkDeploymentAllocationDecisions: NetworkMapped<AllocationDecision[]>,
11481148
epoch: NetworkMapped<number>,
1149-
maxAllocationEpochs: NetworkMapped<number>,
1149+
maxAllocationEpochs: NetworkMapped<bigint>,
11501150
): Promise<void> {
11511151
// --------------------------------------------------------------------------------
11521152
// Filter out networks set to `manual` allocation management mode, and ensure the

packages/indexer-agent/src/db/migrations/14-cost-models-history.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Logger } from '@graphprotocol/common-ts'
2-
import { utils } from 'ethers'
2+
import { isHexString } from 'ethers'
33
import { QueryInterface, DataTypes } from 'sequelize'
44

55
interface MigrationContext {
@@ -45,7 +45,7 @@ export async function up({ context }: Context): Promise<void> {
4545
throw new Error('Deployment ID must be a string')
4646
}
4747
// "0x..." and "global" is ok
48-
if (utils.isHexString(value, 32) || value === COST_MODEL_GLOBAL) {
48+
if (isHexString(value, 32) || value === COST_MODEL_GLOBAL) {
4949
return
5050
}
5151

packages/indexer-cli/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = {
1313
// The glob patterns Jest uses to detect test files
1414
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
1515
testPathIgnorePatterns: ['/node_modules/', '/dist/', '.yalc'],
16+
transformIgnorePatterns: ['!node_modules/'],
1617
testTimeout: 60000,
1718
globals: {
1819
__DATABASE__: {

packages/indexer-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"test:watch": "jest --watch --detectOpenHandles --verbose"
2727
},
2828
"dependencies": {
29-
"@graphprotocol/common-ts": "3.0.0",
29+
"@graphprotocol/common-ts": "3.0.1",
3030
"@graphprotocol/indexer-common": "^0.23.5",
3131
"@iarna/toml": "2.2.5",
3232
"@thi.ng/iterators": "5.1.74",

packages/indexer-cli/src/rules.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SubgraphDeploymentID, parseGRT, formatGRT } from '@graphprotocol/common-ts'
1+
import { SubgraphDeploymentID, parseGRT, formatGRT, commify } from '@graphprotocol/common-ts'
22
import {
33
nullPassThrough,
44
parseBoolean,
@@ -8,7 +8,6 @@ import {
88
IndexingDecisionBasis,
99
IndexingRuleIdentifier,
1010
resolveChainAlias,
11-
commify,
1211
} from '@graphprotocol/indexer-common'
1312
import gql from 'graphql-tag'
1413
import yaml from 'yaml'

packages/indexer-common/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const bail = (s) => {
66
process.env.NODE_NO_WARNINGS = '1'
77

88
module.exports = {
9-
collectCoverage: true,
9+
collectCoverage: false,
1010
preset: 'ts-jest',
1111
forceExit: true,
1212
testEnvironment: 'node',

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.2.3",
27+
"@graphprotocol/toolshed": "0.3.0",
2828
"@graphprotocol/tap-contracts-bindings": "2.0.0",
2929
"@thi.ng/heaps": "1.2.38",
3030
"@types/lodash.clonedeep": "^4.5.7",

packages/indexer-common/src/network.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -292,22 +292,22 @@ export class Network {
292292
// --------------------------------------------------------------------------------
293293
// * Allocation Receipt Collector
294294
// --------------------------------------------------------------------------------
295-
let scalarCollector: AllocationReceiptCollector | undefined = undefined
296-
if (!(tapContracts && tapSubgraph)) {
297-
logger.warn(
298-
"deprecated scalar voucher collector is enabled - you probably don't want this",
299-
)
300-
scalarCollector = await AllocationReceiptCollector.create({
301-
logger,
302-
metrics,
303-
transactionManager: transactionManager,
304-
models: queryFeeModels,
305-
allocationExchange: contracts.allocationExchange,
306-
allocations,
307-
networkSpecification: specification,
308-
networkSubgraph,
309-
})
310-
}
295+
const scalarCollector: AllocationReceiptCollector | undefined = undefined
296+
// if (!(tapContracts && tapSubgraph)) {
297+
// logger.warn(
298+
// "deprecated scalar voucher collector is enabled - you probably don't want this",
299+
// )
300+
// scalarCollector = await AllocationReceiptCollector.create({
301+
// logger,
302+
// metrics,
303+
// transactionManager: transactionManager,
304+
// models: queryFeeModels,
305+
// allocationExchange: contracts.allocationExchange,
306+
// allocations,
307+
// networkSpecification: specification,
308+
// networkSubgraph,
309+
// })
310+
// }
311311

312312
// --------------------------------------------------------------------------------
313313
// * TAP Collector
@@ -488,7 +488,7 @@ export class Network {
488488
}
489489
const receipt = await this.transactionManager.executeTransaction(
490490
() =>
491-
this.contracts.LegacyServiceRegistry.estimateGas.registerFor(
491+
this.contracts.LegacyServiceRegistry.registerFor.estimateGas(
492492
this.specification.indexerOptions.address,
493493
this.specification.indexerOptions.url,
494494
geoHash,
@@ -510,9 +510,9 @@ export class Network {
510510
const events = receipt.logs
511511
const event = events.find((event) =>
512512
event.topics.includes(
513-
this.contracts.LegacyServiceRegistry.interface.getEventTopic(
514-
'ServiceRegistered',
515-
),
513+
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
514+
this.contracts.LegacyServiceRegistry.interface.getEvent('ServiceRegistered')
515+
?.topicHash!,
516516
),
517517
)
518518
assert.ok(event)
@@ -563,7 +563,7 @@ async function connectToProtocolContracts(
563563
network: networkIdentifier,
564564
})
565565

566-
let contracts
566+
let contracts: GraphHorizonContracts & SubgraphServiceContracts
567567
try {
568568
const horizonContracts = connectGraphHorizon(numericNetworkId, wallet, addressBook)
569569
const subgraphServiceContracts = connectSubgraphService(
@@ -582,14 +582,14 @@ async function connectToProtocolContracts(
582582
throw new Error(`${errorMessage} Error: ${error}`)
583583
}
584584
logger.info(`Successfully connected to contracts`, {
585-
curation: contracts.curation.address,
586-
disputeManager: contracts.disputeManager.address,
587-
epochManager: contracts.epochManager.address,
588-
gns: contracts.gns.address,
589-
rewardsManager: contracts.rewardsManager.address,
590-
serviceRegistry: contracts.serviceRegistry.address,
591-
staking: contracts.staking.address,
592-
token: contracts.token.address,
585+
curation: contracts.L2Curation.target,
586+
disputeManager: contracts.DisputeManager.target,
587+
epochManager: contracts.EpochManager.target,
588+
gns: contracts.L2GNS.target,
589+
rewardsManager: contracts.RewardsManager.target,
590+
serviceRegistry: contracts.LegacyServiceRegistry.target,
591+
staking: contracts.HorizonStaking.target,
592+
token: contracts.GraphToken.target,
593593
})
594594
return contracts
595595
}

0 commit comments

Comments
 (0)