Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e17d999

Browse files
committedFeb 24, 2025·
fix: deployment id
1 parent 8e01f79 commit e17d999

File tree

3 files changed

+49
-57
lines changed

3 files changed

+49
-57
lines changed
 

‎packages/indexer-common/src/indexer-management/models/indexing-agreement.ts

+17-36
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,19 @@
11
import { toAddress, Address } from '@graphprotocol/common-ts'
2-
import { DataTypes, Sequelize, Model, CreationOptional } from 'sequelize'
2+
import {
3+
DataTypes,
4+
Sequelize,
5+
Model,
6+
CreationOptional,
7+
InferCreationAttributes,
8+
InferAttributes,
9+
} from 'sequelize'
310

411
// Indexing Fees AKA "DIPs"
5-
export interface IndexingAgreementAttributes {
6-
id: string
7-
signature: Buffer
8-
signed_payload: Buffer
9-
protocol_network: string
10-
chain_id: string
11-
base_price_per_epoch: string
12-
price_per_entity: string
13-
subgraph_deployment_id: string
14-
service: string
15-
payee: string
16-
payer: string
17-
deadline: Date
18-
duration_epochs: bigint
19-
max_initial_amount: string
20-
max_ongoing_amount_per_epoch: string
21-
min_epochs_per_collection: bigint
22-
max_epochs_per_collection: bigint
23-
created_at: Date
24-
updated_at: Date
25-
cancelled_at: Date | null
26-
signed_cancellation_payload: Buffer | null
27-
current_allocation_id: string | null
28-
last_allocation_id: string | null
29-
last_payment_collected_at: Date | null
30-
}
3112

