This guide is written for liquidity providers to turn a Raspberry Pi into an always-on OpenDEX node.
Two options are available:
Light setup using Neutrino and a random open eth provider or optionally Infura. This keeps the setup light-weight & cheap, but creates a certain dependency on other people's full nodes. Supported by all Pi3/4 models.
Full setup using bitcoind, litecoind and geth. Requires more resources and an SSD, but keeps the setup trustless. Supported only by the Pi4 with 4GB RAM or more.
If you are not sure, we recommend to start with the light setup. If you opt for the Pi4 4/8GB, you can switch to the full setup at any time.
Download Ubuntu 20.04 for the Pi onto your computer, choosing 64-bit. Any other 64-bit (also called arm64, aarch64, armv8) linux os for the Pi is fine too. Systems like Raspberry Pi OS, which, at the time of writing, are still based on the 32-bit (armv7) architecture , are not supported. This guide was written using Ubuntu 20.04.
Insert the microSD card into your computer and follow the flash instructions.
Optional: If you don't have a screen, usb keyboard and even an ethernet cable available, you can pre-configure Wifi for a headless setup.
# on your linux computer, cd to the mounted microSD card partition "writable" and copy the wifi sample file. If you can't see any partition called "writable", then you are probably running something other than linux and need to figure out how to mount an ext4 filesystem.
sudocp./usr/share/doc/netplan/examples/wireless.yaml./etc/netplan/# open the file to editsudonano./etc/netplan/wireless.yaml# strip down the file to the bare minmum for the Pi to get an IP automatically assigned by your routernetwork:version:2wifis:wlan0:dhcp4:yesdhcp6:noaccess-points:"<YOUR WIFI SSID>":password:"<YOUR WIFI PASSWORD>"# if you can't access your router to read out your Pi's IP, you can also configure a static IP nowaddresses: [192.168.1.42/24]gateway4:192.168.1.1nameservers:addresses: [192.168.1.1, 8.8.8.8]# CTRL+S, CTRL+X.
Insert the microSD card into your Pi, connect it to your router via ethernet cable and to a power supply. Connecting a screen via HDMI and a USB keyboard makes life easier, but checking the assigned IP in your router and SSHing in from your computer works too.
Follow the inital setup instructions. Default user + password is ubuntu. You will be asked to change the password on first login.
Update ubuntu via sudo apt update && sudo apt upgrade
If you are using Ubuntu 20.04, install docker & docker-compose by running sudo apt install docker.io. Otherwise if you are using any version besides Ubuntu 20.04, follow the official instructions (select arm64 in step 4 of "Set up the repository") to install docker.
Add new user opendex:
ubuntu@ubuntu:~$sudoadduseropendexAddinguser`opendex' ...Adding new group `opendex' (1001) ...Addingnewuser `opendex' (1001) with group `opendex'...Creatinghomedirectory`/home/opendex' ...Copying files from `/etc/skel'...Newpassword:Retypenewpassword:passwd:passwordupdatedsuccessfullyChangingtheuserinformationforopendexdEnterthenewvalue,orpressENTERforthedefaultFullName []: RoomNumber []: WorkPhone []: HomePhone []: Other []: Istheinformationcorrect? [Y/n] ubuntu@ubuntu:~$ Y
Add the opendex user to the sudo group (advanced users can skip this and use another user to run sudo commands), the docker group and test if docker is working:
ubuntu@ubuntu:~$sudousermod-aGsudoopendexubuntu@ubuntu:~$sudousermod-aGdockeropendex# switch to user opendexdubuntu@ubuntu:~$sudosu-opendexopendex@ubuntu:~$dockerrunhello-worldHellofromDocker!Thismessageshowsthatyourinstallationappearstobeworkingcorrectly.
Looking good! Optionally, add an alias to enter your opendexd environment by simply typing "opendex":
opendex@ubuntu:~$sudonano~/.bash_aliases# add the linealias opendex='bash ~/opendex.sh'# CTRL+S, CTRL+X. Then runopendex@ubuntu:~$source~/.bashrc
Connect the USB stick to your Pi and set it up. It is very important to do this for a mainnet setup (given you do not want to lose money)!
# check the USB stick's path withopendex@ubuntu:~$ls-la/dev/|grepsdcrw-------1rootroot2,61Dec316:27ptysdbrw-rw----1rootdisk8,0Dec316:27sdabrw-rw----1rootdisk8,1Dec316:27sda1#this is your USB Stickcrw-------1rootroot3,61Dec316:27ttysd# set it to automount via fstabopendex@ubuntu:~$sudonano/etc/fstab# add the line/dev/sda1/media/USBext4defaults02# CTRL+S, CTRL+X. Then mount itopendex@ubuntu:~$sudomkdir/media/USBopendex@ubuntu:~$sudomount-a# check if mounting workedopendex@ubuntu:~$df-h# make sure opendexd can use itopendex@ubuntu:~$sudochownopendex:opendex/media/USB
From here the light and full setup require different settings. Continue choosing one.
Pi Light Setup
If you are using a Pi model with 2GB of RAM or more, you can continue here. If you are using a Pi model with <2GB of RAM, we will have to catch a temporary RAM spike when creating the opendex environment by creating a swap file (overflow RAM) of 2GB on the internal sd card:
# create the swap fileopendex@ubuntu:~$sudofallocate-l2G/home/opendex/swapfile# mark it as swap fileopendex@ubuntu:~$sudochmod600/home/opendex/swapfile&&sudomkswap/home/opendex/swapfile# enable itopendex@ubuntu:~$sudoswapon/home/opendex/swapfile# set it to automount via fstabopendex@ubuntu:~$sudonano/etc/fstab# add the line/home/opendex/swapfilenoneswapsw00# # CTRL+S, CTRL+X. Let's verify it's working & rebootopendex@ubuntu:~$sudoswapon--showNAMETYPESIZEUSEDPRIO/home/opendex/swapfilefile2G0B-2opendex@ubuntu:~$sudoreboot# after reboot, let's check if the swapfile is still activeopendex@ubuntu:~$sudoswapon--showNAMETYPESIZEUSEDPRIO/home/opendex/swapfilefile2G0B-2
# let's check the SSD's pathopendex@ubuntu:~$ls-la/dev/|grepsdcrw-------1rootroot2,61Dec316:27ptysdbrw-rw----1rootdisk8,0Dec316:27sdabrw-rw----1rootdisk8,1Dec316:27sda1#this is your USB Stickbrw-rw----1rootdisk8,16Jan2810:45sdbbrw-rw----1rootdisk8,17Jan2810:45sdb1#this is your SSDcrw-------1rootroot3,61Dec316:27ttysd# set it to automount via fstabopendex@ubuntu:~$sudonano/etc/fstab# add the line/dev/sdb1/media/SSDext4defaults02# CTRL+S, CTRL+X. Then mount itopendex@ubuntu:~$sudomkdir/media/SSDopendex@ubuntu:~$mount-a# check if mounting workedopendex@ubuntu:~$df-h# make sure opendexd can use it without sudo privilegesopendex@ubuntu:~$sudochownopendexd:opendexd/media/SSD
Let's do a quick performance test of the SSD. If you are close to these values, you are good to go, whereas <100 MB/s would be too slow:
Important: geth needs loads of RAM when syncing, so we need to create a swap file (overflow RAM) of 8GB on the external SSD:
# create a swap file on the SSD, we recommend a size of 8GBopendex@ubuntu:~$sudofallocate-l8G/media/SSD/swapfile# mark it as swap fileopendex@ubuntu:~$sudochmod600/media/SSD/swapfile&&sudomkswap/media/SSD/swapfile# enable itopendex@ubuntu:~$sudoswapon/media/SSD/swapfile# set it to automount via fstabopendex@ubuntu:~$sudonano/etc/fstab# add the line/media/SSD/swapfilenoneswapsw00# # CTRL+S, CTRL+X. Let's verify it's working & rebootopendex@ubuntu:~$sudoswapon--showNAMETYPESIZEUSEDPRIO/media/SSD/swapfilefile8G0B-2opendex@ubuntu:~$sudoreboot# after reboot, let's check if the swapfile is still activeopendex@ubuntu:~$sudoswapon--showNAMETYPESIZEUSEDPRIO/media/SSD/swapfilefile8G0B-2