diff --git a/docker-compose.yml b/docker-compose.yml index ef25b19..9502913 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,7 @@ services: environment: - SNAPSHOT_FILE=babylon.tar.gz - RPC_URL=https://rpc.devnet.babylonlabs.io + - GENESIS_PATH="" volumes: - ./scripts/init_master.sh:/scripts/init_master.sh - ./snapshots:/snapshots @@ -47,6 +48,7 @@ services: " environment: - RPC_URL=https://rpc.devnet.babylonlabs.io + - GENESIS_PATH="" volumes: - ./scripts/init_follower.sh:/scripts/init_follower.sh - ./babylond_data_follower:/root/.babylond diff --git a/scripts/init_follower.sh b/scripts/init_follower.sh index 92e3eb7..c19f90e 100755 --- a/scripts/init_follower.sh +++ b/scripts/init_follower.sh @@ -30,11 +30,22 @@ apt-get install -y \ lsof \ jq -# Fetch the genesis file from remote RPC and store it temporarily -echo "Fetching genesis file from $RPC_URL" -GENESIS_TEMP=$(curl -s "$RPC_URL/genesis" | jq '.result.genesis') +# Load genesis from a local file or fetch from RPC as before +if [ -n "$GENESIS_PATH" ]; then + echo "Loading genesis file from $GENESIS_PATH" + if [ -f "$GENESIS_PATH" ]; then + GENESIS_TEMP=$(jq '.' "$GENESIS_PATH") + else + echo "Error: File not found at $GENESIS_PATH" + exit 1 + fi +else + echo "Fetching genesis file from $RPC_URL" + GENESIS_TEMP=$(curl -s "$RPC_URL/genesis" | jq '.result.genesis') +fi + if [ -z "$GENESIS_TEMP" ]; then - echo "Error: Failed to fetch genesis file" + echo "Error: Failed to load genesis" exit 1 fi diff --git a/scripts/init_master.sh b/scripts/init_master.sh index bec4b2d..ecdd3cb 100755 --- a/scripts/init_master.sh +++ b/scripts/init_master.sh @@ -45,11 +45,22 @@ apt-get install -y \ jq -# Fetch the genesis file from remote RPC and store it temporarily -echo "Fetching genesis file from $RPC_URL" -GENESIS_TEMP=$(curl -s "$RPC_URL/genesis" | jq '.result.genesis') +# Load genesis from a local file or fetch from RPC as before +if [ -n "$GENESIS_PATH" ]; then + echo "Loading genesis file from $GENESIS_PATH" + if [ -f "$GENESIS_PATH" ]; then + GENESIS_TEMP=$(jq '.' "$GENESIS_PATH") + else + echo "Error: File not found at $GENESIS_PATH" + exit 1 + fi +else + echo "Fetching genesis file from $RPC_URL" + GENESIS_TEMP=$(curl -s "$RPC_URL/genesis" | jq '.result.genesis') +fi + if [ -z "$GENESIS_TEMP" ]; then - echo "Error: Failed to fetch genesis file" + echo "Error: Failed to load genesis" exit 1 fi