Launch your node on Massa testnet

Cumulo
Cumulo.pro
Published in
11 min readAug 14, 2023

--

Linux/Ubuntu step-by-step installation guide

Updated to testnet 26.1 version, 8 September 2023

TABLE OF CONTENTS

· Getting started: what do I need?
· Server data
· Installing a node in Ubuntu / MacOS
· Installing the libraries and the repository
· Running a node in source code
· #Start the node
· #Start the client
· #Creating a Massa wallet
· Staking
· #Buying rolls
· To sum up:
· #Selling rolls
· Routability
· #Making your node routable
· Last step: activate the score
· MassaBot

The following guide is based on the official Massa project documentation.

You can find the official documentation on node installation at:

Getting started: what do I need?

  • A validated Discord account: https://discord.com/
  • Virtual or dedicated server. Alternatively, you can try it on a personal computer. Minimum requirements: 4 cores and 8 GB RAM.
  • In this document we will use Ubuntu although it is possible to use Windows, Mac and Linux operating systems.
  • SSH or Telnet Client: For remote administration of your Virtual Private Server, Telnet is a service that allows you to control your Virtual Private Server remotely and access other computers outside the area. Telnet is not a secure connection and for that reason SSH is recommended, which transmits data over an encrypted channel.

The client we will use in this guide is Putty:

Server data

To launch the node you will need to have the following data of your server at hand:
- Host IP number
- Username
- Pass

Installing a node in Ubuntu / MacOS

After installing the SSH client and running it, we will log in with our Host and a command line window will open where we will have to enter our username and password.

Access to the server via Putty.

If you don’t want to type the commands by hand, you can copy them from the document with CTRL+C but to paste them you must right-click on the command line and it will paste the last copied text.

Putty command-line window

Installing the libraries and the repository

- pkg-config is software that provides a unified interface for calling installed libraries when compiling a program from source code.

sudo apt install pkg-config curl git build-essential libssl-dev libclang-dev cmake

You can also use:

sudo apt install pkg-config curl git build-essential libssl-dev libclang-dev cmake -f
  • Adding -f forces a search for installation dependencies. Fixes an installation bug in Ubuntu 20.0.
  • It is also recommended to perform an update of the system libraries with:
sudo apt update
sudo apt upgrade

-We installed the open source programming language rustup, used in the Massa project:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

It will ask you if you want to launch the default installation or “customize”, the default installation is sufficient.

  • Set path. PATH is the system variable used by the operating system to search for the necessary executables from the command line or Terminal window:
source $HOME/.cargo/env
  • We check the version of rust:
rustc -version

Install the stable version of rust

rustup toolchain install 1.72.0
  • We set it as the default:
rustup default 1.72.0
  • We checked the version:
rustc --version
  • We clone the Massa repository:
git clone --branch testnet https://github.com/massalabs/massa.git

Running a node in source code

#Start the node

  • In a SHH console window, enter the Massa node directory:
cd massa/massa-node/
  • We launch the node in Ubuntu:
RUST_BACKTRACE=full cargo run --release -- -p <PASSWORD> |& tee logs.txt

Replace <PASSWORD> with a password that you will need to keep to restart your node You should leave the window opened

You can also use:

RUST_BACKTRACE=full nohup cargo run --release -- -p <PASSWORD> |& tee logs.txt

The nohub command keeps the process running even if you close the console window.

Leave it running and start the Putty application again to open a second command line window.

#Start the client

In a second console window.
- Start the client:

cd massa/massa-client/
  • We launched the client:
cargo run --release -- -p <PASSWORD>

Replace <PASSWORD> with a password that you will need to keep to restart your client. Wait until the directories are created before moving on to the next step.

Massa’s command console

#Creating a Massa wallet

A Massa wallet is a file that contains a list of your private keys.

Like other blockchains, Massa uses elliptic curve cryptography for the security of your coins. It means that your private key is the password that allows you to spend coins that were sent to your address (your address is the hash of your public key).

