stack-orchestrator/stack_orchestrator/data/stacks/sushiswap-subgraph
Prathamesh Musale 17e860d6e4
All checks were successful
Fixturenet-Laconicd-Test / Run an Laconicd fixturenet test (push) Successful in 9m39s
Fixturenet-Eth-Plugeth-Arm-Test / Run an Ethereum plugeth fixturenet test (push) Successful in 53m46s
Fixturenet-Eth-Plugeth-Test / Run an Ethereum plugeth fixturenet test (push) Successful in 55m59s
K8s Deploy Test / Run deploy test suite on kind/k8s (push) Successful in 8m44s
Database Test / Run database hosting test on kind/k8s (push) Successful in 10m32s
Container Registry Test / Run contaier registry hosting test on kind/k8s (push) Successful in 4m19s
Lint Checks / Run linter (push) Successful in 38s
Publish / Build and publish (push) Successful in 1m16s
Webapp Test / Run webapp test suite (push) Successful in 4m10s
Deploy Test / Run deploy test suite (push) Successful in 5m30s
Smoke Test / Run basic test suite (push) Successful in 4m53s
Update subgraph watcher versions and instructions to use deployments (#775)
Part of https://www.notion.so/Setup-watchers-on-sandman-34b5514a10634c6fbf3ec338967c871c

Reviewed-on: #775
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-03-12 05:32:55 +00:00
..
README.md Update subgraph watcher versions and instructions to use deployments (#775) 2024-03-12 05:32:55 +00:00
stack.yml Rename app -> stack_orchestrator (#625) 2023-11-07 00:06:55 -07:00

SushiSwap Subgraph

Setup

Clone required repositories:

laconic-so --stack sushiswap-subgraph setup-repositories --pull

Checkout to a non-default branch in the cloned repos if required:

# 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:

laconic-so --stack sushiswap-subgraph build-containers

Create a deployment

Initialize deployment and create "spec" file:

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:

laconic-so --stack sushiswap-subgraph deploy create --spec-file sushiswap-subgraph-spec.yml --deployment-dir sushiswap-subgraph-deployment

Start the stack

Deploy the stack:

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:

    laconic-so deployment --dir sushiswap-subgraph-deployment logs -f graph-node
    
  • Check that the subgraphs have been deployed:

    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:

# 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

Set environment variables

  • The graph-node environment variable ETHEREUM_REORG_THRESHOLD can be set in the deployment compose file

    $ cat sushiswap-subgraph-deployment/compose/docker-compose-graph-node.yml
    services:
      graph-node:
        image: cerc/graph-node:local
        ...
        environment:
          ...
          GRAPH_LOG: debug
          ETHEREUM_REORG_THRESHOLD: 16
    

    Change ETHEREUM_REORG_THRESHOLD to desired value

    • To restart graph-node with updated values, we need to restart only graph-node compose services
      • Comment sushiswap-subgraph-v3 pod in stack.yml so that subgraphs are not deployed again
        $ cat sushiswap-subgraph-deployment/stack.yml
        version: "1.0"
        name: sushiswap-subgraph
        ...
        pods:
          - graph-node
          # - sushiswap-subgraph-v3
        
      • Stop the stack first
        laconic-so deployment --dir sushiswap-subgraph-deployment stop
        
      • Start the stack again (will not start sushiswap-subgraph-v3 pod)
        laconic-so deployment --dir sushiswap-subgraph-deployment start
        
    • To check if environment variable has been updated in graph-node container
      $ laconic-so deployment --dir sushiswap-subgraph-deployment exec graph-node bash
      root@dc4d3abe1615:/# echo $ETHEREUM_REORG_THRESHOLD
      16
      

Clean up

Stop all the services running in background run:

laconic-so deployment --dir sushiswap-subgraph-deployment stop

Clear volumes created by this stack:

laconic-so deployment --dir sushiswap-subgraph-deployment stop --delete-volumes