From 85c2079ca4d260a85c44e604a7fad6521c020ac7 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Mon, 19 Aug 2024 12:48:15 +0530 Subject: [PATCH] Accept stage1 allocations file as input --- .../generate-stage1-genesis-from-json.sh | 28 +++++-------------- .../fixturenet-laconicd/scripts/genesis.sh | 4 +-- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage1-genesis-from-json.sh b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage1-genesis-from-json.sh index af888ee..d9f4ff2 100755 --- a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage1-genesis-from-json.sh +++ b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/generate-stage1-genesis-from-json.sh @@ -5,15 +5,14 @@ set -e set -u # Check args -if [ "$#" -ne 3 ]; then - echo "Usage: $0 " - echo "Example: $0 ./stage-participants.json 1000000 1000000000000" +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + echo "Example: $0 ./stage-participants.json ./stage1-allocations.json" exit 1 fi STAGE1_PARTICIPANTS_FILE="$1" -PARTICIPANT_ALLOCATION="$2" -VALIDATOR_ALLOCATION="$3" +STAGE1_ALLOCATIONS_FILE="$2" STAGE1_GENESIS_DIR=stage1-genesis # Create a temporary target directory @@ -23,24 +22,11 @@ mkdir -p $STAGE1_GENESIS_DIR # Copy over the stage1-participants json file for genesis.sh to use cp $STAGE1_PARTICIPANTS_FILE "$STAGE1_GENESIS_DIR/stage1-participants.json" - echo "Copied over stage1 participants json file to mount dir" -# -------- - -# For each participant, allocate balance on stage1 according to role -stage1_participants=$(cat "$STAGE1_PARTICIPANTS_FILE") -stage1_allocations_file="$STAGE1_GENESIS_DIR/stage1-allocations.json" -jq -n --argjson participants "$stage1_participants" --arg participant_allocation "$PARTICIPANT_ALLOCATION" --arg validator_allocation "$VALIDATOR_ALLOCATION" ' -[ - $participants[] | - { - cosmos_address: .cosmos_address, - balance: (if .role == "validator" then $validator_allocation else $participant_allocation end) - } -]' > $stage1_allocations_file - -echo "Calculated allocations for stage 1 chain" +# Copy over the stage1-participants json file for genesis.sh to use +cp $STAGE1_ALLOCATIONS_FILE "$STAGE1_GENESIS_DIR/stage1-allocations.json" +echo "Copied over stage1 allocations json file to mount dir" # -------- diff --git a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/genesis.sh b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/genesis.sh index 3b65855..7ebaccb 100755 --- a/stack-orchestrator/stacks/fixturenet-laconicd/scripts/genesis.sh +++ b/stack-orchestrator/stacks/fixturenet-laconicd/scripts/genesis.sh @@ -17,8 +17,7 @@ stage1_genesis_file="$NODE_HOME/config/genesis.json" laconicd init $STAGE1_MONIKER --chain-id $CHAINID --default-denom alnt # Update onboarding module state with participants -participants=$(jq -c '.' $stage1_participants_file) -jq --argjson p "$participants" '.app_state.onboarding.participants = $p' "$stage1_genesis_file" > tmp.$$.json && mv tmp.$$.json "$stage1_genesis_file" +jq --argfile p "$stage1_participants_file" '.app_state.onboarding.participants = $p' "$stage1_genesis_file" > tmp.$$.json && mv tmp.$$.json "$stage1_genesis_file" # Disable bank module transfers # jq '.app_state["bank"]["params"]["default_send_enabled"]=false' "$stage1_genesis_file" > tmp.$$.json && mv tmp.$$.json "$stage1_genesis_file" @@ -31,6 +30,7 @@ jq '.app_state["slashing"]["params"]["signed_blocks_window"]="2400"' "$stage1_ge jq '.app_state["slashing"]["params"]["min_signed_per_window"]="0.5"' "$stage1_genesis_file" > tmp.$$.json && mv tmp.$$.json "$stage1_genesis_file" # Read and assign allocations +echo "Adding genesis accounts with allocations..." jq -c '.[]' "$stage1_allocations_file" | while IFS= read -r line; do cosmos_address=$(jq -r '.cosmos_address' <<< "$line") balance=$(jq -r '.balance' <<< "$line")