diff --git a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/export-state.sh b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/export-state.sh deleted file mode 100755 index 279d56d..0000000 --- a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/export-state.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# Exit on error -set -e -set -u - -# Run in docker container with mounted stage1 data - -NODE_HOME="$HOME/.laconicd" -stage1_state="$NODE_HOME/stage1-state.json" - -# Export state -laconicd export | jq > $stage1_state - -# Remove data but keep keys -laconicd cometbft unsafe-reset-all - -rm -r $NODE_HOME/config/gentx -rm $NODE_HOME/config/genesis.json diff --git a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage2-genesis.sh b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage2-genesis.sh index 340d864..e7b3aa2 100755 --- a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage2-genesis.sh +++ b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage2-genesis.sh @@ -45,13 +45,19 @@ remove_module_accounts () { jq --arg NEW_SUPPLY "$new_supply" '(.app_state.bank.supply[] | select(.denom == "alnt") | .amount) |= $NEW_SUPPLY' $stage2_genesis_file > tmp.$$.json && mv tmp.$$.json $stage2_genesis_file } +# Remove existing data but keep keys +laconicd cometbft unsafe-reset-all + +# Remove existing genesis file and gentxs +rm -r $NODE_HOME/config/gentx || true +rm $stage2_genesis_file || true + # Initialize node with given chain id and moniker laconicd config set client chain-id $CHAINID laconicd init $STAGE2_MONIKER --chain-id $CHAINID --default-denom alnt # Import required module state jq --slurpfile nested $stage1_state '.app_state.auth = $nested[0].app_state.auth' "$stage2_genesis_file" > tmp.$$.json && mv tmp.$$.json "$stage2_genesis_file" -jq --slurpfile nested $stage1_state '.app_state.auction = $nested[0].app_state.auction' "$stage2_genesis_file" > tmp.$$.json && mv tmp.$$.json "$stage2_genesis_file" jq --slurpfile nested $stage1_state '.app_state.bank = $nested[0].app_state.bank' "$stage2_genesis_file" > tmp.$$.json && mv tmp.$$.json "$stage2_genesis_file" jq --slurpfile nested $stage1_state '.app_state.bond = $nested[0].app_state.bond' "$stage2_genesis_file" > tmp.$$.json && mv tmp.$$.json "$stage2_genesis_file" jq --slurpfile nested $stage1_state '.app_state.onboarding = $nested[0].app_state.onboarding' "$stage2_genesis_file" > tmp.$$.json && mv tmp.$$.json "$stage2_genesis_file" diff --git a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/initialize-stage2.sh b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/initialize-stage2.sh index d4fadfd..401af73 100755 --- a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/initialize-stage2.sh +++ b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/initialize-stage2.sh @@ -3,25 +3,23 @@ # Exit on error set -e +# Prerequisite: stage1 exported state present at $STAGE2_DEPLOYMENT/data/laconicd-data/stage1-state.json + # Check args if [ "$#" -lt 2 ]; then - echo "Usage: $0 [node-staking-amount]" - echo "Example: $0 /srv/stage2-deployment laconic_9000-2 1000000000000000" + echo "Usage: $0 [node-staking-amount]" + echo "Example: $0 /srv/stage2-deployment laconic_9000-2 LaconicStage2 os 1000000000000000" exit 1 fi STAGE2_DEPLOYMENT=$1 CHAINID=$2 -STAKING_AMOUNT=$3 - -# Export state from current data -docker run -it \ - -v $STAGE2_DEPLOYMENT/data/laconicd-data:/root/.laconicd \ - -v ./scripts:/scripts \ - cerc/laconicd-stage1:local bash -c "/scripts/export-state.sh" +MONIKER=$3 +KEYRING=$4 +STAKING_AMOUNT=$5 # Generate genesis file for state2 chain and init node docker run -it \ -v $STAGE2_DEPLOYMENT/data/laconicd-data:/root/.laconicd \ -v ./scripts:/scripts \ - cerc/laconicd:local bash -c "CHAINID=$CHAINID MONIKER=LaconicStage2 STAKING_AMOUNT=$STAKING_AMOUNT /scripts/generate-stage2-genesis.sh" + cerc/laconicd:local bash -c "CHAINID=$CHAINID MONIKER=$MONIKER KEYRING=$KEYRING STAKING_AMOUNT=$STAKING_AMOUNT /scripts/generate-stage2-genesis.sh"