Here is how to create a Massa wallet.

cd massa/massa-client/

The wallet.dat file is loaded. If it does not exist, it is created.

You can now generate a new private key (and associated public key/address):

wallet_generate_secret_key

It will return the following info:

Or, manually add an existing private key if you already have one from a previous wallet:

wallet_add_secret_keys <your_private_key>.

You can access the list of addresses and passwords of your wallet with:

wallet_info

In the case that we have created the wallet for the first time it is advisable to save the public_key and the private_key in a safe place, to access this information from the massa client use the following commands:

wallet_get_public_key <address>
wallet_get_secret_key <address>

Staking

In Massa, the minimum number of coins required for staking is 100 MASSA (called 1 “roll”).

Addresses are randomly selected to create blocks in all threads, based on the number of rolls they have. Here is the list of players and their rolls: https://test.massa.net/#staking

Rolls can be bought with Massa coins or sold to get the coins back. If you already have more than 100 Massa, you can continue with this tutorial, otherwise, send your wallet address to the faucet bot in the “testnet-faucet” channel on Massa Discord. https://discord.gg/massa

** Remember that you must have a Discord account validated with your phone number beforehand.

Simply log in to the Massa channel, and in testnet-faucet send a message with your wallet Address.

#Buying rolls

- Get the address of the wallet where you have coins. At Massa’s client:

wallet_info
  • Buy rolls: enter your address, the number of rolls you wish to buy and the transaction fee (you can enter 0):
buy_rolls <address> <roll count> <fee>
  • It should take less than a minute for your roll to become final, check the balance with:
wallet_info
  • Now you must tell your node to start staking with your Rolls.

Register your public key (wallet address) so that your node can start staking with it:

node_start_staking <your_address>

Now you must wait a time for your rolls to become active: 3 cycles of 128 periods (a period is 32 blocks — 16 seconds), approximately 1h 40 minutes.

You can check if your rolls are active with the same command:

wallet_info

To sum up:

100 massa = 1 roll
For the rolls to be active we would have 1 candidate 1 final and 1 active.

When your rolls are activated, that’s it — you’re staking!

You should be eligible to create blocks in the different threads.

To check when your address is selected for staking, run this command:

get_addresses <your_address>

Check also that your balance increases, for every block or endorsement you create you should get a small reward.

#Selling rolls

If you want to get some or all of your coins back, sell the rolls in the same way you bought them:

sell_rolls <address> <roll count> <fee>

It should take some time for your coins to be received, and they will freeze for 1 cycle before you can spend them, again check with:

wallet_info

Routability

Massa network nodes need to establish connections between each other to communicate, propagate blocks and operations, and maintain consensus and synchrony all together.

For node A to establish a connection to node B, node B must be routable. This means that node B has a public IP address that can be accessed from node A and that TCP port 31244 and TCP port 31245 are open on node B and that node B’s firewalls allow the incoming connection on those ports. Once communication is established, this connection is bidirectional and it no longer matters which of the two nodes initiated the establishment of the connection.

If only a small number of nodes are routable, all other nodes will be able to connect only to those routable nodes, which may overload them and in general harm the decentralisation and security of the network, as those few routable nodes become de facto central communication hubs, bottlenecks and single points of failure. Therefore, it is important to have as many routable nodes as possible.

In Massa, nodes are not routable by default and require manual operation to become routable.

With the command get_status we will see that the following line appears, which is the one we have to correct.

No routable IP set

#Making your node routable

Make sure that the computer on which the node is running has a static public IP address (IPv4 or IPv6). You can retrieve the public IP address of your computer by opening https://api.ipify.org.

If the computer running the node is behind a router / NAT, you will need to configure your router:

If the router uses DHCP, the MAC address of the computer running the node must be configured to have a permanent DHCP grant (a local IP address that never changes, usually of the form 192.168.X.XX).

Incoming connections on TCP ports 31244 and 31245 must be directed to the local IP address of the computer running the node.

  • netstat is a command line tool that can provide information related to IP addresses, network connections, ports, and services communicating on these ports.
