Skip to content

Building a Bananode from sources

coranos edited this page Feb 27, 2024 · 108 revisions

Ubuntu 16.04, 18.04, and 20.04, Debian 8, 9, 10, and 11

NOTE: UBUNTU 20.10 currently does not have a version of boost that works with bananode. Please use UBUNTU 20.04 until UBUNTU 20.10 is patched.

Recommended Hardware

  • Run the node in a datacenter. Most SSD VPS packages will work. (DigitalOcean, Vultr, Hetzner, OVH, etc.)
  • 1 modern CPU core minimum. 2 or more is recommended especially for voting nodes and principal nodes.
  • 20GB Free disk space (Blockchain database is ~9GB in size at the moment)
  • 2 GB system RAM or more. 4 GB or more is recommended especially for voting nodes and principal nodes

bootstrapping

you can bootstrap off the rocksdb or leveldb files here: http://ledgerfiles.banano.cc/

Installing dependencies

sudo apt update;
sudo apt upgrade -y;
sudo apt-get install -y git cmake make g++ curl wget python-dev;
sudo apt install python3-pip;
sudo pip install cmake-format;

adding swap (optional)

https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-20-04/

sudo fallocate -l 4G /swapfile;
sudo chmod 600 /swapfile;
sudo mkswap /swapfile;
sudo swapon /swapfile;
sudo nano /etc/fstab;

# add the below line to /etc/fstab
/swapfile swap swap defaults 0 0

Installing precompiled Boost (Ubuntu 20.04, Debian 10, Debian 11)

If your distribution includes boost 1.67 or newer (e.g. Ubuntu 20.04) but not "1.74.0.3ubuntu6" (Ubuntu 21.10) you can skip the section "Building static Boost" and simply run:

sudo apt install -y libboost-all-dev

Building static Boost (Ubuntu 16.04, Ubuntu 18.04, Debian 8, Debian 9)

To automate this step, you can use sudo banano_build/util/build_prep/bootstrap_boost.sh --m (the optional m 'minimum' flag reduces compilation time but may break Boost for other use cases than building the bananode) which does essentially this:

wget https://netix.dl.sourceforge.net/project/boost/boost/1.70.0/boost_1_70_0.tar.gz   
tar xzvf boost_1_70_0.tar.gz   
cd boost_1_70_0   
./bootstrap.sh --with-libraries=system,thread,log,filesystem,program_options,coroutine,context  
./b2 --prefix=/usr/local/boost link=static install   
cd ..

Cloning the Bananode's git repository

check out master branch

git clone --recursive https://github.com/BananoCoin/banano.git banano_build   

check out v25.1 branch

git clone --branch v25.1 --recursive https://github.com/BananoCoin/banano.git banano_build

check out v26.1 branch (EXPERIMENTAL).

git clone --branch v26.1 --recursive https://github.com/BananoCoin/banano.git banano_build

Building bananode

cd banano_build   

git submodule update --init --force --recursive

cmake -G "Unix Makefiles"   
make bananode   

Optional: You can also add custom cmake flags like -DACTIVE_NETWORK=nano_test_network if you want to run a private testnet.

# in debug mode
cd banano_build   

git submodule update --init --force --recursive

cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON  -DCMAKE_BUILD_TYPE=Debug -DNANO_STACKTRACE_BACKTRACE=ON -DNANO_TEST=ON -G "Unix Makefiles"
make bananode core_test rpc_test load_test slow_test
# cycle core tests
reset;git pull;make bananode core_test;./core_test
##run in debug mode
apt install gdb
gdb
(gdb) file ./bananode
(gdb) run --daemon

instructions based on nanocurrency's instructions: https://docs.nano.org/integration-guides/build-options/#node_1

Configuring bananode

## copy the node executable into the parent directory
cp bananode ../bananode;
cd ..;
## check if the freshly compiled executable executes 
./bananode --diagnostics;
## generate default config files with all available options. You can then customize the config files, for example to activate RPC or activate voting.
mkdir BananoData;
./bananode --generate_config node > /root/BananoData/config-node.toml 
./bananode --generate_config rpc > /root/BananoData/config-rpc.toml
cp ./banano_build/docker/node/config/config-* BananoData;
## you can delete the banano_build directory now, if you want

config-node.toml

vi BananoData/config-node.toml

[node]
# throttle bandwidth (recommended unless on a large vps)
# bandwidth_limit = 1

# only allow one person to bootstrap from you at a time (recommended unless on a large vps or a principle rep)
# bootstrap_connections_max = 1

# don't allow burst mode (recommended unless on a large vps or a principle rep)
# bandwidth_limit_burst_ratio = 1.0

[node.rocksdb]
enable = true

[node.websocket]
# WebSocket server bind address.
# type:string,ip
address = "::ffff:0.0.0.0"

# Enable or disable WebSocket server. disable unless you need it.
# type:bool
enable = false

[rpc]
# Enable or disable RPC. 
# enable to allow debugging of bootstrapping. disable if not needed after bootstrapping.
# type:bool
enable = true

