Author SHA1 Message Date
Shreerang Kale 0ba5d4cab3 Checkout to relevant branch while setting up tmkms stack 2025-06-12 18:40:57 +05:30
Shreerang Kale 1eaa237070 Add instructions to setup yubihsm 2025-06-12 18:34:04 +05:30
shreerangandShreerang Kale 3a483792f7 Add playbooks to run TMKMS service (#14)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Reviewed-on: #14
Co-authored-by: shreerang <shreerang@noreply.git.vdb.to>
Co-committed-by: shreerang <shreerang@noreply.git.vdb.to>
2025-06-12 11:20:33 +00:00
nabarun 6accde384d Update multisig playbook to setup deployment on remote machine (#15)
Part of <https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e>

Reviewed-on: #15
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
2025-06-11 15:05:04 +00:00
shreerangandShreerang Kale edee217050 Divide generate genesis and create validator playbooks into build and start playbooks (#13)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Reviewed-on: #13
Co-authored-by: shreerang <shreerang@noreply.git.vdb.to>
Co-committed-by: shreerang <shreerang@noreply.git.vdb.to>
2025-06-10 10:07:15 +00:00
shreerangandShreerang Kale 44ab959af5 Update playbooks to sign txs on a separate machine from the one running laconicd node (#5)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Reviewed-on: #5
Co-authored-by: shreerang <shreerang@noreply.git.vdb.to>
Co-committed-by: shreerang <shreerang@noreply.git.vdb.to>
2025-06-09 12:37:50 +00:00
ishavenikarandIshaVenikar 7a94eb2a03 Use zstd to compress testnet state file (#12)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: #12
Co-authored-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
Co-committed-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
2025-06-09 08:51:38 +00:00
ishavenikarandIshaVenikar 6733aa7318 Add steps to compress testnet state JSON file (#11)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: #11
Co-authored-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
Co-committed-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
2025-06-04 11:25:23 +00:00
ishavenikarandIshaVenikar 48939ffbd7 Create lockup module JSON from LPS distribution excel file (#10)
Part of https://www.notion.so/Lockup-LPS-tokens-into-a-module-account-1f2a6b22d472802cbb35e8ce052d22ca?pvs=23

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: #10
Co-authored-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
Co-committed-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
2025-06-04 10:55:10 +00:00
ishavenikarandIshaVenikar b87609436a Update dgraph URL env value in demo steps (#9)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: #9
Co-authored-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
Co-committed-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
2025-06-02 11:36:23 +00:00
ishavenikarandIshaVenikar 8a7d184610 Update port for multisig app (#8)
Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: #8
Co-authored-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
Co-committed-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
2025-05-30 06:32:11 +00:00
ishavenikarandIshaVenikar e3927d4af2 Update chain registry name in vars file (#7)
Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: #7
Co-authored-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
Co-committed-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
2025-05-29 05:06:54 +00:00
ishavenikarandIshaVenikar 1886a9acf0 Add playbook to setup cosmos multisig app (#6)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: #6
Co-authored-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
Co-committed-by: ishavenikar <ishavenikar@noreply.git.vdb.to>
2025-05-28 13:36:34 +00:00
nabarun 40ac26bd78 Add steps to configure TMKMS in node deployments (#4)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e

- TMKMS config is for `softsign` backend provider

Reviewed-on: #4
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
2025-05-20 13:55:15 +00:00
3d7ba45796 Add playbook to send create-validator tx for subsequent nodes (#3)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e of cerc-io/laconicd#66
- Use calculated staking amount for running validator nodes

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Reviewed-on: #3
Co-authored-by: shreerang <shreerang@noreply.git.vdb.to>
Co-committed-by: shreerang <shreerang@noreply.git.vdb.to>
2025-05-16 09:54:09 +00:00
shreerangandShreerang Kale 3b526fac78 Add playbook to run subsequent validator nodes (#2)
Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Reviewed-on: #2
Co-authored-by: shreerang <shreerang@noreply.git.vdb.to>
Co-committed-by: shreerang <shreerang@noreply.git.vdb.to>
2025-05-16 05:08:33 +00:00
1154cfd0bc Add stack to run mainnet validator node (#1)
Part of https://www.notion.so/Laconic-Mainnet-Plan-1eca6b22d47280569cd0d1e6d711d949

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Reviewed-on: #1
Co-authored-by: shreerang <shreerang@noreply.git.vdb.to>
Co-committed-by: shreerang <shreerang@noreply.git.vdb.to>
2025-05-15 06:38:42 +00:00
41 changed files with 2984 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
*-deployment
*-spec.yml
# Playbook vars
*-vars.yml
+13 -1
View File
@@ -1 +1,13 @@
# mainnet-laconicd-stack
# laconicd-stack
- This stack is used for running nodes to launch Laconic mainnet chain
- It allows you to export SAPO testnet state and start mainnet nodes
- To launch Laconic mainnet, follow these steps:
- **Run the First Validator Node:** Begin by setting up and running the initial validator node as detailed in [run-first-validator.md](docs/run-first-validator.md)
- **Deploy Cosmos Multisig App:** Integrate and run the Cosmos Multisig app using the playbook available at [cosmos-multisig-app playbook](./playbooks/cosmos-multisig-app/README.md)
- **Run Subsequent Validator Nodes:** Run subsequent validator nodes by following the instructions in [run-validator.md](docs/run-validator.md)
View File
+45
View File
@@ -0,0 +1,45 @@
{
"chainId": "laconic-mainnet",
"chainName": "Laconic Mainnet",
"rpc": "",
"rest": "",
"bip44": {
"coinType": 118
},
"bech32Config": {
"bech32PrefixAccAddr": "laconic",
"bech32PrefixAccPub": "laconipub",
"bech32PrefixValAddr": "laconicvaloper",
"bech32PrefixValPub": "laconicvaloperpub",
"bech32PrefixConsAddr": "laconicvalcons",
"bech32PrefixConsPub": "laconicvalconspub"
},
"currencies": [
{
"coinDenom": "ALNT",
"coinMinimalDenom": "alnt",
"coinDecimals": 0
}
],
"feeCurrencies": [
{
"coinDenom": "ALNT",
"coinMinimalDenom": "alnt",
"coinDecimals": 0,
"gasPriceStep": {
"low": 0.001,
"average": 0.001,
"high": 0.002
}
}
],
"stakeCurrency": {
"coinDenom": "ALNT",
"coinMinimalDenom": "alnt",
"coinDecimals": 0
},
"features": [
"stargate",
"ibc-transfer"
]
}
+513
View File
@@ -0,0 +1,513 @@
# demo
## Prerequisites
- [ansible](playbooks/README.md#ansible-installation)
- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install)
- [tmkms](https://github.com/iqlusioninc/tmkms?tab=readme-ov-file#installation)
- Install with `softsign` feature
```bash
cargo install tmkms --features=softsign --version=0.14.0
```
- Install `zstd` using `sudo apt install zstd`
- testnet-state.zst ([exported testnet state](./run-first-validator.md#export-testnet-state))
- LPS distribution Google spreadsheet URL or CSV file path
## Steps
- In current working directory demo, keep exported `testnet-state.zst` file from prerequisites
- Fetch stack:
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
```
- Generate LPS lockup distribution JSON file
```bash
~/cerc/laconicd-stack/scripts/generate-lps-lock.sh -i "<lps-distribution-spreadsheet-url-or-file-path>" -d "~/cerc/laconicd-stack/data"
```
- This will generate the `distribution.json` file
- Export current working directory
```bash
export CWD=$(pwd)
```
- Extract the testnet-state JSON file
```
zstd -dc $CWD/testnet-state.zst > $CWD/testnet-state.json
# Remove zst folder
rm -rf testnet-state.zst
```
- Set envs:
```bash
export EXPORTED_STATE_PATH=$CWD/testnet-state.json
export LPS_DISTRIBUTION_PATH=~/cerc/laconicd-stack/data/distribution.json
# Test address that does not exist on testnet chain
export EARLY_SUPPORTS_ACC_ADDR=laconic1gwytamfk3m5n0gsawh5vpwxkwd3vapmvzpp6nz
```
- 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
```
- Run playbook to use exported state for generating mainnet genesis:
```bash
ansible-playbook -v -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
```bash
# List files in output directory - genesis.json and staking-amount.json
ls -l output
```
- Set env for key of account with balance in testnet:
```bash
export FIRST_ACCOUNT_KEY=<KEY_OF_ACCOUNT_WITH_BALANCE_IN_TESTNET>
```
- Create and populate first-validator-vars.yml:
```bash
cat > ~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml << EOL
# Use a private key of an existing account with balance in testnet
pvt_key: $FIRST_ACCOUNT_KEY
# Path to the generated mainnet genesis file
# Use the absolute path of generated output directory in the previous steps
genesis_file: "$CWD/output/genesis.json"
# Path to staking-amount.json generated in previous steps
staking_amount_file: "$CWD/output/staking-amount.json"
# Set custom moniker for the node
cerc_moniker: "LaconicMainnet"
# Set desired key name
key_name: "laconic-validator"
cerc_chain_id: "laconic-mainnet"
min_gas_price: 0.001
cerc_loglevel: "info"
key_name: "laconic-validator"
EOL
```
- Export the data directory and mainnet deployment directory as environment variables:
```bash
# Parent directory where the deployment directory will live
export DATA_DIRECTORY=$CWD
# Set mainnet deployment directory
export MAINNET_DEPLOYMENT_DIR=mainnet-laconicd-deployment
```
- Run ansible playbook to submit gentx and setup the node:
```bash
ansible-playbook -v -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/setup-first-validator.yml
```
- Create tmks config directory for first validator node
```bash
tmkms init ./tmkms-first-node
```
- Update the TMKMS configuration file `./tmkms-first-node/tmkms.toml`:
```bash
cat > ./tmkms-first-node/tmkms.toml << EOL
[[chain]]
id = "laconic-mainnet"
key_format = { type = "cosmos-json", account_key_prefix = "laconicpub", consensus_key_prefix = "laconicvalconspub" }
state_file = "$CWD/tmkms-first-node/state/priv_validator_state.json"
[[validator]]
chain_id = "laconic-mainnet"
addr = "tcp://localhost:26659"
secret_key = "$CWD/tmkms-first-node/secrets/kms-identity.key"
protocol_version = "v0.34"
reconnect = true
[[providers.softsign]]
key_type = "consensus"
path = "$CWD/tmkms-first-node/secrets/priv_validator_key"
chain_ids = ["laconic-mainnet"]
EOL
```
- Import the private validator key into tmkms:
```bash
tmkms softsign import $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json $CWD/tmkms-first-node/secrets/priv_validator_key
```
- Start TMKMS:
```bash
tmkms start --config $CWD/tmkms-first-node/tmkms.toml
```
- Expected example output:
```bash
INFO tmkms::commands::start: tmkms 0.14.0 starting up...
INFO tmkms::keyring: [keyring:softsign] added consensus Ed25519 key: {"@type":"/cosmos.crypto.ed25519.PubKey","key":"T24No1A1FmetNRVCOSg2G2XAKWh97oBXuELdAD6DFgw="}
INFO tmkms::connection::tcp: KMS node ID: 7f5fd8dae8953e964e7e56edd4700f597ea0d45c
ERROR tmkms::client: [laconic-mainnet@tcp://localhost:26659] I/O error: Connection refused (os error 111)
```
NOTE: The errors dissapear once the laconicd node starts
- Note the pubkey logged at start for comparing later with validator pubkey on chain
- In a new terminal export envs
```bash
export CWD=$(pwd)
export DATA_DIRECTORY=$CWD
export MAINNET_DEPLOYMENT_DIR=mainnet-laconicd-deployment
# Test address that does not exist on testnet chain
export EARLY_SUPPORTS_ACC_ADDR=laconic1gwytamfk3m5n0gsawh5vpwxkwd3vapmvzpp6nz
```
- Enable TMKMS in the laconicd node configuration:
```bash
echo "TMKMS_ENABLED=true" >> $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/config.env
```
- Remove the validator key from node deployment as it is no longer required
```bash
rm $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json
```
- Run the first validator node
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR start
```
- Check logs to ensure that node is running:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR logs laconicd -f
```
- The chain will start running after some time.
- Verify that validator and TMKMS pubkeys match
- Get validator pubkey on chain
```bash
# Check consensus_pubkey in output
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query staking validators -o json | jq .validators'
```
- Compare it with the pubkey noted from logs in TMKMS
- Check bonds list to confirm that testnet state was transferred properly:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query bond list'
```
- Check `alps` and `alnt` tokens total supply:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query bank total-supply'
```
- Query the `lps_lockup` account and view distribution:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query auth module-account lps_lockup'
```
- Query the `lps_lockup` and early supports accounts balances:
```bash
lockup_account_address=$(laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query auth module-account lps_lockup -o json | jq -r .account.value.base_account.address')
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd "laconicd query bank balances $lockup_account_address"
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd "laconicd query bank balances $EARLY_SUPPORTS_ACC_ADDR"
```
- Copy the genesis file to [config](./config) folder:
```bash
cp $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/genesis.json ~/cerc/laconicd-stack/config/mainnet-genesis.json
```
- Copy the staking amount file to [config](./config) folder:
```bash
cp $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/tmp/staking-amount.json ~/cerc/laconicd-stack/config/staking-amount.json
```
- Copy the example variables file:
```bash
cp ~/cerc/laconicd-stack/playbooks/validator/validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml
```
- Check first validator node address using:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'echo $(laconicd cometbft show-node-id)@host.docker.internal:26656'
```
- Update `cerc_peers` in `~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml`:
```bash
cerc_moniker: "LaconicMainnetNode-2"
cerc_peers: "<node-id>@host.docker.internal:26656"
```
- Export the data directory and mainnet deployment directory as environment variables:
```bash
# Parent directory where the deployment directory will live
export DATA_DIRECTORY=$CWD
# Set mainnet deployment directory
export MAINNET_DEPLOYMENT_DIR=mainnet-validator-deployment
```
- Update port mappings in `~/cerc/laconicd-stack/playbooks/validator/templates/specs/spec-template.yml.j2` to avoid port conflicts with first validator node:
```bash
network:
ports:
laconicd:
- '3060:6060'
- '36659:26659'
- '36657:26657'
- '36656:26656'
- '3473:9473'
- '3090:9090'
- '3317:1317'
```
- Run ansible playbook to set up your validator node deployment:
```bash
ansible-playbook -v -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/setup-validator.yml
```
- Create tmks config directory for second validator node
```bash
tmkms init ./tmkms-second-node
```
- Update the TMKMS configuration file `./tmkms-second-node/tmkms.toml`:
```bash
cat > ./tmkms-second-node/tmkms.toml << EOL
[[chain]]
id = "laconic-mainnet"
key_format = { type = "cosmos-json", account_key_prefix = "laconicpub", consensus_key_prefix = "laconicvalconspub" }
state_file = "$CWD/tmkms-second-node/state/priv_validator_state.json"
[[validator]]
chain_id = "laconic-mainnet"
addr = "tcp://localhost:36659"
secret_key = "$CWD/tmkms-second-node/secrets/kms-identity.key"
protocol_version = "v0.34"
reconnect = true
[[providers.softsign]]
key_type = "consensus"
path = "$CWD/tmkms-second-node/secrets/priv_validator_key"
chain_ids = ["laconic-mainnet"]
EOL
```
- Import the private validator key into tmkms:
```bash
tmkms softsign import $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json $CWD/tmkms-second-node/secrets/priv_validator_key
```
- Start TMKMS:
```bash
tmkms start --config $CWD/tmkms-second-node/tmkms.toml
```
- In a new terminal export envs
```bash
export CWD=$(pwd)
export DATA_DIRECTORY=$CWD
export MAINNET_DEPLOYMENT_DIR=mainnet-validator-deployment
```
- Enable TMKMS in the laconicd node configuration:
```bash
echo "TMKMS_ENABLED=true" >> $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/config.env
```
- Start the node:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR start
```
- Check logs to ensure that node is running:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR logs laconicd -f
```
- Export required env vars for creating validator:
```bash
# private key of another existing account with balance
export PVT_KEY=<private-key-in-hex-format>
# desired key name
export KEY_NAME=validator-2
```
- Run ansible playbook to create validator on running chain:
```bash
ansible-playbook -v -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/create-validator.yml
```
- Check the validator list:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query staking validators'
```
- Remove the validator key from node deployment as it is no longer required
```bash
rm $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json
```
- Copy the example variables file for cosmos-multisig app playbook:
```bash
cp ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/cosmos-multisig-vars.example.yml ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/cosmos-multisig-vars.yml
```
- Update env values in `cosmos-multisig-vars.yml` with your node RPC URL
```bash
next_public_node_addresses: '["http://localhost:26657"]'
node_rest_endpoint: 'http://localhost:1317'
next_public_is_http_enabled: true
# Set network mode to host so that browser app and backend can use the same node localhost RPC URL
use_host_network: "host"
# Set local host URL for dgraph server
dgraph_domain: "http://localhost:8090"
```
- Set envs:
```bash
# Set multisig app deployment directory
export MULTISIG_DEPLOYMENT_DIR=cosmos-multisig-deployment
```
- Run playbook to setup cosmos multisig app
```bash
ansible-playbook -v -i localhost, -c local ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/cosmos-multisig-app-start.yml
```
- Check logs to ensure that the app is running:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MULTISIG_DEPLOYMENT_DIR logs -f
```
- The app will be running on <http://localhost:7000/laconic>
### Create a multisig with both the validator accounts
- On opening the app, a prompt will be shown to add laconic network to you Keplr wallet. Click on `Approve`
- Go to home and click on `I don't have a multisig`
- Add the addresses of your validators as member 1 and member 2
- Set the threshold to 2 out of 2 members (Both the validators should sign the TX to broadcast it)
- Click on `Submit` and `Create multisig`
### Create and sign transaction
- Add accounts in Keplr wallet for signing the transaction
- Open Keplr wallet and click on the user icon in the top right corner
- Click on `Add wallet`, then select `Import an existing wallet` and go to `Use recovery phrase or private key`
- Select the `Private key` tab and then paste the private key of the validator account and click on import
- Set a name for the wallet (used when connecting wallet to app for signing transaction) and click on next
- Search for `Laconic network` and select it, then click on `Save`
- Follow the above steps for the second validator account
- Send fund to the generated multisig address using Keplr
- Open Keplr wallet and select the account from which you wish to transfer the funds to the multisig address
- Search and `laconic` and select the network. Select `Send` and paste the multisig address and set amount to `0.000000000001` (1000000alnt)
- Go to `home`, paste your multisig address and click on `Use this multisig`
- You will see the multisig members and holdings for the address
- Click on `Create new transaction` and then click on `Bank Send` under `Add New Msg`
- Enter the recipient address ( Eg: `laconic1n4wa366kh0zxndwyq3kkse9ulz9jv9xukx3hy4`), amount to be transfered and memo (optional)
- Click on create transaction
- Go back to the multisig info page and scroll down to the `Transactions` section
- Click on `Verify identity` and connect the app to your validator account in the Keplr wallet
- After approving the connection, you will see the list of transactions created by your multisig
- Click on your transaction and under `Choose wallet to sign`, click on connect Keplr
- After connecting the wallet, click on `Sign transaction` and approve the transaction
- Go back to multisig info page, switch to the second validator account in Keplr wallet and repeat the same process to sign the transaction with the second validator account
- Once the transaction is signed by both the validators, click on `Broadcast Transaction`
- Confirm funds transfer by checking balance of recipient address
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd "laconicd query bank balances laconic1n4wa366kh0zxndwyq3kkse9ulz9jv9xukx3hy4"
```
## Cleanup
- Remove deployments and other config files
```bash
rm -rf *-spec.yml *-deployment tmkms-* output
```
+415
View File
@@ -0,0 +1,415 @@
# Run First Validator Node
## Prerequisites
- Machine 1: Where the SAPO testnet node is already running
- Install `zstd` using `sudo apt install zstd`
- Machine 2: Where the mainnet first validator node is to be setup
- Machine 3: Where the genesis file is to be generated
- Install `zstd` using `sudo apt install zstd`
- LPS distribution Google spreadsheet URL or CSV file path
- Machine 4: Where the TMKMS service is to be setup
- Following tools are required in all machines:
- [ansible](playbooks/README.md#ansible-installation)
- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install)
- laconicd-stack
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
```
## Build laconicd to generate genesis file
- Run the following steps in a secure machine (machine 3) separate from the one where the node is to be setup (machine 2)
- Run playbook to build laconicd container:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/build-laconicd.yml
```
## Setup node
- Run the following steps in the machine where the mainnet node is to be setup (machine 2)
- Copy the example variables file if not already done:
```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
# Set custom moniker for the node
cerc_moniker: "LaconicMainnetNode"
# Set desired key name
key_name: "laconic-validator"
# Enable TMKMS
tmkms_enabled: true
```
- 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
export MAINNET_DEPLOYMENT_DIR=mainnet-laconicd-deployment
```
- Run ansible playbook to setup the node:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/setup-first-validator.yml
```
- Get the public key of your node:
```bash
docker run -it \
-v $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data:/root/.laconicd \
cerc/laconicd:local bash -c "laconicd tendermint show-validator"
```
NOTE: This public key is required in [next step to generate the genesis file](#generate-mainnet-genesis-file)
- Copy over the `priv_validator_key.json` located at `$DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json` to the machine where the TMKMS service is to be setup (machine 4)
## Setup TMKMS
- For integrating TMKMS with laconicd, follow steps below in the machine where the TMKMS service is to be setup (machine 4)
- Copy the example variables file:
```bash
cp ~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.example.yml ~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.yml
```
- Update `~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.yml` with required values:
```yaml
# Set the mode of operation for TMKMS (e.g., "softsign", "yubihsm")
tmkms_mode: <tmkms-mode>
```
- Export the data directory and TMKMS deployment directory as environment variables:
```bash
# Parent directory where the deployment directory will live
export DATA_DIRECTORY=
```
- Run ansible playbook to setup the TMKMS service:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/tmkms/setup-tmkms.yml
```
## Export testnet state
- Run the following steps in machine where the testnet node is already running (machine 1)
- Get your private key from testnet deployment:
```bash
laconic-so deployment --dir <testnet-deployment-dir> exec laconicd "laconicd keys export <key-name> --unarmored-hex --unsafe"
```
NOTE: Store this key securely as it is needed in later steps
- Stop the node for SAPO testnet:
```bash
laconic-so deployment --dir <testnet-deployment-dir> stop
```
- Run script to export state from testnet chain:
```bash
~/cerc/laconicd-stack/scripts/export-testnet-state.sh <absolute-path-to-testnet-deployment>
```
- The compressed zst file will be generated at `<absolute-path-to-testnet-deployment>/export/testnet-state.zst`
## Generate mainnet genesis file
- Run the following steps in machine where [the genesis file is to be generated (machine 3)](#build-laconicd-to-generate-genesis-file)
- Copy over compressed `testnet-state.zst` file to target machine
- Set envs:
```bash
# Path where exported testnet state JSON file will be created
export EXPORTED_STATE_PATH=<absolute-path-to-be-exported-testnet-state-json>
# Path where LPS distribution JSON file will be created
export LPS_DISTRIBUTION_PATH=<absolute-path-to-be-generated-distribution-json>
export EARLY_SUPPORTS_ACC_ADDR=<account-address-controlled-by-laconic-foundation>
# Parent directory where the deployment directory will live
export DATA_DIRECTORY=
```
- Extract the testnet-state JSON file:
```bash
zstd -dc <path-to-compressed-file>/testnet-state.zst > $EXPORTED_STATE_PATH
# Remove zst folder
rm -rf <path-to-compressed-file>/testnet-state.zst
```
- Generate LPS lockup distribution JSON file
```bash
~/cerc/laconicd-stack/scripts/generate-lps-lock.sh -i "<lps-distribution-spreadsheet-url-or-csv-file-path>" -o $LPS_DISTRIBUTION_PATH
```
- This will generate the `distribution.json` file at `$LPS_DISTRIBUTION_PATH`
- 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
```
- Edit `~/cerc/laconicd-stack/playbooks/first-validator/first-validator-vars.yml` with required values:
NOTE: Use the public key exported in [previous step](#setup-node)
```bash
# Make sure to wrap it with single quotes ('')
validator_pub_key: '<public-key-of-your-node>'
```
- Run playbook to use exported state for generating mainnet genesis file with gentx:
```bash
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"
```
- Input private key of the existing account that was exported in previous steps when prompted
- 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
### Start TMKMS
- Run these steps in the machine where [the TMKMS service is setup (machine 4)](#setup-tmkms)
- Copy the example variables file:
```bash
cp ~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.example.yml ~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.yml
```
- Update `~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.yml` with required values:
NOTE: Use the `priv_validator_key.json` file copied from the node setup machine (Machine 2) in [previous step](#setup-node)
```yaml
# Absolute path to the node's private validator key file
priv_validator_key_file_path: "</path/to/priv_validator_key.json>"
# Set the IP address of the machine where the laconicd node is setup
node_ip: "<NODE_PUBLIC_IP_ADDRESS>"
# Set the port of the laconicd node
node_port: "26659"
```
- If using `yubihsm` mode, run following command to setup the yubihsm:
**WARNING: THIS PROCESS PERFORMS A FACTORY RESET OF THE YUBIHSM, DELETING ALL EXISTING KEYS AND REPLACING THEM WITH NEW ONES. MAKE SURE YOU HAVE MADE BACKUPS OF IMPORTANT KEYS BEFORE PROCEEDING!!!**
```bash
# Use a strong password for YubiHSM
docker run -it --rm \
-v $DATA_DIRECTORY/tmkms-deployment/data/tmkms-data:/home/tmkmsuser/tmkms \
-v ~/cerc/tmkms-stack/stack-orchestrator/config/tmkms/setup-yubihsm.sh:/scripts/setup-yubihsm.sh \
-e "PASSWORD=<yubihsm-password>" \
-e "CHAIN_ID=laconic-mainnet" \
-e "NODE_IP=<NODE_PUBLIC_IP_ADDRESS>" \
-e "NODE_PORT=26659" \
cerc/tmkms:local bash -c "/scripts/setup-yubihsm.sh"
```
- Run ansible playbook to run the TMKMS:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/tmkms/run-tmkms.yml
```
- Check logs to ensure that TMKMS is running:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/tmkms-deployment logs tmkms -f
```
- Expected example output:
```bash
INFO tmkms::commands::start: tmkms 0.14.0 starting up...
INFO tmkms::keyring: [keyring:softsign] added consensus Ed25519 key: {"@type":"/cosmos.crypto.ed25519.PubKey","key":"T24No1A1FmetNRVCOSg2G2XAKWh97oBXuELdAD6DFgw="}
INFO tmkms::connection::tcp: KMS node ID: 7f5fd8dae8953e964e7e56edd4700f597ea0d45c
ERROR tmkms::client: [laconic-mainnet@tcp://<node-ip>:26659] I/O error: Connection refused (os error 111)
```
NOTE: The errors dissapear once the laconicd node starts
- Note the pubkey logged at start for comparing later with validator pubkey on chain
### Start node
- Run the following steps in the machine where [the mainnet node is setup (machine 2)](#setup-node)
- Remove the validator key from node deployment as it is no longer required:
NOTE: Store it safely offline in case of an emergency
```bash
rm -rf $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json
```
- Copy the genesis file to the mainnet deployment tmp directory:
```bash
cp <absolute-path-to-genesis-json> $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/tmp/genesis.json
```
- Command to run node:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR start
```
- Check logs to ensure that node is running:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR logs laconicd -f
```
- Verify that validator and TMKMS pubkeys match:
- Get validator pubkey on chain
```bash
# Check consensus_pubkey in output
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query staking validators -o json | jq .validators'
```
- Compare it with the pubkey noted from logs in TMKMS
- Check bonds list to confirm that testnet state was transferred properly:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query bond list'
```
- Check `alps` and `alnt` tokens total supply:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query bank total-supply'
```
- Query the `lps_lockup` account and view distribution:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query auth module-account lps_lockup'
```
- Query the `lps_lockup` and early supports accounts balances:
```bash
lockup_account_address=$(laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query auth module-account lps_lockup -o json | jq -r .account.value.base_account.address')
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd "laconicd query bank balances $lockup_account_address"
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd "laconicd query bank balances $EARLY_SUPPORTS_ACC_ADDR"
```
## Update config
- Run following steps to update the config for TMKMS and node
### TMKMS
- Run these steps in the machine where the TMKMS service is setup (machine 4)
- Stop the TMKMS deployment:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$TMKMS_DEPLOYMENT_DIR stop
```
- Update `~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.yml` with required values
- Run ansible playbook to run the TMKMS:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/tmkms/run-tmkms.yml
```
### Node
- Run these steps in the machine where the mainnet node is setup (machine 2)
- Stop the node deployment:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR stop
```
- Update `$DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/config.env` with required values
- Start the node deployment:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR start
```
## Publish required artifacts
- Run the following steps in machine where the genesis file and staking amount files are generated (machine 3)
- Copy the genesis file to [config](./config) folder:
```bash
cp $DATA_DIRECTORY/output/genesis.json ~/cerc/laconicd-stack/config/mainnet-genesis.json
```
- Copy the staking amount file to [config](./config) folder:
```bash
cp $DATA_DIRECTORY/output/staking-amount.json ~/cerc/laconicd-stack/config/staking-amount.json
```
- Get your node's address by running following command in the machine where the mainnet node is running (machine 2):
```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, staking amount file and node address so that it is available to other validators
+332
View File
@@ -0,0 +1,332 @@
# Run Validator Node
## Prerequisites
- Machine 1: Where the SAPO testnet node is already running
- Machine 2: Where the mainnet validator node is to be setup
- laconicd-stack
- [ansible](playbooks/README.md#ansible-installation)
- Machine 3: Where the create-validator transaction is to be signed
- laconicd-stack
- [ansible](playbooks/README.md#ansible-installation)
- Machine 4: Where the TMKMS service is to be setup
- laconicd-stack
- [ansible](playbooks/README.md#ansible-installation)
- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install) is required in all machines
- To fetch laconicd-stack:
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
```
## Stop SAPO testnet node
- Run the following steps in machine where the testnet node is already running (machine 1)
- Get your private key from testnet deployment:
```bash
laconic-so deployment --dir <testnet-deployment-dir> exec laconicd "laconicd keys export <key-name> --unarmored-hex --unsafe"
```
NOTE: Store this key securely as it is needed in [later steps](#create-validator)
- Stop the node for SAPO testnet:
```bash
laconic-so deployment --dir <testnet-deployment-dir> stop
```
## Build laconicd to create validator
- Run the following steps in a secure machine (machine 3) separate from the one where the node is to be setup (machine 2)
- Run playbook to build laconicd container:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/build-laconicd.yml
```
## Setup Node
- Run the following steps in the machine where the validator node is to be setup (machine 2)
- Copy the example variables file:
```bash
cp ~/cerc/laconicd-stack/playbooks/validator/validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml
```
- Update `~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml` with required values:
```bash
# Set custom moniker for the node
cerc_moniker: "<your-moniker>"
# Set persistent peers (comma-separated list of node IDs and addresses)
# You can find the list of available peers in https://git.vdb.to/cerc-io/laconicd-stack/src/branch/main/node-addresses.yml
cerc_peers: "<node-id>@<node-host>:26656,<node-id>@<node-host>:26656"
# Enable TMKMS
tmkms_enabled: true
```
- 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
export MAINNET_DEPLOYMENT_DIR=mainnet-validator-deployment
```
- Run ansible playbook to set up your validator node deployment:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/setup-validator.yml
```
- Copy over the `priv_validator_key.json` located at `$DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json` to the machine from where the TMKMS service is to be setup (machine 4)
## Setup TMKMS
- For integrating TMKMS with laconicd, follow steps below in the machine where the TMKMS service is to be setup (machine 4)
- Copy the example variables file:
```bash
cp ~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.example.yml ~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.yml
```
- Update `~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.yml` with required values:
```yaml
# Set the mode of operation for TMKMS (e.g., "softsign", "yubihsm")
tmkms_mode: <tmkms-mode>
```
- Export the data directory as environment variable:
```bash
# Parent directory where the deployment directory will live
export DATA_DIRECTORY=
```
- Run ansible playbook to setup the TMKMS service:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/tmkms/setup-tmkms.yml
```
## Run Node
### Start TMKMS
- Run the following steps in the machine where [the TMKMS service is setup (Machine 4)](#setup-tmkms)
- Copy the example variables file:
```bash
cp ~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.example.yml ~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.yml
```
- Update `~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.yml` with required values:
NOTE: Use the `priv_validator_key.json` file copied from the node setup machine (Machine 2) in [previous step](#setup-node)
```yaml
# Absolute path to the node's private validator key file
priv_validator_key_file_path: "</path/to/priv_validator_key.json>"
# Set the IP address of the machine where the laconicd node is setup
node_ip: "<NODE_PUBLIC_IP_ADDRESS>"
# Set the port of the laconicd node
node_port: "26659"
```
- If using `yubihsm` mode, run following command to setup the yubihsm:
**WARNING: THIS PROCESS PERFORMS A FACTORY RESET OF THE YUBIHSM, DELETING ALL EXISTING KEYS AND REPLACING THEM WITH NEW ONES. MAKE SURE YOU HAVE MADE BACKUPS OF IMPORTANT KEYS BEFORE PROCEEDING!!!**
```bash
# Use a strong password for YubiHSM
docker run -it --rm \
-v $DATA_DIRECTORY/tmkms-deployment/data/tmkms-data:/home/tmkmsuser/tmkms \
-v ~/cerc/tmkms-stack/stack-orchestrator/config/tmkms/setup-yubihsm.sh:/scripts/setup-yubihsm.sh \
-e "PASSWORD=<yubihsm-password>" \
-e "CHAIN_ID=laconic-mainnet" \
-e "NODE_IP=<NODE_PUBLIC_IP_ADDRESS>" \
-e "NODE_PORT=26659" \
cerc/tmkms:local bash -c "/scripts/setup-yubihsm.sh"
```
- Run ansible playbook to run the TMKMS:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/tmkms/run-tmkms.yml
```
- Check logs to ensure that TMKMS is running:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/tmkms-deployment logs tmkms -f
```
- Expected example output:
```bash
INFO tmkms::commands::start: tmkms 0.14.0 starting up...
INFO tmkms::keyring: [keyring:softsign] added consensus Ed25519 key: {"@type":"/cosmos.crypto.ed25519.PubKey","key":"T24No1A1FmetNRVCOSg2G2XAKWh97oBXuELdAD6DFgw="}
INFO tmkms::connection::tcp: KMS node ID: 7f5fd8dae8953e964e7e56edd4700f597ea0d45c
ERROR tmkms::client: [laconic-mainnet@<node-ip>:26659] I/O error: Connection refused (os error 111)
```
NOTE: The errors dissapear once the laconicd node starts
- Note the pubkey logged at start for comparing later with validator pubkey on chain
### Start Node
- Run the following steps in the machine where [the validator node is setup (machine 2)](#setup-node)
- Start the laconicd node:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR start
```
- Check logs to ensure that node is running:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR logs laconicd -f
```
- Get the public key of your node:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd "laconicd tendermint show-validator"
```
NOTE: This public key is required in next step to create validator
## Create Validator
- Run these steps in a machine from where [the create-validator transaction is to be signed (machine 3)](#build-laconicd-to-create-validator)
- Copy the example variables file:
```bash
cp ~/cerc/laconicd-stack/playbooks/validator/validator-vars.example.yml ~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml
```
- Update `~/cerc/laconicd-stack/playbooks/validator/validator-vars.yml` with required values:
NOTE: Use the public key exported in [previous step](#start-node)
```bash
# Same moniker as set above
cerc_moniker: "<your-moniker>"
# Make sure to wrap it with single quotes ('')
validator_pub_key: '<public-key-of-your-node>'
# Set the public IP address of the machine where your node is running
node_url: "tcp://NODE_PUBLIC_IP_ADDRESS:26657"
```
- Export required env vars:
```bash
export DATA_DIRECTORY=<data-directory>
```
- Run ansible playbook to create validator on running chain:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/validator/create-validator.yml
```
- Input private key of the existing account that was exported in [previous steps](#stop-sapo-testnet-node) when prompted
- Run the following commands in the machine where the validator node is running (machine 2)
- Check the validator list:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR exec laconicd 'laconicd query staking validators'
```
- Remove the validator key from node deployment as TMKMS is configured:
NOTE: Store it safely offline in case of an emergency
```bash
rm -rf $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/data/laconicd-data/config/priv_validator_key.json
```
## Update config
- Run following steps to update the config for TMKMS and node
### TMKMS
- Run these steps in the machine where the TMKMS service is setup (machine 4)
- Stop the TMKMS deployment:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/tmkms-deployment stop
```
- Update `~/cerc/laconicd-stack/playbooks/tmkms/tmkms-vars.yml` with required values
- Run ansible playbook to run the TMKMS:
```bash
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/tmkms/run-tmkms.yml
```
### Node
- Run these steps in the machine where the mainnet node is setup (machine 2)
- Stop the node deployment:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR stop
```
- Update `$DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR/config.env` with required values
- Start the node deployment:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MAINNET_DEPLOYMENT_DIR start
```
## Register Your Node
- Run the following steps in the machine where the mainnet node is setup (machine 2)
- 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 the `~/cerc/laconicd-stack/node-addresses.yml` file
- Submit a PR to add your node address to the repository
+4
View File
@@ -0,0 +1,4 @@
# Add your node addresses here
# Example:
# - node-1-id@node-1-host:26656
# - node-2-id@node-2-host:26656
+42
View File
@@ -0,0 +1,42 @@
# 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:
```bash
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]
```
+95
View File
@@ -0,0 +1,95 @@
# Cosmos Multisig App Setup
This playbook sets up the Cosmos Multisig application for managing multisig wallets on the Laconic chain.
## Prerequisites
- [Mainnet node RPC and REST API endpoints](../../docs/run-first-validator.md)
- [ansible](../README.md#ansible-installation)
- If running playbook to setup deployment on remote machine, the following need to be installed in remote:
- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install)
- [yq](https://github.com/mikefarah/yq?tab=readme-ov-file#wget)
## Configuration
* Fetch the stack:
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
```
* Copy the example variables file:
```bash
cp ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/cosmos-multisig-vars.example.yml ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/cosmos-multisig-vars.yml
```
* Update `~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/cosmos-multisig-vars.yml` with your node configuration:
```yaml
# TODO: Update with example domains mapped to ports
next_public_node_addresses: '["https://laconicd-mainnet.laconic.com"]'
node_rest_endpoint: "https://api.laconicd-mainnet.laconic.com"
```
## Setup Steps
* Set common environment variables:
```bash
# Parent directory where the deployment directory will live
export DATA_DIRECTORY=<path/to/deployments/directory>
export MULTISIG_DEPLOYMENT_DIR=cosmos-multisig-deployment
```
### Local Setup
* Setup and start the multisig app:
```bash
ansible-playbook -v -i hosts.ini ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/cosmos-multisig-app-start.yml --limit local
```
* Access the app at <http://localhost:7000/laconic>
### Remote Setup
* Create and configure hosts.ini:
* Copy the example file:
```bash
cp ~/cerc/laconicd-stack/playbooks/hosts.ini.example ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/hosts.ini
```
* Edit `~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/hosts.ini` and update the remote host details:
```ini
[remote]
# Replace with your actual remote host details
remote_host ansible_host=your.remote.host ansible_user=your_remote_user ansible_ssh_common_args='-o ForwardAgent=yes'
```
* Verify SSH connection using Ansible ping:
```bash
ansible all -m ping -i ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/hosts.ini --limit remote_host
```
* Run the playbook targeting the remote host:
```bash
ansible-playbook -v -i ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/hosts.ini ~/cerc/laconicd-stack/playbooks/cosmos-multisig-app/cosmos-multisig-app-start.yml --limit remote_host
```
* Access the app at <http://your.remote.host:7000/laconic>
## Check Status
* Check app logs:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MULTISIG_DEPLOYMENT_DIR logs -f cosmos-multisig-ui
```
## Clean up
- To stop the deployment:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MULTISIG_DEPLOYMENT_DIR stop
```
- To stop and delete all data:
```bash
laconic-so deployment --dir $DATA_DIRECTORY/$MULTISIG_DEPLOYMENT_DIR stop --delete-volumes
sudo rm -rf $DATA_DIRECTORY/$MULTISIG_DEPLOYMENT_DIR
```
@@ -0,0 +1,116 @@
---
- name: Setup and deploy the cosmos multisig app
hosts: multihosts
# To use yq binary installed in user bin path
environment:
PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin"
vars_files:
- cosmos-multisig-vars.yml
vars:
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
multisig_deployment_dir: "{{ lookup('env', 'MULTISIG_DEPLOYMENT_DIR') }}"
spec_output: "{{data_directory}}/cosmos-multisig-ui-spec.yml"
spec_template: "./templates/specs/cosmos-multisig-app-spec-template.yml.j2"
remote_spec_template: "{{data_directory}}/cosmos-multisig-app-spec-template.yml.j2"
network_json: "../../config/network.json"
remote_network_json: "{{data_directory}}/network.json"
build_args: "{{ '--force-rebuild' if (lookup('env', 'FORCE_REBUILD') | default(omit, true)) not in [ 'false', 'False', '0' ] else '' }}"
tasks:
- name: Fail if DATA_DIRECTORY env var is not set
fail:
msg: "Environment variable DATA_DIRECTORY is not set. Please export it before running the playbook."
when: lookup('env', 'DATA_DIRECTORY') == ''
- name: Clone cosmos-multisig-ui repo
shell: |
laconic-so fetch-stack git.vdb.to/cerc-io/cosmos-multisig-ui@v0.1.2 --git-ssh --pull
- name: Build container image
shell: |
laconic-so --stack ~/cerc/cosmos-multisig-ui/stack-orchestrator/stacks/cosmos-multisig-ui build-containers {{ build_args }}
- name: Create deployment spec file
shell: |
laconic-so --stack ~/cerc/cosmos-multisig-ui/stack-orchestrator/stacks/cosmos-multisig-ui deploy init --output {{ spec_output }}
- name: Copy spec template to remote server
copy:
src: "{{ spec_template }}"
dest: "{{ remote_spec_template }}"
mode: '0644'
- name: Replace network section in spec_output
shell: >
yq eval '(.network) = load("{{ remote_spec_template }}").network' -i {{ spec_output }}
- name: Check if deployment directory exists
stat:
path: "{{data_directory}}/{{ multisig_deployment_dir }}"
register: deployment_dir_stat
- name: Create deployment from spec file
shell: |
laconic-so --stack ~/cerc/cosmos-multisig-ui/stack-orchestrator/stacks/cosmos-multisig-ui/ deploy create --spec-file {{ spec_output }} --deployment-dir {{data_directory}}/{{ multisig_deployment_dir }}
when: not deployment_dir_stat.stat.exists
- name: Create config.env in deployment dir
copy:
dest: "{{data_directory}}/{{ multisig_deployment_dir }}/config.env"
content: |
NEXT_PUBLIC_MULTICHAIN={{ next_public_multichain }}
NEXT_PUBLIC_REGISTRY_NAME={{ next_public_registry_name }}
NEXT_PUBLIC_LOGO={{ next_public_logo }}
NEXT_PUBLIC_CHAIN_ID={{ next_public_chain_id }}
NEXT_PUBLIC_CHAIN_DISPLAY_NAME={{ next_public_chain_display_name }}
NEXT_PUBLIC_NODE_ADDRESSES={{ next_public_node_addresses }}
NODE_REST_ENDPOINT={{ node_rest_endpoint }}
NEXT_PUBLIC_DENOM={{ next_public_denom }}
NEXT_PUBLIC_DISPLAY_DENOM={{ next_public_display_denom }}
NEXT_PUBLIC_DISPLAY_DENOM_EXPONENT={{ next_public_display_denom_exponent }}
NEXT_PUBLIC_ASSETS={{ next_public_assets }}
NEXT_PUBLIC_GAS_PRICE={{ next_public_gas_price }}
NEXT_PUBLIC_ADDRESS_PREFIX={{ next_public_address_prefix }}
NEXT_PUBLIC_IS_HTTP_ENABLED={{ next_public_is_http_enabled }}
USE_HOST_NETWORK={{ use_host_network }}
DGRAPH_DOMAIN={{ dgraph_domain }}
CHAIN_CONFIG_PATH="{{data_directory}}/{{ multisig_deployment_dir }}/config/cosmos-multisig-ui/network.json"
mode: '0644'
- name: Copy network.json to remote server
copy:
src: "{{ network_json }}"
dest: "{{ remote_network_json }}"
mode: '0644'
- name: Update network.json with environment endpoints
shell: |
RPC_VALUE=$(echo '{{ next_public_node_addresses }}' | jq -r '.[0]')
echo "Using RPC value: $RPC_VALUE"
jq --arg rpc "$RPC_VALUE" --arg rest "{{ node_rest_endpoint }}" \
--arg chainId "{{ next_public_chain_id }}" --arg chainName "{{ next_public_chain_display_name }}" \
'.rpc = $rpc | .rest = $rest | .chainId = $chainId | .chainName = $chainName' "{{ remote_network_json }}" > "{{ remote_network_json }}.tmp" && \
mv "{{ remote_network_json }}.tmp" "{{ remote_network_json }}"
args:
executable: /bin/bash
- name: Copy modified network JSON to deployment config directory
copy:
src: "{{ remote_network_json }}"
dest: "{{data_directory}}/{{ multisig_deployment_dir }}/config/cosmos-multisig-ui/network.json"
remote_src: true
mode: '0644'
- name: Clean up temporary files
file:
path: "{{ item }}"
state: absent
with_items:
- "{{ remote_spec_template }}"
- "{{ remote_network_json }}"
- name: Start the deployment
shell: |
laconic-so deployment --dir {{data_directory}}/{{ multisig_deployment_dir }} start
@@ -0,0 +1,47 @@
# Set to true if the application supports multiple chains
next_public_multichain: false
# The name of the blockchain registry
next_public_registry_name: "laconic-mainnet"
# URL or path to the blockchain's logo
next_public_logo: ""
# The chain ID for the blockchain network
next_public_chain_id: "laconic-mainnet"
# Display name for the blockchain network
next_public_chain_display_name: "Laconic Mainnet"
# Comma-separated list of node addresses for the application to connect to
next_public_node_addresses: '[]'
# The REST endpoint for the node
node_rest_endpoint: ""
# The base denomination of the native token
next_public_denom: "alnt"
# The display denomination of the native token
next_public_display_denom: "ALNT"
# The exponent for the display denomination
next_public_display_denom_exponent: 0
# JSON array of asset definitions, including denom units, base, name, display, and symbol
next_public_assets: '[{"denom_units":[{"denom":"alnt","exponent":0}],"base":"alnt","name":"Laconic Token","display":"ALNT","symbol":"alnt"}]'
# Default gas price for transactions
next_public_gas_price: "0.001alnt"
# The address prefix for the blockchain
next_public_address_prefix: "laconic"
# Set to true if HTTP is enabled for the application
next_public_is_http_enabled: false
# Set to true to use host network mode for the Docker container
use_host_network: ""
# Domain for Dgraph service
dgraph_domain: ""
@@ -0,0 +1,6 @@
network:
ports:
cosmos-multisig-ui:
- 7000:7000
alpha:
- 8090:8080
@@ -0,0 +1,23 @@
# The public key of the validator node. This is required for generating the genesis file
# It should be wrapped in single quotes
validator_pub_key: ''
# Custom moniker for the validator node
cerc_moniker: "LaconicMainnetNode"
# The chain ID for the blockchain network
cerc_chain_id: "laconic-mainnet"
# Set to true to enable TMKMS (Tendermint Key Management System) for this node
# If true, the node will use an external TMKMS for signing validator operations
tmkms_enabled:
# Minimum gas price for transactions, in ALNT (e.g., 0.001alnt)
min_gas_price: 0.001
# Log level for the laconicd node (e.g., "info", "debug", "error")
cerc_loglevel: "info"
# Desired key name for the validator account
key_name: "laconic-validator"
@@ -0,0 +1,102 @@
---
- name: Generate Mainnet Genesis File
hosts: localhost
vars_files:
- first-validator-vars.yml
vars:
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
gentx_genesis_dir: "{{data_directory}}/generate-gentx-genesis"
spec_file: "{{data_directory}}/laconicd-spec.yml"
connection: local
tasks:
- name: Fail if DATA_DIRECTORY env vars are not set
fail:
msg: >-
Required environment variables are not set.
Please export both DATA_DIRECTORY before running the playbook.
when: lookup('env', 'DATA_DIRECTORY') == ''
- 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 {{ exported_state_path }} {{ lps_distribution_path }}"
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: 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"
- name: Create data directory
file:
path: "{{ gentx_genesis_dir }}"
state: directory
mode: '0755'
- name: Ensure tmp directory exists inside gentx genesis directory
file:
path: "{{gentx_genesis_dir}}/tmp"
state: directory
mode: '0755'
- name: Ensure output directory exists inside gentx genesis directory
file:
path: "{{gentx_genesis_dir}}/output"
state: directory
mode: '0755'
- name: Copy staking amount file to gentx genesis tmp directory
copy:
src: "{{ lookup('env', 'PWD') }}/output/staking-amount.json"
dest: "{{gentx_genesis_dir}}/tmp/staking-amount.json"
mode: '0644'
- name: Copy genesis file to gentx genesis tmp directory
copy:
src: "{{ lookup('env', 'PWD') }}/output/genesis.json"
dest: "{{gentx_genesis_dir}}/tmp/genesis.json"
mode: '0644'
- name: Prompt for validator private key
vars:
private_key_prompt: "Please enter your validator private key: "
pause:
prompt: "{{ private_key_prompt }}"
echo: no
register: private_key_input
- name: Fail if private key is not provided
fail:
msg: "Private key is required for creating the gentx."
when: private_key_input.user_input | default('') | trim == ''
- name: Run script to create and collect gentx
shell: |
docker run -i \
-v {{gentx_genesis_dir}}:/root/generate-gentx-genesis \
-v ~/cerc/laconicd-stack/stack-orchestrator/config/mainnet-laconicd:/scripts \
-e "PVT_KEY={{ private_key_input.user_input }}" \
-e "KEY_NAME={{ key_name }}" \
-e "CERC_MONIKER={{ cerc_moniker }}" \
-e "CERC_CHAIN_ID={{ cerc_chain_id }}" \
-e "VALIDATOR_PUB_KEY={{ validator_pub_key | to_json }}" \
cerc/laconicd:local bash -c "/scripts/create-and-collect-gentx.sh"
- name: Update genesis file in output
copy:
src: "{{gentx_genesis_dir}}/output/genesis.json"
dest: "{{ lookup('env', 'PWD') }}/output/genesis.json"
mode: '0644'
- name: Clear tmp directory
file:
path: "{{gentx_genesis_dir}}/tmp"
state: absent
@@ -0,0 +1,65 @@
---
- name: Run mainnet validator node
hosts: localhost
vars_files:
- 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"
build_args: "{{ '--force-rebuild' if (lookup('env', 'FORCE_REBUILD') | default(omit, true)) not in [ 'false', 'False', '0' ] else '' }}"
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: 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 {{ build_args }}
- 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 }}"
MIN_GAS_PRICE: "{{ min_gas_price }}"
CERC_LOGLEVEL: "{{ cerc_loglevel }}"
TMKMS_ENABLED: "{{ tmkms_enabled }}"
mode: '0777'
- name: Initialize laconicd node
shell: |
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 "CERC_MONIKER={{ cerc_moniker }}" \
-e "CERC_CHAIN_ID={{ cerc_chain_id }}" \
cerc/laconicd:local bash -c "/scripts/setup-laconicd.sh"
- name: Ensure tmp directory exists inside laconicd-data
file:
path: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp"
state: directory
mode: '0755'
@@ -0,0 +1,10 @@
network:
ports:
laconicd:
- '6060:6060'
- '26659:26659'
- '26657:26657'
- '26656:26656'
- '9473:9473'
- '9090:9090'
- '1317:1317'
+10
View File
@@ -0,0 +1,10 @@
[local]
localhost ansible_connection=local
[remote]
# Replace these values with your actual remote host details
remote_host ansible_host=your.remote.host ansible_user=your_remote_user ansible_ssh_common_args='-o ForwardAgent=yes'
[multihosts:children]
local
remote
+54
View File
@@ -0,0 +1,54 @@
---
- name: Run TMKMS stack
hosts: localhost
vars_files:
- tmkms-vars.yml
vars:
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
tmkms_deployment_dir: "{{ lookup('env', 'TMKMS_DEPLOYMENT_DIR') | default('tmkms-deployment', true) }}"
tasks:
- name: Fail if DATA_DIRECTORY env var is not set
fail:
msg: >-
Required environment variable DATA_DIRECTORY is not set.
Please export DATA_DIRECTORY before running the playbook.
when: lookup('env', 'DATA_DIRECTORY') == ''
- name: Ensure tmp directory exists inside tmkms-data volume
file:
path: "{{data_directory}}/{{ tmkms_deployment_dir }}/data/tmkms-data/tmp"
state: directory
mode: '0755'
- name: Check if priv_validator_key_file_path exists
stat:
path: "{{ priv_validator_key_file_path }}"
register: priv_key_file
- name: Copy private validator key to tmkms deployment tmp directory
copy:
src: "{{ priv_validator_key_file_path }}"
dest: "{{data_directory}}/{{ tmkms_deployment_dir }}/data/tmkms-data/tmp/priv_validator_key.json"
mode: '0644'
when: priv_key_file.stat.exists
- name: Create config.env for tmkms deployment
copy:
dest: "{{data_directory}}/{{ tmkms_deployment_dir }}/config.env"
content: |
CHAIN_ID: "{{ chain_id }}"
NODE_IP: "{{ node_ip }}"
NODE_PORT: "{{ node_port }}"
KEY_PREFIX: "{{ key_prefix }}"
TMKMS_MODE: "{{ tmkms_mode }}"
mode: '0777'
- name: Start tmkms deployment
shell: |
laconic-so deployment --dir {{data_directory}}/{{ tmkms_deployment_dir }} start
- name: Remove input private validator key file
file:
path: "{{ priv_validator_key_file_path }}"
state: absent
when: priv_key_file.stat.exists
+33
View File
@@ -0,0 +1,33 @@
---
- name: Setup TMKMS stack
hosts: localhost
vars_files:
- tmkms-vars.yml
vars:
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
tmkms_deployment_dir: "{{ lookup('env', 'TMKMS_DEPLOYMENT_DIR') | default('tmkms-deployment', true) }}"
tmkms_spec_file: "{{data_directory}}/tmkms-spec.yml"
build_args: "{{ '--force-rebuild' if (lookup('env', 'FORCE_REBUILD') | default(omit, true)) not in [ 'false', 'False', '0' ] else '' }}"
tasks:
- name: Fail if DATA_DIRECTORY env var is not set
fail:
msg: >-
Required environment variable DATA_DIRECTORY is not set.
Please export DATA_DIRECTORY before running the playbook.
when: lookup('env', 'DATA_DIRECTORY') == ''
- name: Fetch tmkms stack
shell: |
laconic-so fetch-stack git.vdb.to/LaconicNetwork/tmkms-stack@sk-yubihsm --git-ssh --pull
- name: Build tmkms container images
shell: |
laconic-so --stack ~/cerc/tmkms-stack/stack-orchestrator/stacks/tmkms build-containers {{ build_args }} --extra-build-args "--build-arg BACKEND={{ tmkms_mode }}"
- name: Create tmkms deployment spec file
shell: |
laconic-so --stack ~/cerc/tmkms-stack/stack-orchestrator/stacks/tmkms deploy init --output {{ tmkms_spec_file }}
- name: Create tmkms deployment from spec file
shell: |
laconic-so --stack ~/cerc/tmkms-stack/stack-orchestrator/stacks/tmkms deploy create --spec-file {{ tmkms_spec_file }} --deployment-dir {{data_directory}}/{{ tmkms_deployment_dir }}
+19
View File
@@ -0,0 +1,19 @@
# Absolute path to the node's private validator key file (e.g., /path/to/priv_validator_key.json).
# This file is copied into the TMKMS deployment
priv_validator_key_file_path: ""
# The IP address of the machine where the laconicd node is set up
# TMKMS will connect to this IP address
node_ip: ""
# The port of the laconicd node that TMKMS will connect to
node_port: "26659"
# The key prefix used for account and consensus public keys in the blockchain
key_prefix: "laconic"
# The chain ID for the blockchain network
chain_id: "laconic-mainnet"
# The mode of operation for TMKMS (e.g., "softsign", "yubihsm")
tmkms_mode: "softsign"
+15
View File
@@ -0,0 +1,15 @@
---
- name: Build Laconicd
hosts: localhost
connection: local
vars:
build_args: "{{ '--force-rebuild' if (lookup('env', 'FORCE_REBUILD') | default(omit, true)) not in [ 'false', 'False', '0' ] else '' }}"
tasks:
- 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 {{ build_args }}
+64
View File
@@ -0,0 +1,64 @@
---
- name: Create validator on running chain
hosts: localhost
vars_files:
- validator-vars.yml
vars:
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
create_validator_dir: "{{data_directory}}/create-validator"
spec_file: "{{data_directory}}/laconicd-validator-spec.yml"
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 staking_amount_file in validator-vars.yml.
when: not staking_amount_file
- name: Ensure tmp directory exists inside laconicd-data
file:
path: "{{create_validator_dir}}/tmp"
state: directory
mode: '0755'
- name: Copy staking amount file to laconicd-data tmp directory
copy:
src: "{{ staking_amount_file }}"
dest: "{{create_validator_dir}}/tmp/staking-amount.json"
mode: '0644'
- name: Prompt for validator private key
vars:
private_key_prompt: "Please enter your validator private key: "
pause:
prompt: "{{ private_key_prompt }}"
echo: no
register: private_key_input
- name: Fail if private key is not provided
fail:
msg: "Private key is required for creating the gentx."
when: private_key_input.user_input | default('') | trim == ''
- name: Run create-validator script
shell: |
docker run -i \
-v {{create_validator_dir}}:/root/create-validator \
-v ~/cerc/laconicd-stack/stack-orchestrator/config/mainnet-laconicd/create-validator.sh:/scripts/create-validator.sh \
-e "KEY_NAME={{ key_name }}" \
-e "NODE_URL={{ node_url }}" \
-e "CERC_MONIKER={{ cerc_moniker }}" \
-e "CERC_CHAIN_ID={{ cerc_chain_id }}" \
-e "MIN_GAS_PRICE={{ min_gas_price }}" \
-e "VALIDATOR_PUB_KEY={{ validator_pub_key | to_json }}" \
-e "PVT_KEY={{ private_key_input.user_input }}" \
--network=host \
cerc/laconicd:local \
sh -c "/scripts/create-validator.sh"
+85
View File
@@ -0,0 +1,85 @@
---
- name: Setup mainnet validator node
hosts: localhost
vars_files:
- validator-vars.yml
vars:
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}"
spec_file: "{{data_directory}}/laconicd-validator-spec.yml"
spec_template: "./templates/specs/spec-template.yml.j2"
build_args: "{{ '--force-rebuild' if (lookup('env', 'FORCE_REBUILD') | default(omit, true)) not in [ 'false', 'False', '0' ] else '' }}"
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 and staking_amount_file in validator-vars.yml.
when: not genesis_file or not staking_amount_file
- 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 {{ build_args }}
- 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 }}"
TMKMS_ENABLED: "{{ tmkms_enabled }}"
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 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 }}"
dest: "{{data_directory}}/{{ mainnet_deployment_dir }}/data/laconicd-data/tmp/genesis.json"
mode: '0644'
- name: Initialize laconicd node
shell: |
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 "CERC_MONIKER={{ cerc_moniker }}" \
-e "CERC_CHAIN_ID={{ cerc_chain_id }}" \
cerc/laconicd:local bash -c "/scripts/setup-laconicd.sh"
@@ -0,0 +1,10 @@
network:
ports:
laconicd:
- '6060:6060'
- '26659:26659'
- '26657:26657'
- '26656:26656'
- '9473:9473'
- '9090:9090'
- '1317:1317'
@@ -0,0 +1,35 @@
# The URL of the laconicd node's RPC endpoint (e.g., "tcp://NODE_PUBLIC_IP_ADDRESS:26657")
node_url: ""
# The public key of the validator node. This is required for creating the validator on chain
# It should be wrapped in single quotes
validator_pub_key: ''
# Custom moniker for the validator node
cerc_moniker: ""
# Comma-separated list of persistent peers for the laconicd node
# You can find available peers in https://git.vdb.to/cerc-io/laconicd-stack/src/branch/main/node-addresses.yml
cerc_peers: ""
# Set to true to enable TMKMS (Tendermint Key Management System) for this node
# If true, the node will use an external TMKMS for signing validator operations
tmkms_enabled:
# The chain ID for the blockchain network
cerc_chain_id: "laconic-mainnet"
# Minimum gas price for transactions, in ALNT (e.g., 0.001alnt)
min_gas_price: 0.001
# Log level for the laconicd node (e.g., "info", "debug", "error")
cerc_loglevel: "info"
# Absolute path to the mainnet genesis.json file
genesis_file: "~/cerc/laconicd-stack/config/mainnet-genesis.json"
# Absolute path to the staking-amount.json file
staking_amount_file: "~/cerc/laconicd-stack/config/staking-amount.json"
# Desired key name for the validator account
key_name: "laconic-validator"
+28
View 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.zst"
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 | zstd > "$testnet_state_file"
echo "Exported state from testnet to $testnet_state_file"
+128
View File
@@ -0,0 +1,128 @@
import sys
import requests
import pandas as pd
import json
import re
import argparse
import urllib.parse
from bech32 import bech32_decode
# Column names in the input CSV
PLACEHOLDER_COLUMN = 'Placeholder'
LACONIC_ADDRESS_COLUMN = 'Laconic Address'
TOTAL_LPS_ALLOCATION_COLUMN = 'Total LPS Allocation'
LOCK_MONTHS_COLUMN = 'Lock (months)'
VEST_MONTHS_COLUMN = 'Vest (months)'
# Required columns in the input CSV
REQUIRED_COLUMNS = [
PLACEHOLDER_COLUMN,
LACONIC_ADDRESS_COLUMN,
TOTAL_LPS_ALLOCATION_COLUMN,
LOCK_MONTHS_COLUMN,
VEST_MONTHS_COLUMN
]
def to_number(val):
"""
Convert a value to a number, handling empty values and invalid inputs.
Returns None for empty or invalid values.
"""
if pd.isna(val) or str(val).strip() == '':
return None
try:
return float(val)
except (ValueError, TypeError):
return None
def get_csv_download_url(google_sheet_url):
"""
Convert a full Google Sheets URL to a CSV export URL using the `gid` in the query string.
"""
# Extract the sheet ID
match = re.search(r'/d/([a-zA-Z0-9-_]+)', google_sheet_url)
if not match:
raise ValueError('Invalid Google Sheets URL')
sheet_id = match.group(1)
# Extract gid from query params
gid_match = re.search(r'[?&]gid=([0-9]+)', google_sheet_url)
if not gid_match:
raise ValueError('Missing gid in Google Sheets URL')
gid = gid_match.group(1)
# Build export URL
return f'https://docs.google.com/spreadsheets/d/{sheet_id}/export?format=csv&gid={gid}'
def download_csv(url, output_path):
"""
Download the CSV file from the given URL.
"""
response = requests.get(url)
if response.status_code != 200:
raise Exception(f'Failed to download file: {response.status_code}')
with open(output_path, 'wb') as f:
f.write(response.content)
def convert_csv_to_json(csv_path, json_path):
"""
Read the CSV file, extract columns, and save as JSON.
"""
df = pd.read_csv(csv_path)
for col in REQUIRED_COLUMNS:
if col not in df.columns:
raise Exception(f'Missing required column: {col}')
result = {}
for _, row in df.iterrows():
placeholder = str(row[PLACEHOLDER_COLUMN]) if not pd.isna(row[PLACEHOLDER_COLUMN]) else ''
laconic_address = str(row[LACONIC_ADDRESS_COLUMN]) if not pd.isna(row[LACONIC_ADDRESS_COLUMN]) else ''
# Use laconic_address as key if placeholder is missing or empty
key = placeholder if placeholder and placeholder.lower() != 'nan' else laconic_address
# Skip the row if both 'Placeholder' and 'Laconic Address' are missing or invalid
if not key or key.lower() == 'nan':
continue
# If key is the laconic address, validate that it's a valid bech32 address
if key == laconic_address:
hrp, data = bech32_decode(laconic_address)
if hrp is None or data is None or not hrp.startswith("laconic"):
print(f"Skipping invalid Laconic address: {laconic_address}")
continue
entry = {
'total_lps_allocation': to_number(row[TOTAL_LPS_ALLOCATION_COLUMN]),
'lock_months': row[LOCK_MONTHS_COLUMN] if not pd.isna(row[LOCK_MONTHS_COLUMN]) else None,
'vest_months': row[VEST_MONTHS_COLUMN] if not pd.isna(row[VEST_MONTHS_COLUMN]) else None,
'laconic_address': row[LACONIC_ADDRESS_COLUMN] if not pd.isna(row[LACONIC_ADDRESS_COLUMN]) else None
}
result[key] = entry
with open(json_path, 'w') as f:
json.dump(result, f, indent=2)
def main():
parser = argparse.ArgumentParser(description='Generate LPS distribution JSON from CSV or Google Sheet')
parser.add_argument('--input', '-i', required=True, help='Input: Google Sheet URL or local CSV file path')
parser.add_argument('--output', '-o', default='distribution.json', help='Output JSON file path (default: distribution.json)')
args = parser.parse_args()
if args.input.startswith('https://'):
csv_url = get_csv_download_url(args.input)
csv_path = 'sheet.csv'
print(f'Downloading CSV file from: {csv_url}')
download_csv(csv_url, csv_path)
else:
csv_path = args.input
print(f'Using CSV file at path: {csv_path}')
print('Converting CSV to JSON...')
convert_csv_to_json(csv_path, args.output)
print(f'JSON saved to {args.output}')
if __name__ == '__main__':
main()
+54
View File
@@ -0,0 +1,54 @@
#!/bin/bash
set -e
# Default values
INPUT=""
OUTPUT_FILE="./distribution.json"
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-i|--input)
INPUT="$2"
shift 2
;;
-o|--output)
OUTPUT_FILE="$2"
shift 2
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 -i|--input <input_url_or_path> [-o|--output <output_file_path>]"
exit 1
;;
esac
done
# Check if input is provided
if [ -z "$INPUT" ]; then
echo "Error: Input URL or path is required"
echo "Usage: $0 -i|--input <input_url_or_path> [-o|--output <output_file_path>]"
exit 1
fi
venv_dir="$PWD/venv-lps-lock"
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Create venv if it doesn't exist
if [ ! -d "$venv_dir" ]; then
python3 -m venv "$venv_dir"
fi
# Activate venv and install dependencies
"$venv_dir/bin/pip" install --upgrade pip
"$venv_dir/bin/pip" install requests pandas openpyxl bech32
echo "Running LPS lock generation script..."
"$venv_dir/bin/python" "$script_dir/generate-lps-distribution-json.py" \
--input "$INPUT" \
--output "$OUTPUT_FILE"
# Clean up venv
echo "Cleaning up..."
rm -rf "$venv_dir"
+80
View File
@@ -0,0 +1,80 @@
#!/bin/bash
# Exit on error
set -e
set -u
# Check args
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 and distribution to required dir
cp $TESTNET_STATE_FILE $MAINNET_GENESIS_DIR/testnet-state.json
cp $LPS_DISTRIBUTION_FILE $MAINNET_GENESIS_DIR/distribution.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
# 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
fi
echo "Carrying over state from testnet state to mainnet genesis..."
"$venv_dir/bin/python" "$script_dir/transfer-state.py"
# Clean up venv
rm -rf "$venv_dir"
# --------
# Run a script with cerc/laconicd:local to generate the genesis file
# with onboarding module state and given allocations
echo "Performing alps allocations..."
docker run \
-v ./$MAINNET_GENESIS_DIR:/root/.laconicd \
-v $script_dir:/scripts \
-e "CHAIN_ID=$CHAIN_ID" \
-e "EARLY_SUPPORTS_ACC_ADDRESS=$EARLY_SUPPORTS_ACC_ADDRESS" \
cerc/laconicd:local bash -c "/scripts/genesis.sh"
# Copy over the genesis file to output folder
cp ./$MAINNET_GENESIS_DIR/config/genesis.json $OUTPUT_DIR/genesis.json
echo "Genesis file for mainnet written to $OUTPUT_DIR/genesis.json"
# --------
# Clean up
rm -rf $MAINNET_GENESIS_DIR
+52
View File
@@ -0,0 +1,52 @@
#!/bin/bash
# Exit on error
set -e
set -u
# Note: Needs to be run in a docker container with image cerc/laconicd:local
KEYRING="test"
NODE_HOME="/root/.laconicd"
EARLY_SUPPORTS_ACC_ADDRESS=${EARLY_SUPPORTS_ACC_ADDRESS}
if [ -z "$EARLY_SUPPORTS_ACC_ADDRESS" ]; then
echo "EARLY_SUPPORTS_ACC_ADDRESS not provided, exiting..."
exit 1
fi
# 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="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
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 lps allocations
laconicd genesis add-genesis-account $EARLY_SUPPORTS_ACC_ADDRESS $EARLY_SUPPORTS_ALLOC$LPS_DENOM --keyring-backend $KEYRING --append
laconicd genesis add-genesis-lockup-account lps_lockup $distribution_file $LOCKUP_ALLOC$LPS_DENOM
# Ensure that resulting genesis file is valid
laconicd genesis validate
+17
View File
@@ -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
+172
View File
@@ -0,0 +1,172 @@
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"]
# Update authority auction durations from 3600s to 60s
mainnet_state["app_state"]["registry"]["params"]["authority_auction_commits_duration"] = "60s"
mainnet_state["app_state"]["registry"]["params"]["authority_auction_reveals_duration"] = "60s"
#------
# 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
if "ModuleAccount" not in account_type:
account["sequence"] = "0"
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)
@@ -0,0 +1,36 @@
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}
TMKMS_ENABLED: ${TMKMS_ENABLED:-false}
volumes:
- laconicd-data:/root/.laconicd
- ../config/mainnet-laconicd/run-laconicd.sh:/opt/run-laconicd.sh
- ../config/mainnet-laconicd/setup-laconicd.sh:/scripts/setup-laconicd.sh
- ../config/mainnet-laconicd/create-validator.sh:/scripts/create-validator.sh
ports:
- "6060"
- "26659"
- "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:
@@ -0,0 +1,83 @@
#!/bin/bash
set -e
NODE_HOME=/root/.laconicd
GENTX_DIR=/root/generate-gentx-genesis
genesis_file_path=$NODE_HOME/config/genesis.json
KEYRING="test"
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 "$VALIDATOR_PUB_KEY" ]; then
echo "VALIDATOR_PUB_KEY environment variable not set, exiting..."
exit 1
fi
input_genesis_file=$GENTX_DIR/tmp/genesis.json
if [ ! -f ${input_genesis_file} ]; then
echo "Genesis file not provided, exiting..."
exit 1
fi
staking_amount_file="$GENTX_DIR/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')
# 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
# Make config directory accessible without root permissions in docker host
chmod -R 777 $NODE_HOME/config
# Copy over provided genesis config
cp $input_genesis_file $genesis_file_path
# Import private key
laconicd keys import-hex "$KEY_NAME" "$PVT_KEY" --keyring-backend $KEYRING
# 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)
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 '.common_staking_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 --keyring-backend $KEYRING --pubkey "$VALIDATOR_PUB_KEY"
# Collect the gentx and validate
laconicd genesis collect-gentxs
laconicd genesis validate
chmod 777 $genesis_file_path
cp $genesis_file_path $GENTX_DIR/output
@@ -0,0 +1,68 @@
#!/bin/bash
set -e
DENOM=alnt
CREATE_VALIDATOR_DIR=/root/create-validator
KEYRING="test"
staking_amount_file="$CREATE_VALIDATOR_DIR/tmp/staking-amount.json"
if [ ! -f "$staking_amount_file" ]; then
echo "staking-amount.json file not provided, exiting..."
exit 1
fi
if [ -z "$KEY_NAME" ]; then
echo "KEY_NAME environment variable not set, exiting..."
exit 1
fi
if [ -z "$CERC_MONIKER" ]; then
echo "CERC_MONIKER environment variable not set, exiting..."
exit 1
fi
if [ -z "$NODE_URL" ]; then
echo "NODE_URL environment variable not set, exiting..."
exit 1
fi
if [ -z "$VALIDATOR_PUB_KEY" ]; then
echo "VALIDATOR_PUB_KEY environment variable not set, exiting..."
exit 1
fi
if [ -z "$PVT_KEY" ]; then
echo "PVT_KEY environment variable not set, exiting..."
exit 1
fi
laconicd keys import-hex "$KEY_NAME" "$PVT_KEY" --keyring-backend test
# Set staking amount
stake_amount=$(jq -r '.common_staking_amount' "$staking_amount_file")
# Create validator.json file
validator_json="$CREATE_VALIDATOR_DIR/tmp/validator.json"
cat > "$validator_json" << EOF
{
"pubkey": $VALIDATOR_PUB_KEY,
"amount": "${stake_amount}${DENOM}",
"moniker": "${CERC_MONIKER}",
"commission-rate": "0.0",
"commission-max-rate": "0.0",
"commission-max-change-rate": "0.0",
"min-self-delegation": "1"
}
EOF
# Create validator using the JSON file
laconicd tx staking create-validator "$validator_json" \
--chain-id "$CERC_CHAIN_ID" \
--gas auto \
--gas-adjustment 1.5 \
--gas-prices $MIN_GAS_PRICE$DENOM \
--from $KEY_NAME \
--keyring-backend $KEYRING \
--node $NODE_URL \
--yes
+64
View File
@@ -0,0 +1,64 @@
#!/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 "Persistent peers: $CERC_PEERS"
echo "Min gas price: $MIN_GAS_PRICE"
echo "Log level: $CERC_LOGLEVEL"
echo "TMKMS enabled: $TMKMS_ENABLED"
/scripts/setup-laconicd.sh
# 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
if [[ "${TMKMS_ENABLED,,}" == "true" ]]; then
# Configure private validator for external tmkms
sed -i "s/^priv_validator_laddr *=.*/priv_validator_laddr = \"tcp:\/\/0.0.0.0:26659\"/" $NODE_HOME/config/config.toml
# Comment out validator key files when using external TMKMS
sed -i 's/^priv_validator_key_file =/# priv_validator_key_file =/' $NODE_HOME/config/config.toml
sed -i 's/^priv_validator_state_file =/# priv_validator_state_file =/' $NODE_HOME/config/config.toml
else
echo "Warning: TMKMS disabled, node will run with local validator keys"
fi
# 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 \
--minimum-gas-prices=${MIN_GAS_PRICE}alnt \
--rpc.laddr="tcp://0.0.0.0:26657" \
--api.address="tcp://0.0.0.0:1317" \
--gql-playground --gql-server \
--log_level $CERC_LOGLEVEL \
--home $NODE_HOME
@@ -0,0 +1,29 @@
#!/bin/bash
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
set -x
fi
set -e
NODE_HOME=/root/.laconicd
echo "Env:"
echo "Moniker: $CERC_MONIKER"
echo "Chain Id: $CERC_CHAIN_ID"
# 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
# Make config directory accessible without root permissions in docker host
chmod -R 777 $NODE_HOME/config
else
echo "Node data dir $NODE_HOME/data already exists, skipping initialization..."
fi
@@ -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
@@ -0,0 +1 @@
# mainnet-laconicd
@@ -0,0 +1,9 @@
version: "1.0"
name: mainnet-laconicd
description: "Laconicd full node"
repos:
- git.vdb.to/cerc-io/laconicd@mainnet # TODO: Use a release
containers:
- cerc/laconicd
pods:
- mainnet-laconicd