Skip to content

Commit bbba0ad

Browse files
authored
docs: quick start guide (#57)
- Add clone repository as first step in setup process <!--- Provide a general summary of your changes in the Title above by following our Developer Guidelines --> ## Description <!--- Describe your changes in detail; use bullet points. --> ## Related Problem <!--- If this pull request relates to an existing Problem, please link to it here (https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) --> <!-- example: resolves: #112330 --> resolves: trufnetwork/node#934 ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> I ensure everything can be copy pasted
2 parents 92b2090 + e119eff commit bbba0ad

File tree

2 files changed

+226
-7
lines changed

2 files changed

+226
-7
lines changed

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
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.
44

5+
> **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.
6+
57
## Prerequisites
68

79
Before you begin, ensure you have the following:
@@ -17,7 +19,16 @@ Before you begin, ensure you have the following:
1719

1820
## Setup Steps
1921

20-
### 1. Generate Initial Configuration
22+
### 1. Clone the Repository
23+
24+
First, clone the TRUF.NETWORK node operator repository:
25+
26+
```bash
27+
git clone https://github.com/trufnetwork/truf-node-operator.git
28+
cd truf-node-operator
29+
```
30+
31+
### 2. Generate Initial Configuration
2132

2233
Use `kwild` to create your initial configuration file:
2334

@@ -30,7 +41,7 @@ kwild setup init \
3041

3142
For detailed instructions on configuration options more relevant to a production setup, refer to our [Configuration Guide](docs/creating-config.md).
3243

33-
### 2. Enable State Sync
44+
### 3. Enable State Sync
3445

3546
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:
3647

@@ -42,7 +53,7 @@ sed -i 's/trusted_providers = \[\]/trusted_providers = ["0c830b69790eaa093158264
4253

4354
This will configure your node to use state sync for faster synchronization with the network.
4455

45-
### 3. Set Up PostgreSQL
56+
### 4. Set Up PostgreSQL
4657

4758
For a quick setup, run Kwil's pre-configured PostgreSQL Docker image:
4859

@@ -89,7 +100,7 @@ If you prefer a custom PostgreSQL setup, ensure it meets the requirements specif
89100

90101
**Security Warning**: It is recommended to not expose port 5432 publicly in production environments.
91102

92-
### 4. Deploy TN Node
103+
### 5. Deploy TN Node
93104

94105
Run the kwild binary to deploy your node:
95106

@@ -111,7 +122,7 @@ Ensure your firewall allows incoming connections on:
111122

112123
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.
113124

114-
### 5. Verify Node Synchronization
125+
### 6. Verify Node Synchronization
115126

116127
Before proceeding to become a validator, ensure your node is fully synced with the network:
117128

@@ -121,7 +132,7 @@ kwild admin status
121132

122133
Look for the `syncing: false` in the output, and check that your `best_block_height` is close to the current network height.
123134

124-
### 6. Become a Validator (Optional)
135+
### 7. Become a Validator (Optional)
125136

126137
To upgrade your node to a validator:
127138

@@ -160,7 +171,7 @@ This will show your node's public key and key type, which you'll need for valida
160171

161172
You can always reach out to the community for help with the validator process.
162173

163-
### 7. Submit Your Node to Available Node List (Optional)
174+
### 8. Submit Your Node to Available Node List (Optional)
164175

165176
To help others discover your node:
166177

docs/installation-guide.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# TRUF.NETWORK Quick Installation Guide
2+
3+
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.
4+
5+
> **Note**: This guide uses Ubuntu-specific package managers (`apt-get`) and paths. If you're using a different Linux distribution:
6+
> - Replace `apt-get` with your distribution's package manager (e.g., `yum` for RHEL/CentOS, `dnf` for Fedora)
7+
> - Adjust package names if they differ in your distribution
8+
> - The core concepts and steps remain the same
9+
10+
## Prerequisites Installation
11+
12+
Run the following commands to install all required dependencies:
13+
14+
```bash
15+
# 1) Docker Engine & Compose v2 plugin (plus GCC via build-essential)
16+
sudo apt-get update
17+
sudo apt-get install -y ca-certificates curl gnupg lsb-release build-essential
18+
sudo mkdir -p /etc/apt/keyrings
19+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
20+
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
21+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
22+
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
23+
| sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
24+
sudo apt-get update
25+
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
26+
27+
# 1b) Enable and start Docker
28+
sudo systemctl enable docker
29+
sudo systemctl start docker
30+
31+
# 1c) Add your user to the docker group
32+
sudo usermod -aG docker $USER
33+
34+
# 1d) Install PostgreSQL client (includes pg_dump)
35+
sudo apt-get install -y postgresql-client
36+
37+
# 2) Install Go (required for building kwild)
38+
LATEST_GO_VERSION=$(curl -sSL https://go.dev/VERSION?m=text | head -n1)
39+
echo "Installing ${LATEST_GO_VERSION}..."
40+
curl -fsSL "https://go.dev/dl/${LATEST_GO_VERSION}.linux-amd64.tar.gz" \
41+
-o "${LATEST_GO_VERSION}.linux-amd64.tar.gz"
42+
sudo rm -rf /usr/local/go
43+
sudo tar -C /usr/local -xzf "${LATEST_GO_VERSION}.linux-amd64.tar.gz"
44+
rm "${LATEST_GO_VERSION}.linux-amd64.tar.gz"
45+
46+
# 2b) Add Go to PATH
47+
grep -qxF 'export GOPATH=$HOME/go' ~/.bashrc \
48+
|| echo 'export GOPATH=$HOME/go' >> ~/.bashrc
49+
grep -qxF 'export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin' ~/.bashrc \
50+
|| echo 'export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin' >> ~/.bashrc
51+
52+
# 3) Reload your shell
53+
source ~/.bashrc
54+
55+
# 4) Install Taskfile (go-task)
56+
go install github.com/go-task/task/v3/cmd/task@latest
57+
58+
# 5) Clone the node repository and build kwild
59+
git clone https://github.com/trufnetwork/node.git
60+
cd node
61+
task build
62+
63+
# 6) Add the built kwild binary to PATH
64+
sudo cp .build/kwild /usr/local/bin/
65+
sudo chmod +x /usr/local/bin/kwild
66+
67+
# 7) Apply new docker group immediately
68+
newgrp docker
69+
```
70+
71+
## Verify Installation
72+
73+
Verify that everything is installed correctly:
74+
75+
```bash
76+
docker --version
77+
docker compose version
78+
pg_dump --version
79+
go version
80+
task --version
81+
kwild version
82+
```
83+
84+
## Node Setup
85+
86+
Now that you have all prerequisites installed, follow these steps to set up your node:
87+
88+
```bash
89+
# 1) Go to home directory
90+
cd
91+
92+
# 2) Clone the TRUF.NETWORK node operator repository
93+
git clone https://github.com/trufnetwork/truf-node-operator.git
94+
cd truf-node-operator
95+
96+
# 3) Generate initial configuration
97+
kwild setup init \
98+
--genesis ./configs/network/v2/genesis.json \
99+
--root ./my-node-config \
100+
--p2p.bootnodes "4e0b5c952be7f26698dc1898ff3696ac30e990f25891aeaf88b0285eab4663e1#ed25519@node-1.mainnet.truf.network:26656,0c830b69790eaa09315826403c2008edc65b5c7132be9d4b7b4da825c2a166ae#ed25519@node-2.mainnet.truf.network:26656"
101+
102+
# 4) Enable state sync (for faster synchronization)
103+
sed -i '/\[state_sync\]/,/^\[/ s/enable = false/enable = true/' ./my-node-config/config.toml
104+
sed -i 's/trusted_providers = \[\]/trusted_providers = ["0c830b69790eaa09315826403c2008edc65b5c7132be9d4b7b4da825c2a166ae#ed25519@node-2.mainnet.truf.network:26656"]/' ./my-node-config/config.toml
105+
106+
# 5) Set up PostgreSQL using Docker
107+
docker run -d -p 5432:5432 --name tn-postgres \
108+
-e "POSTGRES_HOST_AUTH_METHOD=trust" \
109+
-v tn-pgdata:/var/lib/postgresql/data \
110+
--shm-size=1gb \
111+
kwildb/postgres:latest
112+
113+
# 5b) Wait for PostgreSQL to initialize
114+
echo "Waiting for PostgreSQL to initialize..."
115+
sleep 10
116+
117+
# 6) Create systemd service for kwild
118+
sudo tee /etc/systemd/system/kwild.service << EOF
119+
[Unit]
120+
Description=TRUF.NETWORK Node Service
121+
After=network.target tn-postgres.service
122+
Requires=tn-postgres.service
123+
124+
[Service]
125+
Type=simple
126+
User=$USER
127+
WorkingDirectory=$(pwd)
128+
ExecStart=$(which kwild) start -r ./my-node-config
129+
Restart=always
130+
RestartSec=10
131+
LimitNOFILE=65535
132+
133+
[Install]
134+
WantedBy=multi-user.target
135+
EOF
136+
137+
# 7) Create systemd service for PostgreSQL
138+
sudo tee /etc/systemd/system/tn-postgres.service << EOF
139+
[Unit]
140+
Description=TRUF.NETWORK PostgreSQL Service
141+
After=docker.service
142+
Requires=docker.service
143+
144+
[Service]
145+
Type=simple
146+
User=$USER
147+
ExecStart=docker start -a tn-postgres
148+
ExecStop=docker stop tn-postgres
149+
Restart=always
150+
RestartSec=10
151+
152+
[Install]
153+
WantedBy=multi-user.target
154+
EOF
155+
156+
# 8) Enable and start services
157+
sudo systemctl daemon-reload
158+
sudo systemctl enable tn-postgres
159+
sudo systemctl enable kwild
160+
sudo systemctl start tn-postgres
161+
sudo systemctl start kwild
162+
163+
# 9) Check service status
164+
echo "Checking service status..."
165+
sudo systemctl status kwild
166+
```
167+
168+
## Check Node Status
169+
170+
To check if your node is running properly:
171+
172+
```bash
173+
# Check service status
174+
sudo systemctl status kwild
175+
176+
# Check node status
177+
kwild admin status
178+
```
179+
180+
Your node is fully synced when you see `syncing: false` and your `best_block_height` is close to the current network height.
181+
182+
## Troubleshooting
183+
184+
If you encounter any issues:
185+
186+
1. Check service status: `sudo systemctl status kwild`
187+
2. Watch logs in real-time: `sudo journalctl -u kwild -f`
188+
- Press `Ctrl+C` to stop watching
189+
3. Check Docker container status: `docker ps`
190+
4. Check PostgreSQL logs: `docker logs tn-postgres`
191+
192+
### Common Commands
193+
194+
```bash
195+
# Watch kwild logs in real-time
196+
sudo journalctl -u kwild -f
197+
198+
# Watch last 100 lines of logs
199+
sudo journalctl -u kwild -n 100
200+
201+
# Watch logs since last boot
202+
sudo journalctl -u kwild -b
203+
204+
# Watch logs with timestamps
205+
sudo journalctl -u kwild -f --output=short-precise
206+
```
207+
208+
For more detailed configuration options and validator setup, refer to the main [README.md](../README.md).

0 commit comments

Comments
 (0)