running the bananode

# start the node in the background
screen -dmSL bananode ./bananode --daemon;

# check that it has peers (firewall may prevent peers)
curl -g -d '{"action": "peers"}' 'localhost:7072';

# check local block count (RPC)
curl -g -d '{"action": "block_count"}' 'localhost:7072';

# check local block count (CLI)
./bananode --debug_block_count;

# check kalium block count (RPC)
curl -g -d '{"action": "block_count"}' 'https://kaliumapi.appditto.com/api';

# check how many accounts are still being processed.
cat BananoData/log/* | grep -e 'accounts in pull queue' | tail -n 2

Configuring rocksdb (optional)

if you want to enable rocksdb follow these instructions: https://docs.nano.org/running-a-node/ledger-management/#enable-rocksdb

Configuring bandwidth limit (optional)

The default bandwidth limit is 10 MB/s.

https://github.com/nanocurrency/nano-node/blob/bb95786d8713ac2bd39cafe7f14dfa199e457f1e/nano/node/nodeconfig.hpp#L94

if this is too high, try a few things:

vi BananoData/config-node.toml 

disable web sockets

[node.websocket]
enable = false

disable rpc

[rpc]
enable = false

set bandwidth limit:

Default bandwidth limit is 10 MB/s, which is 10.

To set it to 1 MB/s, use 1

[node]
bandwidth_limit = 1
bootstrap_connections_max = 1
bandwidth_limit_burst_ratio = 1.0

RPC commands are explained in NANO's wiki. Only use the 'raw' unit when sending commands to the Bananode.

If a build fails, delete these temporary files before you try again

rm -rf CmakeCache.txt
rm -rf CMakeFiles

CentOS 7

You need to install a custom repository or this will fail with c++: error: unrecognized command line option ‘-std=c++14’

sudo yum -y check-update   
sudo yum -y install git curl wget bzip2 python-devel cmake

sudo yum -y install centos-release-scl
sudo yum -y install devtoolset-7
scl enable devtoolset-7 bash

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y cryptopp cryptopp-devel

Tools that are included in the above package: gcc gcc-c++ libstdc++-static make

compiling on low end VPS

You'll need either 2GB Ram for a successful compile, or a generous swap file:

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

check block count

./bananode --debug_block_count

OSX

git clone https://github.com/BananoCoin/banano.git
cd banano
sh ci/bootstrap_boost.sh
git submodule update --init --recursive
cmake -DBOOST_ROOT=/usr/local/boost/ -G "Unix Makefiles"
make
./bananode --daemon

To shorten boost build time, you can add --m after bootstrap_boost.sh, but you may break boost for other use cases then.

data will be stored in ~/Library/Banano

Creating the wallet for your representative

  1. If you plan to use your node as a representative in Banano network voting consensus, you must create a wallet within your node so that you can share it with your friends / family / community so that they can delegate their voting weight to your node and thus contribute with network decentralization. In order to this, you need to follow the next steps:
  2. If ./bananode --debug_block_count command output is fine you will receive the current block state and it will be ready to go;
  3. Do a RPC call with curl -d '{ "action" : "wallet_create" }' [::1]:7072 to generate your wallet's seed. Take on consideration about ipv6 usage. If your node is running over ipv4 use curl -d '{ "action" : "wallet_create" }' 127.0.0.1:7072 instead. 7072 is Banano node port and you need to keep it free for sharing information with another pairs;
  4. After done, you must have your seed and it will look like this 82E20E9E4FC8957A223E05E8325FD39BB6EA81A2D8DB40B3E79227BB6557BC1, make sure you copy it in a safe place (use a pen or an offline environment for this). Generate a new account for your seed sending this RPC command curl -d '{ "action": "account_create", "wallet": "82E20E9E4FC8957A223E05E8325FD39BB6EA81A2D8DB40B3E79227BB6557BC1" }' 127.0.0.1:7072 and voilá! The output will be a ban_address that you will use to set your representative in all your seeds, friend or family ones.

Set up a node monitor

https://github.com/NanoTools/nanoNodeMonitor

on ubuntu allow port 80

sudo ufw allow http
apt-get install ca-certificates apt-transport-https software-properties-common gnupg2 -y;
add-apt-repository ppa:ondrej/php;
apt-get install php8.0 -y;
apt-get install php8.0-common php8.0-curl php8.0-gd php8.0-mysql php8.0-xml php8.0-imagick php8.0-cli php8.0-mbstring php8.0-opcache php8.0-soap php8.0-zip php8.0-dev php8.0-imap -y;
apt-get install libapache2-mod-php8.0 -y;
apt autoremove -y;
systemctl restart apache2;
cd /var/www/html;
rm index.html;
git clone https://github.com/NanoTools/nanoNodeMonitor .;
cd modules/;
cp config.sample.php config.php;
nano config.php;

set up monit to monitor and restart the node if it crashes

https://github.com/BananoCoin/banano/wiki/set-up-monit-for-monitoring