Accept stage1 allocations file as input
This commit is contained in:
parent
a1540bda67
commit
85c2079ca4
@ -5,15 +5,14 @@ set -e
|
||||
set -u
|
||||
|
||||
# Check args
|
||||
if [ "$#" -ne 3 ]; then
|
||||
echo "Usage: $0 <stage1-participants-json> <participant-allocation> <validator-allocation>"
|
||||
echo "Example: $0 ./stage-participants.json 1000000 1000000000000"
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <stage1-participants-json> <stage1-allocations-json>"
|
||||
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"
|
||||
|
||||
# --------
|
||||
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user