Add a script to export testnet state

This commit is contained in:
Prathamesh Musale 2025-05-14 11:05:44 +05:30
parent daad25a049
commit b3ebd32499
2 changed files with 32 additions and 12 deletions

28
scripts/export-testnet-state.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
# Note: Needs to be run in a docker container with image testnet cerc/laconicd:local
# Exit on error
set -e
set -u
# Check args
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <testnet-deployment-dir-absolute>"
exit 1
fi
TESTNET_DEPLOYMENT_DIR="$1"
# Create a temporary target directory
OUTPUT_DIR=${TESTNET_DEPLOYMENT_DIR}/export
mkdir -p $OUTPUT_DIR
# Export state from testnet chain
testnet_state_file="$OUTPUT_DIR/testnet-state.json"
docker run -it \
-v ${TESTNET_DEPLOYMENT_DIR}/data/laconicd-data:/root/testnet-deployment/.laconicd \
cerc/laconicd:local bash -c "laconicd export --home /root/testnet-deployment/.laconicd" \
| jq .app_state.onboarding > "$testnet_state_file"
echo "Exported state from testnet to $testnet_state_file"

View File

@ -6,11 +6,11 @@ set -u
# Check args
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <testnet-deployment-dir-absolute>"
echo "Usage: $0 <testnet-state-json-file-path>"
exit 1
fi
TESTNET_DEPLOYMENT_DIR="$1"
TESTNET_STATE_FILE="$1"
MAINNET_GENESIS_DIR=mainnet-genesis
# Create a temporary target directory
@ -18,16 +18,8 @@ mkdir -p $MAINNET_GENESIS_DIR
# --------
# Export state from testnet chain
# Use cerc/laconicd-testnet:local image for testnet laconicd build
testnet_state_file="$MAINNET_GENESIS_DIR/testnet-state.json"
docker run -it \
-v ${TESTNET_DEPLOYMENT_DIR}/data/laconicd-data:/root/testnet-deployment/.laconicd \
cerc/laconicd-testnet:local bash -c "laconicd export --home /root/testnet-deployment/.laconicd" \
| jq .app_state.onboarding > "$testnet_state_file"
echo "Exported state from testnet"
# Copy testnet state file to required dir
cp $TESTNET_STATE_FILE $MAINNET_GENESIS_DIR/testnet-state.json
# --------