Docs
Ecosystem Roles
Validator
Running with Systemd
Validator Node

Running with Systemd

You can run your validator node as a Systemd process so that it will automatically restart on server reboots or crashes (and helps to avoid getting slashed!).

Before following this guide you should have already set up your machines environment, installed the dependencies, and compiled the Tangle binary. If you have not done so, please refer to the Requirements page.

Standalone Testnet

Generate and store keys

We need to generate the required keys for our node. For more information on these keys, please see the Required Keys (opens in a new tab) section. The keys we need to generate include the following:

  • DKG key (Ecdsa)
  • Aura key (Sr25519)
  • Account key (Sr25519)
  • Grandpa key (Ed25519)
  • ImOnline key (Sr25519)

Let's now insert our required secret keys, we will not pass the SURI in the command, instead it will be interactive, where you should paste your SURI when the command asks for it.

Account Keys

# it will ask for your suri, enter it.
./target/release/tangle-standalone key insert --base-path /data/validator/<USERNAME> \
--chain ./chainspecs/tangle-standalone.json \
--scheme Sr25519 \
--suri <SURI> \
--key-type acco

Aura Keys

# it will ask for your suri, enter it.
./target/release/tangle-standalone key insert --base-path /data/validator/<USERNAME> \
--chain ./chainspecs/tangle-standalone.json \
--scheme Sr25519 \
--suri <SURI> \
--key-type aura

Im-online Keys - these keys are optional

# it will ask for your suri, enter it.
./target/release/tangle-standalone key insert --base-path /data/validator/<USERNAME> \
--chain ./chainspecs/tangle-standalone.json \
--scheme Sr25519 \
--suri <SURI> \
--key-type imon

DKG Keys

# it will ask for your suri, enter it.
./target/release/tangle-standalone key insert --base-path /data/validator/<USERNAME> \
--chain ./chainspecs/tangle-standalone.json \
--scheme Ecdsa \
--suri <SURI> \
--key-type wdkg

Grandpa Keys

# it will ask for your suri, enter it.
./target/release/tangle-standalone key insert --base-path /data/validator/<USERNAME> \
--chain ./chainspecs/tangle-standalone.json \
--scheme Ed25519 \
--suri <SURI> \
--key-type gran

To ensure you have successfully generated the keys correctly run:

ls ~/data/validator/<USERNAME>/keystore
# You should see a some file(s) there, these are the keys.

System service setup

Run the following commands to create the service configuration file:

# Move the tangle-standalone binary to the bin directory (assumes you are in repo root directory)
sudo mv ./target/release/tangle-standalone /usr/bin/

# navigate to /etc
cd /etc/systemd/system

# create the service configuration file
sudo touch validator.service

Add the following contents to the service configuration file. Make sure to replace the USERNAME with the username you created in the previous step, add your own node name, and update any paths or ports to your own preference.

Note: The below configuration assumes you are targeting the Tangle Network chainspec.

Validator Node

[Unit]
Description=Tangle Validator Node
After=network-online.target
StartLimitIntervalSec=0

[Service]
User=<USERNAME>
Restart=always
RestartSec=3
ExecStart=/usr/bin/tangle-standalone \
  --base-path /data/validator/<USERNAME> \
  --name <NODE-NAME> \
  --chain tangle \
  --node-key-file "/home/<USERNAME>/node-key" \
  --port 30333 \
  --validator \
  --no-mdns

[Install]
WantedBy=multi-user.target

Enable the services

Double check that the config has been written to /etc/systemd/system/validator.service correctly. If so, enable the service so it runs on startup, and then try to start it now:

sudo systemctl enable validator

sudo systemctl start validator

Check the status of the service:

systemctl status validator

You should see the node connecting to the network and syncing the latest blocks. If you need to tail the latest output, you can use:

journalctl -u validator.service -f

If the node is running correctly, you should see an output similar to below:

2023-03-22 14:55:51 Tangle Standalone Node
2023-03-22 14:55:51 ✌️  version 0.1.15-54624e3-aarch64-macos
2023-03-22 14:55:51 ❤️  by Webb Technologies Inc., 2017-2023
2023-03-22 14:55:51 📋 Chain specification: Tangle Testnet
2023-03-22 14:55:51 🏷  Node name: cooing-morning-2891
2023-03-22 14:55:51 👤 Role: FULL
2023-03-22 14:55:51 💾 Database: RocksDb at /Users/local/Library/Application Support/tangle-standalone/chains/local_testnet/db/full
2023-03-22 14:55:51 ⛓  Native runtime: tangle-standalone-115 (tangle-standalone-1.tx1.au1)
2023-03-22 14:55:51 Bn254 x5 w3 params
2023-03-22 14:55:51 Verifier params for mixer
2023-03-22 14:55:51 Verifier params for vanchor
2023-03-22 14:55:51 [0] 💸 generated 5 npos voters, 5 from validators and 0 nominators
2023-03-22 14:55:51 [0] 💸 generated 5 npos targets
2023-03-22 14:55:51 [0] 💸 generated 5 npos voters, 5 from validators and 0 nominators
2023-03-22 14:55:51 [0] 💸 generated 5 npos targets
2023-03-22 14:55:51 [0] 💸 new validator set of size 5 has been processed for era 1
2023-03-22 14:55:52 🔨 Initializing Genesis block/state (state: 0xfd16…aefd, header-hash: 0x7c05…a27d)
2023-03-22 14:55:52 👴 Loading GRANDPA authority set from genesis on what appears to be first startup.
2023-03-22 14:55:53 Using default protocol ID "sup" because none is configured in the chain specs
2023-03-22 14:55:53 🏷  Local node identity is: 12D3KooWDaeXbqokqvEMqpJsKBvjt9BUz41uP9tzRkYuky1Wat7Z
2023-03-22 14:55:53 💻 Operating system: macos
2023-03-22 14:55:53 💻 CPU architecture: aarch64
2023-03-22 14:55:53 📦 Highest known block at #0
2023-03-22 14:55:53 〽️ Prometheus exporter started at 127.0.0.1:9615
2023-03-22 14:55:53 Running JSON-RPC HTTP server: addr=127.0.0.1:9933, allowed origins=["http://localhost:*", "http://127.0.0.1:*", "https://localhost:*", "https://127.0.0.1:*", "https://polkadot.js.org"]
2023-03-22 14:55:53 Running JSON-RPC WS server: addr=127.0.0.1:9944, allowed origins=["http://localhost:*", "http://127.0.0.1:*", "https://localhost:*", "https://127.0.0.1:*", "https://polkadot.js.org"]
2023-03-22 14:55:53 discovered: 12D3KooWMr4L3Dun4BUyp23HZtLfxoQjR56dDp9eH42Va5X6Hfgi /ip4/192.168.0.125/tcp/30304
2023-03-22 14:55:53 discovered: 12D3KooWNHhcCUsZTdTkADmDJbSK9YjbtscHHA8R4jvrbGwjPVez /ip4/192.168.0.125/tcp/30305
2023-03-22 14:55:53 discovered: 12D3KooWMr4L3Dun4BUyp23HZtLfxoQjR56dDp9eH42Va5X6Hfgi /ip4/192.168.88.12/tcp/30304
2023-03-22 14:55:53 discovered: 12D3KooWNHhcCUsZTdTkADmDJbSK9YjbtscHHA8R4jvrbGwjPVez /ip4/192.168.88.12/tcp/30305

Congratulations! You have officially setup an Tangle Network node using Systemd. If you are interested in learning how to setup monitoring for your node, please refer to the monitoring page.