From 800db5972835809b4c743d10daf087cefda5be9d Mon Sep 17 00:00:00 2001 From: Michael Buntarman Date: Thu, 29 May 2025 07:34:08 +0700 Subject: [PATCH 1/3] docs: Add clone step to README - Add clone repository as first step in setup process --- README.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b0e6610..fe6854c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,16 @@ Before you begin, ensure you have the following: ## Setup Steps -### 1. Generate Initial Configuration +### 1. Clone the Repository + +First, clone the TRUF.NETWORK node operator repository: + +```bash +git clone https://github.com/trufnetwork/truf-node-operator.git +cd truf-node-operator +``` + +### 2. Generate Initial Configuration Use `kwild` to create your initial configuration file: @@ -30,7 +39,7 @@ kwild setup init \ For detailed instructions on configuration options more relevant to a production setup, refer to our [Configuration Guide](docs/creating-config.md). -### 2. Enable State Sync +### 3. Enable State Sync Edit the `config.toml` file in your node configuration directory to enable state sync. The following example assumes you used `./my-node-config` as your root directory in the previous step. Adjust the path if you used a different directory: @@ -42,7 +51,7 @@ sed -i 's/trusted_providers = \[\]/trusted_providers = ["0c830b69790eaa093158264 This will configure your node to use state sync for faster synchronization with the network. -### 3. Set Up PostgreSQL +### 4. Set Up PostgreSQL For a quick setup, run Kwil's pre-configured PostgreSQL Docker image: @@ -89,7 +98,7 @@ If you prefer a custom PostgreSQL setup, ensure it meets the requirements specif **Security Warning**: It is recommended to not expose port 5432 publicly in production environments. -### 4. Deploy TN Node +### 5. Deploy TN Node Run the kwild binary to deploy your node: @@ -111,7 +120,7 @@ Ensure your firewall allows incoming connections on: The `--statesync.enable` and `--statesync.trusted_providers` flags are optional and will help your node sync faster with the network using snapshots provided by the RPC servers. -### 5. Verify Node Synchronization +### 6. Verify Node Synchronization Before proceeding to become a validator, ensure your node is fully synced with the network: @@ -121,7 +130,7 @@ kwild admin status Look for the `syncing: false` in the output, and check that your `best_block_height` is close to the current network height. -### 6. Become a Validator (Optional) +### 7. Become a Validator (Optional) To upgrade your node to a validator: @@ -160,7 +169,7 @@ This will show your node's public key and key type, which you'll need for valida You can always reach out to the community for help with the validator process. -### 7. Submit Your Node to Available Node List (Optional) +### 8. Submit Your Node to Available Node List (Optional) To help others discover your node: From 6fe18e186e8bf54677bd34146bd51605039cf239 Mon Sep 17 00:00:00 2001 From: Michael Buntarman Date: Thu, 29 May 2025 11:16:53 +0700 Subject: [PATCH 2/3] docs: add quick start guide - Add quick start guide for fresh server instances - Add systemd service setup for kwild and PostgreSQL - Add comprehensive log monitoring instructions - Improve troubleshooting section with common commands - Make installation guide more general for any server instance - Add proper service dependencies and auto-restart --- README.md | 2 + docs/installation-guide.md | 203 +++++++++++++++++++++++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100644 docs/installation-guide.md diff --git a/README.md b/README.md index fe6854c..62ee19e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ This guide will walk you through the process of setting up and running a TRUF.NETWORK (TN) node. By following these steps, you'll be able to deploy a node, optionally become a validator, and contribute to the TN v2 mainnet. +> **New to server setup or need a quick start?** Check our [Quick Installation Guide](docs/installation-guide.md) with copy-paste commands for a fresh server instance. + ## Prerequisites Before you begin, ensure you have the following: diff --git a/docs/installation-guide.md b/docs/installation-guide.md new file mode 100644 index 0000000..c5e4c8f --- /dev/null +++ b/docs/installation-guide.md @@ -0,0 +1,203 @@ +# TRUF.NETWORK Quick Installation Guide + +This guide provides step-by-step instructions for setting up a TRUF.NETWORK node on a fresh Ubuntu installation. + +## Prerequisites Installation + +Run the following commands to install all required dependencies: + +```bash +# 1) Docker Engine & Compose v2 plugin (plus GCC via build-essential) +sudo apt-get update +sudo apt-get install -y ca-certificates curl gnupg lsb-release build-essential +sudo mkdir -p /etc/apt/keyrings +curl -fsSL https://download.docker.com/linux/ubuntu/gpg \ + | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg +echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \ + https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \ + | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null +sudo apt-get update +sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin + +# 1b) Enable and start Docker +sudo systemctl enable docker +sudo systemctl start docker + +# 1c) Add your user to the docker group +sudo usermod -aG docker $USER + +# 1d) Install PostgreSQL client (includes pg_dump) +sudo apt-get install -y postgresql-client + +# 2) Install Go (required for building kwild) +LATEST_GO_VERSION=$(curl -sSL https://go.dev/VERSION?m=text | head -n1) +echo "Installing ${LATEST_GO_VERSION}..." +curl -fsSL "https://go.dev/dl/${LATEST_GO_VERSION}.linux-amd64.tar.gz" \ + -o "${LATEST_GO_VERSION}.linux-amd64.tar.gz" +sudo rm -rf /usr/local/go +sudo tar -C /usr/local -xzf "${LATEST_GO_VERSION}.linux-amd64.tar.gz" +rm "${LATEST_GO_VERSION}.linux-amd64.tar.gz" + +# 2b) Add Go to PATH +grep -qxF 'export GOPATH=$HOME/go' ~/.bashrc \ + || echo 'export GOPATH=$HOME/go' >> ~/.bashrc +grep -qxF 'export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin' ~/.bashrc \ + || echo 'export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin' >> ~/.bashrc + +# 3) Reload your shell +source ~/.bashrc + +# 4) Install Taskfile (go-task) +go install github.com/go-task/task/v3/cmd/task@latest + +# 5) Clone the node repository and build kwild +git clone https://github.com/trufnetwork/node.git +cd node +task build + +# 6) Add the built kwild binary to PATH +sudo cp .build/kwild /usr/local/bin/ +sudo chmod +x /usr/local/bin/kwild + +# 7) Apply new docker group immediately +newgrp docker +``` + +## Verify Installation + +Verify that everything is installed correctly: + +```bash +docker --version +docker compose version +pg_dump --version +go version +task --version +kwild version +``` + +## Node Setup + +Now that you have all prerequisites installed, follow these steps to set up your node: + +```bash +# 1) Go to home directory +cd + +# 2) Clone the TRUF.NETWORK node operator repository +git clone https://github.com/trufnetwork/truf-node-operator.git +cd truf-node-operator + +# 3) Generate initial configuration +kwild setup init \ + --genesis ./configs/network/v2/genesis.json \ + --root ./my-node-config \ + --p2p.bootnodes "4e0b5c952be7f26698dc1898ff3696ac30e990f25891aeaf88b0285eab4663e1#ed25519@node-1.mainnet.truf.network:26656,0c830b69790eaa09315826403c2008edc65b5c7132be9d4b7b4da825c2a166ae#ed25519@node-2.mainnet.truf.network:26656" + +# 4) Enable state sync (for faster synchronization) +sed -i '/\[state_sync\]/,/^\[/ s/enable = false/enable = true/' ./my-node-config/config.toml +sed -i 's/trusted_providers = \[\]/trusted_providers = ["0c830b69790eaa09315826403c2008edc65b5c7132be9d4b7b4da825c2a166ae#ed25519@node-2.mainnet.truf.network:26656"]/' ./my-node-config/config.toml + +# 5) Set up PostgreSQL using Docker +docker run -d -p 5432:5432 --name tn-postgres \ + -e "POSTGRES_HOST_AUTH_METHOD=trust" \ + -v tn-pgdata:/var/lib/postgresql/data \ + --shm-size=1gb \ + kwildb/postgres:latest + +# 5b) Wait for PostgreSQL to initialize +echo "Waiting for PostgreSQL to initialize..." +sleep 10 + +# 6) Create systemd service for kwild +sudo tee /etc/systemd/system/kwild.service << EOF +[Unit] +Description=TRUF.NETWORK Node Service +After=network.target tn-postgres.service +Requires=tn-postgres.service + +[Service] +Type=simple +User=$USER +WorkingDirectory=$(pwd) +ExecStart=$(which kwild) start -r ./my-node-config +Restart=always +RestartSec=10 +LimitNOFILE=65535 + +[Install] +WantedBy=multi-user.target +EOF + +# 7) Create systemd service for PostgreSQL +sudo tee /etc/systemd/system/tn-postgres.service << EOF +[Unit] +Description=TRUF.NETWORK PostgreSQL Service +After=docker.service +Requires=docker.service + +[Service] +Type=simple +User=$USER +ExecStart=docker start -a tn-postgres +ExecStop=docker stop tn-postgres +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target +EOF + +# 8) Enable and start services +sudo systemctl daemon-reload +sudo systemctl enable tn-postgres +sudo systemctl enable kwild +sudo systemctl start tn-postgres +sudo systemctl start kwild + +# 9) Check service status +echo "Checking service status..." +sudo systemctl status kwild +``` + +## Check Node Status + +To check if your node is running properly: + +```bash +# Check service status +sudo systemctl status kwild + +# Check node status +kwild admin status +``` + +Your node is fully synced when you see `syncing: false` and your `best_block_height` is close to the current network height. + +## Troubleshooting + +If you encounter any issues: + +1. Check service status: `sudo systemctl status kwild` +2. Watch logs in real-time: `sudo journalctl -u kwild -f` + - Press `Ctrl+C` to stop watching +3. Check Docker container status: `docker ps` +4. Check PostgreSQL logs: `docker logs tn-postgres` + +### Common Commands + +```bash +# Watch kwild logs in real-time +sudo journalctl -u kwild -f + +# Watch last 100 lines of logs +sudo journalctl -u kwild -n 100 + +# Watch logs since last boot +sudo journalctl -u kwild -b + +# Watch logs with timestamps +sudo journalctl -u kwild -f --output=short-precise +``` + +For more detailed configuration options and validator setup, refer to the main [README.md](../README.md). \ No newline at end of file From e119eff28fc9672ce70fc2f36dab6b48f39d5ba2 Mon Sep 17 00:00:00 2001 From: Michael Buntarman Date: Thu, 29 May 2025 12:40:32 +0700 Subject: [PATCH 3/3] docs: add distribution disclaimer to quick start guide - Add note about Ubuntu-specific commands - Provide guidance for other Linux distributions - Clarify that core concepts remain the same --- docs/installation-guide.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/installation-guide.md b/docs/installation-guide.md index c5e4c8f..bd7269a 100644 --- a/docs/installation-guide.md +++ b/docs/installation-guide.md @@ -1,6 +1,11 @@ # TRUF.NETWORK Quick Installation Guide -This guide provides step-by-step instructions for setting up a TRUF.NETWORK node on a fresh Ubuntu installation. +This guide provides step-by-step instructions for setting up a TRUF.NETWORK node on a fresh server instance. While the commands are written for Ubuntu, they can be adapted for other Linux distributions with minimal changes. + +> **Note**: This guide uses Ubuntu-specific package managers (`apt-get`) and paths. If you're using a different Linux distribution: +> - Replace `apt-get` with your distribution's package manager (e.g., `yum` for RHEL/CentOS, `dnf` for Fedora) +> - Adjust package names if they differ in your distribution +> - The core concepts and steps remain the same ## Prerequisites Installation