stack-orchestrator/app/data/stacks/sushiswap-subgraph/README.md

129 lines
3.3 KiB
Markdown
Raw Normal View History

# SushiSwap Subgraph
## Setup
Clone required repositories:
```bash
laconic-so --stack sushiswap-subgraph setup-repositories --pull
```
Checkout to a non-default branch in the cloned repos if required:
```bash
# Default repo base dir
cd ~/cerc
# Example
cd graph-node
git checkout <your-branch> && git pull
# Remove the corresponding docker image if it already exists
docker image rm cerc/graph-node:local
# Remove any dangling images
docker image prune
```
Build the container images:
```bash
laconic-so --stack sushiswap-subgraph build-containers
```
## Create a deployment
Initialize deployment and create "spec" file:
```bash
laconic-so --stack sushiswap-subgraph deploy init --output sushiswap-subgraph-spec.yml
```
We need to assign a fixed port `8000` for graph-node subgraph GQL endpoint. The values can be
customized by editing the "spec" file generated by `laconic-so deploy init`.
```
$ cat sushiswap-subgraph-spec.yml
stack: sushiswap-subgraph
ports:
graph-node:
- '8000:8000'
- '8001'
- '8020'
- '8030'
...
```
Create deployment:
```bash
laconic-so deploy create --spec-file sushiswap-subgraph-spec.yml --deployment-dir sushiswap-subgraph-deployment
```
## Start the stack
Deploy the stack:
```bash
laconic-so deployment --dir sushiswap-subgraph-deployment start
# Note: Remove any existing volumes for the cluster for a fresh start
```
After all services have started:
* Follow `graph-node` logs:
```bash
laconic-so deployment --dir sushiswap-subgraph-deployment logs -f graph-node
```
* Check that the subgraphs have been deployed:
```bash
laconic-so deployment --dir sushiswap-subgraph-deployment logs -f sushiswap-subgraph-v3
# Expected output:
# .
# .
# sushigraph-sushiswap-subgraph-v3-1 | - Deploying to Graph node http://graph-node:8020/
# sushigraph-sushiswap-subgraph-v3-1 | Deployed to http://graph-node:8000/subgraphs/name/sushiswap/blocks/graphql
# sushigraph-sushiswap-subgraph-v3-1 |
# sushigraph-sushiswap-subgraph-v3-1 |
# sushigraph-sushiswap-subgraph-v3-1 | Subgraph endpoints:
# sushigraph-sushiswap-subgraph-v3-1 | Queries (HTTP): http://graph-node:8000/subgraphs/name/sushiswap/blocks
# .
# .
# sushigraph-sushiswap-subgraph-v3-1 | - Deploying to Graph node http://graph-node:8020/
# sushigraph-sushiswap-subgraph-v3-1 | Deployed to http://graph-node:8000/subgraphs/name/sushiswap/v3-filecoin/graphql
# sushigraph-sushiswap-subgraph-v3-1 |
# sushigraph-sushiswap-subgraph-v3-1 |
# sushigraph-sushiswap-subgraph-v3-1 | Subgraph endpoints:
# sushigraph-sushiswap-subgraph-v3-1 | Queries (HTTP): http://graph-node:8000/subgraphs/name/sushiswap/v3-filecoin
# sushigraph-sushiswap-subgraph-v3-1 |
# sushigraph-sushiswap-subgraph-v3-1 |
# sushigraph-sushiswap-subgraph-v3-1 | Done
```
After `graph-node` has fetched the latest blocks from upstream, use the subgraph (GQL) endpoints for querying:
```bash
# Blocks subgraph endpoint:
http://127.0.0.1:8000/subgraphs/name/sushiswap/blocks/graphql
# v3 subgraph endpoint:
http://127.0.0.1:8000/subgraphs/name/sushiswap/v3-filecoin/graphql
```
## Clean up
Stop all the services running in background run:
```bash
laconic-so deployment --dir sushiswap-subgraph-deployment stop
```
Clear volumes created by this stack:
```bash
laconic-so deployment --dir sushiswap-subgraph-deployment stop --delete-volumes
```