From 0c25f9daff9996356ef841f5b5703d6d6d89b278 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Tue, 13 May 2025 12:19:15 +0530 Subject: [PATCH] Add initial stack to create gentx --- .../compose/docker-compose-create-gentx.yml | 32 ++++++++++ .../config/laconicd/create-gentx.sh | 59 +++++++++++++++++++ .../container-build/cerc-laconicd/build.sh | 5 ++ .../stacks/create-gentx/README.md | 3 + 4 files changed, 99 insertions(+) create mode 100644 stack-orchestrator/compose/docker-compose-create-gentx.yml create mode 100755 stack-orchestrator/config/laconicd/create-gentx.sh create mode 100755 stack-orchestrator/container-build/cerc-laconicd/build.sh create mode 100644 stack-orchestrator/stacks/create-gentx/README.md diff --git a/stack-orchestrator/compose/docker-compose-create-gentx.yml b/stack-orchestrator/compose/docker-compose-create-gentx.yml new file mode 100644 index 0000000..5a1a22f --- /dev/null +++ b/stack-orchestrator/compose/docker-compose-create-gentx.yml @@ -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:-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} + 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 new file mode 100755 index 0000000..860d3a0 --- /dev/null +++ b/stack-orchestrator/config/laconicd/create-gentx.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then + set -x +fi + +set -e + +input_genesis_file=/root/.laconicd/tmp/genesis.json +if [ ! -f ${input_genesis_file} ]; then + echo "Genesis 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 + +# TODO: Add command to import key +# 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 + + # TODO: Add command to create gentxs + # Use provided genesis config + cp $input_genesis_file $NODE_HOME/config/genesis.json +else + echo "Node data dir $NODE_HOME/data already exists, skipping initialization..." +fi + +# Enable cors +sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $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/container-build/cerc-laconicd/build.sh b/stack-orchestrator/container-build/cerc-laconicd/build.sh new file mode 100755 index 0000000..65bab74 --- /dev/null +++ b/stack-orchestrator/container-build/cerc-laconicd/build.sh @@ -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 diff --git a/stack-orchestrator/stacks/create-gentx/README.md b/stack-orchestrator/stacks/create-gentx/README.md new file mode 100644 index 0000000..b88e13f --- /dev/null +++ b/stack-orchestrator/stacks/create-gentx/README.md @@ -0,0 +1,3 @@ +# create-gentx + +Instructions for creating gentxs for joining as a validator