Skip to content

Commit

Permalink
local chain setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Dec 10, 2024
1 parent 6d29d5d commit d0fddb2
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 12 deletions.
35 changes: 28 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
postgres:
build:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
[
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions scripts/run-chain.sh
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions scripts/wait-for-blocks.sh
Original file line number Diff line number Diff line change
@@ -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
'

0 comments on commit d0fddb2

Please sign in to comment.