2023-08-30 10:35:16 +00:00
|
|
|
# SushiSwap Subgraph
|
2023-08-14 08:47:21 +00:00
|
|
|
|
|
|
|
## Setup
|
|
|
|
|
|
|
|
Clone required repositories:
|
|
|
|
|
|
|
|
```bash
|
2023-08-30 10:35:16 +00:00
|
|
|
laconic-so --stack sushiswap-subgraph setup-repositories --pull
|
2023-08-14 08:47:21 +00:00
|
|
|
```
|
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
Checkout to a non-default branch in the cloned repos if required:
|
2023-08-14 08:47:21 +00:00
|
|
|
|
|
|
|
```bash
|
2023-08-30 10:35:16 +00:00
|
|
|
# Default repo base dir
|
|
|
|
cd ~/cerc
|
2023-08-14 08:47:21 +00:00
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
# Example
|
|
|
|
cd graph-node
|
|
|
|
git checkout <your-branch> && git pull
|
2023-08-14 08:47:21 +00:00
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
# Remove the corresponding docker image if it already exists
|
|
|
|
docker image rm cerc/graph-node:local
|
|
|
|
# Remove any dangling images
|
|
|
|
docker image prune
|
2023-08-14 08:47:21 +00:00
|
|
|
```
|
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
Build the container images:
|
2023-08-14 08:47:21 +00:00
|
|
|
|
|
|
|
```bash
|
2023-08-30 10:35:16 +00:00
|
|
|
laconic-so --stack sushiswap-subgraph build-containers
|
2023-08-14 08:47:21 +00:00
|
|
|
```
|
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
## Create a deployment
|
|
|
|
|
|
|
|
Initialize deployment and create "spec" file:
|
2023-08-14 13:58:38 +00:00
|
|
|
|
|
|
|
```bash
|
2023-08-30 10:35:16 +00:00
|
|
|
laconic-so --stack sushiswap-subgraph deploy init --output sushiswap-subgraph-spec.yml
|
2023-08-14 13:58:38 +00:00
|
|
|
```
|
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
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'
|
|
|
|
...
|
2023-08-14 13:58:38 +00:00
|
|
|
```
|
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
Create deployment:
|
2023-08-14 13:58:38 +00:00
|
|
|
|
|
|
|
```bash
|
2023-08-30 10:35:16 +00:00
|
|
|
laconic-so deploy create --spec-file sushiswap-subgraph-spec.yml --deployment-dir sushiswap-subgraph-deployment
|
2023-08-14 13:58:38 +00:00
|
|
|
```
|
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
## Start the stack
|
2023-08-14 13:58:38 +00:00
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
Deploy the stack:
|
2023-08-14 13:58:38 +00:00
|
|
|
|
|
|
|
```bash
|
2023-08-30 10:35:16 +00:00
|
|
|
laconic-so deployment --dir sushiswap-subgraph-deployment start
|
2023-08-14 13:58:38 +00:00
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
# Note: Remove any existing volumes for the cluster for a fresh start
|
2023-08-14 13:58:38 +00:00
|
|
|
```
|
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
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:
|
2023-08-14 13:58:38 +00:00
|
|
|
|
|
|
|
```bash
|
2023-08-30 10:35:16 +00:00
|
|
|
# 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
|
2023-08-14 13:58:38 +00:00
|
|
|
```
|
|
|
|
|
2023-08-14 08:47:21 +00:00
|
|
|
## Clean up
|
|
|
|
|
|
|
|
Stop all the services running in background run:
|
|
|
|
|
|
|
|
```bash
|
2023-08-30 10:35:16 +00:00
|
|
|
laconic-so deployment --dir sushiswap-subgraph-deployment stop
|
2023-08-14 08:47:21 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Clear volumes created by this stack:
|
|
|
|
|
|
|
|
```bash
|
2023-08-30 10:35:16 +00:00
|
|
|
laconic-so deployment --dir sushiswap-subgraph-deployment stop --delete-volumes
|
2023-08-14 08:47:21 +00:00
|
|
|
```
|