Skip to content

Commit

Permalink
load from genesis file
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar955 committed Nov 12, 2024
1 parent 760a668 commit c233247
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 15 additions & 4 deletions scripts/init_follower.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 15 additions & 4 deletions scripts/init_master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c233247

Please sign in to comment.