Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa861bcf34 | ||
|
|
1154cfd0bc |
+2
-2
@@ -1,5 +1,5 @@
|
||||
*-deployment
|
||||
*-spec.yml
|
||||
|
||||
# Validator playbook vars
|
||||
playbooks/validator/validator-vars.yml
|
||||
# Playbook vars
|
||||
playbooks/first-validator/first-validator-vars.yml
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
# laconicd-stack
|
||||
|
||||
- Follow [run-first-validator.md](./docs/run-first-validator.md) to run the first validator node
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
# Run First Validator Node
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [ansible](playbooks/README.md#ansible-installation)
|
||||
- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install)
|
||||
|
||||
## Generate mainnet genesis file
|
||||
|
||||
- Fetch the stack in machine where the testnet chain node is running
|
||||
|
||||
```bash
|
||||
laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
|
||||
```
|
||||
|
||||
- Run script to export state from testnet chain
|
||||
|
||||
```bash
|
||||
~/cerc/laconicd-stack/scripts/export-testnet-state.sh <path-to-testnet-deployment>
|
||||
```
|
||||
|
||||
- The file will be generated in `<path-to-testnet-deployment>/export/testnet-state.json`
|
||||
|
||||
- If mainnet node will be setup in new machine, fetch the stack again
|
||||
|
||||
```bash
|
||||
laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
|
||||
```
|
||||
|
||||
- Copy over the exported `testnet-state.json` file to target machine
|
||||
|
||||
- Set envs
|
||||
|
||||
```bash
|
||||
export EXPORTED_STATE_PATH=<absolute-path-to-exported-testnet-state-json>
|
||||
export EARLY_SUPPORTS_ACC_ADDR=<account-address-controlled-by-laconic-foundation>
|
||||
```
|
||||
|
||||
- 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"
|
||||
```
|
||||
|
||||
- Genesis file will be generated in output directory along with a file specifying the staking amount
|
||||
|
||||
```bash
|
||||
# List files in output directory - genesis.json and staking-amount.json
|
||||
ls -l output
|
||||
```
|
||||
|
||||
## Run node
|
||||
|
||||
<!-- TODO: Add steps to get private key of validator account from laconic testnet -->
|
||||
|
||||
- Copy the example variables file:
|
||||
```bash
|
||||
cp ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml
|
||||
```
|
||||
|
||||
- Update `~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml` with required values:
|
||||
|
||||
```bash
|
||||
# Private key of the existing account in hex format (required for gentx)
|
||||
pvt_key: ""
|
||||
|
||||
# Path to the generated mainnet genesis file
|
||||
# Use the absolute path of generated output directory in the previous steps
|
||||
genesis_file: "<absolute-path-to-generated-output-dir>/genesis.json"
|
||||
|
||||
# Path to staking-amount.json generated in previous steps
|
||||
staking_amount_file: "<absolute-path-to-generated-output-dir>/staking-amount.json"
|
||||
|
||||
# Set custom moniker for the node
|
||||
cerc_moniker: "LaconicMainnetNode"
|
||||
|
||||
# Set desired key name
|
||||
key_name: "laconic-validator"
|
||||
```
|
||||
|
||||
- Export the data directory and mainnet deployment directory as environment variables:
|
||||
|
||||
```bash
|
||||
# Parent directory where the deployment directory will live
|
||||
export DATA_DIRECTORY=
|
||||
|
||||
# Set mainnet deployment directory
|
||||
# for eg: mainnet-laconicd-deployment
|
||||
export MAINNET_DEPLOYMENT_DIR=
|
||||
```
|
||||
|
||||
- Run ansible playbook to submit the gentx and run the node:
|
||||
|
||||
```bash
|
||||
ansible-playbook -i localhost, -c local playbooks/first-validator/run-first-validator.yml
|
||||
```
|
||||
|
||||
- Check logs to ensure that node is running:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR logs laconicd -f
|
||||
```
|
||||
|
||||
## Publish Genesis File and Node Address
|
||||
|
||||
- Copy the genesis file to [genesis](./genesis) folder:
|
||||
|
||||
```bash
|
||||
sudo cp $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/genesis.json ./genesis/mainnet-genesis.json
|
||||
```
|
||||
|
||||
- Get your node's address:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'echo $(laconicd cometbft show-node-id)@YOUR_PUBLIC_IP_ADDRESS:26656'
|
||||
```
|
||||
|
||||
- Add your node's address to [node-addresses.yml](./node-addresses.yml)
|
||||
|
||||
- Submit a PR with this genesis file and node address so that it is available to other validators
|
||||
@@ -0,0 +1,4 @@
|
||||
# Add your node addresses here
|
||||
# Example:
|
||||
# - node-1-id@node-1-host:26656
|
||||
# - node-2-id@node-2-host:26656
|
||||
+2
-10
@@ -1,6 +1,4 @@
|
||||
# playbooks
|
||||
|
||||
## Ansible Installation
|
||||
# Ansible Installation
|
||||
|
||||
- Install [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-and-upgrading-ansible-with-pip)
|
||||
|
||||
@@ -28,7 +26,7 @@
|
||||
|
||||
- Set the `LANG` variable to en_US.UTF-8:
|
||||
|
||||
```
|
||||
```bash
|
||||
LANG="en_US.UTF-8"
|
||||
```
|
||||
|
||||
@@ -42,9 +40,3 @@
|
||||
ansible --version
|
||||
# ansible [core 2.17.2]
|
||||
```
|
||||
|
||||
- Install `sshpass` used for automating SSH password authentication
|
||||
|
||||
```bash
|
||||
sudo apt-get install sshpass
|
||||
```
|
||||
@@ -0,0 +1,8 @@
|
||||
cerc_moniker: "LaconicMainnetNode"
|
||||
cerc_chain_id: "laconic-mainnet"
|
||||
min_gas_price: 0.001
|
||||
cerc_loglevel: "info"
|
||||
key_name: "validator"
|
||||
pvt_key: ""
|
||||
genesis_file:
|
||||
staking_amount_file:
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
- name: Generate Mainnet Genesis File
|
||||
hosts: localhost
|
||||
vars_files:
|
||||
- first-validator-vars.yml
|
||||
connection: local
|
||||
tasks:
|
||||
- name: Fetch repositories
|
||||
ansible.builtin.shell:
|
||||
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd setup-repositories --git-ssh --pull"
|
||||
|
||||
- name: Build containers
|
||||
ansible.builtin.shell:
|
||||
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers"
|
||||
|
||||
- name: Copy exported testnet state file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ exported_state_path }}"
|
||||
dest: "~/cerc/laconicd-stack/testnet-state.json"
|
||||
remote_src: true # Set to true if exported_state_path is on the target host
|
||||
|
||||
- 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"
|
||||
chdir: "{{ lookup('env', 'PWD') }}"
|
||||
always:
|
||||
- name: Clean up temporary genesis directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ ansible_env.HOME }}/cerc/laconicd-stack/playbooks/first-validator/mainnet-genesis"
|
||||
state: absent
|
||||
|
||||
- name: Remove temporary copied state file
|
||||
ansible.builtin.file:
|
||||
path: "~/cerc/laconicd-stack/testnet-state.json"
|
||||
state: absent
|
||||
|
||||
- name: Display genesis file location
|
||||
ansible.builtin.debug:
|
||||
msg: "Mainnet genesis file generated at output/genesis.json"
|
||||
|
||||
- name: Display staking-amount file location
|
||||
ansible.builtin.debug:
|
||||
msg: "Staking amount written to output/staking-amount.json"
|
||||
@@ -1,13 +0,0 @@
|
||||
cerc_moniker: "TestnetNode"
|
||||
cerc_chain_id: "laconic_9000-1"
|
||||
cerc_peers:
|
||||
min_gas_price: 0.001
|
||||
cerc_loglevel: "info"
|
||||
# Token denomination (alnt or alps)
|
||||
denom: "alnt"
|
||||
# Validator key name
|
||||
key_name: "validator"
|
||||
# Private key in hex format (required for gentx)
|
||||
pvt_key: ""
|
||||
# Required files
|
||||
genesis_file:
|
||||
@@ -2,7 +2,7 @@
|
||||
- name: Run mainnet validator node
|
||||
hosts: localhost
|
||||
vars_files:
|
||||
- run-first-validator-vars.yml
|
||||
- first-validator-vars.yml
|
||||
vars:
|
||||
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
|
||||
mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}"
|
||||
@@ -20,8 +20,9 @@
|
||||
fail:
|
||||
msg: >-
|
||||
Required key files are not defined.
|
||||
Please set genesis_file in run-first-validator-vars.yml.
|
||||
when: not genesis_file
|
||||
Please set genesis_file and staking_amount_file in first-validator-vars.yml.
|
||||
when: not genesis_file or not staking_amount_file
|
||||
|
||||
- name: Fetch laconicd stack
|
||||
shell: laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
|
||||
|
||||
@@ -52,10 +53,8 @@
|
||||
content: |
|
||||
CERC_MONIKER: "{{ cerc_moniker }}"
|
||||
CERC_CHAIN_ID: "{{ cerc_chain_id }}"
|
||||
CERC_PEERS: "{{ cerc_peers}}"
|
||||
MIN_GAS_PRICE: "{{ min_gas_price }}"
|
||||
CERC_LOGLEVEL: "{{ cerc_loglevel }}"
|
||||
DENOM: "{{ denom }}"
|
||||
KEY_NAME: "{{ key_name }}"
|
||||
mode: '0777'
|
||||
|
||||
@@ -65,6 +64,12 @@
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Copy staking amount file to laconicd-data tmp directory
|
||||
copy:
|
||||
src: "{{ staking_amount_file }}"
|
||||
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/staking-amount.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Copy genesis file to laconicd-data tmp directory
|
||||
copy:
|
||||
src: "{{ genesis_file }}"
|
||||
@@ -74,18 +79,17 @@
|
||||
- name: Fail if pvt_key is not set
|
||||
fail:
|
||||
msg: >-
|
||||
Private key (pvt_key) is not set in run-first-validator-vars.yml.
|
||||
Private key (pvt_key) is not set in first-validator-vars.yml.
|
||||
This is required for creating the gentx.
|
||||
when: not pvt_key
|
||||
|
||||
- name: Run script to create and collect gentx
|
||||
shell: |
|
||||
docker run -it \
|
||||
docker run -i \
|
||||
-v {{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data:/root/.laconicd \
|
||||
-v {{data_directory}}/{{ mainnet_deployment_dir }}/config/mainnet-laconicd:/scripts \
|
||||
-e "PVT_KEY={{ pvt_key }}" \
|
||||
-e "KEY_NAME={{ key_name }}" \
|
||||
-e "DENOM={{ denom }}" \
|
||||
-e "CERC_MONIKER={{ cerc_moniker }}" \
|
||||
-e "CERC_CHAIN_ID={{ cerc_chain_id }}" \
|
||||
cerc/laconicd:local bash -c "/scripts/create-and-collect-gentx.sh"
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# validator
|
||||
|
||||
This directory contains playbooks for setting up and managing a validator on the Laconic chain. There are two main playbooks:
|
||||
|
||||
* `create-validator.yml` - Creates a validator on an already running node
|
||||
* (Coming soon) `setup-validator.yml` - Sets up and runs a validator node
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Ansible](../README.md#ansible-installation)
|
||||
- [Stack orchestrator](https://git.vdb.to/cerc-io/testnet-ops/src/branch/main/stack-orchestrator-setup)
|
||||
- Private key or mnemonic of validator account from previous testnet
|
||||
- Use <https://wallet.laconic.com>
|
||||
|
||||
## Configuration
|
||||
|
||||
* Set the required environment variables:
|
||||
```bash
|
||||
export DATA_DIRECTORY=/path/to/deployment/parent/directory
|
||||
export DEPLOYMENT_DIR=validator-laconicd-deployment
|
||||
```
|
||||
|
||||
* Copy the example variables file and edit it:
|
||||
```bash
|
||||
cp validator-vars.example.yml validator-vars.yml
|
||||
```
|
||||
|
||||
* Edit `validator-vars.yml` to set your validator parameters:
|
||||
```yaml
|
||||
# Chain configuration
|
||||
cerc_moniker: "YourValidatorName" # Your validator's name
|
||||
cerc_chain_id: "laconic-mainnet" # Chain ID
|
||||
|
||||
# TODO: Add persistent peer addresses
|
||||
cerc_peers: "" # Comma-separated list of peers
|
||||
```
|
||||
|
||||
## Creating a Validator
|
||||
|
||||
To create a validator:
|
||||
|
||||
* Make sure your validator node is running and synced
|
||||
|
||||
<!-- TODO: Add playbook and steps for setting up and running validator node -->
|
||||
* Set key name used for importing validator account
|
||||
```bash
|
||||
export KEY_NAME=<key-name>
|
||||
```
|
||||
|
||||
* Run the create-validator playbook:
|
||||
```bash
|
||||
ansible-playbook playbooks/validator/create-validator.yml
|
||||
```
|
||||
|
||||
## Verification
|
||||
|
||||
After running the playbook, you can verify your validator was created by:
|
||||
|
||||
* Check the validator list:
|
||||
```bash
|
||||
laconic-so deployment --dir $DATA_DIRECTORY/$DEPLOYMENT_DIR exec laconicd 'laconicd query staking validators'
|
||||
```
|
||||
|
||||
* Check your validator's details:
|
||||
```bash
|
||||
laconic-so deployment --dir $DATA_DIRECTORY/$DEPLOYMENT_DIR exec laconicd 'laconicd query staking validator $(laconicd keys show validator --bech val -a)'
|
||||
```
|
||||
@@ -1,27 +0,0 @@
|
||||
---
|
||||
- name: Create validator on running chain
|
||||
hosts: localhost
|
||||
vars_files:
|
||||
- validator-vars.yml
|
||||
vars:
|
||||
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
|
||||
deployment_dir: "{{ lookup('env', 'DEPLOYMENT_DIR') }}"
|
||||
key_name: "{{ lookup('env', 'KEY_NAME') }}"
|
||||
tasks:
|
||||
- name: Fail if DATA_DIRECTORY or DEPLOYMENT_DIR env vars are not set
|
||||
fail:
|
||||
msg: >-
|
||||
Required environment variables are not set.
|
||||
Please export both DATA_DIRECTORY and DEPLOYMENT_DIR before running the playbook.
|
||||
when: lookup('env', 'DATA_DIRECTORY') == '' or lookup('env', 'DEPLOYMENT_DIR') == ''
|
||||
|
||||
- name: Fail if neither pvt_key nor mnemonic is set
|
||||
fail:
|
||||
msg: >-
|
||||
Neither private key (pvt_key) nor mnemonic is set in validator-vars.yml.
|
||||
Please set one of them to create the validator.
|
||||
when: not pvt_key and not mnemonic
|
||||
|
||||
- name: Run create-validator script
|
||||
shell: |
|
||||
laconic-so deployment --dir {{data_directory}}/{{deployment_dir}} exec laconicd "export KEY_NAME={{ key_name }} /scripts/create-validator.sh"
|
||||
@@ -1,6 +0,0 @@
|
||||
# Chain configuration
|
||||
cerc_moniker:
|
||||
cerc_chain_id: "laconic-mainnet"
|
||||
cerc_peers: # Comma-separated list of peers
|
||||
min_gas_price: 0.001
|
||||
cerc_loglevel: "info"
|
||||
@@ -23,6 +23,6 @@ testnet_state_file="$OUTPUT_DIR/testnet-state.json"
|
||||
docker run -it \
|
||||
-v ${TESTNET_DEPLOYMENT_DIR}/data/laconicd-data:/root/testnet-deployment/.laconicd \
|
||||
cerc/laconicd:local bash -c "laconicd export --home /root/testnet-deployment/.laconicd" \
|
||||
| jq .app_state.onboarding > "$testnet_state_file"
|
||||
| jq > "$testnet_state_file"
|
||||
|
||||
echo "Exported state from testnet to $testnet_state_file"
|
||||
|
||||
@@ -12,9 +12,11 @@ fi
|
||||
|
||||
TESTNET_STATE_FILE="$1"
|
||||
MAINNET_GENESIS_DIR=mainnet-genesis
|
||||
OUTPUT_DIR=output
|
||||
|
||||
# Create a temporary target directory
|
||||
# Create a required target directories
|
||||
mkdir -p $MAINNET_GENESIS_DIR
|
||||
mkdir -p $OUTPUT_DIR
|
||||
|
||||
# --------
|
||||
|
||||
@@ -23,19 +25,38 @@ cp $TESTNET_STATE_FILE $MAINNET_GENESIS_DIR/testnet-state.json
|
||||
|
||||
# --------
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
echo "Initializing a new empty chain with chain-id $CHAIN_ID..."
|
||||
docker run \
|
||||
-v ./$MAINNET_GENESIS_DIR:/root/.laconicd \
|
||||
-v $script_dir:/scripts \
|
||||
-e "CHAIN_ID=$CHAIN_ID" \
|
||||
cerc/laconicd:local bash -c "/scripts/init-mainnet.sh"
|
||||
|
||||
# --------
|
||||
|
||||
# Install required bech32 dependency
|
||||
# TODO: Avoid installing bech32 system-wide
|
||||
python3 -m pip install bech32 --break-system-packages
|
||||
|
||||
# Carry over state from testnet to mainnet
|
||||
echo "Carrying over state from testnet state to mainnet genesis..."
|
||||
python3 $script_dir/transfer-state.py
|
||||
|
||||
# --------
|
||||
|
||||
# Run a script with cerc/laconicd:local to generate the genesis file
|
||||
# with onboarding module state and given allocations
|
||||
docker run -it \
|
||||
echo "Performing alps allocations..."
|
||||
docker run \
|
||||
-v ./$MAINNET_GENESIS_DIR:/root/.laconicd \
|
||||
-v ./scripts:/scripts \
|
||||
-v $script_dir:/scripts \
|
||||
-e "CHAIN_ID=$CHAIN_ID" \
|
||||
-e "EARLY_SUPPORTS_ACC_ADDRESS=$EARLY_SUPPORTS_ACC_ADDRESS" \
|
||||
-e "LPS_LOCKUP_ACC_ADDRESS=$LPS_LOCKUP_ACC_ADDRESS" \
|
||||
cerc/laconicd:local bash -c "/scripts/genesis.sh"
|
||||
|
||||
# Copy over the genesis file to output folder
|
||||
OUTPUT_DIR=output
|
||||
mkdir -p $OUTPUT_DIR
|
||||
cp ./$MAINNET_GENESIS_DIR/config/genesis.json $OUTPUT_DIR/genesis.json
|
||||
|
||||
echo "Genesis file for mainnet written to $OUTPUT_DIR/genesis.json"
|
||||
@@ -43,4 +64,4 @@ echo "Genesis file for mainnet written to $OUTPUT_DIR/genesis.json"
|
||||
# --------
|
||||
|
||||
# Clean up
|
||||
echo "Please remove the temporary data directory: sudo rm -rf $MAINNET_GENESIS_DIR"
|
||||
rm -rf $MAINNET_GENESIS_DIR
|
||||
|
||||
+25
-14
@@ -6,15 +6,13 @@ set -u
|
||||
|
||||
# Note: Needs to be run in a docker container with image cerc/laconicd:local
|
||||
|
||||
CHAINID=${CHAINID:-"laconic-mainnet"}
|
||||
MONIKER=${MONIKER:-"mainnet-node"}
|
||||
KEYRING="test"
|
||||
NODE_HOME="/root/.laconicd"
|
||||
|
||||
EARLY_SUPPORTS_ACC_ADDRESS=${EARLY_SUPPORTS_ACC_ADDRESS}
|
||||
LPS_LOCKUP_ACC_ADDRESS=${LPS_LOCKUP_ACC_ADDRESS}
|
||||
|
||||
if [ -z "$EARLY_SUPPORTS_ACC_ADDRESS" ] || [ -z "$LPS_LOCKUP_ACC_ADDRESS" ]; then
|
||||
echo "EARLY_SUPPORTS_ACC_ADDRESS or LPS_LOCKUP_ACC_ADDRESS not provided, exiting..."
|
||||
if [ -z "$EARLY_SUPPORTS_ACC_ADDRESS" ]; then
|
||||
echo "EARLY_SUPPORTS_ACC_ADDRESS not provided, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -23,31 +21,44 @@ fi
|
||||
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_LOCKUP_MODULE_ACCOUNT="lps_lockup"
|
||||
LPS_DENOM="alps"
|
||||
|
||||
testnet_state_file="$NODE_HOME/testnet-state.json"
|
||||
mainnet_genesis_file="$NODE_HOME/config/genesis.json"
|
||||
|
||||
laconicd config set client chain-id $CHAINID
|
||||
laconicd init $MONIKER --chain-id $CHAINID --default-denom alnt
|
||||
|
||||
# Import required state
|
||||
jq --slurpfile nested $testnet_state_file '.app_state.auth = $nested[0].app_state' "$mainnet_genesis_file" > tmp.$$.json && mv tmp.$$.json "$mainnet_genesis_file"
|
||||
jq --slurpfile nested $testnet_state_file '.consensus.auth = $nested[0].consensus' "$mainnet_genesis_file" > tmp.$$.json && mv tmp.$$.json "$mainnet_genesis_file"
|
||||
|
||||
# Update any module params if required here
|
||||
update_genesis() {
|
||||
jq "$1" $NODE_HOME/config/genesis.json > $NODE_HOME/config/tmp_genesis.json &&
|
||||
mv $NODE_HOME/config/tmp_genesis.json $NODE_HOME/config/genesis.json
|
||||
}
|
||||
|
||||
# Set distribution community tax to 1 for disabling staking rewards and redirect them to the community pool
|
||||
update_genesis '.app_state["distribution"]["params"]["community_tax"]="1.000000000000000000"'
|
||||
|
||||
# Increase threshold in gov proposals for making it difficult to spend community pool funds
|
||||
echo "Setting high threshold for accepting governance proposal"
|
||||
update_genesis '.app_state["gov"]["params"]["quorum"]="1.000000000000000000"'
|
||||
# Set expedited threshold to 100%
|
||||
update_genesis '.app_state["gov"]["params"]["expedited_threshold"]="1.000000000000000000"'
|
||||
# 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
|
||||
laconicd genesis add-genesis-account $ADDRESS $EARLY_SUPPORTS$DENOM --keyring-backend $KEYRING
|
||||
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 $EARLY_SUPPORTS$DENOM --keyring-backend $KEYRING --module-name $LPS_LOCKUP_MODULE_ACCOUNT
|
||||
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
|
||||
|
||||
# Ensure that resulting genesis file is valid
|
||||
laconicd genesis validate
|
||||
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
set -u
|
||||
|
||||
# Note: Needs to be run in a docker container with image cerc/laconicd:local
|
||||
|
||||
CHAIN_ID=${CHAIN_ID:-"laconic-mainnet"}
|
||||
MONIKER=${MONIKER:-"mainnet-node"}
|
||||
NODE_HOME="/root/.laconicd"
|
||||
|
||||
laconicd config set client chain-id $CHAIN_ID
|
||||
laconicd init $MONIKER --chain-id $CHAIN_ID --default-denom alnt
|
||||
|
||||
# Allow all permissions to process further
|
||||
chmod -R 777 $NODE_HOME/data $NODE_HOME/config
|
||||
@@ -0,0 +1,165 @@
|
||||
import json
|
||||
|
||||
from decimal import Decimal
|
||||
from collections import defaultdict
|
||||
from bech32 import bech32_decode, bech32_encode, convertbits
|
||||
|
||||
#------
|
||||
|
||||
# Helper methods
|
||||
|
||||
def valoper_to_account_address(valoper_addr: str, new_prefix = "laconic") -> str:
|
||||
hrp, data = bech32_decode(valoper_addr)
|
||||
if hrp is None or data is None:
|
||||
raise ValueError("Invalid bech32 address")
|
||||
|
||||
# Convert back from 5-bit to 8-bit
|
||||
decoded = convertbits(data, 5, 8, False)
|
||||
if decoded is None:
|
||||
raise ValueError("Failed to convert bits")
|
||||
|
||||
# Re-encode with new prefix
|
||||
converted_data = convertbits(decoded, 8, 5, True)
|
||||
return bech32_encode(new_prefix, converted_data)
|
||||
|
||||
def get_min_delegation_share(state):
|
||||
validators = state["app_state"]["staking"]["validators"]
|
||||
delegations = state["app_state"]["staking"]["delegations"]
|
||||
|
||||
shares_list = []
|
||||
|
||||
for val in validators:
|
||||
valoper_addr = val["operator_address"]
|
||||
orig_delegator_addr = valoper_to_account_address(valoper_addr)
|
||||
|
||||
# Find delegations where the delegator is the original delegator and delegated to their validator
|
||||
for delegation in delegations:
|
||||
if (delegation["delegator_address"] == orig_delegator_addr and
|
||||
delegation["validator_address"] == valoper_addr):
|
||||
shares = int(Decimal(delegation["shares"]))
|
||||
shares_list.append(shares)
|
||||
|
||||
break
|
||||
|
||||
# Find minimum
|
||||
return min(shares_list)
|
||||
|
||||
#------
|
||||
|
||||
# Read testnet and mainnet states
|
||||
|
||||
mainnet_genesis_dir="mainnet-genesis"
|
||||
testnet_state_file=f"{mainnet_genesis_dir}/testnet-state.json"
|
||||
mainnet_genesis_file=f"{mainnet_genesis_dir}/config/genesis.json"
|
||||
staking_amount_file=f"output/staking-amount.json"
|
||||
|
||||
with open(testnet_state_file) as f:
|
||||
testnet_state = json.load(f)
|
||||
|
||||
with open(mainnet_genesis_file) as f:
|
||||
mainnet_state = json.load(f)
|
||||
|
||||
#------
|
||||
|
||||
# Import required module state
|
||||
mainnet_state["app_state"]["auth"] = testnet_state["app_state"]["auth"]
|
||||
mainnet_state["app_state"]["bond"] = testnet_state["app_state"]["bond"]
|
||||
mainnet_state["app_state"]["bank"] = testnet_state["app_state"]["bank"]
|
||||
mainnet_state["app_state"]["registry"] = testnet_state["app_state"]["registry"]
|
||||
mainnet_state["app_state"]["slashing"]["params"] = testnet_state["app_state"]["slashing"]["params"]
|
||||
mainnet_state["consensus"]["params"] = testnet_state["consensus"]["params"]
|
||||
|
||||
#------
|
||||
|
||||
# Allocate back delegation stakes
|
||||
|
||||
# Build map of address -> extra balance to add (as integers)
|
||||
deltas = {}
|
||||
for delegation in testnet_state["app_state"]["staking"]["delegations"]:
|
||||
addr = delegation["delegator_address"]
|
||||
amount = int(Decimal(delegation["shares"]))
|
||||
deltas[addr] = deltas.get(addr, 0) + amount
|
||||
|
||||
# Now apply the deltas to existing balances
|
||||
supply_increment = 0
|
||||
for balance in mainnet_state["app_state"]["bank"]["balances"]:
|
||||
addr = balance["address"]
|
||||
if addr in deltas:
|
||||
for coin in balance["coins"]:
|
||||
if coin["denom"] == "alnt":
|
||||
coin["amount"] = str(int(coin["amount"]) + deltas[addr])
|
||||
supply_increment += deltas[addr]
|
||||
break
|
||||
del deltas[addr]
|
||||
|
||||
# Increase the total supply
|
||||
for coin in mainnet_state["app_state"]["bank"]["supply"]:
|
||||
if coin["denom"] == "alnt":
|
||||
coin["amount"] = str(int(coin["amount"]) + supply_increment)
|
||||
|
||||
#------
|
||||
|
||||
# Remove non-required module accounts
|
||||
|
||||
# Addresses to remove
|
||||
addresses_to_remove = {
|
||||
"bonded_tokens_pool",
|
||||
"not_bonded_tokens_pool",
|
||||
"distribution"
|
||||
}
|
||||
|
||||
# Remove from auth.accounts and get their addresses
|
||||
removed_addresses = set()
|
||||
new_accounts = []
|
||||
for account in mainnet_state["app_state"]["auth"]["accounts"]:
|
||||
account_type = account.get("@type", "")
|
||||
if "ModuleAccount" in account_type and account.get("name") in addresses_to_remove:
|
||||
removed_addresses.add(account["base_account"]["address"])
|
||||
continue
|
||||
new_accounts.append(account)
|
||||
|
||||
mainnet_state["app_state"]["auth"]["accounts"] = new_accounts
|
||||
|
||||
# Remove from bank.balances and tally removed amounts
|
||||
new_balances = []
|
||||
removed_amounts = defaultdict(int)
|
||||
|
||||
for bal in mainnet_state["app_state"]["bank"]["balances"]:
|
||||
if bal["address"] in removed_addresses:
|
||||
# Skip this account
|
||||
for coin in bal["coins"]:
|
||||
denom = coin["denom"]
|
||||
amount = int(coin["amount"])
|
||||
removed_amounts[denom] += amount
|
||||
|
||||
continue
|
||||
|
||||
new_balances.append(bal)
|
||||
|
||||
mainnet_state["app_state"]["bank"]["balances"] = new_balances
|
||||
|
||||
# Reduce from bank supply
|
||||
new_supply = []
|
||||
for coin in mainnet_state["app_state"]["bank"]["supply"]:
|
||||
denom = coin["denom"]
|
||||
amount = int(coin["amount"])
|
||||
amount -= removed_amounts.get(denom, 0)
|
||||
new_supply.append({
|
||||
"denom": denom,
|
||||
"amount": str(amount)
|
||||
})
|
||||
|
||||
mainnet_state["app_state"]["bank"]["supply"] = new_supply
|
||||
|
||||
#------
|
||||
|
||||
# Find minimum delegation share for common staking amount
|
||||
|
||||
min_delegation_share = get_min_delegation_share(testnet_state)
|
||||
with open(staking_amount_file, "w") as f:
|
||||
json.dump({"common_staking_amount": min_delegation_share}, f, indent=2)
|
||||
print(f"Staking amount written to {staking_amount_file}")
|
||||
|
||||
# Write back modified state
|
||||
with open(mainnet_genesis_file, "w") as f:
|
||||
json.dump(mainnet_state, f, indent=2)
|
||||
@@ -12,7 +12,6 @@ services:
|
||||
volumes:
|
||||
- laconicd-data:/root/.laconicd
|
||||
- ../config/mainnet-laconicd/run-laconicd.sh:/opt/run-laconicd.sh
|
||||
- ../config/mainnet-laconicd/create-validator.sh:/scripts/create-validator.sh
|
||||
ports:
|
||||
- "6060"
|
||||
- "26657"
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
# Early supports: 12960 * 10^18 alps (10% of 129600 * 10^18 alps)
|
||||
EARLY_SUPPORTS="12960000000000000000000"
|
||||
|
||||
DENOM=alps
|
||||
|
||||
input_genesis_file=$INPUT_GENESIS_FILE
|
||||
if [ ! -f ${input_genesis_file} ]; then
|
||||
echo "Genesis file not provided, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$RECIPIENT_ADDRESS" ]; then
|
||||
echo "Recipient address not provided, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
update_genesis() {
|
||||
jq "$1" ${input_genesis_file} > ${input_genesis_file}.tmp &&
|
||||
mv ${input_genesis_file}.tmp ${input_genesis_file}
|
||||
}
|
||||
|
||||
# Add new account to auth.accounts
|
||||
update_genesis '.app_state["auth"]["accounts"] += [{"@type": "/cosmos.auth.v1beta1.BaseAccount", "address": "'$RECIPIENT_ADDRESS'", "pub_key": null, "account_number": "0", "sequence": "0"}]'
|
||||
|
||||
# Add balance for the new account
|
||||
update_genesis '.app_state["bank"]["balances"] += [{"address": "'$RECIPIENT_ADDRESS'", "coins": [{"denom": "'$DENOM'", "amount": "'$EARLY_SUPPORTS'"}]}]'
|
||||
|
||||
# Get current supply
|
||||
CURRENT_SUPPLY=$(jq -r '.app_state["bank"]["supply"][0]["amount"]' ${input_genesis_file})
|
||||
|
||||
# Calculate new supply
|
||||
NEW_SUPPLY=$((CURRENT_SUPPLY + EARLY_SUPPORTS))
|
||||
|
||||
# Update total supply
|
||||
update_genesis '.app_state["bank"]["supply"][0]["amount"] = "'$NEW_SUPPLY'"'
|
||||
|
||||
echo "Genesis file updated with new account ${RECIPIENT_ADDRESS} and allocated ${EARLY_SUPPORTS} ${DENOM}"
|
||||
@@ -4,6 +4,8 @@ set -e
|
||||
|
||||
NODE_HOME=/root/.laconicd
|
||||
genesis_file_path=$NODE_HOME/config/genesis.json
|
||||
# TODO: Set to OS keyring backend
|
||||
KEYRING="test"
|
||||
|
||||
if [ -f "$genesis_file_path" ]; then
|
||||
echo "Genesis file already created, exiting..."
|
||||
@@ -20,41 +22,49 @@ if [ -z "$KEY_NAME" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$DENOM" ]; then
|
||||
echo "DENOM environment variable not set, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
input_genesis_file=$NODE_HOME/tmp/genesis.json
|
||||
if [ ! -f ${input_genesis_file} ]; then
|
||||
echo "Genesis file not provided, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
staking_amount_file="$NODE_HOME/tmp/staking-amount.json"
|
||||
if [ ! -f "$staking_amount_file" ]; then
|
||||
echo "staking-amount.json file not provided, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DENOM=alnt
|
||||
|
||||
# Strip leading and trailing quotes ("") if they exist
|
||||
export MONIKER=$(echo "$CERC_MONIKER" | sed -e 's/^["'\'']//g' -e 's/["'\'']$//g')
|
||||
export CHAIN_ID=$(echo "$CERC_CHAIN_ID" | sed -e 's/^["'\'']//g' -e 's/["'\'']$//g')
|
||||
export DENOM=$(echo "$DENOM" | sed -e 's/^["'\'']//g' -e 's/["'\'']$//g')
|
||||
|
||||
# Init
|
||||
laconicd config set client chain-id $CHAIN_ID --home $NODE_HOME
|
||||
laconicd config set client keyring-backend $KEYRING
|
||||
laconicd init $MONIKER --chain-id=$CHAIN_ID --home $NODE_HOME
|
||||
|
||||
# Copy over provided genesis config
|
||||
cp $input_genesis_file $genesis_file_path
|
||||
|
||||
# Import private key passed via PVT_KEY
|
||||
laconicd keys import-hex "$KEY_NAME" "$PVT_KEY"
|
||||
# Import private key
|
||||
laconicd keys import-hex "$KEY_NAME" "$PVT_KEY" --keyring-backend $KEYRING
|
||||
|
||||
account_address=$(laconicd keys list | awk -v key_name="$KEY_NAME" '
|
||||
$1 == "name:" && $2 == key_name {found=1}
|
||||
found && $1 == "- address:" {print $3; exit}
|
||||
')
|
||||
# Get account address corresponding to the imported key
|
||||
account_address=$(laconicd keys show "$KEY_NAME" --keyring-backend "$KEYRING" | grep 'address:' | awk -F': ' '{print $2}' | xargs)
|
||||
|
||||
stake_amount=$(jq -r --arg address "$account_address" --arg denom "$DENOM" '.app_state.bank.balances[] | select(.address == $address) | .coins[] | select(.denom == $denom) | .amount' $genesis_file_path)
|
||||
if [ -z "$account_address" ]; then
|
||||
echo "Failed to get account address for key name $KEY_NAME, exiting..."
|
||||
laconicd keys list --keyring-backend $KEYRING
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set staking amount
|
||||
stake_amount=$(jq -r '.amount' "$staking_amount_file")
|
||||
|
||||
# Create gentx with staked amount equal to allocated balance
|
||||
laconicd genesis gentx $KEY_NAME $stake_amount$DENOM --chain-id $CHAIN_ID
|
||||
laconicd genesis gentx $KEY_NAME $stake_amount$DENOM --chain-id $CHAIN_ID --keyring-backend $KEYRING
|
||||
|
||||
# Collect the gentx and validate
|
||||
laconicd genesis collect-gentxs
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
DENOM=alnt
|
||||
|
||||
# Create validator with fixed parameters
|
||||
laconicd tx staking create-validator \
|
||||
--amount 900000000$DENOM \
|
||||
--pubkey $(laconicd tendermint show-validator) \
|
||||
--moniker "$CERC_MONIKER" \
|
||||
--chain-id "$CERC_CHAIN_ID" \
|
||||
--commission-rate 0.0 \
|
||||
--commission-max-rate 0.0 \
|
||||
--commission-max-change-rate 0.0 \
|
||||
--min-self-delegation 1 \
|
||||
--gas auto \
|
||||
--gas-adjustment 1.5 \
|
||||
--gas-prices $MIN_GAS_PRICE$DENOM \
|
||||
--from $KEY_NAME \
|
||||
--yes
|
||||
@@ -29,19 +29,31 @@ if [ -z "$(ls -A "$NODE_HOME/data")" ]; then
|
||||
# Init node
|
||||
echo "Initializing a new laconicd node with moniker $CERC_MONIKER and chain id $CERC_CHAIN_ID"
|
||||
laconicd init $CERC_MONIKER --chain-id=$CERC_CHAIN_ID --home $NODE_HOME
|
||||
|
||||
# Use provided config files
|
||||
cp $input_genesis_file $NODE_HOME/config/genesis.json
|
||||
else
|
||||
echo "Node data dir $NODE_HOME/data already exists, skipping initialization..."
|
||||
fi
|
||||
|
||||
# Use provided config files
|
||||
cp $input_genesis_file $NODE_HOME/config/genesis.json
|
||||
|
||||
# Enable cors
|
||||
sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $NODE_HOME/config/config.toml
|
||||
|
||||
# Update config with persistent peers
|
||||
sed -i "s/^persistent_peers *=.*/persistent_peers = \"$CERC_PEERS\"/g" $NODE_HOME/config/config.toml
|
||||
|
||||
# Enable telemetry (prometheus metrics: http://localhost:1317/metrics?format=prometheus)
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' 's/enabled = false/enabled = true/g' $NODE_HOME/config/app.toml
|
||||
sed -i '' 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $NODE_HOME/config/app.toml
|
||||
sed -i '' 's/prometheus = false/prometheus = true/g' $NODE_HOME/config/config.toml
|
||||
else
|
||||
sed -i 's/enabled = false/enabled = true/g' $NODE_HOME/config/app.toml
|
||||
sed -i 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $NODE_HOME/config/app.toml
|
||||
sed -i 's/prometheus = false/prometheus = true/g' $NODE_HOME/config/config.toml
|
||||
fi
|
||||
|
||||
|
||||
echo "Starting laconicd node..."
|
||||
laconicd start \
|
||||
--api.enable \
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
# mainnet-laconicd
|
||||
|
||||
Instructions for running validator nodes
|
||||
|
||||
@@ -2,7 +2,7 @@ version: "1.0"
|
||||
name: mainnet-laconicd
|
||||
description: "Laconicd full node"
|
||||
repos:
|
||||
- git.vdb.to/cerc-io/laconicd@v0.1.11
|
||||
- git.vdb.to/cerc-io/laconicd@mainnet # TODO: Use a release
|
||||
containers:
|
||||
- cerc/laconicd
|
||||
pods:
|
||||
|
||||
Reference in New Issue
Block a user