Skip to content

Commit cad130e

Browse files
committed
chore(testnet): Add more logs and double check for contracts to be deployed already
1 parent 740a947 commit cad130e

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

setup-test-network.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,34 @@ timeout 300 bash -c 'until docker ps | grep graph-node | grep -q healthy; do sle
2525
echo "Deploying contract services..."
2626
docker compose up -d graph-contracts
2727
# Wait for contracts to be deployed
28-
sleep 20
28+
timeout 300 bash -c 'until docker ps -a | grep graph-contracts | grep -q "Exited (0)"; do sleep 5; done'
29+
30+
# Verify the contracts have code, usually when starting from scratch
31+
# there could be timing issues between contract deployment
32+
# and when transaction gets approved and contract address gets available
33+
# in the network.
34+
# So bellow is a kind of double check
35+
# Extract a few key contract addresses from the contracts.json file
36+
graph_token_address=$(jq -r '."1337".GraphToken.address' contracts.json)
37+
controller_address=$(jq -r '."1337".Controller.address' contracts.json)
38+
39+
echo "Checking GraphToken contract at $graph_token_address"
40+
code=$(docker exec chain cast code $graph_token_address --rpc-url http://localhost:8545)
41+
if [ -z "$code" ] || [ "$code" == "0x" ]; then
42+
echo "ERROR: GraphToken contract has no code!"
43+
exit 1
44+
fi
45+
echo "GraphToken contract verified."
46+
47+
echo "Checking Controller contract at $controller_address"
48+
code=$(docker exec chain cast code $controller_address --rpc-url http://localhost:8545)
49+
if [ -z "$code" ] || [ "$code" == "0x" ]; then
50+
echo "ERROR: Controller contract has no code!"
51+
exit 1
52+
fi
53+
echo "Controller contract verified."
54+
echo "Contract deployment successful."
55+
2956
docker compose up -d tap-contracts
3057

3158
echo "Starting indexer services..."
@@ -44,6 +71,7 @@ timeout 300 bash -c 'until docker ps | grep indexer-agent | grep -q healthy; do
4471

4572
echo "Starting TAP services..."
4673
docker compose up -d tap-aggregator
74+
# sleep 10
4775
# tap-scrow-manager requires subgraph-deploy
4876
# docker compose up -d tap-escrow-manager
4977
sleep 10

0 commit comments

Comments
 (0)