Make wormhole.sh script more robust

* Unify commands between architectures

* Handle errors correctly

* Stream logs to stdout and TRAP exit so killing the process shuts down
  the docker instance
This commit is contained in:
Csongor Kiss 2022-07-01 13:26:16 +00:00
parent 36bdb145bc
commit 69efaf3759
1 changed files with 54 additions and 65 deletions

119
projects/wormhole-local-validator/wormhole.sh Normal file → Executable file
View File

@ -1,68 +1,57 @@
#!/usr/bin/env bash
# Run Guardiand
if [ $(uname -m) = "arm64" ]; then
docker run -d --name guardiand -p 7070:7070 -p 7071:7071 -p 7073:7073 --platform linux/amd64 --hostname guardian-0 --cap-add=IPC_LOCK --entrypoint /guardiand guardian node \
--unsafeDevMode --guardianKey /tmp/bridge.key --publicRPC "[::]:7070" --publicWeb "[::]:7071" --adminSocket /tmp/admin.sock --dataDir /tmp/data \
--ethRPC ws://host.docker.internal:8545 \
--ethContract "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550" \
--bscRPC ws://host.docker.internal:8546 \
--bscContract "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550" \
--polygonRPC ws://host.docker.internal:8545 \
--avalancheRPC ws://host.docker.internal:8545 \
--auroraRPC ws://host.docker.internal:8545 \
--fantomRPC ws://host.docker.internal:8545 \
--oasisRPC ws://host.docker.internal:8545 \
--karuraRPC ws://host.docker.internal:8545 \
--acalaRPC ws://host.docker.internal:8545 \
--klaytnRPC ws://host.docker.internal:8545 \
--celoRPC ws://host.docker.internal:8545 \
--moonbeamRPC ws://host.docker.internal:8545 \
--neonRPC ws://host.docker.internal:8545 \
--terraWS ws://host.docker.internal:8545 \
--terra2WS ws://host.docker.internal:8545 \
--terraLCD https://host.docker.internal:1317 \
--terra2LCD http://host.docker.internal:1317 \
--terraContract terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5 \
--terra2Contract terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5 \
--solanaContract Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o \
--solanaWS ws://host.docker.internal:8900 \
--solanaRPC http://host.docker.internal:8899 \
--algorandIndexerRPC ws://host.docker.internal:8545 \
--algorandIndexerToken "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--algorandAlgodToken "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--algorandAlgodRPC https://host.docker.internal:4001 \
--algorandAppID "4"
else
docker run -d --name guardiand --network host --hostname guardian-0 --cap-add=IPC_LOCK --entrypoint /guardiand guardian node \
--unsafeDevMode --guardianKey /tmp/bridge.key --publicRPC "[::]:7070" --publicWeb "[::]:7071" --adminSocket /tmp/admin.sock --dataDir /tmp/data \
--ethRPC ws://localhost:8545 \
--ethContract "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550" \
--bscRPC ws://localhost:8546 \
--bscContract "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550" \
--polygonRPC ws://localhost:8545 \
--avalancheRPC ws://localhost:8545 \
--auroraRPC ws://localhost:8545 \
--fantomRPC ws://localhost:8545 \
--oasisRPC ws://localhost:8545 \
--karuraRPC ws://localhost:8545 \
--acalaRPC ws://localhost:8545 \
--klaytnRPC ws://localhost:8545 \
--celoRPC ws://localhost:8545 \
--moonbeamRPC ws://localhost:8545 \
--neonRPC ws://localhost:8545 \
--terraWS ws://localhost:8545 \
--terra2WS ws://localhost:8545 \
--terraLCD https://terra-terrad:1317 \
--terra2LCD http://localhost:1317 \
--terraContract terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5 \
--terra2Contract terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5 \
--solanaContract Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o \
--solanaWS ws://localhost:8900 \
--solanaRPC http://localhost:8899 \
--algorandIndexerRPC ws://localhost:8545 \
--algorandIndexerToken "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--algorandAlgodToken "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--algorandAlgodRPC https://localhost:4001 \
--algorandAppID "4"
set -euo pipefail
GUARDIAND_FLAGS=
HOST=
TERRAD_HOST=
if [ "$(uname -m)" = "arm64" ]; then
GUARDIAND_FLAGS="-p 7070:7070 -p 7071:7071 -p 7073:7073 --platform linux/amd64"
HOST="host.docker.internal"
TERRAD_HOST="host.docker.internal"
else
GUARDIAND_FLAGS="--network host"
TERRAD_HOST="terra-terrad"
fi
echo "Guardiand Running! To look at logs: \"docker logs guardiand -f\""
function cleanup {
docker kill guardiand 2>/dev/null || true
docker rm guardiand 2>/dev/null || true
}
trap cleanup EXIT
docker run -d --name guardiand $GUARDIAND_FLAGS --hostname guardian-0 --cap-add=IPC_LOCK --entrypoint /guardiand guardian node \
--unsafeDevMode --guardianKey /tmp/bridge.key --publicRPC "[::]:7070" --publicWeb "[::]:7071" --adminSocket /tmp/admin.sock --dataDir /tmp/data \
--ethRPC ws://$HOST:8545 \
--ethContract "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550" \
--bscRPC ws://$HOST:8546 \
--bscContract "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550" \
--polygonRPC ws://$HOST:8545 \
--avalancheRPC ws://$HOST:8545 \
--auroraRPC ws://$HOST:8545 \
--fantomRPC ws://$HOST:8545 \
--oasisRPC ws://$HOST:8545 \
--karuraRPC ws://$HOST:8545 \
--acalaRPC ws://$HOST:8545 \
--klaytnRPC ws://$HOST:8545 \
--celoRPC ws://$HOST:8545 \
--moonbeamRPC ws://$HOST:8545 \
--neonRPC ws://$HOST:8545 \
--terraWS ws://$HOST:8545 \
--terra2WS ws://$HOST:8545 \
--terraLCD https://$TERRAD_HOST:1317 \
--terra2LCD http://$HOST:1317 \
--terraContract terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5 \
--terra2Contract terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5 \
--solanaContract Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o \
--solanaWS ws://$HOST:8900 \
--solanaRPC http://$HOST:8899 \
--algorandIndexerRPC ws://$HOST:8545 \
--algorandIndexerToken "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--algorandAlgodToken "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--algorandAlgodRPC https://$HOST:4001 \
--algorandAppID "4"
docker logs guardiand -f