Putting a Kaspa Node (Rust) into operation on Debian 11 (KRC20)

Putting a Kaspa Node (Rust) into operation on Debian 11 (KRC20)

In this tutorial you will install a current Kaspa node based on rust under Debian 11. The go node is not compatible with KRC20, which is why the use of a rust node is recommended. This tutorial not only shows how to install the node, but also how to set up an additional user for execution and create a separate service for the Kaspa node under this user. This also includes an automatic start of the Kaspa Node service at system startup.

The node runs on ports 16111 / 16110.

Tutorial (simplified)

Updated on 16.09.2024 to RustyKaspa v0.15.1

In the following we simplify the whole process a bit. We simply use the already finished application instead of compiling it ourselves.

First we edit the user configuration:

sudo visudo

and add the following settings within the file (not at the end):

Defaults:kaspanode runaspw
kaspanode ALL=(ALL) ALL

We then create a new user and assign a secure password for it:

adduser kaspanode

We then switch to this new user

su - kaspanode

and start the installation of required dependencies and tools

sudo apt install curl git build-essential libssl-dev pkg-config cmake screen unzip
sudo apt install protobuf-compiler libprotobuf-dev #Required for gRPC
sudo apt-get install clang-format clang-tidy \
clang-tools clang clangd libc -dev \
libc 1 libc abi-dev libc abi1 \
libclang-dev libclang1 liblldb-dev \
libllvm-ocaml-dev libomp-dev libomp5 \
lld lldb llvm-dev llvm-runtime \
llvm python3-clang
#wget https://github.com/kaspanet/rusty-kaspa/releases/download/v0.14.1/rusty-kaspa-v0.14.1-linux-gnu-amd64.zip
#unzip rusty-kaspa-v0.14.1-linux-gnu-amd64.zip
wget https://github.com/kaspanet/rusty-kaspa/releases/download/v0.15.1/rusty-kaspa-v0.15.1-linux-musl-amd64.zip
unzip rusty-kaspa-v0.15.1-linux-musl-amd64.zip
sudo touch /home/kaspanode/kaspa.log
sudo chmod 777 /home/kaspanode/kaspa.log

The command to start it would be (but we don’t use this command here)

#command to run it: /home/kaspanode/bin/kaspad --utxoindex

We want to start the node as a service automatically, so we create a new file for the service:

sudo nano /etc/systemd/system/kaspa.service

with the following content

[Unit]
Description=Kaspa Node Service
After=network.target

[Service]
User=kaspanode
WorkingDirectory=/home/kaspanode/bin
ExecStart=/bin/bash -c '/home/kaspanode/bin/kaspad --utxoindex >> /home/kaspanode/kaspa.log 2>&1'
Restart=always
RestartSec=10s
StartLimitBurst=3
StartLimitIntervalSec=60

[Install]
WantedBy=multi-user.target

We then execute the following commands

sudo systemctl daemon-reload
sudo systemctl reset-failed
sudo systemctl enable kaspa.service
sudo systemctl start kaspa.service

The Kaspa node is now set up

sudo systemctl status kaspa.service

Logs can also be displayed with the following command

tail -n 10 /home/kaspanode/kaspa.log

We automatically cut the log from time to time

sudo nano /etc/logrotate.d/kaspa

We insert the following content and save the file:

/home/kaspanode/kaspa.log {
    missingok
    notifempty
    size 10M
    copytruncate
    compress
    delaycompress
    daily
    rotate 7
    create 644 kaspanode kaspanode
}

Tutorial Rust (currently not possible)

Unfortunately, there is currently an error when compiling with libmimalloc-sys on Debian 11 and Ubuntu 22. I therefore recommend using the simplified tutorial (see above).

First we edit the user configuration:

sudo visudo

and add the following settings inside the file (not at the end):

Defaults:kaspanode runaspw
kaspanode ALL=(ALL) ALL

We then create a new user and assign a secure password for it:

adduser kaspanode

We then switch to this new user

su - kaspanode

and start the installation of required dependencies and tools

sudo apt install curl git build-essential libssl-dev pkg-config cmake screen
sudo apt install protobuf-compiler libprotobuf-dev #Required for gRPC
sudo apt-get install clang-format clang-tidy \
clang-tools clang clangd libc -dev \
libc 1 libc abi-dev libc abi1 \
libclang-dev libclang1 liblldb-dev \
libllvm-ocaml-dev libomp-dev libomp5 \
lld lldb llvm-dev llvm-runtime \
llvm python3-clang
sudo curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.profile
cargo install wasm-pack
rustup target add wasm32-unknown-unknown
git clone https://github.com/kaspanet/rusty-kaspa

The command to start it would be (but we don’t use this command here)

#command to run it: cargo run --release --manifest-path /home/kaspanode/rusty-kaspa/Cargo.toml --bin kaspad -- --utxoindex

We create a new file for the service

sudo nano /etc/systemd/system/kaspa.service

with the following content

[Service]
User=kaspanode
WorkingDirectory=/home/kaspanode/rusty-kaspa
Environment="PATH=/home/kaspanode/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ExecStart=/usr/bin/screen -DmS kaspa-session /usr/bin/bash -c 'cargo run --release --manifest-path /home/kaspanode/rusty-kaspa/Cargo.toml --bin kaspad -- --utxoindex > /home/kaspanode/kaspa.log 2>&1'
Restart=always
RestartSec=10s
StartLimitBurst=3
StartLimitIntervalSec=60

We then execute the following commands

sudo systemctl daemon-reload
sudo systemctl reset-failed
sudo systemctl enable kaspa.service
sudo systemctl start kaspa.service

The Kaspa node is now set up

sudo systemctl status kaspa.service

Logs can also be displayed with the following command

cat /home/kaspanode/kaspa.log

2 Antworten zu “Putting a Kaspa Node (Rust) into operation on Debian 11 (KRC20)”

  1. Thanks for the great tutorial! I have been looking for this, especially the auto-start. Do you know if the 2nd option works with Debian 12?

Leave a Reply

Your email address will not be published. Required fields are marked *