Skip to content
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,25 @@ query {
}
```

# Local development
# Local development

# Re-indexing

When changing code we would need to re-index follow this process.

1. Stop the existing index process

2. Reset the state

```
subql-node reindex -f ./ --db-schema=turing --targetHeight=the-block-to-start-the-reindex --log-level=trace
```

After running this, the metadata and pointer will be reset to the `targetHeight`
all data higher than or equal to that block height is delete and we are ready to
resume the index process

3. Resume the index process

We write code in an idempotent way so we will be able to restart from that
height
12 changes: 7 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ services:
DB_PORT: 5432
volumes:
- ./:/app
command:
- -f=/app
- --db-schema=turing
- --log-level=${LOG_LEVEL:-info}
- -workers=4
entrypoint: [ "sleep" ]
command: ["infinity" ]
#command:
# - -f=/app
# - --db-schema=turing
# - --log-level=${LOG_LEVEL:-info}
# - -workers=4
healthcheck:
test: ["CMD", "curl", "-f", "http://subquery-node:3000/ready"]
interval: 3s
Expand Down
7 changes: 5 additions & 2 deletions mixer/src/etl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ export const populateTask = async() => {
inner join events on extrinsics.id = events.extrinsic_id
where events.data->>'taskId' is not null
and events.method = 'TaskScheduled'
and extrinsics.module = 'automationTime'
and extrinsics.method like 'schedule%'
and (
(extrinsics.module = 'automationTime' and extrinsics.method like 'schedule%')
-- this is XCM task
or (extrinsics.module = 'parachainSystem' and extrinsics.method = 'setValidationData')
)
order by events.block_height asc, idx asc
)

Expand Down
1 change: 1 addition & 0 deletions mixer/src/migrate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const migrate = async () => {
client.query('alter table turing.tasks add column if not exists scheduled_start_at timestamp'),
client.query('alter table turing.tasks add column if not exists scheduled_end_at timestamp'),
client.query('alter table turing.tasks add column if not exists executed_count integer default(0)'),
client.query('alter table turing.tasks alter column executed_count set default(0)'),
])

// column need to be create before commit
Expand Down
1 change: 1 addition & 0 deletions project-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ network:
genesisHash: '0x0f62b701fb12d02237a33b84818c11f621653d2b1614c777973babf4652b535d'
chaintypes:
file: ./dist/chaintypes.js
dictionary: "https://api.subquery.network/sq/subquery/kusama-dictionary"
dataSources:
- kind: substrate/Runtime
startBlock: 1
Expand Down
3 changes: 2 additions & 1 deletion project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ schema:
network:
endpoint: 'wss://rpc.turing-staging.oak.tech'
chainId: '0xd54f0988402deb4548538626ce37e4a318441ea0529ca369400ebec4e04dfe4b'
#dictionary: "https://api.subquery.network/sq/subquery/kusama-dictionary"

dictionary: "https://api.subquery.network/sq/subquery/kusama-dictionary"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using subql 2.0 but the project has been update and the default discover url is no longer valid subquery/templates@e28f826 so we explicitly set it here.

chaintypes:
file: ./dist/chaintypes.js

Expand Down
12 changes: 10 additions & 2 deletions src/mappings/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,23 @@ export async function findOrCreateEvent(substrateEvent: SubstrateEvent): Promise
const blockHeight = block.block.header.number;

let callId = null;

if (typeof extrinsic !== 'undefined') {
const { section: extrinsicModule, method: extrinsicMethod } = extrinsic.extrinsic.method;

// Skip indexing events for mandatory system extrinsics
if ((extrinsicModule === 'parachainSystem' && extrinsicMethod === 'setValidationData') ||
(extrinsicModule === 'timestamp' && extrinsicMethod === 'set')) {
if (extrinsicModule === 'timestamp' && extrinsicMethod === 'set') {
return;
}

if (extrinsicModule === 'parachainSystem' && extrinsicMethod === 'setValidationData') {
if ((event.section !== 'automationTime') && (event.section !== 'xcmpQueue')) {
// we want to track anything related to our time/price automation,
// adn xcmp so we can cross check the schedule from other chain
return;
}
}

callId = canonicalExtrinsicID(extrinsic);
}

Expand Down