Wiki

Clone wiki

AywaCore / MasternodeSetupGuide2

Masternode Setup Guide

##Terms and Conditions

Aywa Blockchain Platform (Aywa Platform, Aywa Blockchain, Aywa)- decentralised public blockchain with blockchain-based applications, such as instant payments transfer, communications, voting, etc.

Aywa Network Node (Network Node, Aywa Node, Node) - any network node, connected to Aywa.

Aywa Fullnode (Fullnode) - Aywa Network Node, which has database of all the Aywa blockchain transactions and blocks, connected to other Nodes, and accepts incoming connections from other Nodes.

Aywa Core (AywaCore) - is a program that fully validates transactions and blocks by accepting transactions and blocks from Nodes, validating those transactions and blocks, and then relaying them to further nodes.

AywaCore GUI - Aywa Core with graphical user interface.

AywaCore cli - Aywa Core with command line interface.

Masternode (MN) - Aywa Fullnode, with extension, providing additional security of Aywa Network and special blockchain services, such as locking transactions with InstantSend, coordinate mixing of coins, and voting on proposals.

Masternode Cost (MNC) - AYWA amount required for MN. Aywa has different MNC for different periods.

Masternode Collateral Transaction (MN collateral, MN tx, Masternode Unspent Transaction Output, MN UTXO) - a blockchain transaction which have exact required amount (MNC) for certain period.

Masternode Owner (MNO) - a person, who own the private key for address with MN collateral.

