Subgraphs are populated from the following directories and naming conventions:
./config/{subgraph}/{chain}.json
: This config directory contains all subgraph configuration for respective chains../src/{subgraph}/
:src
directory contains actual source code for subgraph indexing../abis/{subgraph}/
: This directory contains abis for each subgraph
NETWORK | BASE_URL |
---|---|
Avalanche | https://graph-avalanche.pangolin.network |
Flare | https://flare.pangolin.network |
evmos-main | https://graph-evmos-main.pangolin.network |
evmos-main2 | https://graph-evmos-main2.pangolin.network |
evmos-test | https://graph-evmos-test.pangolin.network |
evmos-test2 | https://graph-evmos-test2.pangolin.network |
skale-bellatrix | https://graph-skale-bellatrix.pangolin.network |
CHAIN | SUBGRAPH_NAME | SUBGRAPH_ID |
---|---|---|
Avalanche | avalanche/pangolin-v2 | Qmd4zwpvVwJnveCGCeryhNyHzuvZ4TdUbMgDbc8VTv8fj9 |
avalanche/pangolin-elixir | QmbhLwg2rSzS7XEmx5HDFCmesPg3p4Not1VR9biiWprBan | |
avalanche/blocks | QmbFvbSGzV2bYY2wtrRtXMebshcMfMaJM8y5outPbPdUtr | |
avalanche/governorAlpha | QmRA2kkrjWLfQco5bBaKJvNkfzkB6q1BJFDnWUaFR4bq5P | |
Fuji | fuji/pangolin-elixir | QmVqjmENnrkEYyZzLS34v1uTfEyM1Emkxvd68V7qVcgdon |
fuji/blocks | QmW3JiWbHdbguwqKqjGX48hrokWd45dihSvLwa9juo8EpX | |
fuji/pangolin-v2 | QmfYw9JcTTvD2WveK39sTR7iiocmS9cmtBPGavRcFn3oWR | |
skale-bellatrix | blocks | QmXMeK13n4gqqvKS7Mi1RiU8rm92LWjLwcFkqJMNKMifXx |
skale-bellatrix/pangolin-v2 | QmNdGgeykYgP2DHukwdC2j3Eqh5PKpZ7MTTXEVnmDiegWy | |
skale-bellatrix/pangolin-elixir | QmZCJdEcCRDgCiQVSCCCTGr8MGAnms1889Zq1Br2eEmvi5 | |
skale-bellatrix/stakingPositions | Qmc4zTsteT6pobAR6SD3qajJiPXz5SDiPm9wWRcJk2J7ua | |
coston | coston/governorPango | QmboVJtxrAbGyDaMrBQqLNxAhYrHG9Z96BV8T4arY8FTSt |
flare | flare/governorPango | QmPCZBeFQM4BFk6h3GGZ7AzQVJhm48WZDCdYFPaEd5DXke |
songbird | songbird/governorPango | QmcJgKv9P2hq7swoLtGJp3ZgNRhMdLR5ELUj7ybJkwjvE4 |
Follow the following steps to run the subgraph locally:
- Create files from templates:
yarn run template {chain}/{subgraph}
- Create entities:
yarn run codegen
- Compile subgraph:
yarn run build
- Start Docker:
docker-compose up --build
- Create subgraph:
yarn run create:local {chain}/{subgraph}
- Deploy subgraph:
yarn run deploy:local {chain}/{subgraph}
Relace {chain}/{subgraph}
with actual value. e.g. avalanche/pangolin-v2
To deploy to cloud, replace above step 5 & 6 with below commands.
- Create files from templates:
yarn run template {chain}/{subgraph}
- Create entities:
yarn run codegen
- Compile subgraph:
yarn run build
- Create subgraph:
yarn run create:avalanche {chain}/{subgraph}
- Deploy subgraph:
yarn run deploy:avalanche {chain}/{subgraph}
Relace {chain}/{subgraph}
with actual value. e.g. avalanche/pangolin-v2
Above last 2 steps are for avalanche group. You can find commands for other group in package.json.
- Add chain-wise configuration .json file for the subgraph directory
./config/{subgraph}/{chain}.json
- To get the Contract Address, we can find it from the SDK.
- To get the block number, use the respective explorer to search for the contract address.
Run <BASE_URL>/graphql
. You can find BASE_URL
from above table.
{
indexingStatuses {
subgraph
health
}
indexingStatusesForSubgraphName(
subgraphName: "SUBGRAPH_NAME"
) {
subgraph
synced
nonFatalErrors {
message
}
fatalError {
block {
number
}
message
}
chains {
latestBlock {
number
hash
}
chainHeadBlock {
number
}
}
}
}
Subgraphs are deployed into a kubernetes environment grouped by logical chain and sharing one IPFS Cluster. Each grouping contains 1 postgres database replica set and 1 graph-node. The following is an examples of one such grouping:
Avalanche Group @ https://graph-avalanche.pangolin.network
Chains:
avalanche
fuji
The kubernetes resources can be interacted with via the GKE UI
or via the command line utility kubectl. Here are some common kubectl
commands:
# Show pods
kubectl -n graph get pods
# Show Logs
kubectl -n graph logs avalanche-graph-node-0 -f
# Show stateful sets
kubectl -n graph get sts
# Restart stateful set
kubectl -n graph rollout restart sts avalanche-graph-node
Graphman is a cli included inside graph-node containers and is used for admin or advanced management of a graph node. Be careful! Here are some common commands:
# Exec into graph-node to use graphman
kubectl -n graph exec --stdin --tty avalanche-graph-node-0 -- bash
# Helpful alias
alias gm='graphman --config /config/config.toml'
# Information about a subgraph(s)
gm info avalanche --status
# Restart subgraph
gm reassign SUBGRAPH_ID -
gm reassign SUBGRAPH_ID avalanche-graph-node-0 # this is the previous node_id before it was reassigned to '-'
# Truncate cached blocks
gm chain truncate avalanche
# Re-ingest certain blocks to cache bust
gm chain check-blocks avalanche by-range --from BLOCK_NUMBER