X1 Fastnet Node Setup

SERVER SPECIFICATION I AM USING

My Server is a hosted cloud virtual server. If you want to build your own server then you can but there will be extra requirements. All I list here is valid for hosted servers.

6 vCPU Cores

16 GB RAM

600 GB SSD

32 TB Traffic*Unlimited Incoming

Ubuntu 20.04

All instructions below are based on using Ubuntu. If you are using a different version of Linux then you may need to adjust the commands. All commands that need typing in are in red and you will need to press the enter button after each one.

One point to note is that validation or creation of new blocks isn't possible yet. There will be another version of this chain where people will be allowed to start block production

Docker Based Installation

Putty is required for this as well so please use the instructions above for installing and using Putty.

First thing we need to do is install docker. I am not going to go deeply into what docker is and how to use it as I want to keep this simple but there are plenty of good resources online.

Step 1 — Installing Docker

The Docker installation package available in the official Ubuntu repository may not be the latest version. To ensure we get the latest version, we’ll install Docker from the official Docker repository. To do that, we’ll add a new package source, add the GPG key from Docker to ensure the downloads are valid, and then install the package. All instructions assume that you have root access. If your user does not then you will need to add ‘sudo’ in front of them.

First, update your existing list of packages:

apt update

Next, install a few prerequisite packages which let apt use packages over HTTPS:

apt install apt-transport-https ca-certificates curl software-properties-common

Then add the GPG key for the official Docker repository to your system:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add the Docker repository to APT sources:

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

This will also update our package database with the Docker packages from the newly added repo.

Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:

apt-cache policy docker-ce

You’ll see output like this, although the version number for Docker may be different:

Output of apt-cache policy docker-ce

docker-ce:
  Installed: (none)
  Candidate: 5:19.03.9~3-0~ubuntu-focal
  Version table:
     5:19.03.9~3-0~ubuntu-focal 500
        500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages

Finally, install Docker:

apt install docker-ce

Docker should now be installed, the daemon started, and the process enabled to start on boot. Check x

systemctl status docker

The output should be similar to the following, showing that the service is active and running:

Output
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2020-05-19 17:00:41 UTC; 17s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 24321 (dockerd)
      Tasks: 8
     Memory: 46.4M
     CGroup: /system.slice/docker.service
             └─24321 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Step 2 — Installing AND RUNNING THE NODE

Full credit for this package goes to Xen Community member bok11. He created this docker package so big thanks to him.

Run

docker pull bok11/x1-validator  

This pulls down the docker package

mkdir x1

Run

docker run -v x1:/home/opera bok11/x1-validator

You will now see the X1 validator start up and begin to sync. Again, this took 18 hours for me so just let it do what it needs to.

You can check the status of the service with systemctl status x1-validator.service and stop it with systemctl stop x1-validator.services. To see the logs, run journalctl -u x1-validator.service -f

Here I list some useful docker commands. Please always do your research before using any of them if you are inexperienced with Docker. Google is a great resource. As of Docker 19, the complete list of available subcommands includes:

Output
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

Additional notes

You will need to set the number of files Opera can use. This can be done with the command

 ulimit -n 200000

You can check the number of open files with the command

ls -ltr /proc/12298/fd | wc -l 

where the 12298 is the PID of my Opera instance. You will need to change that for the PID of your particular instance. To get your PID run the command top and you will get something similar to below where you can see where I got my PID from.

swap space

It is also useful and advisable to have a swap file activated. A swap file allows Linux to simulate the disk space as RAM. When your system starts running out of RAM, it uses the swap space to and swaps some content of the RAM on to the disk space. This frees up the RAM to serve more important processes. When the RAM is free again, it swaps back the data from the disk. I have 16gb swap space set but you could just as easily use 32gb.

Check swap space in Linux

Before you go and start adding swap space, it would be a good idea to check whether you have swap space already available in your system.

free -h
              total        used        free      shared  buff/cache   available
Mem:           7.5G        4.1G        267M        971M        3.1G        2.2G
Swap:           16G          0B         16G

If you don’t have a swap space on your system, it should show something like this:

free -h
              total        used        free      shared  buff/cache   available
Mem:           7.5G        4.1G        267M        971M        3.1G        2.2G
Swap:           0B          0B         0B

The swapon command won’t show any output.

Create swap file on Linux

First thing first, create a file with the size of swap space you want. Let’s say that I want to add 16 GB of swap space to my system. Use the fallocate command to create a file of size 16 GB.

sudo fallocate -l 16G /swapfile

It is recommended to allow only root to read and write to the swap file. You’ll even see warning like “insecure permissions 0644, 0600 suggested” when you try to use this file for swap area.

sudo chmod 600 /swapfile
 
 

Do note that the name of the swap file could be anything. If you need multiple swap spaces, you can give it any appropriate name like swap_file_1, swap_file_2 etc. It’s just a file with a predefined size.

Your need to tell the Linux system that this file will be used as swap space. You can do that with mkswap tool.

sudo mkswap /swapfile
 

Now your system knows that the file swapfile can be used as swap space. But it is not done yet. You need to enable the swap file so that your system can start using this file as swap.

sudo swapon /swapfile

Now if you check the swap space, you should see that your Linux system recognizes and uses it as the swap area:

swapon –show
 
NAME       TYPE   SIZE USED PRIO
/swapfile  file 16G   0B   -2

Whatever you have done so far is temporary. Reboot your system and all the changes will disappear.

You can make the changes permanent by adding the newly created swap file to /etc/fstab file.

It’s always a good idea to make a backup before you make any changes to the /etc/fstab file.

sudo cp /etc/fstab /etc/fstab.back

Now you can add the following line to the end of /etc/fstab file:

/swapfile none swap sw 0 0

You can do it manually using a command line text editor or you just use the following command:

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Now you have everything in place. Your swap file will be used even after you reboot your Linux system.

Last updated