laconicd-stack/scripts/generate-mainnet-genesis.sh
shreerang 3d7ba45796 Add playbook to send create-validator tx for subsequent nodes (#3)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e of cerc-io/laconicd#66
- Use calculated staking amount for running validator nodes

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Reviewed-on: #3
Co-authored-by: shreerang <shreerang@noreply.git.vdb.to>
Co-committed-by: shreerang <shreerang@noreply.git.vdb.to>
2025-05-16 09:54:09 +00:00

81 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Exit on error
set -e
set -u
# Check args
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <testnet-state-json-file-path> <lps-distribution-json-file-path>"
exit 1
fi
TESTNET_STATE_FILE="$1"
LPS_DISTRIBUTION_FILE="$2"
MAINNET_GENESIS_DIR=mainnet-genesis
OUTPUT_DIR=output
if ! jq empty $LPS_DISTRIBUTION_FILE >/dev/null 2>&1; then
echo "$LPS_DISTRIBUTION_FILE is not a valid JSON"
exit 1
fi
# Create a required target directories
mkdir -p $MAINNET_GENESIS_DIR
mkdir -p $OUTPUT_DIR
# --------
# Copy testnet state file and distribution to required dir
cp $TESTNET_STATE_FILE $MAINNET_GENESIS_DIR/testnet-state.json
cp $LPS_DISTRIBUTION_FILE $MAINNET_GENESIS_DIR/distribution.json
# --------
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Initializing a new empty chain with chain-id $CHAIN_ID..."
docker run \
-v ./$MAINNET_GENESIS_DIR:/root/.laconicd \
-v $script_dir:/scripts \
-e "CHAIN_ID=$CHAIN_ID" \
cerc/laconicd:local bash -c "/scripts/init-mainnet.sh"
# --------
# Install required bech32 dependency
# Define and create venv if not exists
venv_dir="$PWD/venv"
if [ ! -d "$venv_dir" ]; then
python3 -m venv "$venv_dir"
"$venv_dir/bin/pip" install bech32
fi
echo "Carrying over state from testnet state to mainnet genesis..."
"$venv_dir/bin/python" "$script_dir/transfer-state.py"
# Clean up venv
rm -rf "$venv_dir"
# --------
# Run a script with cerc/laconicd:local to generate the genesis file
# with onboarding module state and given allocations
echo "Performing alps allocations..."
docker run \
-v ./$MAINNET_GENESIS_DIR:/root/.laconicd \
-v $script_dir:/scripts \
-e "CHAIN_ID=$CHAIN_ID" \
-e "EARLY_SUPPORTS_ACC_ADDRESS=$EARLY_SUPPORTS_ACC_ADDRESS" \
cerc/laconicd:local bash -c "/scripts/genesis.sh"
# Copy over the genesis file to output folder
cp ./$MAINNET_GENESIS_DIR/config/genesis.json $OUTPUT_DIR/genesis.json
echo "Genesis file for mainnet written to $OUTPUT_DIR/genesis.json"
# --------
# Clean up
rm -rf $MAINNET_GENESIS_DIR