32-
export class IndexingAgreement
33-
extends Model<IndexingAgreementAttributes>
34-
implements IndexingAgreementAttributes
35-
{
13+
export class IndexingAgreement extends Model<
14+
InferAttributes<IndexingAgreement>,
15+
InferCreationAttributes<IndexingAgreement>
16+
> {
3617
declare id: CreationOptional<string>
3718
declare signature: Buffer
3819
declare signed_payload: Buffer
@@ -41,9 +22,9 @@ export class IndexingAgreement
4122
declare base_price_per_epoch: string
4223
declare price_per_entity: string
4324
declare subgraph_deployment_id: string
44-
declare service: Address
45-
declare payee: Address
46-
declare payer: Address
25+
declare service: string
26+
declare payee: string
27+
declare payer: string
4728
declare deadline: Date
4829
declare duration_epochs: bigint
4930
declare max_initial_amount: string
@@ -54,8 +35,8 @@ export class IndexingAgreement
5435
declare updated_at: Date
5536
declare cancelled_at: Date | null
5637
declare signed_cancellation_payload: Buffer | null
57-
declare current_allocation_id: Address | null
58-
declare last_allocation_id: Address | null
38+
declare current_allocation_id: string | null
39+
declare last_allocation_id: string | null
5940
declare last_payment_collected_at: Date | null
6041
}
6142

‎packages/indexer-common/src/indexing-fees/__tests__/dips.test.ts

+27-20
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
createIndexerManagementClient,
1616
Operator,
1717
ActionManager,
18+
IndexerManagementClient,
1819
} from '@graphprotocol/indexer-common'
1920
import {
2021
connectDatabase,
@@ -23,6 +24,7 @@ import {
2324
Logger,
2425
Metrics,
2526
parseGRT,
27+
SubgraphDeploymentID,
2628
toAddress,
2729
} from '@graphprotocol/common-ts'
2830
import { Sequelize } from 'sequelize'
@@ -46,6 +48,8 @@ let managementModels: IndexerManagementModels
4648
let queryFeeModels: QueryFeeModels
4749
let network: Network
4850
let dipsCollector: DipsCollector
51+
let indexerManagementClient: IndexerManagementClient
52+
let operator: Operator
4953
const networkSpecWithDips = {
5054
...testNetworkSpecification,
5155
indexerOptions: {
@@ -59,13 +63,13 @@ const networkSpecWithDips = {
5963

6064
const mockSubgraphDeployment = (id: string) => {
6165
return {
62-
id: id,
66+
id: new SubgraphDeploymentID(id),
6367
ipfsHash: id,
6468
deniedAt: null,
6569
stakedTokens: BigNumber.from('1000'),
6670
signalledTokens: BigNumber.from('1000'),
6771
queryFeesAmount: BigNumber.from('0'),
68-
protocolNetwork: 'eip155:42161',
72+
protocolNetwork: 'eip155:421614',
6973
}
7074
}
7175

@@ -105,10 +109,7 @@ const setup = async () => {
105109
metrics,
106110
)
107111
dipsCollector = network.dipsCollector!
108-
}
109-
110-
const ensureGlobalIndexingRule = async () => {
111-
const indexerManagementClient = await createIndexerManagementClient({
112+
indexerManagementClient = await createIndexerManagementClient({
112113
models: managementModels,
113114
graphNode,
114115
logger,
@@ -121,7 +122,10 @@ const ensureGlobalIndexingRule = async () => {
121122
network,
122123
})
123124

124-
const operator = new Operator(logger, indexerManagementClient, networkSpecWithDips)
125+
operator = new Operator(logger, indexerManagementClient, networkSpecWithDips)
126+
}
127+
128+
const ensureGlobalIndexingRule = async () => {
125129
await operator.ensureGlobalIndexingRule()
126130
logger.debug('Ensured global indexing rule')
127131
}
@@ -225,7 +229,7 @@ describe('DipsManager', () => {
225229
payer: '123456df40c29949a75a6693c77834c00b8a5678',
226230
signature: Buffer.from('1234', 'hex'),
227231
signed_payload: Buffer.from('5678', 'hex'),
228-
protocol_network: 'arbitrum-one',
232+
protocol_network: 'arbitrum-sepolia',
229233
chain_id: 'eip155:1',
230234
base_price_per_epoch: '100',
231235
price_per_entity: '1',
@@ -333,6 +337,7 @@ describe('DipsManager', () => {
333337
protocolNetwork: 'eip155:421614',
334338
allocationAmount: '1030',
335339
})
340+
336341
// Mock fetch the subgraph deployment from the network subgraph
337342
network.networkMonitor.subgraphDeployment = jest
338343
.fn()
@@ -445,7 +450,7 @@ describe('DipsCollector', () => {
445450
payer: '123456df40c29949a75a6693c77834c00b8a5678',
446451
signature: Buffer.from('1234', 'hex'),
447452
signed_payload: Buffer.from('5678', 'hex'),
448-
protocol_network: 'arbitrum-one',
453+
protocol_network: 'arbitrum-sepolia',
449454
chain_id: 'eip155:1',
450455
base_price_per_epoch: '100',
451456
price_per_entity: '1',
@@ -476,17 +481,19 @@ describe('DipsCollector', () => {
476481
status: CollectPaymentStatus.ACCEPT,
477482
tapReceipt: Buffer.from('1234', 'hex'),
478483
})
479-
jest.spyOn(GatewayDipsServiceMessages, 'decodeTapReceipt').mockImplementation(() => {
480-
logger.info('MOCK Decoding TAP receipt')
481-
return {
482-
allocation_id: toAddress(testAllocationId),
483-
signer_address: toAddress('0xabcd56df41234949a75a6693c77834c00b8abbbb'),
484-
signature: Buffer.from('1234', 'hex'),
485-
timestamp_ns: 1234567890,
486-
nonce: 1,
487-
value: '1000',
488-
}
489-
})
484+
jest
485+
.spyOn(GatewayDipsServiceMessages, 'decodeTapReceipt')
486+
.mockImplementation(() => {
487+
logger.info('MOCK Decoding TAP receipt')
488+
return {
489+
allocation_id: toAddress(testAllocationId),
490+
signer_address: toAddress('0xabcd56df41234949a75a6693c77834c00b8abbbb'),
491+
signature: Buffer.from('1234', 'hex'),
492+
timestamp_ns: 1234567890,
493+
nonce: 1,
494+
value: '1000',
495+
}
496+
})
490497
;(getEscrowSenderForSigner as jest.Mock).mockImplementation(() => {
491498
return toAddress('0x123456df40c29949a75a6693c77834c00b8a5678')
492499
})

‎packages/indexer-common/src/indexing-fees/dips.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ export class DipsManager {
133133
}, deployment ${subgraphDeploymentID.toString()}`,
134134
)
135135
// If there is not yet an indexingRule that deems this deployment worth allocating to, make one
136-
if (!(await this.parent.matchingRuleExists(this.logger, subgraphDeploymentID))) {
136+
const ruleExists = await this.parent.matchingRuleExists(
137+
this.logger,
138+
subgraphDeploymentID,
139+
)
140+
if (!ruleExists) {
137141
this.logger.info(
138142
`Creating indexing rule for agreement ${agreement.id}, deployment ${agreement.subgraph_deployment_id}`,
139143
)

0 commit comments

Comments
 (0)
Please sign in to comment.