Update genesis generation to use add-genesis-lockup-account command

This commit is contained in:
Prathamesh Musale 2025-05-16 14:29:00 +05:30
parent fbdb598e79
commit c31ed033ef
5 changed files with 28 additions and 29 deletions

View File

@ -43,10 +43,13 @@
- Copy over the exported `testnet-state.json` file to target machine
- Copy over the LPS lockup distribution `distribution.json` file to target machine
- Set envs:
```bash
export EXPORTED_STATE_PATH=<absolute-path-to-exported-testnet-state-json>
export LPS_DISTRIBUTION_PATH=<absolute-path-to-distribution-json>
export EARLY_SUPPORTS_ACC_ADDR=<account-address-controlled-by-laconic-foundation>
```
@ -59,7 +62,7 @@
- Run playbook to use exported state for generating mainnet genesis:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/generate-genesis.yml -e "exported_state_path=$EXPORTED_STATE_PATH" -e "early_supports_acc_address=$EARLY_SUPPORTS_ACC_ADDR"
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/generate-genesis.yml -e "exported_state_path=$EXPORTED_STATE_PATH" -e "lps_distribution_path=$LPS_DISTRIBUTION_PATH" -e "early_supports_acc_address=$EARLY_SUPPORTS_ACC_ADDR"
```
- Genesis file will be generated in output directory along with a file specifying the staking amount

View File

@ -9,9 +9,10 @@
ansible.builtin.shell:
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd setup-repositories --git-ssh --pull"
# TODO: Add a flag to control force rebuild
- name: Build containers
ansible.builtin.shell:
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers"
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers --force-rebuild"
- name: Copy exported testnet state file
ansible.builtin.copy:
@ -22,7 +23,7 @@
- block:
- name: Run script to generate genesis file
ansible.builtin.shell:
cmd: "CHAIN_ID={{ cerc_chain_id }} EARLY_SUPPORTS_ACC_ADDRESS={{ early_supports_acc_address }} {{ ansible_env.HOME }}/cerc/laconicd-stack/scripts/generate-mainnet-genesis.sh {{ ansible_env.HOME }}/cerc/laconicd-stack/testnet-state.json"
cmd: "CHAIN_ID={{ cerc_chain_id }} EARLY_SUPPORTS_ACC_ADDRESS={{ early_supports_acc_address }} {{ ansible_env.HOME }}/cerc/laconicd-stack/scripts/generate-mainnet-genesis.sh {{ ansible_env.HOME }}/cerc/laconicd-stack/testnet-state.json {{ lps_distribution_path }}"
chdir: "{{ lookup('env', 'PWD') }}"
always:
- name: Clean up temporary genesis directory

View File

@ -33,7 +33,7 @@
- name: Build container images
shell: |
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers --force-rebuild
- name: Create deployment spec file
shell: |

View File

@ -5,23 +5,30 @@ set -e
set -u
# Check args
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <testnet-state-json-file-path>"
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <testnet-state-json-file-path> <lps-distribution-json-file-path>"
exit 1
fi
TESTNET_STATE_FILE="$1"
LPS_DISTRIBUTION_FILE="$2"
MAINNET_GENESIS_DIR=mainnet-genesis
OUTPUT_DIR=output
if ! jq empty $LPS_DISTRIBUTION_FILE >/dev/null 2>&1; then
echo "$LPS_DISTRIBUTION_FILE is not a valid JSON"
exit 1
fi
# Create a required target directories
mkdir -p $MAINNET_GENESIS_DIR
mkdir -p $OUTPUT_DIR
# --------
# Copy testnet state file to required dir
# Copy testnet state file and distribution to required dir
cp $TESTNET_STATE_FILE $MAINNET_GENESIS_DIR/testnet-state.json
cp $LPS_DISTRIBUTION_FILE $MAINNET_GENESIS_DIR/distribution.json
# --------
@ -40,8 +47,8 @@ docker run \
# Define and create venv if not exists
venv_dir="$PWD/venv"
if [ ! -d "$venv_dir" ]; then
python3 -m venv "$venv_dir"
"$venv_dir/bin/pip" install bech32
python3 -m venv "$venv_dir"
"$venv_dir/bin/pip" install bech32
fi
echo "Carrying over state from testnet state to mainnet genesis..."

View File

@ -16,14 +16,15 @@ if [ -z "$EARLY_SUPPORTS_ACC_ADDRESS" ]; then
exit 1
fi
# alps allocations
# Total supply: 129600 * 10^18 alps
EARLY_SUPPORTS_ALLOC="12960000000000000000000" # Early supports: 12960 * 10^18 alps (10% of total supply)
LOCKUP_ALLOC="116640000000000000000000" # Lockup: 116640 * 10^18 alps (90% of total supply)
# lps allocations
# Total supply: 129600 lps
EARLY_SUPPORTS_ALLOC="25920" # Early supports: 25920 lps (20% of total supply)
LOCKUP_ALLOC="103680" # Lockup: 103680 lps (80% of total supply)
LPS_LOCKUP_MODULE_ACCOUNT="lps_lockup"
LPS_DENOM="alps"
LPS_DENOM="lps"
testnet_state_file="$NODE_HOME/testnet-state.json"
distribution_file="$NODE_HOME/distribution.json"
mainnet_genesis_file="$NODE_HOME/config/genesis.json"
# Update any module params if required here
@ -43,22 +44,9 @@ update_genesis '.app_state["gov"]["params"]["expedited_threshold"]="1.0000000000
# Set normal threshold to 99% since it needs to be lesser than expedited threshold
update_genesis '.app_state["gov"]["params"]["threshold"]="0.990000000000000000"'
# Perform alps allocations
# Perform lps allocations
laconicd genesis add-genesis-account $EARLY_SUPPORTS_ACC_ADDRESS $EARLY_SUPPORTS_ALLOC$LPS_DENOM --keyring-backend $KEYRING --append
# Use zero address to add an account for lps_lockup
zero_address="laconic1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqklcls0"
laconicd genesis add-genesis-account $zero_address $LOCKUP_ALLOC$LPS_DENOM --keyring-backend $KEYRING --module-name $LPS_LOCKUP_MODULE_ACCOUNT
# Update the lps_lockup address in bank module state
lps_lockup_address=$(jq -r '.app_state.auth.accounts[] | select(.name == "lps_lockup") | .base_account.address' $HOME/.laconicd/config/genesis.json)
jq --arg old "$zero_address" --arg new "$lps_lockup_address" \
'.app_state.bank.balances |= map(if .address == $old then .address = $new else . end)' "$mainnet_genesis_file" > tmp.$$.json \
&& mv tmp.$$.json "$mainnet_genesis_file"
jq '(.app_state.auth.accounts[] | select(.name == "lps_lockup") | .permissions) = []' "$mainnet_genesis_file" > tmp.$$.json \
&& mv tmp.$$.json "$mainnet_genesis_file"
# TODO: Dump JSON for allocations in LPS_LOCKUP_MODULE_ACCOUNT state
laconicd genesis add-genesis-lockup-account lps_lockup $distribution_file $LOCKUP_ALLOC$LPS_DENOM
# Ensure that resulting genesis file is valid
laconicd genesis validate