From 44219c801c833799703f1962b1f3b2ab86b88785 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Tue, 13 May 2025 15:14:56 +0530 Subject: [PATCH] Add initial stack to run mainnet nodes --- .gitignore | 2 + README.md | 2 +- .../compose/docker-compose-create-gentx.yml | 25 ------- .../docker-compose-mainnet-laconicd.yml | 35 +++++++++ .../config/laconicd/create-gentx.sh | 55 -------------- .../config/laconicd/run-laconicd.sh | 71 +++++++++++++++++++ .../README.md | 0 .../stacks/mainnet-laconicd/stack.yaml | 9 +++ 8 files changed, 118 insertions(+), 81 deletions(-) create mode 100644 .gitignore delete mode 100644 stack-orchestrator/compose/docker-compose-create-gentx.yml create mode 100644 stack-orchestrator/compose/docker-compose-mainnet-laconicd.yml delete mode 100755 stack-orchestrator/config/laconicd/create-gentx.sh create mode 100755 stack-orchestrator/config/laconicd/run-laconicd.sh rename stack-orchestrator/stacks/{create-gentx => mainnet-laconicd}/README.md (100%) create mode 100644 stack-orchestrator/stacks/mainnet-laconicd/stack.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..abaaaab --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*-deployment +*-spec.yml diff --git a/README.md b/README.md index 450b5e3..2d49303 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# mainnet-laconicd-stack +# laconicd-stack diff --git a/stack-orchestrator/compose/docker-compose-create-gentx.yml b/stack-orchestrator/compose/docker-compose-create-gentx.yml deleted file mode 100644 index bf126aa..0000000 --- a/stack-orchestrator/compose/docker-compose-create-gentx.yml +++ /dev/null @@ -1,25 +0,0 @@ -services: - laconicd: - restart: unless-stopped - image: cerc/laconicd:local - command: ["bash", "-c", "/opt/create-gentx.sh"] - environment: - CERC_MONIKER: ${CERC_MONIKER:-TestnetNode} - CERC_CHAIN_ID: ${CERC_CHAIN_ID:-laconic_9000-1} - DENOM: ${DENOM} - KEY_NAME: ${KEY_NAME:-mykey} - PVT_KEY: ${PVT_KEY} - volumes: - - laconicd-data:/root/.laconicd - - ../config/laconicd/create-gentx.sh:/opt/create-gentx.sh - 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: diff --git a/stack-orchestrator/compose/docker-compose-mainnet-laconicd.yml b/stack-orchestrator/compose/docker-compose-mainnet-laconicd.yml new file mode 100644 index 0000000..fd420ee --- /dev/null +++ b/stack-orchestrator/compose/docker-compose-mainnet-laconicd.yml @@ -0,0 +1,35 @@ +services: + laconicd: + restart: unless-stopped + image: cerc/laconicd:local + command: ["bash", "-c", "/opt/run-laconicd.sh"] + environment: + CERC_MONIKER: ${CERC_MONIKER:-TestnetNode} + CERC_CHAIN_ID: ${CERC_CHAIN_ID:-laconic_9000-1} + CERC_PEERS: ${CERC_PEERS} + MIN_GAS_PRICE: ${MIN_GAS_PRICE:-0.001} + CERC_LOGLEVEL: ${CERC_LOGLEVEL:-info} + INPUT_GENESIS_FILE: ${INPUT_GENESIS_FILE} + INPUT_NODE_KEY_FILE: ${INPUT_NODE_KEY_FILE} + INPUT_PRIV_VALIDATOR_KEY_FILE: ${INPUT_PRIV_VALIDATOR_KEY_FILE} + volumes: + - laconicd-data:/root/.laconicd + - ../config/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: diff --git a/stack-orchestrator/config/laconicd/create-gentx.sh b/stack-orchestrator/config/laconicd/create-gentx.sh deleted file mode 100755 index fe00dc1..0000000 --- a/stack-orchestrator/config/laconicd/create-gentx.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then - set -x -fi - -if [ -z "$DENOM" ]; then - echo "DENOM environment variable not set, exiting..." - exit 1 -fi - -set -e - -echo "Env:" -echo "Moniker: $CERC_MONIKER" -echo "Chain Id: $CERC_CHAIN_ID" -echo "Denom: $DENOM" -echo "Key name: $KEY_NAME" -echo "PVT Key: $PVT_KEY" - -NODE_HOME=/root/.laconicd - -KEYRING=test - -# Set chain id in config -laconicd config set client chain-id $CERC_CHAIN_ID --home $NODE_HOME - -export CERC_MONIKER=$(echo "$CERC_MONIKER" | sed -e 's/^["'\'']//g' -e 's/["'\'']$//g') -export CERC_CHAIN_ID=$(echo "$CERC_CHAIN_ID" | sed -e 's/^["'\'']//g' -e 's/["'\'']$//g') -export DENOM=$(echo "$DENOM" | sed -e 's/^["'\'']//g' -e 's/["'\'']$//g') - -# TODO: Update amounts -BALANCE=100000000000000000000000$DENOM -STAKE_AMOUNT=100000000000000000000$DENOM - -# 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 - -# Support both importing key and generating account -if [ -n "$PVT_KEY" ]; then - # If PVT_KEY is provided, import the key - laconicd keys import-hex "$KEY_NAME" "$PVT_KEY" -else - # If PVT_KEY is not provided, create a new key - laconicd keys add "$KEY_NAME" -fi - -laconicd genesis add-genesis-account $KEY_NAME $BALANCE --keyring-backend $KEYRING --home $NODE_HOME - -laconicd genesis gentx $KEY_NAME $STAKE_AMOUNT --keyring-backend $KEYRING --home $NODE_HOME - -echo "Genesis transaction created successfully..." -# Keep the script running indefinitely -tail -f /dev/null diff --git a/stack-orchestrator/config/laconicd/run-laconicd.sh b/stack-orchestrator/config/laconicd/run-laconicd.sh new file mode 100755 index 0000000..c0ea753 --- /dev/null +++ b/stack-orchestrator/config/laconicd/run-laconicd.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then + set -x +fi + +set -e + +input_genesis_file=$INPUT_GENESIS_FILE +if [ ! -f ${input_genesis_file} ]; then + echo "Genesis file not provided, exiting..." + exit 1 +fi + +input_node_key_file=$INPUT_NODE_KEY_FILE +if [ ! -f ${input_node_key_file} ]; then + echo "Node key file not provided, exiting..." + exit 1 +fi + +input_priv_validator_key_file=$INPUT_PRIV_VALIDATOR_KEY_FILE +if [ ! -f ${input_priv_validator_key_file} ]; then + echo "Priv validator key file not provided, exiting..." + exit 1 +fi + +if [ -z "$CERC_PEERS" ]; then + echo "Persistent peers 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" + +NODE_HOME=/root/.laconicd + +# Set chain id in config +laconicd config set client chain-id $CERC_CHAIN_ID --home $NODE_HOME + +# Check if node data dir already exists +if [ -z "$(ls -A "$NODE_HOME/data")" ]; then + # Init node + echo "Initializing a new laconicd node with moniker $CERC_MONIKER and chain id $CERC_CHAIN_ID" + laconicd init $CERC_MONIKER --chain-id=$CERC_CHAIN_ID --home $NODE_HOME + + # Use provided config files + cp $input_genesis_file $NODE_HOME/config/genesis.json + cp $input_node_key_file $NODE_HOME/config/node_key.json + cp $input_priv_validator_key_file $NODE_HOME/config/priv_validator_key.json +else + echo "Node data dir $NODE_HOME/data already exists, skipping initialization..." +fi + +# Enable cors +sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $NODE_HOME/.laconicd/config/config.toml + +# Update config with persistent peers +sed -i "s/^persistent_peers *=.*/persistent_peers = \"$CERC_PEERS\"/g" $NODE_HOME/config/config.toml + +echo "Starting laconicd node..." +laconicd start \ + --api.enable \ + --minimum-gas-prices=${MIN_GAS_PRICE}alnt \ + --rpc.laddr="tcp://0.0.0.0:26657" \ + --gql-playground --gql-server \ + --log_level $CERC_LOGLEVEL \ + --home $NODE_HOME diff --git a/stack-orchestrator/stacks/create-gentx/README.md b/stack-orchestrator/stacks/mainnet-laconicd/README.md similarity index 100% rename from stack-orchestrator/stacks/create-gentx/README.md rename to stack-orchestrator/stacks/mainnet-laconicd/README.md diff --git a/stack-orchestrator/stacks/mainnet-laconicd/stack.yaml b/stack-orchestrator/stacks/mainnet-laconicd/stack.yaml new file mode 100644 index 0000000..d65a7e0 --- /dev/null +++ b/stack-orchestrator/stacks/mainnet-laconicd/stack.yaml @@ -0,0 +1,9 @@ +version: "1.0" +name: mainnet-laconicd +description: "Laconicd full node" +repos: + - git.vdb.to/cerc-io/laconicd@v0.1.11 +containers: + - cerc/laconicd +pods: + - mainnet-laconicd