diff --git a/app/data/compose/docker-compose-watcher-sushiswap.yml b/app/data/compose/docker-compose-watcher-sushiswap.yml index 915f39cd..f5c5c0b9 100644 --- a/app/data/compose/docker-compose-watcher-sushiswap.yml +++ b/app/data/compose/docker-compose-watcher-sushiswap.yml @@ -59,6 +59,7 @@ services: command: ["node", "--enable-source-maps", "dist/job-runner.js"] volumes: - ../config/watcher-sushiswap/sushi-watcher.toml:/app/packages/uni-watcher/environments/local.toml + - ../config/watcher-sushiswap/sushi-watcher-test.toml:/app/packages/uni-watcher/environments/test.toml ports: - "0.0.0.0:9004:9000" healthcheck: @@ -78,12 +79,15 @@ services: sushi-watcher-job-runner: condition: service_healthy image: cerc/watcher-sushiswap:local + env_file: + - ../config/watcher-sushiswap/lotus-params.env environment: - DEBUG=vulcanize:* working_dir: /app/packages/uni-watcher command: ["node", "--enable-source-maps", "dist/server.js"] volumes: - ../config/watcher-sushiswap/sushi-watcher.toml:/app/packages/uni-watcher/environments/local.toml + - ../config/watcher-sushiswap/sushi-watcher-test.toml:/app/packages/uni-watcher/environments/test.toml ports: - "0.0.0.0:3003:3003" - "0.0.0.0:9005:9001" @@ -112,6 +116,7 @@ services: command: ["node", "--enable-source-maps", "dist/job-runner.js"] volumes: - ../config/watcher-sushiswap/sushi-info-watcher.toml:/app/packages/uni-info-watcher/environments/local.toml + - ../config/watcher-sushiswap/sushi-info-watcher-test.toml:/app/packages/uni-info-watcher/environments/test.toml ports: - "0.0.0.0:9006:9002" healthcheck: @@ -135,10 +140,13 @@ services: sushi-info-watcher-job-runner: condition: service_healthy image: cerc/watcher-sushiswap:local + env_file: + - ../config/watcher-sushiswap/lotus-params.env working_dir: /app/packages/uni-info-watcher command: ["node", "--enable-source-maps", "dist/server.js"] volumes: - ../config/watcher-sushiswap/sushi-info-watcher.toml:/app/packages/uni-info-watcher/environments/local.toml + - ../config/watcher-sushiswap/sushi-info-watcher-test.toml:/app/packages/uni-info-watcher/environments/test.toml ports: - "0.0.0.0:3004:3004" - "0.0.0.0:9007:9003" @@ -163,13 +171,13 @@ services: sushiswap-v3-core: image: cerc/sushiswap-v3-core:local env_file: - - ../config/watcher-sushiswap/contract-deployment.env + - ../config/watcher-sushiswap/lotus-params.env # Deploys the periphery (NFPM, token, etc.) contracts sushiswap-v3-periphery: image: cerc/sushiswap-v3-periphery:local env_file: - - ../config/watcher-sushiswap/contract-deployment.env + - ../config/watcher-sushiswap/lotus-params.env volumes: uniswap_watcher_db_data: diff --git a/app/data/config/watcher-sushiswap/erc20-watcher.toml b/app/data/config/watcher-sushiswap/erc20-watcher.toml index f8882829..65dc1a2f 100644 --- a/app/data/config/watcher-sushiswap/erc20-watcher.toml +++ b/app/data/config/watcher-sushiswap/erc20-watcher.toml @@ -21,11 +21,10 @@ logging = false maxQueryExecutionTime = 100 -# TODO: Update to use rpc-eth-client [upstream] [upstream.ethServer] - gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql" - rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082" + rpcProviderEndpoint = "http://lotus-node-1:1234/rpc/v1" + rpcClient = true [upstream.cache] name = "requests" diff --git a/app/data/config/watcher-sushiswap/contract-deployment.env b/app/data/config/watcher-sushiswap/lotus-params.env similarity index 67% rename from app/data/config/watcher-sushiswap/contract-deployment.env rename to app/data/config/watcher-sushiswap/lotus-params.env index 8cd749dc..dc132361 100644 --- a/app/data/config/watcher-sushiswap/contract-deployment.env +++ b/app/data/config/watcher-sushiswap/lotus-params.env @@ -1,3 +1,6 @@ +# Lotus node config ETH_RPC_ENDPOINT="http://lotus-node-1:1234/rpc/v1" CHAIN_ID=31415926 + +# From app/data/config/fixturenet-lotus/fund-account.sh ACCOUNT_PRIVATE_KEY="0xc05fd3613bcd62a4f25e5eba1f464d0b76d74c3f771a7c2f13e26ad6439444b3" diff --git a/app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml b/app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml new file mode 100644 index 00000000..e8f2d935 --- /dev/null +++ b/app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml @@ -0,0 +1,45 @@ +[server] + host = "0.0.0.0" + port = 3004 + # Use mode demo when running watcher locally. + # Mode demo whitelists all tokens so that entity values get updated. + mode = "demo" + +[database] + type = "postgres" + host = "sushiswap-watcher-db" + port = 5432 + database = "sushi-info-watcher" + username = "vdbm" + password = "password" + synchronize = true + logging = false + maxQueryExecutionTime = 100 + +[upstream] + [upstream.ethServer] + rpcProviderEndpoint = "http://lotus-node-1:1234/rpc/v1" + rpcClient = true + + [upstream.cache] + name = "requests" + enabled = false + deleteOnStart = false + + [upstream.uniWatcher] + gqlEndpoint = "http://sushi-watcher-server:3003/graphql" + gqlSubscriptionEndpoint = "ws://sushi-watcher-server:3003/graphql" + + [upstream.tokenWatcher] + gqlEndpoint = "http://erc20-watcher-server:3001/graphql" + gqlSubscriptionEndpoint = "ws://erc20-watcher-server:3001/graphql" + +[jobQueue] + dbConnectionString = "postgres://vdbm:password@sushiswap-watcher-db:5432/sushi-info-watcher-job-queue" + maxCompletionLagInSecs = 300 + jobDelayInMilliSecs = 1000 + eventsInBatch = 50 + subgraphEventsOrder = true + blockDelayInMilliSecs = 2000 + prefetchBlocksInMem = true + prefetchBlockCount = 10 diff --git a/app/data/config/watcher-sushiswap/sushi-info-watcher.toml b/app/data/config/watcher-sushiswap/sushi-info-watcher.toml index 3bf3e288..2a300831 100644 --- a/app/data/config/watcher-sushiswap/sushi-info-watcher.toml +++ b/app/data/config/watcher-sushiswap/sushi-info-watcher.toml @@ -61,11 +61,10 @@ # maximum number of clients the pool should contain max = 20 -# TODO: Update to use rpc-eth-client [upstream] [upstream.ethServer] - gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql" - rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082" + rpcProviderEndpoint = "http://lotus-node-1:1234/rpc/v1" + rpcClient = true [upstream.cache] name = "requests" diff --git a/app/data/config/watcher-sushiswap/sushi-watcher-test.toml b/app/data/config/watcher-sushiswap/sushi-watcher-test.toml new file mode 100644 index 00000000..0420cf75 --- /dev/null +++ b/app/data/config/watcher-sushiswap/sushi-watcher-test.toml @@ -0,0 +1,34 @@ +[server] + host = "0.0.0.0" + port = 3003 + +[database] + type = "postgres" + host = "sushiswap-watcher-db" + port = 5432 + database = "sushi-watcher" + username = "vdbm" + password = "password" + synchronize = true + logging = false + maxQueryExecutionTime = 100 + +[upstream] + [upstream.ethServer] + rpcProviderEndpoint = "http://lotus-node-1:1234/rpc/v1" + rpcClient = true + + [upstream.cache] + name = "requests" + enabled = false + deleteOnStart = false + +[jobQueue] + dbConnectionString = "postgres://vdbm:password@sushiswap-watcher-db:5432/sushi-watcher-job-queue" + maxCompletionLagInSecs = 300 + jobDelayInMilliSecs = 0 + eventsInBatch = 50 + lazyUpdateBlockProgress = true + blockDelayInMilliSecs = 2000 + prefetchBlocksInMem = false + prefetchBlockCount = 10 diff --git a/app/data/config/watcher-sushiswap/sushi-watcher.toml b/app/data/config/watcher-sushiswap/sushi-watcher.toml index d386f5b6..d8dfa594 100644 --- a/app/data/config/watcher-sushiswap/sushi-watcher.toml +++ b/app/data/config/watcher-sushiswap/sushi-watcher.toml @@ -20,11 +20,10 @@ logging = false maxQueryExecutionTime = 100 -# TODO: Update to use rpc-eth-client [upstream] [upstream.ethServer] - gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql" - rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082" + rpcProviderEndpoint = "http://lotus-node-1:1234/rpc/v1" + rpcClient = true [upstream.cache] name = "requests" diff --git a/app/data/stacks/sushiswap/README.md b/app/data/stacks/sushiswap/README.md index 42cde33d..1a636135 100644 --- a/app/data/stacks/sushiswap/README.md +++ b/app/data/stacks/sushiswap/README.md @@ -21,5 +21,27 @@ laconic-so --stack sushiswap build-containers Deploy the stack: ```bash -laconic-so --stack sushiswap deploy --cluster lotus up +laconic-so --stack sushiswap deploy --cluster sushiswap up +``` + +## Tests + +Follow [smoke-tests.md](./smoke-tests.md) to run smoke tests + +## Clean up + +Stop all the services running in background run: + +```bash +laconic-so --stack sushiswap deploy --cluster sushiswap down +``` + +Clear volumes created by this stack: + +```bash +# List all relevant volumes +docker volume ls -q --filter "name=sushiswap" + +# Remove all the listed volumes +docker volume rm $(docker volume ls -q --filter "name=sushiswap") ``` diff --git a/app/data/stacks/sushiswap/smoke-tests.md b/app/data/stacks/sushiswap/smoke-tests.md new file mode 100644 index 00000000..713f8373 --- /dev/null +++ b/app/data/stacks/sushiswap/smoke-tests.md @@ -0,0 +1,77 @@ +# SushiSwap Watcher Smoke Tests + +## sushi-watcher + +Deploy required contracts and set the addresses to variables: + +```bash +# Deploy UniswapV3Factory +docker exec -it sushiswap-sushiswap-v3-core-1 pnpm hardhat --network docker deploy --tags UniswapV3Factory + +# Set the returned address to a variable +export FACTORY_ADDRESS= + +# Deploy TestUniswapV3Callee +docker exec -it sushiswap-sushiswap-v3-core-1 pnpm hardhat --network docker deploy --tags TestUniswapV3Callee + +# Set the returned address to a variable +export UNISWAP_CALLEE_ADDRESS= + +# Deploy NFPM contract +docker exec -it sushiswap-sushiswap-v3-periphery-1 bash -c "export FACTORY_ADDRESS=$FACTORY_ADDRESS && yarn hardhat --network docker deploy --tags NonfungiblePositionManager" + +# Set the returned address to a variable +export POSITION_MANAGER_ADDRESS= + +# Deploy two test tokens +docker exec -it sushiswap-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 +docker exec -it sushiswap-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 + +# Set the returned addresses to variables +export TOKEN0_ADDRESS= +export TOKEN1_ADDRESS= +``` + +Watch the contracts: + +```bash +# Watch factory contract +docker exec -it sushiswap-sushiswap-watcher-server-1 bash -c "yarn watch:contract --address $FACTORY_ADDRESS --kind factory --startingBlock 100 --checkpoint false" +docker exec -it sushiswap-sushiswap-info-watcher-server-1 bash -c "yarn watch:contract --address $FACTORY_ADDRESS --kind factory --startingBlock 100 --checkpoint false" + +# Watch NFPM contract +docker exec -it sushiswap-sushiswap-watcher-server-1 bash -c "yarn watch:contract --address $POSITION_MANAGER_ADDRESS --kind nfpm --startingBlock 100 --checkpoint false" +docker exec -it sushiswap-sushiswap-info-watcher-server-1 bash -c "yarn watch:contract --address $POSITION_MANAGER_ADDRESS --kind nfpm --startingBlock 100 --checkpoint false" +``` + +Run the smoke test: + +```bash +docker exec -it sushiswap-sushiswap-watcher-server-1 bash -c "export TOKEN0_ADDRESS=$TOKEN0_ADDRESS && export TOKEN1_ADDRESS=$TOKEN1_ADDRESS && export UNISWAP_CALLEE_ADDRESS=$UNISWAP_CALLEE_ADDRESS && yarn smoke-test" +``` + +## sushi-info-watcher + +Deploy required contracts and set the addresses to variables: + +```bash +# Deploy TestUniswapV3Callee +docker exec -it sushiswap-sushiswap-v3-core-1 pnpm hardhat --network docker deploy --tags TestUniswapV3Callee + +# Set the returned address to a variable +export UNISWAP_CALLEE_ADDRESS= + +# Deploy two test tokens +docker exec -it sushiswap-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 +docker exec -it sushiswap-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 + +# Set the returned addresses to variables +export TOKEN0_ADDRESS= +export TOKEN1_ADDRESS= +``` + +Run the smoke test: + +```bash +docker exec -it sushiswap-sushiswap-info-watcher-server-1 bash -c "export TOKEN0_ADDRESS=$TOKEN0_ADDRESS && export TOKEN1_ADDRESS=$TOKEN1_ADDRESS && export UNISWAP_CALLEE_ADDRESS=$UNISWAP_CALLEE_ADDRESS && yarn smoke-test" +```