docs
Tangle Network
Node Operators
Running with Systemd
Collator 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.

Parachain 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)
  • Nimbus key (Sr25519)
  • Rand key (Sr25519)
  • 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-parachain key insert --base-path /data/validator/<USERNAME> \
--chain ./chainspecs/tangle-parachain.json \
--scheme Sr25519 \
--suri <SURI> \
--key-type acco

Aura Keys

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

DKG Keys

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

Nimbus Keys

docker run --rm -it --platform linux/amd64 --network="host" -v "/var/lib/data" \
ghcr.io/webb-tools/tangle/tangle-parachain:main \
    tangle-parachain key insert --base-path /data \
    --chain /data/chainspecs/tangle-parachain.json \
    --scheme Sr25519 \
    --key-type nmbs

Rand Keys

docker run --rm -it --platform linux/amd64 --network="host" -v "/var/lib/data" \
ghcr.io/webb-tools/tangle/tangle-parachain:main \
    tangle-parachain key insert --base-path /data \
    --chain /data/chainspecs/tangle-parachain.json \
    --scheme Sr25519 \
    --key-type rand

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-parachain binary to the bin directory (assumes you are in repo root directory)
sudo mv ./target/release/tangle-parachain /usr/bin/

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

# create the service configuration file
sudo touch collator.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.

Collator Node

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

[Service]
User=<USERNAME>
Restart=always
RestartSec=3
ExecStart=/usr/bin/tangle-parachain \
  --base-path /data/collator/<USERNAME> \
  --name <NODE-NAME> \
  --chain tangle \
  --node-key-file "/home/<USERNAME>/node-key" \
  --port 30333 \
  --collator \
  --no-mdns \
  --wasm-execution compiled \
  --trie-cache-size 0 \
  -- \
  --execution wasm \
  --name="YOUR-NODE-NAME (Embedded Relay)"

[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 collator

sudo systemctl start collator

Check the status of the service:

systemctl status collator

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 collator.service -f

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

2023-03-22 14:55:51 Tangle Parachain
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-parachain/chains/local_testnet/db/full
2023-03-22 14:55:51 ⛓  Native runtime: tangle-parachain-115 (tangle-parachain-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"]

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.