AYWA (₳) - (Pronounce as 'æɪwə) The digital coin of Aywa Platform. It has limited emission by the blockchain and is internal hard currency, an engine to motivate the mining of blocks, a development and further improvements of the platform.

Masternode Server - local or remote server with AywaCore Instance and Masternode Extension, physical (PHS) or virtual (VPS).

Requirements for a Masternode

You must have at your wallet or exchange (+0.0001₳ for transaction fees):

1,000 AYWA (until 31 Dec 2018)

2,000 AYWA (for period from 01 Jan 2019 to 30 Jun 2019)

5,000 AYWA (from 01 Jul 2019 to 31 Dec 2020)

10,000 AYWA (from 01 Jan 2021).

Masternode Collateral Tranaction, created at certain period can be used for Masternode at any later period. For example, is you have MN collateral for 1000 AYWA created at 2018, you can start (or restart) MN at 2019, 2020 or later, even if MN Cost will be 10,000 AYWA.

Masternode can be installed at a server, connected to internet, which meets the following requirements:

Virtual private server (VPS) is recommended for this. Well tested VPS provider is Vutlr, but any other are suitable also.

Ubuntu VPS Setup

If you don’t have a VPS already, get the 1GB Ram VPS from Vultr: Rent VPS

Install Ubuntu OS 16.04 onto it.

We will begin by connecting to your newly provisioned server. On Windows, we will first download an app called PuTTY to connect to the server. Go to the PuTTY download page and select the appropriate MSI installer for your system. On Mac or Linux you can ssh directly from the terminal - simply type ssh root@<server_ip> and enter your password when prompted.

We will create a new user with the following command, replacing <username> with a username of your choice:

adduser <username>

You will be prompted for a password. Enter and confirm using a new password (different to your root password) and store it in a safe place. You will also see prompts for user information, but this can be left blank. Once the user has been created, we will add them to the sudo group so they can perform commands as root:

usermod -aG sudo <username>

Now, while still as root, we will update the system from the Ubuntu package repository:

sudo apt-get update
sudo apt-get upgrade

The system will show a list of upgradable packages. Press Y and Enter to install the packages. We will now install a firewall (and some other packages we will use later), add swap memory and reboot the server to apply any necessary kernel updates, and then login to our newly secured environment as the new user:

sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils
sudo apt-get install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev
sudo apt-get install ufw python virtualenv git fail2ban 
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install libdb4.8-dev libdb4.8++-dev
sudo apt-get install libminiupnpc-dev
sudo apt-get install libzmq3-dev

(press Y and Enter to confirm)

Firewall Setup:

ufw allow ssh/tcp
ufw limit ssh/tcp
ufw allow 2777/tcp
ufw logging on
ufw enable

Additional Swap Space to improve stability:

fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo -e "/swapfile none swap sw 0 0 \n" >> /etc/fstab

To see that this worked you can type use the following command:

free

Free shows you the swap space. Here is a screenshot of showing installed swap space:

image-20181111192356694.png

You can also check you have disk space left with this command:

df

Finally, in order to prevent brute force password hacking attacks, open the SSH configuration file to disable root login over SSH:

nano /etc/ssh/sshd_config

Locate the line that reads PermitRootLogin yes and set it to PermitRootLogin no. Directly below this, add a line which reads AllowUsers <username>, replacing <username> with the username you selected above. The press Ctrl + X to close the editor, then Y and Enter save the file.

Then reboot the server:

reboot now

PuTTY will disconnect when the server reboots.

While this setup includes basic steps to protect your server against attacks, much more can be done. In particular, authenticating with a public key instead of a username/password combination and enabling automatic security updates is advisable. More tips are available here. However, since the masternode does not actually store the private keys, these steps are considered beyond the scope of this guide.

Send the collateral

An Aywa address with a single unspent transaction output (UTXO) of exactly value AYWA for certain period (Masternode Cost) is required to operate a masternode. Once it has been sent, various keys regarding the transaction must be extracted for later entry in a configuration file as proof that the transaction was completed successfully. A masternode can be started from Aywa Core.

Open Aywa Core wallet and wait for it to synchronize with the network. It should look like this when ready:

image-20181111194943791.png

Fully synchronized Aywa Core wallet

Click Tools > Debug console to open the console. Type the following two commands into the console to generate a masternode key and get a fresh address:

masternode genkey
getaccountaddress 0

2387815063-image-20181111195544089.png

Generating a masternode private key in Aywa Core wallet

Take note of the masternode private key and collateral address, since we will need it later. The next step is to secure your wallet (if you have not already done so). First, encrypt the wallet by selecting Settings > Encrypt wallet. You should use a strong, new password that you have never used somewhere else. Take note of your password and store it somewhere safe or you will be permanently locked out of your wallet and lose access to your funds. Next, back up your wallet file by selecting File > Backup Wallet. Save the file to a secure location physically separate to your computer, since this will be the only way you can access our funds if anything happens to your computer.

Now send exactly 1000 AYWA (2000, 5000, 10000 depending on period) in a single transaction to the account address you generated in the previous step. This may be sent from another wallet, or from funds already held in your current wallet. Once the transaction is complete, view the transaction in a blockchain explorer by searching for the address. You will need 15 confirmations before you can start the masternode, but you can continue with the next step at this point already: installing Aywa Core on your VPS.

image-20181111195804160.png

Aywa blockchain explorer showing 15 confirmations for collateral transfer.

Aywa Masternode Setup

AywaCore Setup

Aywa Core is the software behind both the Aywa Core GUI wallet and Aywa masternodes. If not displaying a GUI, it runs as a daemon on your VPS (aywad), controlled by a simple command interface (aywa-cli).

Open PuTTY or a console again and connect using the username and password you just created for your new, non-root user.

Manual installation

To manually download and install the components of your Aywa Masternode, visit https://github.com/GetAywa/AywaCore/releases on your computer to find the link to the latest Aywa Core wallet. Right-click on Aywa-cli_ubuntu.tar.gz and select Copy link address. Go back to your terminal window at VPS and enter the following command, pasting in the address to the latest version of Aywa Core by right clicking or pressing Ctrl + V:

cd ~
wget https://github.com/GetAywa/AywaCore/releases/download/v0.1.2.1/Aywa-cli_ubuntu.tar.gz

Create a working directory for Aywa, extract the compressed archive, copy the necessary files to the directory and set them as executable:

mkdir .aywacore
mkdir aywacore
cd aywacore
mkdir bin
tar xfvz Aywa-cli_ubuntu.tar.gz
mv aywad aywacore/bin
mv aywa-cli aywacore/bin
chmod 777 aywacore/bin/*

Clean up unneeded files:

rm Aywa-cli_ubuntu.tar.gz

Create a configuration file using the following command:

nano ~/.aywacore/aywa.conf

An editor window will appear. We now need to create a configuration file specifying several variables. Copy and paste the following text to get started, then replace the variables specific to your configuration as follows:

#----
rpcuser=XXXXXXXXXXXXX
rpcpassword=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
rpcallowip=127.0.0.1
#----
listen=1
server=1
daemon=1
maxconnections=64
#----
masternode=1
masternodeprivkey=XXXXXXXXXXXXXXXXXXXXXXX
externalip=XXX.XXX.XXX.XXX
#----

Replace the fields marked with XXXXXXX as follows:

  • rpcuser: enter any string of numbers or letters, no special characters allowed
  • rpcpassword: enter any string of numbers or letters, no special characters allowed
  • masternodeprivkey: this is the private key you generated in the previous step
  • externalip: this is the IP address of your VPS

The result should look something like this:

image-20181111200337502.png

Entering key data in aywa.conf on the masternode

Press Ctrl + X to close the editor and Y and Enter save the file. You can now start running AywaCore on the masternode to begin synchronization with the blockchain:

~/aywacore/aywad

You will see a message reading Aywa Core server starting.

Enter following command to check status of blocks download:

watch ~/aywacore/aywa-cli getinfo

Wait until all the blocks are downloaded. When block counter value reaches the last block (you can check it from you local wallet: 'Tools'->'Information'->'Information Tab'->'Current Number of blocks'), go back to terminal (Press Ctrl-C).

We will now install Sentinel, a piece of software which operates as a watchdog to communicate to the network that your node is working properly:

cd ~
git clone https://github.com/GetAywa/Aywa_Masternode
cd Aywa_Masternode/sentinel
sudo apt-get update  && sudo apt-get -y install python-virtualenv && sudo apt-get install virtualenv
export LC_ALL=C
virtualenv venv
venv/bin/pip install -r requirements.txt
venv/bin/python bin/sentinel.py

If you're getting an error about "Aywa.conf not found" edit ~/Aywa_Masternode/sentinel/sentinel.conf file, put correct path to aywa.conf. You will see a message reading aywad not synced with network! Awaiting full sync before running Sentinel. Add aywad and sentinel to crontab to make sure it runs every minute to check on your masternode:

crontab -e

Choose nano as your editor and enter the following lines at the end of the file:

* * * * * cd ~/Aywa_Masternode/sentinel && ./venv/bin/python bin/sentinel.py 2>&1 >> sentinel-cron.log
* * * * * pidof aywad || ~/.aywacore/aywad

Press enter to make sure there is a blank line at the end of the file, then press Ctrl + X to close the editor and Y and Enter save the file. We now need to wait for 15 confirmations of the collateral transaction to complete, and wait for the blockchain to finish synchronizing on the masternode. You can use the following commands to monitor progress:

~/.aywacore/aywa-cli mnsync status

When synchronisation is complete, you should see the following response:

{
 "AssetID": 999,
 "AssetName": "MASTERNODE_SYNC_FINISHED",
 "Attempt": 0,
 "IsBlockchainSynced": true,
 "IsMasternodeListSynced": true,
 "IsWinnersListSynced": true,
 "IsSynced": true,
 "IsFailed": false
}

Continue with the next step to start your masternode.

Start your masternode

You will need to start your masternode by Aywa Core wallet. Before you continue, you must ensure that your MNC AYWA collateral transaction has at least 15 confirmation, and that aywad is running and fully synchronized with the blockchain on your masternode. See the previous step for details on how to do this. During the startup process, your masternode may pass through the following states:

  • MASTERNODE_SYNC: This indicates the data currently being synchronised in the masternode
  • MASTERNODE_SYNC_FAILED: Synchronisation could not complete, check your firewall and restart aywad
  • WATCHDOG_EXPIRED: Waiting for sentinel to restart, make sure it is entered in crontab
  • NEW_START_REQUIRED: Start command must be sent from wallet
  • PRE_ENABLED: Waiting for network to recognize started masternode
  • ENABLED: Masternode successfully started

If you masternode does not seem to start immediately, do not arbitrarily issue more start commands. Each time you do so, you will reset your position in the payment queue.

Starting from Aywa Core wallet

If you used an address in Aywa Core wallet for your collateral transaction, you now need to find the txid of the transaction. Click Tools > Debug console and enter the following command:

masternode outputs

This should return a string of characters similar to this:

{
"06e38868bb8f9958e34d5155437d009b72dff33fc28874c87fd42e51c0f74fdb" : "0",
}

The first long string is your transaction hash, while the last number is the index. We now need to create a file called masternode.conf for this wallet in order to be able to use it to issue the command to start your masternode on the network. Open a new text file in Notepad (or TextEdit on macOS, gedit on Linux) and enter the following information:

  • Label: Any single word used to identify your masternode, e.g. MN1
  • IP and port: The IP address and port (usually 2777) configured in the dash.conf file, separated by a colon (:)
  • Masternode private key: This is the result of your masternode genkey command earlier, also the same as configured in the dash.conf file
  • Transaction hash: The txid we just identified using masternode outputs
  • Index: The index we just identified using masternode outputs

Enter all of this information on a single line with each item separated by a space, for example:

MN1 52.14.2.67:2777 XrxSr3fXpX3dZcU7CoiFuFWqeHYw83r28btCFfIHqf6zkMp1PZ4 06e38868bb8f9958e34d5155437d009b72dff33fc28874c87fd42e51c0f74fdb 0

Save this file in the AywaCore data folder on the PC running the Aywa Core wallet using the filename masternode.conf. (Menu 'Tools'->'Open Masternode Configuration File') If you use AywaCore cli, you may need to enable View hidden items to view this folder. Be sure to select All files if using Notepad so you don’t end up with a .conf.txt file extension by mistake. For different operating systems, the AywaCore folder can be found in the following locations (copy and paste the shortcut text into the Save dialog to find it quickly):

Platform Path Shortcut
Linux /home/yourusername/.aywacore ~/.aywacore
macOS /home/yourusername/Library/Application Support/AywaCore ~/Library/Application Support/AywaCore
Windows C:\Users\yourusername\AppData\Roaming\Aywa Core %APPDATA%\AywaCore

Now close your text editor and also shut down and restart Aywa Core wallet. Aywa Core will recognize masternode.conf during startup, and is now ready to activate your masternode. Go to Settings > Unlock Wallet and enter your wallet passphrase. Then click Tools > Debug consoleagain and enter the following command to start your masternode (replace MN1 with the label for your masternode):

masternode start-alias MN1

You will probably need to wait around 30 minutes as the node passes through the PRE_ENABLED stage and finally reaches ENABLED.

At this point you can safely log out of your server by typing exit. Congratulations! Your masternode is now running.

Updated