Aeternity testnet deployment

Chris
5 min readDec 5, 2017

--

This post will guide you through deploying an Aeternity testnet node and start mining on it if your system has the required specs.

Getting started

First of you need to install a Linux distribution. In this tutorial Ubuntu Server 17.10 is used. After you installed the Linux distribution you create a new user, replace “username” with the name you want:

sudo adduser username

You will be asked to enter the root password you choose during installation.
Next there will be a prompt to choose a password and additional information

Now we need to add the new user to the root category with the following command:, again replace the username with the username you chose in the previous step.

usermod -aG sudo username

By default, on ubuntu, members of the “sudo” group have sudo priviliges.

Updating the system

We update the system before continuing. You do this with the following 2 commands:

sudo apt-get update
sudo apt-get upgrade

When this process is completed. It can take some time depending on the processing speed of you system and connection.

Getting the files

Now to get the release files on our system you do the following code:


mkdir node
cd node
wget https://github.com/aeternity/epoch/releases/download/v0.21.0/epoch-0.21.0-ubuntu-x86_64.tar.gz

Next we need to extract the downloaded files. You can do this using the following command:

Tar epoch-0.21.0-ubuntu-x86_64.tar.gz

If you now give the “ls” command you can see that the files have been extracted into different folders. now we can continue configuring it.

Joining the Testnet

In order for your node to join the testnet, you need to specify in the configuration file:

  • The initial network peers to join (peers parameter);
  • How peers (on the Internet) can contact your node (http > external > peer_address parameter).

Please notice that, if your node is behind a firewall, you need to open a TCP port in your firewall (http > external > peer_address parameter) and map that port to the one the node actually listens on (http > external > port parameter). The two port numbers can be distinct.

The following example configuration assumes that:

  • Your public IP address is 1.2.3.4;
  • The listening TCP port on that public IP address is 8080;
  • The listening TCP port on your node is 3003.

In order for your node to manage the correct account (able to hold tokens on the blockchain), you need to specify in the configuration file the location of your public-private key pair. The storage of the key pair by the node is basic:

  • Each node handles one key pair;
  • The key pair is stored on disk;
  • The location of the key pair is configurable (keys > dir parameter);
  • The key pair is encrypted with a configurable password stored in clear in the configuration file (keys > passwordparameter);
  • A fresh key pair is generated if none is found in the configured location.

You do not need to create a key pair yourself: the node will generate one (keys > dir parameter) in the configured location if none found there. After the node generates the key pair in the configured location, you should make a backup of that directory (and remember the password): if you destroy the node, you can setup a new node with the same account in order to lose the tokens you had obtained by mining on the chain. You shall not share the private key (or the password) with anyone.

Create the file /node/epoch.yaml by doing the following command:

sudo nano epoch.yaml

Then enter the following data into the text file, amend the http > external > peer_address parameter and http > external > port parameter to match with your actual values.

---
peers:
- "http://31.13.248.102:3013/"
keys:
dir: keys
password: "secret"
http:
external:
peer_address: http://1.2.3.4:8080/
port: 3003
internal:
port: 3103
websocket:
internal:
port: 3104
mining:
autostart: true
chain:
persist: true
db_path: ./db

Ensure the configured path for storing the blockchain exists:

mkdir db

Starting the node:

cd bin
./epoch start

Verify the node is up, by inspecting the current top of the blockchain as seen by the node:

curl http://127.0.0.1:3003/v1/top

If the node is unresponsive, inspect the log directory for errors.

Backup the key pair:

cp -pr keys ~/my_epoch_keys

Verify that node mines

Inspect the mining log file of the node:

less log/epoch_mining.log

If the node is mining, you shall read log entries like the following:

2017-11-30 18:02:40.705 [info] <0.833.0>@aec_conductor:create_block_candidate:591 Creating block candidate
2017-11-30 18:02:40.708 [info] <0.833.0>@aec_conductor:handle_block_candidate_reply:605 Created block candidate and nonce (max 17995532323347653506, current 17995532323347653507).
2017-11-30 18:02:40.708 [info] <0.833.0>@aec_conductor:start_mining:475 Starting mining
2017-11-30 18:02:51.804 [info] <0.833.0>@aec_conductor:start_mining:475 Starting mining

Manage account

Check your public key

Retrieve the public key of your node:

curl http://127.0.0.1:3103/v1/account/pub-key

It will show you something like you see in the picture below.

Check your balance

To check the balance associated with the retrieved public key use the code below and replace the public key (“pub_key=yourkey=”)

curl -G http://127.0.0.1:3003/v1/account/balance --data-urlencode "pub_key=BNngPLE0UBkgJN+z3JR6jOO5Z/7Cz9zseB1JBzexa+ru3x3y/P1hDh5BL7QRfzZ0Mb0Y7PLcVUKik7JDKE7SEo4="

You will see a reply from the node showing your balance. It’s easy to miss.

If you have zero balance you will get the following reply:

{"reason":"Account not found"}

Good luck and let me know if there are issues!

Special thanks to @cr-mn for testing the guide.

--

--