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>
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
services:
|
||||
laconicd:
|
||||
restart: unless-stopped
|
||||
image: cerc/laconicd:local
|
||||
command: ["bash", "-c", "/opt/run-laconicd.sh"]
|
||||
environment:
|
||||
CERC_MONIKER: ${CERC_MONIKER}
|
||||
CERC_CHAIN_ID: ${CERC_CHAIN_ID:-laconic-mainnet}
|
||||
CERC_PEERS: ${CERC_PEERS}
|
||||
MIN_GAS_PRICE: ${MIN_GAS_PRICE:-0.001}
|
||||
CERC_LOGLEVEL: ${CERC_LOGLEVEL:-info}
|
||||
volumes:
|
||||
- laconicd-data:/root/.laconicd
|
||||
- ../config/mainnet-laconicd/run-laconicd.sh:/opt/run-laconicd.sh
|
||||
ports:
|
||||
- "6060"
|
||||
- "26657"
|
||||
- "26656"
|
||||
- "9473"
|
||||
- "9090"
|
||||
- "1317"
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "127.0.0.1", "26657"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
volumes:
|
||||
laconicd-data:
|
||||
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
NODE_HOME=/root/.laconicd
|
||||
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
|
||||
|
||||
input_genesis_file=$NODE_HOME/tmp/genesis.json
|
||||
if [ ! -f ${input_genesis_file} ]; then
|
||||
echo "Genesis 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
|
||||
|
||||
# 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
|
||||
|
||||
# TODO: Use staking amount from output/staking-amount.json
|
||||
# Get balance of account
|
||||
stake_amount=$(jq -r --arg address "$account_address" --arg denom "$DENOM" '.app_state.bank.balances[] | select(.address == $address) | .coins[] | select(.denom == $denom) | .amount' $genesis_file_path)
|
||||
|
||||
# Create gentx with staked amount equal to allocated balance
|
||||
laconicd genesis gentx $KEY_NAME $stake_amount$DENOM --chain-id $CHAIN_ID --keyring-backend $KEYRING
|
||||
|
||||
# Collect the gentx and validate
|
||||
laconicd genesis collect-gentxs
|
||||
laconicd genesis validate
|
||||
|
||||
# Update the input genesis file
|
||||
cp $genesis_file_path $input_genesis_file
|
||||
@@ -0,0 +1,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 "Moniker: $CERC_MONIKER"
|
||||
echo "Chain Id: $CERC_CHAIN_ID"
|
||||
echo "Persistent peers: $CERC_PEERS"
|
||||
echo "Min gas price: $MIN_GAS_PRICE"
|
||||
echo "Log level: $CERC_LOGLEVEL"
|
||||
|
||||
# Set chain id in config
|
||||
laconicd config set client chain-id $CERC_CHAIN_ID --home $NODE_HOME
|
||||
|
||||
# Check if node data dir already exists
|
||||
if [ -z "$(ls -A "$NODE_HOME/data")" ]; then
|
||||
# Init node
|
||||
echo "Initializing a new laconicd node with moniker $CERC_MONIKER and chain id $CERC_CHAIN_ID"
|
||||
laconicd init $CERC_MONIKER --chain-id=$CERC_CHAIN_ID --home $NODE_HOME
|
||||
else
|
||||
echo "Node data dir $NODE_HOME/data already exists, skipping initialization..."
|
||||
fi
|
||||
|
||||
# Use provided config files
|
||||
cp $input_genesis_file $NODE_HOME/config/genesis.json
|
||||
|
||||
# Enable cors
|
||||
sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $NODE_HOME/config/config.toml
|
||||
|
||||
# Update config with persistent peers
|
||||
sed -i "s/^persistent_peers *=.*/persistent_peers = \"$CERC_PEERS\"/g" $NODE_HOME/config/config.toml
|
||||
|
||||
# Enable telemetry (prometheus metrics: http://localhost:1317/metrics?format=prometheus)
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' 's/enabled = false/enabled = true/g' $NODE_HOME/config/app.toml
|
||||
sed -i '' 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $NODE_HOME/config/app.toml
|
||||
sed -i '' 's/prometheus = false/prometheus = true/g' $NODE_HOME/config/config.toml
|
||||
else
|
||||
sed -i 's/enabled = false/enabled = true/g' $NODE_HOME/config/app.toml
|
||||
sed -i 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $NODE_HOME/config/app.toml
|
||||
sed -i 's/prometheus = false/prometheus = true/g' $NODE_HOME/config/config.toml
|
||||
fi
|
||||
|
||||
|
||||
echo "Starting laconicd node..."
|
||||
laconicd start \
|
||||
--api.enable \
|
||||
--minimum-gas-prices=${MIN_GAS_PRICE}alnt \
|
||||
--rpc.laddr="tcp://0.0.0.0:26657" \
|
||||
--gql-playground --gql-server \
|
||||
--log_level $CERC_LOGLEVEL \
|
||||
--home $NODE_HOME
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user