hydra
Search…
Hydra Processor
Hydra processor is a client-side 'sink' tool used to fetch substrate events from a Hydra indexer. It sequentially applies the event handlers one by one in the order the events have been emitted.

Commands

hydra-processor help [COMMAND]

display help for hydra-processor
1
display help for <%= config.bin %>
2
3
USAGE
4
$ hydra-processor help [COMMAND]
5
6
ARGUMENTS
7
COMMAND command to show help for
8
9
OPTIONS
10
--all see all commands in CLI
Copied!
See code: @oclif/plugin-help

hydra-processor migrate

1
undefined
2
3
USAGE
4
$ hydra-processor migrate
5
6
OPTIONS
7
-e, --env=env Path to a file with environment variables
Copied!

hydra-processor run

1
undefined
2
3
USAGE
4
$ hydra-processor run
5
6
OPTIONS
7
-e, --env=env Path to a file with environment variables
8
-m, --manifest=manifest Manifest file
9
--id=id ID of the processor (useful for multi-processor setups)
10
--indexer=indexer Indexer URL to source events
Copied!

Qickstart

Before the first run, the processor should set up auxiliary database tables required for its work:
1
hydra-processor migrate
Copied!
Then hydra-processor can be run against the manifest file (by default, it looks up manifest.yml in the current folder)
1
hydra-processor run -m <path/to/manifest> -e <path to a file with env variables>
Copied!

Environment variables

Hydra processor requires a manifest file and certain environment variables to be set.
Variable
Default
Required
Description
INDEXER_ENDPOINT_URL
-
Yes
Hydra indexer endpoint to source the raw event and extrinsic data
MANIFEST_PATH
manifest.yml
No
Path to the manifest file
DB_NAME
-
Yes
Database name
DB_PORT
-
Yes
Database port
DB_HOST
-
Yes
Database host
DB_USER
-
Yes
Database user
DB_PASS
-
Yes
Database password
PROMETHEUS_PORT
3000
No
A prometheus metrics endpoint is started at this port
POLL_INTERVAL_MS
1 sec (60000 msec)
No
How often the processor polls the indexer for new blocks
The required variables can either be set externally or loaded from a file using the -e flag, e.g.:
1
hydra-processor migrate -e .env
Copied!

Manifest file

The manifest file describes which and how the events and extrinsics should be processed. Here is an example for Kusama blockchain:
1
version: '0.1'
2
description: Test manifest
3
repository: https://github.com/
4
## currently only these settings for the datasouce section are accepted
5
dataSource:
6
kind: substrate
7
chain: kusama
8
indexerVersion: '0.0.4'
9
# compiled model classes generated by hydra-cli codegen from the input schema
10
entities:
11
- mappings/lib/generated/**/*.model.js
12
mappings:
13
hydraCommonVersion: '0.0.3'
14
# process only blocks with height >= 1M
15
blockInterval: '[1000000,]'
16
# js module that exports the handler functions
17
mappingsModule: mappings/lib/mappings
18
# additinal libraries the processor loads
19
# typically it is a module with event and extrinsic types generated by hydra-typegen
20
imports:
21
- mappings/lib/mappings/generated/types
22
eventHandlers:
23
# event name
24
- event: balances.Transfer
25
# function handler name with the argument types
26
handler: balancesTransfer(DatabaseManager, Balances.TransferEvent)
27
extrinsicHandlers:
28
# infer defaults here
29
#- extrinsic: Balances.Transfer
30
#- extrinsic: Sudo.batchCall
31
# handler: handleSudoCall(DatabaseManager,SubstrateEvent)
32
preBlockHooks:
33
postBlockHooks:
Copied!
Last modified 4mo ago