sudo apt install net-tools
sudo netstat –pl

p Displays the PID.
-l Will show only listening ports.

sudo netstat -plnt | grep :31244
sudo netstat -plnt | grep :31245
  • We will have to execute the following script to open the ports (of the Massa community), in case they are closed:
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/ports_opening.sh) 31244 31245
  • Configure the firewall on your computer to allow incoming TCP connections on ports 31244 and 31245.

To list the services allowed by the Firewall:

sudo ufw app list

The OpenSSH service should appear; if it does not, enable it:

sudo ufw allow "OpenSSH"

We enabled the ports of the Massa node:

ufw allow 31244 && ufw allow 31245

Finally, we activate the Firewall:

sudo ufw enable

Edit the file massa-node / config / config.toml (create it if not available) with the following content:

[protocol]
routable_ip = "AAA.BBB.CCC.DDD"

Where AAA.BBB.CCC.CCC.DDD should be replaced with your public IP address. IPV6 is also supported.

sudo vi massa/massa-node/config/config.toml

With the vi command, we use the Insert key to move through the file and edit it.

We use the arrow keys until we find the line and we add:

[protocol]
routable_ip = "IP of your node"

To save first ESC key, then the command to exit and save:

:wq

AND DONE!

Now we must restart the node to update this modification. From the Massa client console:

cd massa/massa-client
cargo run --release -- -p <PASSWORD>
node_stop

Command to restart it:

cd massa/massa-node/
RUST_BACKTRACE=full nohup cargo run --release -- -p <PASSWORD> |& tee logs.txt

Command launch client:

cd massa/massa-client/
cargo run --release -- -p <PASSWORD>

Once corrected, with the command: get_status we will see this line:

Node's ID:

Node's IP:

You can then test if your ports are open by typing your public IP address and port 31244 at https://www.yougetsignal.com/tools/open-ports/ (the same with port 31245).

Once your node is routable, you must send the public IP address of your node to the Discord bot. You must first register for the participation rewards programme.

Last step: activate the score

To validate your participation in the testnet participation rewards programme, you must register with your Discord account.

Write something in the testnet-rewards-registration channel on Massa’s Discord and the bot will send you instructions by email. More information here: Testnet rewards program.

MassaBot

A conversation will be opened with the bot with the following message:

Welcome! Here is how to register for the testnet participation rewards programme (see https://github.com/massalabs/massa/blob/main/docs/testnet_rules.md for details).

We assume here that you successfully installed your node, got your first coins from the faucet and started staking.

To register, run the command in the Massa client:

cd massa/massa-node/
RUST_BACKTRACE=full nohup cargo run --release -- -p <PASSWORD> |& tee logs.txt

node_testnet_rewards_program_ownership_proof (your_staking_address) xxxx

in your Massa client and give me the result here.

You have to replace your_staking_address with your own wallet address (see wallet_info)!

This will link your Discord name with your share address and node ID.

With this, you will be able to track the blocks you created and mark the stability of your node: don’t miss your slots!

>> Result:

Your discord account XXX has been associated with this node ID: XXX and this staking address: XXX. Congratulations!
Now you can check your registration and your score by sending me this message: info. A leaderboard of the best scores will be updated in channel leaderboard! The second step is optional, but is worth half of your score.

As the confirmation message tells us we can send the info message to get more information about the rewards in our wallet.

The second step is optional, but worth half of your score.

To help us decentralise the network, you can configure your node to be routable (see tutorials here:

https://github.com/massalabs/massa/blob/main/docs/routability.md).

Once your node is routable, send me the public IP address of your node here.

With your IP address (and the node ID I already have), I will be able to track when your node can be accessed from other nodes.

Finally you have your Massa testnet node ready and configured!!! :-) :-)

Useful links about Massa:

We are Cumulo

Follow us : Twitter | Medium | LinkedIn | cumulo.pro

Follow us in our news channel

--

--