diff --git a/scripts/generate-mainnet-genesis.sh b/scripts/generate-mainnet-genesis.sh new file mode 100755 index 0000000..bc24eb2 --- /dev/null +++ b/scripts/generate-mainnet-genesis.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Exit on error +set -e +set -u + +# Check args +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +TESTNET_DEPLOYMENT_DIR="$1" +MAINNET_GENESIS_DIR=mainnet-genesis + +# Create a temporary target directory +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" + +# -------- + +# Run a script with cerc/laconicd:local to generate the genesis file +# with onboarding module state and given allocations +docker run -it \ + -v ./$MAINNET_GENESIS_DIR:/root/.laconicd \ + -v ./scripts:/scripts \ + cerc/laconicd:local bash -c "/scripts/genesis.sh" + +# Copy over the genesis file to output folder +OUTPUT_DIR=output +mkdir -p $OUTPUT_DIR +cp ./$MAINNET_GENESIS_DIR/config/genesis.json $OUTPUT_DIR/genesis.json + +echo "Genesis file for mainnet written to $OUTPUT_DIR/genesis.json" + +# -------- + +# Clean up +echo "Please remove the temporary data directory: sudo rm -rf $MAINNET_GENESIS_DIR" diff --git a/scripts/genesis.sh b/scripts/genesis.sh new file mode 100755 index 0000000..4c5dee0 --- /dev/null +++ b/scripts/genesis.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Exit on error +set -e +set -u + +# Note: Needs to be run in a docker container with image cerc/laconicd:local + +CHAINID=${CHAINID:-"laconic-mainnet"} +MONIKER=${MONIKER:-"mainnet-node"} +NODE_HOME="/root/.laconicd" + +testnet_state_file="$NODE_HOME/testnet-state.json" +mainnet_genesis_file="$NODE_HOME/config/genesis.json" + +laconicd config set client chain-id $CHAINID +laconicd init $MONIKER --chain-id $CHAINID --default-denom alnt + +# Import required state +jq --slurpfile nested $testnet_state_file '.app_state.auth = $nested[0].app_state' "$mainnet_genesis_file" > tmp.$$.json && mv tmp.$$.json "$mainnet_genesis_file" +jq --slurpfile nested $testnet_state_file '.consensus.auth = $nested[0].consensus' "$mainnet_genesis_file" > tmp.$$.json && mv tmp.$$.json "$mainnet_genesis_file" + +# Update any module params if required here + +# TODO: Perform alps allocations + +# Ensure that resulting genesis file is valid +laconicd genesis validate