Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -17,7 +19,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:

Expand All @@ -30,7 +41,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:

Expand All @@ -42,7 +53,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:

Expand Down Expand Up @@ -89,7 +100,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:

Expand All @@ -111,7 +122,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:

Expand All @@ -121,7 +132,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:

Expand Down Expand Up @@ -160,7 +171,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:

Expand Down
208 changes: 208 additions & 0 deletions docs/installation-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
# TRUF.NETWORK Quick Installation Guide

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

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).