stack-orchestrator/app/data/stacks/sushiswap-subgraph
Nabarun Gogoi bab3a8dba8
Add steps to change ETHEREUM_REORG_THRESHOLD env in deployed stack (#517)
* Add steps to set environment variable in deployed stack

* Change ETHEREUM_REORG_THRESHOLD value to 3
2023-08-31 18:10:36 +05:30
..
README.md Add steps to change ETHEREUM_REORG_THRESHOLD env in deployed stack (#517) 2023-08-31 18:10:36 +05:30
stack.yml Update sushiswap-subgraph stack to point to filecoin endpoint (#509) 2023-08-30 16:05:16 +05:30

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