diff --git a/app/data/compose/docker-compose-contract-sushiswap.yml b/app/data/compose/docker-compose-contract-sushiswap.yml new file mode 100644 index 00000000..b157909e --- /dev/null +++ b/app/data/compose/docker-compose-contract-sushiswap.yml @@ -0,0 +1,49 @@ +version: '3.2' + +services: + # Deploys the core (UniswapV3Factory) contract + sushiswap-v3-core: + image: cerc/sushiswap-v3-core:local + restart: on-failure + env_file: + # Defaults + - ../config/contract-sushiswap/deployment-params.env + environment: + # Overrides + CERC_ETH_RPC_ENDPOINT: ${ETH_RPC_ENDPOINT} + CERC_CHAIN_ID: ${CHAIN_ID} + CERC_ACCOUNT_PRIVATE_KEY: ${ACCOUNT_PRIVATE_KEY} + CERC_DEPLOY: ${DEPLOY} + volumes: + - ../config/network/wait-for-it.sh:/app/wait-for-it.sh + - ../config/contract-sushiswap/deploy-core-contracts.sh:/app/deploy-core-contracts.sh + - sushiswap_core_deployment:/app/deployments/docker + command: ["bash", "-c", "/app/deploy-core-contracts.sh && tail -f"] + extra_hosts: + - "host.docker.internal:host-gateway" + + # Deploys the periphery (NFPM, token, etc.) contracts + sushiswap-v3-periphery: + image: cerc/sushiswap-v3-periphery:local + restart: on-failure + env_file: + # Defaults + - ../config/contract-sushiswap/deployment-params.env + environment: + # Overrides + CERC_ETH_RPC_ENDPOINT: ${ETH_RPC_ENDPOINT} + CERC_CHAIN_ID: ${CHAIN_ID} + CERC_ACCOUNT_PRIVATE_KEY: ${ACCOUNT_PRIVATE_KEY} + CERC_DEPLOY: ${DEPLOY} + volumes: + - ../config/network/wait-for-it.sh:/app/wait-for-it.sh + - ../config/contract-sushiswap/deploy-periphery-contracts.sh:/app/deploy-periphery-contracts.sh + - sushiswap_core_deployment:/app/core-deployments/docker + - sushiswap_periphery_deployment:/app/deployments/docker + command: ["bash", "-c", "/app/deploy-periphery-contracts.sh && tail -f"] + extra_hosts: + - "host.docker.internal:host-gateway" + +volumes: + sushiswap_core_deployment: + sushiswap_periphery_deployment: diff --git a/app/data/compose/docker-compose-fixturenet-graph-node.yml b/app/data/compose/docker-compose-fixturenet-graph-node.yml index 4f30961f..eb47dc2b 100644 --- a/app/data/compose/docker-compose-fixturenet-graph-node.yml +++ b/app/data/compose/docker-compose-fixturenet-graph-node.yml @@ -1,6 +1,15 @@ services: graph-node: image: cerc/graph-node:local + depends_on: + db: + condition: service_healthy + ipfs: + condition: service_healthy + lotus-node-1: + condition: service_healthy + extra_hosts: + - host.docker.internal:host-gateway environment: ipfs: ipfs:5001 postgres_host: db @@ -8,11 +17,20 @@ services: postgres_user: graph-node postgres_pass: password postgres_db: graph-node + # TODO: Get endpoint from env + ethereum: 'lotus-fixturenet:http://lotus-node-1:1234/rpc/v1' + GRAPH_LOG: info ports: - "8000" - "8001" - "8020" - "8030" + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "8020"] + interval: 30s + timeout: 10s + retries: 10 + start_period: 3s ipfs: image: ipfs/kubo:master-2023-02-20-714a968 volumes: @@ -30,6 +48,12 @@ services: POSTGRES_USER: "graph-node" POSTGRES_DB: "graph-node" POSTGRES_PASSWORD: "password" + POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C" + command: + [ + "postgres", + "-cshared_preload_libraries=pg_stat_statements" + ] healthcheck: test: ["CMD", "nc", "-v", "localhost", "5432"] interval: 30s diff --git a/app/data/compose/docker-compose-fixturenet-lotus.yml b/app/data/compose/docker-compose-fixturenet-lotus.yml index a1d2d290..4eb27039 100644 --- a/app/data/compose/docker-compose-fixturenet-lotus.yml +++ b/app/data/compose/docker-compose-fixturenet-lotus.yml @@ -10,7 +10,8 @@ services: - ../config/fixturenet-lotus/setup-miner.sh:/docker-entrypoint-scripts.d/setup-miner.sh - ../config/fixturenet-lotus/fund-account.sh:/fund-account.sh - lotus_miner_params:/var/tmp/filecoin-proof-parameters - - lotus-shared:/root/.lotus-shared + - lotus_shared:/root/.lotus-shared + - lotus_miner_data:/root/data entrypoint: ["sh", "/docker-entrypoint-scripts.d/setup-miner.sh"] ports: - "1234" @@ -29,12 +30,13 @@ services: volumes: - ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh - lotus_node_1_params:/var/tmp/filecoin-proof-parameters - - lotus-shared:/root/.lotus-shared + - lotus_shared:/root/.lotus-shared + - lotus_node_1_data:/root/data healthcheck: test: ["CMD", "nc", "-vz", "localhost", "1234"] interval: 30s timeout: 10s - retries: 10 + retries: 60 start_period: 3s depends_on: - lotus-miner @@ -56,12 +58,13 @@ services: volumes: - ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh - lotus_node_2_params:/var/tmp/filecoin-proof-parameters - - lotus-shared:/root/.lotus-shared + - lotus_shared:/root/.lotus-shared + - lotus_node_2_data:/root/data healthcheck: test: ["CMD", "nc", "-vz", "localhost", "1234"] interval: 30s timeout: 10s - retries: 10 + retries: 60 start_period: 3s depends_on: - lotus-miner @@ -76,4 +79,7 @@ volumes: lotus_miner_params: lotus_node_1_params: lotus_node_2_params: - lotus-shared: + lotus_shared: + lotus_miner_data: + lotus_node_1_data: + lotus_node_2_data: diff --git a/app/data/compose/docker-compose-sushiswap-subgraph-v3.yml b/app/data/compose/docker-compose-sushiswap-subgraph-v3.yml new file mode 100644 index 00000000..b4a7b313 --- /dev/null +++ b/app/data/compose/docker-compose-sushiswap-subgraph-v3.yml @@ -0,0 +1,26 @@ +version: '3.2' + +services: + # Deploys the sushiswap v3 subgraph + sushiswap-subgraph-v3: + image: cerc/sushiswap-subgraphs:local + restart: on-failure + depends_on: + graph-node: + condition: service_healthy + environment: + - APP=v3 + - NETWORK=lotus-fixturenet + command: ["bash", "-c", "./run-v3.sh"] + working_dir: /app/subgraphs/v3 + volumes: + - ../config/sushiswap-subgraph-v3/lotus-fixturenet.js.template:/app/config/lotus-fixturenet.js.template + - ../config/sushiswap-subgraph-v3/run-v3.sh:/app/subgraphs/v3/run-v3.sh + - sushiswap_core_deployment:/app/subgraphs/v3/core-deployments/docker + - sushiswap_periphery_deployment:/app/subgraphs/v3/deployments/docker + extra_hosts: + - "host.docker.internal:host-gateway" + +volumes: + sushiswap_core_deployment: + sushiswap_periphery_deployment: diff --git a/app/data/config/contract-sushiswap/deploy-core-contracts.sh b/app/data/config/contract-sushiswap/deploy-core-contracts.sh new file mode 100755 index 00000000..1f71713e --- /dev/null +++ b/app/data/config/contract-sushiswap/deploy-core-contracts.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -e + +# Chain config +export ETH_RPC_ENDPOINT="${CERC_ETH_RPC_ENDPOINT:-${CERC_DEFAULT_ETH_RPC_ENDPOINT}}" +export CHAIN_ID="${CERC_CHAIN_ID:-${CERC_DEFAULT_CHAIN_ID}}" +export ACCOUNT_PRIVATE_KEY="${CERC_ACCOUNT_PRIVATE_KEY:-${CERC_DEFAULT_ACCOUNT_PRIVATE_KEY}}" + +# Option +DEPLOY="${CERC_DEPLOY:-${CERC_DEFAULT_DEPLOY}}" + +# Create a .env file +echo "ETH_RPC_ENDPOINT=$ETH_RPC_ENDPOINT" > .env +echo "CHAIN_ID=$CHAIN_ID" >> .env +echo "ACCOUNT_PRIVATE_KEY=$ACCOUNT_PRIVATE_KEY" >> .env + +echo "Using RPC endpoint ${ETH_RPC_ENDPOINT}" + +# Wait for the RPC endpoint to be up +endpoint=${ETH_RPC_ENDPOINT#http://} +endpoint=${endpoint#https://} +RPC_HOST=$(echo "$endpoint" | awk -F'[:/]' '{print $1}') +RPC_PORT=$(echo "$endpoint" | awk -F'[:/]' '{print $2}') +./wait-for-it.sh -h "${RPC_HOST}" -p "${RPC_PORT}" -s -t 0 + +if [ "$DEPLOY" = true ] && [ ! -e "/app/deployments/docker/UniswapV3Factory.json" ]; then + echo "Performing core contract deployments..." + pnpm hardhat --network docker deploy --tags UniswapV3Factory +else + echo "Skipping contract deployments" +fi + +echo "Done" diff --git a/app/data/config/contract-sushiswap/deploy-periphery-contracts.sh b/app/data/config/contract-sushiswap/deploy-periphery-contracts.sh new file mode 100755 index 00000000..92466bb9 --- /dev/null +++ b/app/data/config/contract-sushiswap/deploy-periphery-contracts.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -e + +# Chain config +ETH_RPC_ENDPOINT="${CERC_ETH_RPC_ENDPOINT:-${CERC_DEFAULT_ETH_RPC_ENDPOINT}}" +CHAIN_ID="${CERC_CHAIN_ID:-${CERC_DEFAULT_CHAIN_ID}}" +ACCOUNT_PRIVATE_KEY="${CERC_ACCOUNT_PRIVATE_KEY:-${CERC_DEFAULT_ACCOUNT_PRIVATE_KEY}}" + +# Option +DEPLOY="${CERC_DEPLOY:-${CERC_DEFAULT_DEPLOY}}" + +# Create a .env file +echo "ETH_RPC_ENDPOINT=$ETH_RPC_ENDPOINT" > .env +echo "CHAIN_ID=$CHAIN_ID" >> .env +echo "ACCOUNT_PRIVATE_KEY=$ACCOUNT_PRIVATE_KEY" >> .env + +echo "Using RPC endpoint $ETH_RPC_ENDPOINT" + +# Wait for the RPC endpoint to be up +endpoint=${ETH_RPC_ENDPOINT#http://} +endpoint=${endpoint#https://} +RPC_HOST=$(echo "$endpoint" | awk -F'[:/]' '{print $1}') +RPC_PORT=$(echo "$endpoint" | awk -F'[:/]' '{print $2}') +./wait-for-it.sh -h "${RPC_HOST}" -p "${RPC_PORT}" -s -t 0 + +if [ "$DEPLOY" = true ] && [ ! -e "/app/deployments/docker/NonfungiblePositionManager.json" ]; then + # Loop until the factory deployment is detected + echo "Waiting for core deployments to occur" + while [ ! -f /app/core-deployments/docker/UniswapV3Factory.json ]; do + sleep 5 + done + + echo "Reading factory address from core deployments" + FACTORY_ADDRESS=$(jq -r '.address' /app/core-deployments/docker/UniswapV3Factory.json) + + echo "Using UniswapV3Factory at $FACTORY_ADDRESS" + echo "FACTORY_ADDRESS=$FACTORY_ADDRESS" >> .env + + echo "Performing periphery contract deployments..." + yarn hardhat --network docker deploy --tags NonfungiblePositionManager +else + echo "Skipping contract deployments" +fi + +echo "Done" diff --git a/app/data/config/contract-sushiswap/deployment-params.env b/app/data/config/contract-sushiswap/deployment-params.env new file mode 100644 index 00000000..53bf910f --- /dev/null +++ b/app/data/config/contract-sushiswap/deployment-params.env @@ -0,0 +1,11 @@ +# Chain config + +CERC_DEFAULT_ETH_RPC_ENDPOINT="http://lotus-node-1:1234/rpc/v1" +CERC_DEFAULT_CHAIN_ID=31415926 + +# From app/data/config/fixturenet-lotus/fund-account.sh +CERC_DEFAULT_ACCOUNT_PRIVATE_KEY="0xc05fd3613bcd62a4f25e5eba1f464d0b76d74c3f771a7c2f13e26ad6439444b3" + +# Options + +CERC_DEFAULT_DEPLOY=true diff --git a/app/data/config/fixturenet-lotus/lotus-env.env b/app/data/config/fixturenet-lotus/lotus-env.env index 9ffd8e85..2fffed4c 100644 --- a/app/data/config/fixturenet-lotus/lotus-env.env +++ b/app/data/config/fixturenet-lotus/lotus-env.env @@ -1,5 +1,5 @@ -LOTUS_PATH=/root/.lotus-local-net -LOTUS_MINER_PATH=/root/.lotus-miner-local-net +LOTUS_PATH=/root/data/.lotus-local-net +LOTUS_MINER_PATH=/root/data/.lotus-miner-local-net LOTUS_SKIP_GENESIS_CHECK=_yes_ LOTUS_FEVM_ENABLEETHRPC=true CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__" diff --git a/app/data/config/fixturenet-lotus/setup-miner.sh b/app/data/config/fixturenet-lotus/setup-miner.sh index 6c065b52..2e9efb0a 100644 --- a/app/data/config/fixturenet-lotus/setup-miner.sh +++ b/app/data/config/fixturenet-lotus/setup-miner.sh @@ -15,12 +15,16 @@ else echo "Existing proof params found" fi -lotus-seed pre-seal --sector-size 2KiB --num-sectors 2 -lotus-seed genesis new localnet.json -lotus-seed genesis add-miner localnet.json ~/.genesis-sectors/pre-seal-t01000.json +# if genesis is not already setup +if [ ! -f /root/data/localnet.json ]; then + lotus-seed --sector-dir /root/data/.genesis-sectors pre-seal --sector-size 2KiB --num-sectors 2 + lotus-seed --sector-dir /root/data/.genesis-sectors genesis new /root/data/localnet.json + lotus-seed --sector-dir /root/data/.genesis-sectors genesis add-miner /root/data/localnet.json /root/data/.genesis-sectors/pre-seal-t01000.json +fi # start daemon -nohup lotus daemon --lotus-make-genesis=devgen.car --profile=bootstrapper --genesis-template=localnet.json --bootstrap=false > /var/log/lotus.log 2>&1 & +# /root/.lotus-shared/devgen.car path +nohup lotus daemon --lotus-make-genesis=/root/.lotus-shared/devgen.car --profile=bootstrapper --genesis-template=/root/data/localnet.json --bootstrap=false > /var/log/lotus.log 2>&1 & # Loop until the daemon is started echo "Waiting for daemon to start..." @@ -32,21 +36,20 @@ echo "Daemon started." # copy genesis file to shared volume cp /devgen.car /root/.lotus-shared -# publish bootnode peer info to shared volume -# TODO: Improve exporting public address to shared volume -lotus net listen | awk 'NR==4{print}' > /root/.lotus-shared/miner.addr - # if miner not already initialized if [ ! -d $LOTUS_MINER_PATH ]; then # initialize miner - lotus wallet import --as-default ~/.genesis-sectors/pre-seal-t01000.key + lotus wallet import --as-default /root/data/.genesis-sectors/pre-seal-t01000.key # fund a known account for usage /fund-account.sh - lotus-miner init --genesis-miner --actor=t01000 --sector-size=2KiB --pre-sealed-sectors=~/.genesis-sectors --pre-sealed-metadata=~/.genesis-sectors/pre-seal-t01000.json --nosync + lotus-miner init --genesis-miner --actor=t01000 --sector-size=2KiB --pre-sealed-sectors=/root/data/.genesis-sectors --pre-sealed-metadata=/root/data/.genesis-sectors/pre-seal-t01000.json --nosync fi +# publish bootnode peer info to shared volume +lotus net listen | grep "$(ip addr | grep inet | grep -v '127.0.0.1' | sort | head -1 | awk '{print $2}' | cut -d '/' -f1)" | head -1 > /root/.lotus-shared/miner.addr + # start miner nohup lotus-miner run --nosync & diff --git a/app/data/config/fixturenet-lotus/setup-node.sh b/app/data/config/fixturenet-lotus/setup-node.sh index dc3392fe..49511c32 100644 --- a/app/data/config/fixturenet-lotus/setup-node.sh +++ b/app/data/config/fixturenet-lotus/setup-node.sh @@ -9,20 +9,17 @@ while [ ! -f /root/.lotus-shared/miner.addr ]; do done echo "Resuming..." -# if not already initialized -if [ ! -f $LOTUS_PATH/config.toml ]; then - # init node config - mkdir $LOTUS_PATH - lotus config default > $LOTUS_PATH/config.toml +# init node config +mkdir -p $LOTUS_PATH +lotus config default > $LOTUS_PATH/config.toml - # add bootstrap peer info if available - if [ -f /root/.lotus-shared/miner.addr ]; then - MINER_ADDR=\"$(cat /root/.lotus-shared/miner.addr)\" - # add bootstrap peer id to config file - sed -i "/^\[Libp2p\]/a \ \ BootstrapPeers = [$MINER_ADDR]" $LOTUS_PATH/config.toml - else - echo "Bootstrap peer info not found, unable to configure. Manual peering will be required." - fi +# add bootstrap peer info if available +if [ -f /root/.lotus-shared/miner.addr ]; then + MINER_ADDR=\"$(cat /root/.lotus-shared/miner.addr)\" + # add bootstrap peer id to config file + sed -i "/^\[Libp2p\]/a \ \ BootstrapPeers = [$MINER_ADDR]" $LOTUS_PATH/config.toml +else + echo "Bootstrap peer info not found, unable to configure. Manual peering will be required." fi # start node diff --git a/app/data/config/sushiswap-subgraph-v3/lotus-fixturenet.js.template b/app/data/config/sushiswap-subgraph-v3/lotus-fixturenet.js.template new file mode 100644 index 00000000..aee2cf97 --- /dev/null +++ b/app/data/config/sushiswap-subgraph-v3/lotus-fixturenet.js.template @@ -0,0 +1,20 @@ +module.exports = { + network: 'lotus-fixturenet', + v3: { + factory: { + address: 'FACTORY_ADDRESS', + startBlock: FACTORY_BLOCK + }, + positionManager: { + address: 'NFPM_ADDRESS', + startBlock: NFPM_BLOCK + }, + native: { address: 'NATIVE_ADDRESS' }, + whitelistedTokenAddresses: [ + 'NATIVE_ADDRESS', + ], + stableTokenAddresses: [ + ], + minimumEthLocked: 1.5 + } +} diff --git a/app/data/config/sushiswap-subgraph-v3/run-v3.sh b/app/data/config/sushiswap-subgraph-v3/run-v3.sh new file mode 100755 index 00000000..8ca01460 --- /dev/null +++ b/app/data/config/sushiswap-subgraph-v3/run-v3.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -e + +# Loop until the NFPM deployment is detected +echo "Waiting for sushiswap-periphery deployments to occur" +while [ ! -f ./deployments/docker/NonfungiblePositionManager.json ]; do + sleep 5 +done + +echo "Reading contract addresses and block numbers from deployments" +FACTORY_ADDRESS=$(jq -r '.address' ./core-deployments/docker/UniswapV3Factory.json) +FACTORY_BLOCK=$(jq -r '.receipt.blockNumber' ./core-deployments/docker/UniswapV3Factory.json) +NATIVE_ADDRESS=$(jq -r '.address' ./deployments/docker/WFIL.json) +NFPM_ADDRESS=$(jq -r '.address' ./deployments/docker/NonfungiblePositionManager.json) +NFPM_BLOCK=$(jq -r '.receipt.blockNumber' ./deployments/docker/NonfungiblePositionManager.json) + +# Read the JavaScript file content +file_content=$( /app/config/lotus-fixturenet.js + + +echo "Building subgraph and deploying to graph-node..." +pnpm run generate +pnpm run build +pnpm exec graph create --node http://graph-node:8020/ sushiswap/v3-lotus +pnpm exec graph deploy --node http://graph-node:8020/ --ipfs http://ipfs:5001 --version-label 0.1.0 sushiswap/v3-lotus + +echo "Done" diff --git a/app/data/container-build/cerc-lotus/Dockerfile b/app/data/container-build/cerc-lotus/Dockerfile index 0d43077a..01e252b2 100644 --- a/app/data/container-build/cerc-lotus/Dockerfile +++ b/app/data/container-build/cerc-lotus/Dockerfile @@ -99,7 +99,7 @@ CMD ["-help"] FROM lotus-base AS lotus-all-in-one # Install netcat for healthcheck -RUN apt-get update && apt-get install -y netcat +RUN apt-get update && apt-get install -y netcat && apt-get install -y iproute2 ENV FILECOIN_PARAMETER_CACHE /var/tmp/filecoin-proof-parameters ENV LOTUS_MINER_PATH /var/lib/lotus-miner diff --git a/app/data/container-build/cerc-sushiswap-subgraphs/Dockerfile b/app/data/container-build/cerc-sushiswap-subgraphs/Dockerfile new file mode 100644 index 00000000..2196882c --- /dev/null +++ b/app/data/container-build/cerc-sushiswap-subgraphs/Dockerfile @@ -0,0 +1,11 @@ +FROM node:18.15.0-alpine3.16 + +RUN apk --update --no-cache add git alpine-sdk bash jq +RUN curl -L https://unpkg.com/@pnpm/self-installer | node + +WORKDIR /app + +COPY . . + +RUN echo "Installing dependencies..." && \ + pnpm install diff --git a/app/data/container-build/cerc-sushiswap-subgraphs/build.sh b/app/data/container-build/cerc-sushiswap-subgraphs/build.sh new file mode 100755 index 00000000..0d2f8633 --- /dev/null +++ b/app/data/container-build/cerc-sushiswap-subgraphs/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# Build cerc/sushiswap-subgraphs +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker build -t cerc/sushiswap-subgraphs:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/subgraphs diff --git a/app/data/container-build/cerc-sushiswap-v3-core/Dockerfile b/app/data/container-build/cerc-sushiswap-v3-core/Dockerfile index 993897d4..8d85d602 100644 --- a/app/data/container-build/cerc-sushiswap-v3-core/Dockerfile +++ b/app/data/container-build/cerc-sushiswap-v3-core/Dockerfile @@ -1,6 +1,6 @@ FROM node:18.15.0-alpine3.16 -RUN apk --update --no-cache add git python3 alpine-sdk bash +RUN apk --update --no-cache add git python3 alpine-sdk bash jq RUN curl -L https://unpkg.com/@pnpm/self-installer | node WORKDIR /app diff --git a/app/data/container-build/cerc-sushiswap-v3-periphery/Dockerfile b/app/data/container-build/cerc-sushiswap-v3-periphery/Dockerfile index 4fcf712c..a033c39e 100644 --- a/app/data/container-build/cerc-sushiswap-v3-periphery/Dockerfile +++ b/app/data/container-build/cerc-sushiswap-v3-periphery/Dockerfile @@ -1,6 +1,6 @@ FROM node:18.15.0-alpine3.16 -RUN apk --update --no-cache add git python3 alpine-sdk bash +RUN apk --update --no-cache add git python3 alpine-sdk bash jq WORKDIR /app diff --git a/app/data/container-image-list.txt b/app/data/container-image-list.txt index 751b40a3..b674baf8 100644 --- a/app/data/container-image-list.txt +++ b/app/data/container-image-list.txt @@ -48,3 +48,4 @@ cerc/sushiswap-v3-core cerc/sushiswap-v3-periphery cerc/watcher-sushiswap cerc/graph-node +cerc/sushiswap-subgraphs diff --git a/app/data/pod-list.txt b/app/data/pod-list.txt index 5355c90e..c6e55b8d 100644 --- a/app/data/pod-list.txt +++ b/app/data/pod-list.txt @@ -31,3 +31,4 @@ mainnet-go-opera lasso reth watcher-sushiswap +contract-sushiswap diff --git a/app/data/repository-list.txt b/app/data/repository-list.txt index 7069850b..de696335 100644 --- a/app/data/repository-list.txt +++ b/app/data/repository-list.txt @@ -42,3 +42,4 @@ git.vdb.to/cerc-io/plugeth-statediff github.com/cerc-io/sushiswap-v3-core github.com/cerc-io/sushiswap-v3-periphery github.com/graphprotocol/graph-node +github.com/sushiswap/subgraphs diff --git a/app/data/stacks/azimuth/README.md b/app/data/stacks/azimuth/README.md index c4e1671f..67f42b75 100644 --- a/app/data/stacks/azimuth/README.md +++ b/app/data/stacks/azimuth/README.md @@ -55,7 +55,7 @@ This should create the required docker images in the local image registry. ## Clean up -Stop all the services running in background run: +Stop all the services running in background: ```bash laconic-so --stack azimuth deploy-system down diff --git a/app/data/stacks/fixturenet-graph-node/stack.yml b/app/data/stacks/fixturenet-graph-node/stack.yml index 727cceb4..e7ab10f3 100644 --- a/app/data/stacks/fixturenet-graph-node/stack.yml +++ b/app/data/stacks/fixturenet-graph-node/stack.yml @@ -2,9 +2,11 @@ version: "1.0" name: fixturenet-graph-node description: "A graph-node fixturenet" repos: + - github.com/filecoin-project/lotus - github.com/graphprotocol/graph-node containers: + - cerc/lotus - cerc/graph-node pods: + - fixturenet-lotus - fixturenet-graph-node - diff --git a/app/data/stacks/fixturenet-lotus/README.md b/app/data/stacks/fixturenet-lotus/README.md index 2e87e1b9..7d238347 100644 --- a/app/data/stacks/fixturenet-lotus/README.md +++ b/app/data/stacks/fixturenet-lotus/README.md @@ -14,6 +14,9 @@ $ laconic-so --stack fixturenet-lotus build-containers ``` $ laconic-so --stack fixturenet-lotus deploy --cluster lotus up ``` + +Note: When running for the first time (or after clean up), the services will take some time to start properly as the Lotus nodes download the proof params (which are persisted to volumes) + Correct operation should be verified by checking the container logs with: ``` $ laconic-so --stack fixturenet-lotus deploy --cluster lotus logs lotus-miner @@ -26,3 +29,19 @@ $ laconic-so --stack fixturenet-lotus deploy --cluster lotus exec lotus-miner "l $ laconic-so --stack fixturenet-lotus deploy --cluster lotus exec lotus-node-1 "lotus status" $ laconic-so --stack fixturenet-lotus deploy --cluster lotus exec lotus-node-2 "lotus status" ``` + +## 4. Clean up + +Stop all the services running in background: +``` +$ laconic-so --stack fixturenet-lotus deploy --cluster lotus down +``` + +Clear volumes created by this stack: +``` +# List all relevant volumes +$ docker volume ls -q --filter "name=lotus" + +# Remove all the listed volumes +$ docker volume rm $(docker volume ls -q --filter "name=lotus") +``` diff --git a/app/data/stacks/mobymask-v2/README.md b/app/data/stacks/mobymask-v2/README.md index dfbabd09..f4fc12e4 100644 --- a/app/data/stacks/mobymask-v2/README.md +++ b/app/data/stacks/mobymask-v2/README.md @@ -93,7 +93,7 @@ Follow the [demo](./demo.md) to try out the MobyMask app with L2 chain ## Clean up -Stop all the services running in background run: +Stop all the services running in background: ```bash laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 down 30 diff --git a/app/data/stacks/sushiswap-subgraph/README.md b/app/data/stacks/sushiswap-subgraph/README.md new file mode 100644 index 00000000..b341a1a3 --- /dev/null +++ b/app/data/stacks/sushiswap-subgraph/README.md @@ -0,0 +1,111 @@ +# SushiSwap Graph + +## Setup + +Clone required repositories: + +```bash +laconic-so --stack sushiswap-subgraph setup-repositories +``` + +Build the container images: + +```bash +laconic-so --stack sushiswap-subgraph build-containers +``` + +## Deploy + +Deploy the stack: + +```bash +laconic-so --stack sushiswap-subgraph deploy --cluster sushigraph up +``` + +After all services have started, wait and check that the subgraph has been deployed to graph-node + +```bash +laconic-so --stack sushiswap-subgraph deploy --cluster sushigraph logs -f sushiswap-subgraph-v3 + +# Expected end 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/v3-lotus/graphql +# 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-lotus +# sushigraph-sushiswap-subgraph-v3-1 | +# sushigraph-sushiswap-subgraph-v3-1 | Done +``` + +## Run + +To check graph-node logs: +```bash +laconic-so --stack sushiswap-subgraph deploy --cluster sushigraph logs -f graph-node +``` + +To deploy tokens run: +```bash +docker exec -it sushigraph-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 +``` +This can be run multiple times to deploy ERC20 tokens + +Take note of the deployed token addresses to use later + +Get contract address of factory deployed: +```bash +docker exec -it sushigraph-sushiswap-v3-core-1 jq -r '.address' /app/deployments/docker/UniswapV3Factory.json +``` +Set it to environment variable `FACTORY_ADDRESS` to use later + +To create a pool: +```bash +docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:create:docker --factory $FACTORY_ADDRESS --token0 $TOKEN1_ADDRESS --token1 $TOKEN2_ADDRESS --fee 500 +``` + +Set the created pool address to environment variable `POOL_ADDRESS` to use later + +To initialize pool: +```bash +docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:initialize:docker --sqrt-price 4295128939 --pool $POOL_ADDRESS +``` + +Set the recipient address to the contract deployer: +```bash +export RECIPIENT=0xD375B03bd3A2434A9f675bEC4Ccd68aC5e67C743 +``` + +Trigger pool mint event: +```bash +docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:mint:docker --pool $POOL_ADDRESS --recipient $RECIPIENT --amount 10 +``` + +Trigger pool burn event: +```bash +docker exec -it sushigraph-sushiswap-v3-core-1 pnpm run pool:burn:docker --pool $POOL_ADDRESS --amount 10 +``` + +## Clean up + +Stop all the services running in background run: + +```bash +laconic-so --stack sushiswap-subgraph deploy --cluster sushigraph down +``` + +Clear volumes created by this stack: + +```bash +# List all relevant volumes +docker volume ls -q --filter "name=sushigraph" + +# Remove all the listed volumes +docker volume rm $(docker volume ls -q --filter "name=sushigraph") + +# WARNING: After removing volumes with Lotus params +# They will be downloaded again on restart + +# To remove volumes that do not contain Lotus params +docker volume rm $(docker volume ls -q --filter "name=sushigraph" | grep -v "params$") +``` diff --git a/app/data/stacks/sushiswap-subgraph/stack.yml b/app/data/stacks/sushiswap-subgraph/stack.yml new file mode 100644 index 00000000..e4b6915d --- /dev/null +++ b/app/data/stacks/sushiswap-subgraph/stack.yml @@ -0,0 +1,28 @@ +version: "1.0" +name: sushiswap-subgraph +description: "An end-to-end SushiSwap Subgraph stack" +repos: + ## fixturenet-lotus repo + - github.com/filecoin-project/lotus + ## graph-node repo + - github.com/graphprotocol/graph-node + ## sushiswap repos + - github.com/cerc-io/sushiswap-v3-core@watcher-ts + - github.com/cerc-io/sushiswap-v3-periphery@watcher-ts + ## subgraph repo + - github.com/sushiswap/subgraphs +containers: + ## fixturenet-lotus image + - cerc/lotus + ## fixturenet-graph-node image + - cerc/graph-node + ## sushiswap contract deployment images + - cerc/sushiswap-v3-core + - cerc/sushiswap-v3-periphery + ## sushiswap subgraphs image + - cerc/sushiswap-subgraphs +pods: + - fixturenet-lotus + - fixturenet-graph-node + - contract-sushiswap + - sushiswap-subgraph-v3 diff --git a/app/data/stacks/sushiswap/README.md b/app/data/stacks/sushiswap/README.md index 50450613..9d117f03 100644 --- a/app/data/stacks/sushiswap/README.md +++ b/app/data/stacks/sushiswap/README.md @@ -22,13 +22,15 @@ Deploy the stack: laconic-so --stack sushiswap deploy --cluster sushiswap up ``` +Note: When running for the first time (or after clean up), the services will take some time to start as Lotus nodes in the fixturenet download the proof params + ## Tests Follow [smoke-tests.md](./smoke-tests.md) to run smoke tests ## Clean up -Stop all the services running in background run: +Stop all the services running in background: ```bash laconic-so --stack sushiswap deploy --cluster sushiswap down