Compare commits
17 Commits
main
...
ng-create-
Author | SHA1 | Date | |
---|---|---|---|
1df3ab2500 | |||
|
1de4a3dc3e | ||
b3ebd32499 | |||
|
daad25a049 | ||
|
13c95e61c5 | ||
d284d4c321 | |||
|
67405d3809 | ||
74e5f470e2 | |||
|
d769c6e055 | ||
|
f181e67045 | ||
afd2082f6e | |||
|
404951bda7 | ||
|
31a560bb15 | ||
|
08847a3912 | ||
|
44219c801c | ||
|
ad22b6350b | ||
|
0c25f9daff |
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*-deployment
|
||||||
|
*-spec.yml
|
||||||
|
|
||||||
|
# Validator playbook vars
|
||||||
|
playbooks/validator/validator-vars.yml
|
50
playbooks/README.md
Normal file
50
playbooks/README.md
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# playbooks
|
||||||
|
|
||||||
|
## Ansible Installation
|
||||||
|
|
||||||
|
- Install [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-and-upgrading-ansible-with-pip)
|
||||||
|
|
||||||
|
- Add location of the directory containing the ansible binary to your `PATH`
|
||||||
|
|
||||||
|
- Set Locale Encoding to `UTF-8`
|
||||||
|
|
||||||
|
Ansible requires the locale encoding to be `UTF-8`. You can either use the `LANG` prefix when running Ansible commands or set the system-wide locale
|
||||||
|
|
||||||
|
- Option 1: Use `LANG` Prefix in Commands
|
||||||
|
|
||||||
|
If you prefer not to change the system-wide locale, you can use the `LANG` prefix when running Ansible commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.UTF-8 ansible-playbook your_playbook.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
- Option 2: Set System-Wide Locale
|
||||||
|
|
||||||
|
- Edit the `/etc/default/locale` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo nano /etc/default/locale
|
||||||
|
```
|
||||||
|
|
||||||
|
- Set the `LANG` variable to en_US.UTF-8:
|
||||||
|
|
||||||
|
```
|
||||||
|
LANG="en_US.UTF-8"
|
||||||
|
```
|
||||||
|
|
||||||
|
- Reboot your system or log out and log back in to apply the changes
|
||||||
|
|
||||||
|
- Reference: <https://udhayakumarc.medium.com/error-ansible-requires-the-locale-encoding-to-be-utf-8-detected-iso8859-1-6da808387f7d>
|
||||||
|
|
||||||
|
- Verify ansible installation by running the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible --version
|
||||||
|
# ansible [core 2.17.2]
|
||||||
|
```
|
||||||
|
|
||||||
|
- Install `sshpass` used for automating SSH password authentication
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt-get install sshpass
|
||||||
|
```
|
13
playbooks/first-validator/run-first-validator-vars.yml
Normal file
13
playbooks/first-validator/run-first-validator-vars.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
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:
|
95
playbooks/first-validator/run-first-validator.yml
Normal file
95
playbooks/first-validator/run-first-validator.yml
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
---
|
||||||
|
- name: Run mainnet validator node
|
||||||
|
hosts: localhost
|
||||||
|
vars_files:
|
||||||
|
- run-first-validator-vars.yml
|
||||||
|
vars:
|
||||||
|
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
|
||||||
|
mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}"
|
||||||
|
spec_file: "{{data_directory}}/laconicd-spec.yml"
|
||||||
|
spec_template: "./templates/specs/spec-template.yml.j2"
|
||||||
|
tasks:
|
||||||
|
- name: Fail if DATA_DIRECTORY or MAINNET_DEPLOYMENT_DIR env vars are not set
|
||||||
|
fail:
|
||||||
|
msg: >-
|
||||||
|
Required environment variables are not set.
|
||||||
|
Please export both DATA_DIRECTORY and MAINNET_DEPLOYMENT_DIR before running the playbook.
|
||||||
|
when: lookup('env', 'DATA_DIRECTORY') == '' or lookup('env', 'MAINNET_DEPLOYMENT_DIR') == ''
|
||||||
|
|
||||||
|
- name: Fail if required key files are not defined
|
||||||
|
fail:
|
||||||
|
msg: >-
|
||||||
|
Required key files are not defined.
|
||||||
|
Please set genesis_file in run-first-validator-vars.yml.
|
||||||
|
when: not genesis_file
|
||||||
|
- name: Fetch laconicd stack
|
||||||
|
shell: laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
|
||||||
|
|
||||||
|
- name: Setup required repositories
|
||||||
|
shell: >
|
||||||
|
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd
|
||||||
|
setup-repositories --git-ssh --pull
|
||||||
|
|
||||||
|
- name: Build container images
|
||||||
|
shell: |
|
||||||
|
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers
|
||||||
|
|
||||||
|
- name: Create deployment spec file
|
||||||
|
shell: |
|
||||||
|
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd deploy init --output {{ spec_file }}
|
||||||
|
|
||||||
|
- name: Replace network section in spec_file
|
||||||
|
shell: >
|
||||||
|
yq eval '(.network) = load("{{ spec_template }}").network' -i {{ spec_file }}
|
||||||
|
|
||||||
|
- name: Create deployment from spec file
|
||||||
|
shell: |
|
||||||
|
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd deploy create --spec-file {{ spec_file }} --deployment-dir {{data_directory}}/{{ mainnet_deployment_dir }}
|
||||||
|
|
||||||
|
- name: Create config.env
|
||||||
|
copy:
|
||||||
|
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/config.env"
|
||||||
|
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'
|
||||||
|
|
||||||
|
- name: Ensure tmp directory exists inside laconicd-data
|
||||||
|
file:
|
||||||
|
path: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Copy genesis file to laconicd-data tmp directory
|
||||||
|
copy:
|
||||||
|
src: "{{ genesis_file }}"
|
||||||
|
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/genesis.json"
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
- name: Fail if pvt_key is not set
|
||||||
|
fail:
|
||||||
|
msg: >-
|
||||||
|
Private key (pvt_key) is not set in run-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 \
|
||||||
|
-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"
|
||||||
|
|
||||||
|
- name: Run validator node
|
||||||
|
shell: |
|
||||||
|
laconic-so deployment --dir {{data_directory}}/{{ mainnet_deployment_dir }} start
|
@ -0,0 +1,9 @@
|
|||||||
|
network:
|
||||||
|
ports:
|
||||||
|
laconicd:
|
||||||
|
- '6060:6060'
|
||||||
|
- '26657:26657'
|
||||||
|
- '26656:26656'
|
||||||
|
- '9473:9473'
|
||||||
|
- '9090:9090'
|
||||||
|
- '1317:1317'
|
67
playbooks/validator/README.md
Normal file
67
playbooks/validator/README.md
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# 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)'
|
||||||
|
```
|
27
playbooks/validator/create-validator.yml
Normal file
27
playbooks/validator/create-validator.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
- 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"
|
6
playbooks/validator/validator-vars.example.yml
Normal file
6
playbooks/validator/validator-vars.example.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Chain configuration
|
||||||
|
cerc_moniker:
|
||||||
|
cerc_chain_id: "laconic-mainnet"
|
||||||
|
cerc_peers: # Comma-separated list of peers
|
||||||
|
min_gas_price: 0.001
|
||||||
|
cerc_loglevel: "info"
|
28
scripts/export-testnet-state.sh
Executable file
28
scripts/export-testnet-state.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Note: Needs to be run in a docker container with image testnet cerc/laconicd:local
|
||||||
|
|
||||||
|
# Exit on error
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
# Check args
|
||||||
|
if [ "$#" -ne 1 ]; then
|
||||||
|
echo "Usage: $0 <testnet-deployment-dir-absolute>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TESTNET_DEPLOYMENT_DIR="$1"
|
||||||
|
|
||||||
|
# Create a temporary target directory
|
||||||
|
OUTPUT_DIR=${TESTNET_DEPLOYMENT_DIR}/export
|
||||||
|
mkdir -p $OUTPUT_DIR
|
||||||
|
|
||||||
|
# Export state from testnet chain
|
||||||
|
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"
|
||||||
|
|
||||||
|
echo "Exported state from testnet to $testnet_state_file"
|
46
scripts/generate-mainnet-genesis.sh
Executable file
46
scripts/generate-mainnet-genesis.sh
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit on error
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
# Check args
|
||||||
|
if [ "$#" -ne 1 ]; then
|
||||||
|
echo "Usage: $0 <testnet-state-json-file-path>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TESTNET_STATE_FILE="$1"
|
||||||
|
MAINNET_GENESIS_DIR=mainnet-genesis
|
||||||
|
|
||||||
|
# Create a temporary target directory
|
||||||
|
mkdir -p $MAINNET_GENESIS_DIR
|
||||||
|
|
||||||
|
# --------
|
||||||
|
|
||||||
|
# Copy testnet state file to required dir
|
||||||
|
cp $TESTNET_STATE_FILE $MAINNET_GENESIS_DIR/testnet-state.json
|
||||||
|
|
||||||
|
# --------
|
||||||
|
|
||||||
|
# Run a script with cerc/laconicd:local to generate the genesis file
|
||||||
|
# with onboarding module state and given allocations
|
||||||
|
docker run -it \
|
||||||
|
-v ./$MAINNET_GENESIS_DIR:/root/.laconicd \
|
||||||
|
-v ./scripts:/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"
|
||||||
|
|
||||||
|
# --------
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
echo "Please remove the temporary data directory: sudo rm -rf $MAINNET_GENESIS_DIR"
|
53
scripts/genesis.sh
Executable file
53
scripts/genesis.sh
Executable file
@ -0,0 +1,53 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit on error
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
# Note: Needs to be run in a docker container with image cerc/laconicd:local
|
||||||
|
|
||||||
|
CHAINID=${CHAINID:-"laconic-mainnet"}
|
||||||
|
MONIKER=${MONIKER:-"mainnet-node"}
|
||||||
|
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..."
|
||||||
|
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_LOCKUP_MODULE_ACCOUNT="lps_lockup"
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# Perform alps allocations
|
||||||
|
laconicd genesis add-genesis-account $ADDRESS $EARLY_SUPPORTS$DENOM --keyring-backend $KEYRING
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
# Ensure that resulting genesis file is valid
|
||||||
|
laconicd genesis validate
|
@ -0,0 +1,33 @@
|
|||||||
|
services:
|
||||||
|
laconicd:
|
||||||
|
restart: unless-stopped
|
||||||
|
image: cerc/laconicd:local
|
||||||
|
command: ["bash", "-c", "/opt/run-laconicd.sh"]
|
||||||
|
environment:
|
||||||
|
CERC_MONIKER: ${CERC_MONIKER}
|
||||||
|
CERC_CHAIN_ID: ${CERC_CHAIN_ID:-laconic-mainnet}
|
||||||
|
CERC_PEERS: ${CERC_PEERS}
|
||||||
|
MIN_GAS_PRICE: ${MIN_GAS_PRICE:-0.001}
|
||||||
|
CERC_LOGLEVEL: ${CERC_LOGLEVEL:-info}
|
||||||
|
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"
|
||||||
|
- "26656"
|
||||||
|
- "9473"
|
||||||
|
- "9090"
|
||||||
|
- "1317"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-vz", "127.0.0.1", "26657"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 10
|
||||||
|
start_period: 10s
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
laconicd-data:
|
45
stack-orchestrator/config/mainnet-laconicd/allocate-lps.sh
Executable file
45
stack-orchestrator/config/mainnet-laconicd/allocate-lps.sh
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/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}"
|
64
stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh
Executable file
64
stack-orchestrator/config/mainnet-laconicd/create-and-collect-gentx.sh
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
NODE_HOME=/root/.laconicd
|
||||||
|
genesis_file_path=$NODE_HOME/config/genesis.json
|
||||||
|
|
||||||
|
if [ -f "$genesis_file_path" ]; then
|
||||||
|
echo "Genesis file already created, exiting..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$PVT_KEY" ]; then
|
||||||
|
echo "PVT_KEY environment variable not set, exiting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$KEY_NAME" ]; then
|
||||||
|
echo "KEY_NAME environment variable not set, exiting..."
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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 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"
|
||||||
|
|
||||||
|
account_address=$(laconicd keys list | awk -v key_name="$KEY_NAME" '
|
||||||
|
$1 == "name:" && $2 == key_name {found=1}
|
||||||
|
found && $1 == "- address:" {print $3; exit}
|
||||||
|
')
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
# Create gentx with staked amount equal to allocated balance
|
||||||
|
laconicd genesis gentx $KEY_NAME $stake_amount$DENOM --chain-id $CHAIN_ID
|
||||||
|
|
||||||
|
# Collect the gentx and validate
|
||||||
|
laconicd genesis collect-gentxs
|
||||||
|
laconicd genesis validate
|
||||||
|
|
||||||
|
# Update the input genesis file
|
||||||
|
cp $genesis_file_path $input_genesis_file
|
@ -0,0 +1,20 @@
|
|||||||
|
#!/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
|
52
stack-orchestrator/config/mainnet-laconicd/run-laconicd.sh
Executable file
52
stack-orchestrator/config/mainnet-laconicd/run-laconicd.sh
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
NODE_HOME=/root/.laconicd
|
||||||
|
|
||||||
|
input_genesis_file=$NODE_HOME/tmp/genesis.json
|
||||||
|
if [ ! -f ${input_genesis_file} ]; then
|
||||||
|
echo "Genesis file not provided, exiting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Env:"
|
||||||
|
echo "Moniker: $CERC_MONIKER"
|
||||||
|
echo "Chain Id: $CERC_CHAIN_ID"
|
||||||
|
echo "Persistent peers: $CERC_PEERS"
|
||||||
|
echo "Min gas price: $MIN_GAS_PRICE"
|
||||||
|
echo "Log level: $CERC_LOGLEVEL"
|
||||||
|
|
||||||
|
# Set chain id in config
|
||||||
|
laconicd config set client chain-id $CERC_CHAIN_ID --home $NODE_HOME
|
||||||
|
|
||||||
|
# Check if node data dir already exists
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
echo "Starting laconicd node..."
|
||||||
|
laconicd start \
|
||||||
|
--api.enable \
|
||||||
|
--minimum-gas-prices=${MIN_GAS_PRICE}alnt \
|
||||||
|
--rpc.laddr="tcp://0.0.0.0:26657" \
|
||||||
|
--gql-playground --gql-server \
|
||||||
|
--log_level $CERC_LOGLEVEL \
|
||||||
|
--home $NODE_HOME
|
5
stack-orchestrator/container-build/cerc-laconicd/build.sh
Executable file
5
stack-orchestrator/container-build/cerc-laconicd/build.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Build cerc/laconicd
|
||||||
|
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||||
|
docker build -t cerc/laconicd:local ${build_command_args} ${CERC_REPO_BASE_DIR}/laconicd
|
3
stack-orchestrator/stacks/mainnet-laconicd/README.md
Normal file
3
stack-orchestrator/stacks/mainnet-laconicd/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# mainnet-laconicd
|
||||||
|
|
||||||
|
Instructions for running validator nodes
|
9
stack-orchestrator/stacks/mainnet-laconicd/stack.yml
Normal file
9
stack-orchestrator/stacks/mainnet-laconicd/stack.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
version: "1.0"
|
||||||
|
name: mainnet-laconicd
|
||||||
|
description: "Laconicd full node"
|
||||||
|
repos:
|
||||||
|
- git.vdb.to/cerc-io/laconicd@v0.1.11
|
||||||
|
containers:
|
||||||
|
- cerc/laconicd
|
||||||
|
pods:
|
||||||
|
- mainnet-laconicd
|
Loading…
Reference in New Issue
Block a user