diff --git a/docker-compose.yml b/docker-compose.yml index 8fdb74de..862f7772 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - services: postgres: build: @@ -12,15 +10,38 @@ services: environment: POSTGRES_PASSWORD: postgres healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres"] + test: ['CMD-SHELL', 'pg_isready -U postgres'] interval: 5s timeout: 5s retries: 5 + agd: + # cf. https://github.com/Agoric/agoric-3-proposals + image: ghcr.io/agoric/agoric-3-proposals:latest + platform: linux/amd64 + ports: + - 26656:26656 + - 26657:26657 + - 1317:1317 + environment: + DEST: 1 + DEBUG: 'SwingSet:ls,SwingSet:vat' + # SLOGFILE: '~/logs.slog' + volumes: + - .:/workspace + entrypoint: /workspace/scripts/run-chain.sh + healthcheck: + test: ['CMD', 'curl', '-f', 'http://localhost:26657/status'] + interval: 5s + timeout: 10s + retries: 5 + subquery-node: image: subquerynetwork/subql-node-cosmos:latest depends_on: - "postgres": + postgres: + condition: service_healthy + agd: condition: service_healthy restart: always environment: @@ -40,7 +61,7 @@ services: # - --log-level=debug # - --unfinalized-blocks=true healthcheck: - test: ["CMD", "curl", "-f", "http://subquery-node:3000/ready"] + test: ['CMD', 'curl', '-f', 'http://subquery-node:3000/ready'] interval: 3s timeout: 5s retries: 10 @@ -50,9 +71,9 @@ services: ports: - 3000:3000 depends_on: - "postgres": + postgres: condition: service_healthy - "subquery-node": + subquery-node: condition: service_healthy restart: always environment: diff --git a/project.ts b/project.ts index 2a2128bf..00f7ec0e 100644 --- a/project.ts +++ b/project.ts @@ -20,10 +20,10 @@ const project: CosmosProject = { file: "./schema.graphql", }, network: { - // chainId: "agoriclocal", - // endpoint: ["http://host.docker.internal:26657/"], - chainId: "agoric-3", - endpoint: ["https://main-a.rpc.agoric.net:443"], + chainId: "agoriclocal", + endpoint: ["http://host.docker.internal:26657/"], + // chainId: "agoric-3", + // endpoint: ["https://main-a.rpc.agoric.net:443"], chaintypes: new Map([ [ @@ -66,7 +66,7 @@ const project: CosmosProject = { // startBlock: 13017175, // startBlock: 2115669, // Upgrade 8 (launch of Inter Protocol) - startBlock: 7179262, + startBlock: 1020, mapping: { file: "./dist/index.js", diff --git a/scripts/run-chain.sh b/scripts/run-chain.sh new file mode 100755 index 00000000..07516b22 --- /dev/null +++ b/scripts/run-chain.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +. /usr/src/upgrade-test-scripts/env_setup.sh + +# Start the chain in the background +/usr/src/upgrade-test-scripts/start_agd.sh & + +# wait for blocks to start being produced +waitForBlock 1 + +# bring back chain process to foreground +wait diff --git a/scripts/wait-for-blocks.sh b/scripts/wait-for-blocks.sh new file mode 100755 index 00000000..591128dd --- /dev/null +++ b/scripts/wait-for-blocks.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# # Borrowed from https://github.com/DCFoundation/cosmos-proposal-builder/blob/main/.github/workflows/pr.yml#L43-L61 +# # This script waits for the Agoric service to be fully ready before running the tests. +# # It does so by polling the `/abci_info` endpoint of the Agoric service until the last block height is greater than or equal to the target height. + + +timeout 300 bash -c ' +TARGET_HEIGHT='$TARGET_HEIGHT' +SLEEP=10 +echo "Waiting for the Agoric service to be fully ready..." +echo "Target block height: $TARGET_HEIGHT" +RPC=http://localhost:26657 +while true; do + response=$(curl --silent $RPC/abci_info) + height=$(echo $response | jq -r ".result.response.last_block_height | tonumber") + if [ "$height" -ge $TARGET_HEIGHT ]; then + echo "Service is ready! Last block height: $height" + break + else + echo "Waiting for last block height to reach $TARGET_HEIGHT. Current height: $height" + fi + sleep $SLEEP +done +'