Moonriver
This guide is a recommended way of running your node, specifically as a systemd service on a Linux-based machine (be it virtual, or bare metal) and is complementary to the official documentation available here. You could also start your node as a Docker container, but we would recommend using this option only if you are familiar with container technologies and we strongly encourage leveraging the power of containers with an orchestration software such as Kubernetes.
AWS:
c6i.2xlarge
or any equivalent instance type
Bare Metal:
- 16GB RAM
- 8 (v)CPUs
- At least 500 GB of storage - make sure it's extendable
We're going to assume you are already logged into your Virtual Machine as a privileged user or as the root user.
After making sure your operating system is up to date we will need to install a couple of packages before actually getting the node started.
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install git curl wget cmake build-essential clang ufw jq net-tools lz4 -y
Once the installation is done, as a best practice, we will create a service account that will be responsible for running the actual node binary. We will also create a separate directory where we will store the binary and data (we might to be a privileged user to run the following commands).
adduser moonriver_service --system --no-create-home
mkdir /var/lib/moonriver-data
After doing this, we should now get the binary. There are 2 ways of achieving this:
- compiling the binary ourselves (as shown here), which usually takes some time, but can turn out to be useful if you use the proper Rust compiling options for optimizing the binary for your processor;
- downloading the binary from the official releases, which is much easier if you are not experienced with compiling Rust code - another interesting aspect is that the Moonbeam team offers 3 binaries per release: one unoptimized general use-case version (
moonbeam
), one optimized for the Intel Skylake processor family (moonbeam-skylake
) and one optimized for the AMD Zen 3 processor family (moonbeam-znver3
) - this is very helpful if you are aware of the underlying processor of your machine.
For simplicity, we will use the pre-compiled binary made available by the Moonbeam team (please, be aware that it has the proper permissions and owner):
RELEASE_VERSION=v0.30.0 # at the time of writing, this is the latest release
cd /var/lib/moonriver-data
wget https://github.com/PureStake/moonbeam/releases/download/${RELEASE_VERSION}/moonbeam # download the binary
sudo chown -R moonriver_service /var/lib/moonriver-data # ensure proper ownership on the data directory
sudo chmod ugo+x /var/lib/moonriver-data/moonbeam # ensure proper execution permissions on the binary
# for trace/debug/txpool API support
git clone https://github.com/PureStake/moonbeam-runtime-overrides.git
mv moonbeam-runtime-overrides/wasm /var/lib/moonriver-data
rm /var/lib/moonriver-data/wasm/moonbase-runtime-* && rm /var/lib/moonriver-data/wasm/moonbeam-runtime-*
sudo chmod ugo+x /var/lib/moonriver-data/wasm/*
sudo chown -R moonriver_service /var/lib/moonriver-data/wasm # ensure proper ownership on the directory
After performing the previous steps, you can check that everything is in place by running the command:
/var/lib/moonriver-data/moonbeam --version
and if the output lists the Moonbeam binary version and latest commit hash, we're clear to move forward.IMPORTANT NOTE: Make sure you update your tracing runtime overrides each time there is a new runtime upgrade, otherwise you won't be able to support the trace/debug/txpool API properly.
# for trace/debug/txpool API support
cd <DOWNLOAD_DIR>/moonbeam-runtime-overrides
git fetch && git pull
sudo systemctl stop moonriver.service
rm -rf /var/lib/moonriver-data/wasm
mv moonbeam-runtime-overrides/wasm /var/lib/moonriver-data
rm /var/lib/moonriver-data/wasm/moonbase-runtime-* && rm /var/lib/moonriver-data/wasm/moonbeam-runtime-*
sudo chmod ugo+x /var/lib/moonriver-data/wasm/*
sudo chown -R moonriver_service /var/lib/moonriver-data/wasm # ensure proper ownership on the directory
sudo systemctl restart moonriver.service
The next step is to create the systemd configuration file. These are recommended flags that we are running on our production services (for more information regarding all the available flags, please refer to the official documentation here).
First, create the systemd configuration file:
sudo touch /etc/systemd/system/moonbeam.service # create the file
sudo vi /etc/systemd/system/moonbeam.service # open the file for writing - we prefer vi as our text editor, but feel free to use what suits you best
The contents of the systemd configuration file should be:
[Unit]
Description="Moonriver systemd service"
After=network.target
StartLimitIntervalSec=0