Skip to content

Commit 32d8f17

Browse files
authored
agent,cli,common: feature - auto graft sync (#1087)
1 parent cd3c31e commit 32d8f17

File tree

25 files changed

+644
-61
lines changed

25 files changed

+644
-61
lines changed

docs/action-queue.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ enum ActionStatus {
191191
queued
192192
approved
193193
pending
194+
deploying
194195
success
195196
failed
196197
canceled

docs/networks/arbitrum-sepolia.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ testnet (for now) are Mainnet subgraphs. This means:
5656
| `INDEXER_AGENT_EPOCH_SUBGRAPH_ENDPOINT` | `--epoch-subgraph-endpoint` | `https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/BhnsdeZihU4SuokxZMLF4FQBVJ3jgtZf6v51gHvz3bSS` |
5757
| `INDEXER_AGENT_TAP_SUBGRAPH_DEPLOYMENT` | `--tap-subgraph-deployment` | `QmUiLdbsk6c51UMdcNBxsP3KadJpkmp6a3k2NCprR4ZFeM` |
5858
| `INDEXER_AGENT_TAP_SUBGRAPH_ENDPOINT` | `--tap-subgraph-endpoint` | `https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/7ubx365MiqBH5iUz6XWXWT8PTof5BVAyEzdb8m17RvbD` |
59+
| `INDEXER_AGENT_IPFS_ENDPOINT` | `--ipfs-endpoint` | `https://ipfs.network.thegraph.com` |
5960

6061
In order to avoid collecting or claiming query fees below a certain threshold
6162
(e.g. below the cost of the two transactions), the following configuration

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const setup = async () => {
139139
'http://test-admin-endpoint.xyz',
140140
'https://test-query-endpoint.xyz',
141141
'https://test-status-endpoint.xyz',
142+
'https://test-ipfs-endpoint.xyz',
142143
)
143144

144145
const yamlObj = loadTestYamlConfig()

packages/indexer-agent/src/commands/common-options.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ export function injectCommonStartupOptions(argv: Argv): Argv {
101101
default: 50,
102102
group: 'Postgres',
103103
})
104+
.option('ipfs-endpoint', {
105+
description: 'IPFS endpoint for querying manifests.',
106+
type: 'string',
107+
required: true,
108+
group: 'Indexer Infrastructure',
109+
default: 'https://ipfs.network.thegraph.com',
110+
})
104111
.option('graph-node-query-endpoint', {
105112
description: 'Graph Node endpoint for querying subgraphs',
106113
type: 'string',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ export async function run(
502502
argv.graphNodeAdminEndpoint,
503503
argv.graphNodeQueryEndpoint,
504504
argv.graphNodeStatusEndpoint,
505+
argv.ipfsEndpoint,
505506
)
506507

507508
// --------------------------------------------------------------------------------
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Logger } from '@graphprotocol/common-ts'
2+
import { DataTypes, QueryInterface } from 'sequelize'
3+
4+
interface MigrationContext {
5+
queryInterface: QueryInterface
6+
logger: Logger
7+
}
8+
9+
interface Context {
10+
context: MigrationContext
11+
}
12+
13+
export async function up({ context }: Context): Promise<void> {
14+
const { queryInterface, logger } = context
15+
16+
logger.debug(`Checking if 'Actions' table exists`)
17+
const tables = await queryInterface.showAllTables()
18+
if (!tables.includes('Actions')) {
19+
logger.info(`Actions table does not exist, migration not necessary`)
20+
return
21+
}
22+
23+
logger.debug(`Checking if 'Actions' table needs to be migrated`)
24+
const table = await queryInterface.describeTable('Actions')
25+
const statusColumn = table.status
26+
if (statusColumn) {
27+
logger.debug(`'status' column exists with type = ${statusColumn.type}`)
28+
logger.info(`Update 'status' column to support variant 'deploying' status`)
29+
await queryInterface.changeColumn('Actions', 'status', {
30+
type: DataTypes.ENUM(
31+
'queued',
32+
'approved',
33+
'deploying',
34+
'pending',
35+
'success',
36+
'failed',
37+
'canceled',
38+
),
39+
allowNull: false,
40+
})
41+
return
42+
}
43+
}
44+
45+
export async function down({ context }: Context): Promise<void> {
46+
const { logger } = context
47+
logger.info(
48+
`No 'down' migration needed since the 'up' migration simply added a new status 'deploying'`,
49+
)
50+
return
51+
}

packages/indexer-cli/src/__tests__/indexer/cost.test.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
deleteFromAllTables,
66
seedCostModels,
77
setupSingleNetwork,
8-
setupMultiNetworks,
98
} from '../util'
109
import path from 'path'
1110

@@ -199,30 +198,3 @@ describe('Indexer cost tests', () => {
199198
)
200199
})
201200
})
202-
203-
describe('Indexer cost tests multiNetworks', () => {
204-
beforeAll(setupMultiNetworks)
205-
afterAll(teardown)
206-
beforeEach(seedCostModels)
207-
afterEach(deleteFromAllTables)
208-
209-
describe('Cost set...', () => {
210-
cliTest(
211-
'Indexer cost set model deployment id - reject multinetwork mode',
212-
[
213-
'indexer',
214-
'cost',
215-
'set',
216-
'model',
217-
'QmXRpJW3qBuYaiBYHdhv8DF4bHDZhXBmh91MtrnhJfQ5Lk',
218-
'references/basic.agora',
219-
],
220-
'references/indexer-cost-model-deployment-multinetworks',
221-
{
222-
expectedExitCode: 1,
223-
cwd: baseDir,
224-
timeout: 10000,
225-
},
226-
)
227-
})
228-
})

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export const setup = async (multiNetworksEnabled: boolean) => {
8787
'http://test-admin-endpoint.xyz',
8888
'https://test-query-endpoint.xyz',
8989
statusEndpoint,
90+
'https://test-ipfs-endpoint.xyz',
9091
)
9192

9293
const network = await Network.create(

packages/indexer-cli/src/commands/indexer/actions/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ${chalk.bold('graph indexer actions delete')} [options] [<actionID1> ...]
1313
${chalk.dim('Options:')}
1414
1515
-h, --help Show usage information
16-
--status queued|approved|pending|success|failed|canceled Filter by status
16+
--status queued|approved|deploying|pending|success|failed|canceled Filter by status
1717
-o, --output table|json|yaml Choose the output format: table (default), JSON, or YAML
1818
`
1919

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,18 @@ module.exports = {
114114

115115
if (
116116
status &&
117-
!['queued', 'approved', 'pending', 'success', 'failed', 'canceled'].includes(
118-
status,
119-
)
117+
![
118+
'queued',
119+
'approved',
120+
'deploying',
121+
'pending',
122+
'success',
123+
'failed',
124+
'canceled',
125+
].includes(status)
120126
) {
121127
throw Error(
122-
`Invalid '--status' provided, must be one of ['queued', 'approved', 'pending', 'success', 'failed', 'canceled]`,
128+
`Invalid '--status' provided, must be one of ['queued', 'approved', 'deploying', 'pending', 'success', 'failed', 'canceled]`,
123129
)
124130
}
125131

0 commit comments

Comments
 (0)