Add a script to generate genesis file using given allocation amounts #10
@ -7,6 +7,11 @@ services:
|
|||||||
TEST_AUCTION_ENABLED: ${TEST_AUCTION_ENABLED:-false}
|
TEST_AUCTION_ENABLED: ${TEST_AUCTION_ENABLED:-false}
|
||||||
TEST_REGISTRY_EXPIRY: ${TEST_REGISTRY_EXPIRY:-false}
|
TEST_REGISTRY_EXPIRY: ${TEST_REGISTRY_EXPIRY:-false}
|
||||||
ONBOARDING_ENABLED: ${ONBOARDING_ENABLED:-false}
|
ONBOARDING_ENABLED: ${ONBOARDING_ENABLED:-false}
|
||||||
|
STAKING_AMOUNT: ${STAKING_AMOUNT:-1000000000000000}
|
||||||
|
AUTHORITY_AUCTION_ENABLED: ${AUTHORITY_AUCTION_ENABLED}
|
||||||
|
AUTHORITY_AUCTION_COMMITS_DURATION: ${AUTHORITY_AUCTION_COMMITS_DURATION}
|
||||||
|
AUTHORITY_AUCTION_REVEALS_DURATION: ${AUTHORITY_AUCTION_REVEALS_DURATION}
|
||||||
|
AUTHORITY_GRACE_PERIOD: ${AUTHORITY_GRACE_PERIOD}
|
||||||
GENESIS_FILE: /var/tmp/genesis.json
|
GENESIS_FILE: /var/tmp/genesis.json
|
||||||
volumes:
|
volumes:
|
||||||
- laconicd-data:/root/.laconicd
|
- laconicd-data:/root/.laconicd
|
||||||
|
@ -96,9 +96,23 @@ Instructions for running a laconicd fixturenet along with registry CLI and conso
|
|||||||
```bash
|
```bash
|
||||||
# Optional
|
# Optional
|
||||||
|
|
||||||
# Set to true to enable adding participants functionality of the onboarding module
|
# Set to true to enable adding participants functionality of the onboarding module (default: false)
|
||||||
# (default: false)
|
|
||||||
ONBOARDING_ENABLED=
|
ONBOARDING_ENABLED=
|
||||||
|
|
||||||
|
# Staking amount to use for the default validator account (default: 1000000000000000)
|
||||||
|
STAKING_AMOUNT=
|
||||||
|
|
||||||
|
# Enable authority auctions (default: false)
|
||||||
|
AUTHORITY_AUCTION_ENABLED=true
|
||||||
|
|
||||||
|
# Authority auctions commits duration (in secs) (default: 24hrs)
|
||||||
|
AUTHORITY_AUCTION_COMMITS_DURATION=3600
|
||||||
|
|
||||||
|
# Authority auctions reveals duration (in secs) (default: 24hrs)
|
||||||
|
AUTHORITY_AUCTION_REVEALS_DURATION=3600
|
||||||
|
|
||||||
|
# Authority grace period (set bond to authority within this) (in secs) (default: 2 * 24hrs)
|
||||||
|
AUTHORITY_GRACE_PERIOD=7200
|
||||||
```
|
```
|
||||||
|
|
||||||
* Inside the `laconic-console-deployment` deployment directory, open `config.env` file and set following env variables:
|
* Inside the `laconic-console-deployment` deployment directory, open `config.env` file and set following env variables:
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit on error
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
# Check args
|
||||||
|
if [ "$#" -ne 3 ]; then
|
||||||
|
echo "Usage: $0 <stage0-deployment-dir-absolute> <participant-allocation> <validator-allocation>"
|
||||||
|
echo "Example: $0 /home/user/stage0-deployment 1000000 1000000000000"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
STAGE0_DEPLOYMENT_DIR="$1"
|
||||||
|
PARTICIPANT_ALLOCATION="$2"
|
||||||
|
VALIDATOR_ALLOCATION="$3"
|
||||||
|
STAGE1_GENESIS_DIR=stage1-genesis
|
||||||
|
|
||||||
|
# Create a temporary target directory
|
||||||
|
mkdir -p $STAGE1_GENESIS_DIR
|
||||||
|
|
||||||
|
# --------
|
||||||
|
|
||||||
|
# Export onboarding module state from stage0 laconicd chain
|
||||||
|
|
||||||
|
onboarding_state_file="$STAGE1_GENESIS_DIR/stage0-onboarding-state.json"
|
||||||
|
docker run -it \
|
||||||
|
-v ${STAGE0_DEPLOYMENT_DIR}/data/laconicd-data:/root/stage0-deployment/.laconicd \
|
||||||
|
cerc/laconicd:local bash -c "laconicd export --home /root/stage0-deployment/.laconicd" \
|
||||||
|
| jq .app_state.onboarding > "$onboarding_state_file"
|
||||||
|
|
||||||
|
stage0_participants=$(cat "$onboarding_state_file" | jq .participants)
|
||||||
|
|
||||||
|
echo "Exported onboarding module state from stage 0 chain"
|
||||||
|
|
||||||
|
# --------
|
||||||
|
|
||||||
|
# For each participant, using ETH account holdings, figure out balance allocation for stage1
|
||||||
|
stage1_allocations_file="$STAGE1_GENESIS_DIR/stage1-allocations.json"
|
||||||
|
jq -n --argjson participants "$stage0_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"
|
||||||
|
|
||||||
|
# --------
|
||||||
|
|
||||||
|
# Run a script with cerc/laconicd:local to generate the genesis file
|
||||||
|
# with onboarding module state and given allocations
|
||||||
|
docker run -it \
|
||||||
|
-v ./$STAGE1_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 ./$STAGE1_GENESIS_DIR/config/genesis.json $OUTPUT_DIR/genesis.json
|
||||||
|
|
||||||
|
echo "Genesis file for stage1 written to $OUTPUT_DIR/genesis.json"
|
||||||
|
|
||||||
|
# --------
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
echo "Please remove the temporary data directory: sudo rm -rf $STAGE1_GENESIS_DIR"
|
@ -61,18 +61,18 @@ echo "Calculated allocations for stage 1 chain"
|
|||||||
# Run a script with cerc/laconicd:local to generate the genesis file
|
# Run a script with cerc/laconicd:local to generate the genesis file
|
||||||
# with onboarding module state and given allocations
|
# with onboarding module state and given allocations
|
||||||
docker run -it \
|
docker run -it \
|
||||||
-v ./stage1-genesis:/root/.laconicd \
|
-v ./$STAGE1_GENESIS_DIR:/root/.laconicd \
|
||||||
-v ./scripts:/scripts \
|
-v ./scripts:/scripts \
|
||||||
cerc/laconicd:local bash -c "/scripts/genesis.sh"
|
cerc/laconicd:local bash -c "/scripts/genesis.sh"
|
||||||
|
|
||||||
# Copy over the genesis file to output folder
|
# Copy over the genesis file to output folder
|
||||||
OUTPUT_DIR=output
|
OUTPUT_DIR=output
|
||||||
mkdir -p $OUTPUT_DIR
|
mkdir -p $OUTPUT_DIR
|
||||||
cp ./stage1-genesis/config/genesis.json $OUTPUT_DIR/genesis.json
|
cp ./$STAGE1_GENESIS_DIR/config/genesis.json $OUTPUT_DIR/genesis.json
|
||||||
|
|
||||||
echo "Genesis file for stage1 written to $OUTPUT_DIR/genesis.json"
|
echo "Genesis file for stage1 written to $OUTPUT_DIR/genesis.json"
|
||||||
|
|
||||||
# --------
|
# --------
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
echo "Please remove the temporary data directory: sudo rm -rf stage1-genesis"
|
echo "Please remove the temporary data directory: sudo rm -rf $STAGE1_GENESIS_DIR"
|
||||||
|
Loading…
Reference in New Issue
Block a user