10.0.0-alpha.22 • Published 7 months ago

polymesh-subquery v10.0.0-alpha.22

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

semantic-release Github Actions Workflow Sonar Status Issues

Polymesh Subquery

This project has been initially created to replace the harvester meaning the output of both should match as much as possible, however since the harvester serializes chain objects in slightly different ways than polkadot-js, this project contains a list of special cases handled both at the initial deserialization level (in project.yaml.network.types) and at the serialization level in serializeLikeHarvester.ts.

Running

  1. In the docker-compose.yml file, set the appropriate environment variables for subquery-node container
  2. Install subql cli: npm i -g @subql/cli
  3. ./rerun.sh (requires docker compose). To persist data between runs, remove the -v flag, which causes the docker volume to be removed

Using event_arg_x indexes.

The event_arg_x columns are now text, in order for them to fit in BTree indexes they are truncated to 100 characters like in the harvester. This means that if you want to take advantage of the index in your query, you must use an expression like: WHERE left(event_arg_x, 100) = 'foobar'. Otherwise using WHERE event_arg_x = 'foobar' will result in a full table scan.

Debugging using the found_types table

The found_types table generated by subquery contains all types that have been serialized like the harvester, the actual type is in column ID which is the primary key and therefore unique and the raw type is in the raw_type column, if things break this is the first place to look for potential mismatches between types.

Version

This SubQuery version works with chain version 5.3.x

ENV settings

The behavior of the dev image can be controlled by setting ENV variables. The default entrypoint is docker-entrypoint.sh, which should be looked at to fully understand these settings. Notable ones include:

  • NETWORK_ENDPOINT - the wss endpoint of the blockchain to be indexed
  • NETWORK_CHAIN_ID - The genesis hash of the chain. This value can be retrieved by going to the explorer and looking for the block hash of block 0. e.g. for mainnet
  • START_BLOCK - block from which indexing should start. Generally this should be set to 1, but other values can be useful for debugging.

More advanced options are:

  • NO_NATIVE_GRAPHQL_DATA — this will set the event handler to only record what is necessary for tooling gql. This allows a stable indexer to be ran as native GraphQL handlers get developed
  • MAX_OLD_SPACE_SIZE — this will be passed onto the node process as --max-old-space-size flag. The recommendation is for this to be ~75% of available RAM. Defaults to 1536, a setting appropriate for 2GB.

License

This project uses SubQuery, which is Apache 2.0 licensed.

The project itself is also Apache 2.0 licensed.