Dev:Build a Nexus Testnet: Difference between revisions

From Nexus Wiki
Jump to navigation Jump to search
Created page with "This guide will help to set up a standalone nexus tesnet or join the nexus public testnet with mining. Mining is required to produce blocks on testnet as it mimics the mainnet. Testnet mining is very economical as the mining difficulty is very low. Developers can connect their testnet node to the public testnet, which gives an opportunity to test dapps extensively on testnet before porting to the main net. To set up a standalone testnet which will mint coins for testin..."
 
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 3: Line 3:
Developers can connect their testnet node to the public testnet, which gives an opportunity to test dapps extensively on testnet before porting to the main net.
Developers can connect their testnet node to the public testnet, which gives an opportunity to test dapps extensively on testnet before porting to the main net.


To set up a standalone testnet which will mint coins for testing, a minimum of two nodes are required with mining and after some coins are mined, they can be used to add staking to the testnet. The minted coins can be used to test dapps to mimic the mainnet and also distributed test coins to other testers. The two nodes will be set up similarly except for the connect flag in configuration which will refer to each other.
To set up a standalone testnet which will mint coins for testing, a minimum of two nodes are required with mining. After some coins are mined, they can be used to add staking to the testnet. The minted coins can be used to test dapps to mimic the mainnet and also distributed test coins to other testers. The two nodes will be set up similarly except for the connect flag in configuration which will refer to each other.


The testnet miner will use the CPU to mine the hash channel. Mining for testnet is very simple, economical and will use only a single worker with a single core CPU to make it as energy efficient as possible.
The testnet miner will use the CPU to mine the hash channel. Mining for testnet is very simple, economical and will use only a single worker with a single core CPU to make it as energy efficient as possible.
Line 14: Line 14:


* Two computers with dual core CPU and 2GB RAM, with a good CPU cooler and case cooling. VPS also can be used.
* Two computers with dual core CPU and 2GB RAM, with a good CPU cooler and case cooling. VPS also can be used.
* Ubuntu server 20.04 LTS for AMD/IA64 (Use any linux distribution of choice, but this guide is tailored for ubuntu).
* Ubuntu server 24.04 LTS for AMD/IA64 (Use any linux distribution of choice, but this guide is tailored for ubuntu).
* USB drive or SD card to install ubuntu.
* USB drive or SD card to install ubuntu.
* Etcher – To burn the OS image file to USB/SD card.
* Etcher – To burn the OS image file to USB/SD card.
Line 24: Line 24:
Update and upgrade the node:
Update and upgrade the node:


  sudo apt update; sudo apt upgrade -y
sudo apt update
sudo apt upgrade -y


Open SSH port before enabling firewall (If using SSH):
Open SSH port before enabling firewall (If using SSH):


  sudo ufw allow ssh
sudo ufw allow ssh


Open ports for API, RPC and mining:
Open ports for API, RPC and mining:


  sudo ufw allow 7080/tcp sudo ufw allow 8336/tcp sudo ufw allow 8325/tcp
sudo ufw allow 7080/tcp
sudo ufw allow 8336/tcp
sudo ufw allow 8325/tcp


Enable firewall:
Enable firewall:


  sudo ufw enable
sudo ufw enable


Check firewall status:
Check firewall status:


  sudo ufw status
sudo ufw status


Set timezone:
Set timezone:


  sudo dpkg-reconfigure tzdata
sudo dpkg-reconfigure tzdata


Change the hostname – Not compulsory if already set during the install:
Change the hostname – Not compulsory if already set during the install:


  sudo hostnamectl set-hostname <newhostname>
sudo hostnamectl set-hostname <newhostname>


Reboot node:
Reboot node:


  sudo reboot
sudo reboot


== Compile the Nexus Wallet ==
== Compile the Nexus Wallet ==
Line 58: Line 61:
Installs the dependencies required for compiling nexus core CLI, It will take some time to complete depending on the internet speed.
Installs the dependencies required for compiling nexus core CLI, It will take some time to complete depending on the internet speed.


  sudo apt-get install -y build-essential libssl-dev libdb-dev libdb++-dev libminiupnpc-dev git
sudo apt-get install -y build-essential libssl-dev libdb-dev libdb++-dev libminiupnpc-dev git


Download the latest nexus core source code, and should only take a few seconds to complete: (The Nexus master branch is linked to the merging branch. For stable build or specific builds refer to the github or contact telegram support).
Download the latest nexus core source code, and should only take a few seconds to complete: (The Nexus master branch is linked to the merging branch. For stable build or specific builds refer to the github or contact telegram support).


  git clone --depth 1 https://github.com/Nexusoft/LLL-TAO
git clone --depth 1 --branch merging https://github.com/Nexusoft/LLL-TAO


Change into the source code directory:
Change into the source code directory:


  cd LLL-TAO
cd LLL-TAO


Lastly run this command to compile from source. This begins compiling the nexus core, please be patient, as this can take a very long time depending on the CPU. Replace the 1 in ‘j1’to the number of cores / threads for compiling faster:
Lastly run this command to compile from source. This begins compiling the nexus core, please be patient, as this can take a very long time depending on the CPU. Replace the 1 in ‘j1’to the number of cores / threads for compiling faster:


  make -f makefile.cli -j1 AMD64=1
make -f makefile.cli -j1
 
NOTE: compiler specifications have changed and might suggest the missing explicit header lines needed to compile from source.


Will show “Finished building nexus” on a successful compile.
Will show “Finished building nexus” on a successful compile.
Line 80: Line 85:
Create the Nexus hidden data folder:
Create the Nexus hidden data folder:


  mkdir ~/.Nexus
mkdir ~/.Nexus


Create the nexus.conf file:
Create the nexus.conf file:


  nano nexus.config
nano nexus.conf


Copy the configuration below and change the values to suitable values:
Copy the configuration below and change the values to suitable values:


  #Nexus testnet with Miner config- PLEASE CHANGE THESE TO SUITABLE VALUES
#Nexus testnet with Miner config- PLEASE CHANGE THESE TO SUITABLE VALUES
  #Set RPC credentials
#Set RPC credentials
  rpcuser=<username>
rpcuser=<username>
  rpcpassword=<password>
rpcpassword=<password>
  #Set API credentials
#Set API credentials
  apiuser=<username>
apiuser=<username>
  apipassword=<password>
apipassword=<password>
  #To enable API authentication for testing
#To enable API authentication for testing
  apiauth=1
apiauth=1
  #To enable API remote access
#To enable API remote access
  apiremote=1
apiremote=1
  #To enable debug mode
#To enable debug mode
  debug=1
debug=1
  #To enable the daemon mode
#To enable the daemon mode
  daemon=1
daemon=1
  #To accept incoming JSON-RPC commands
#To accept incoming JSON-RPC commands
  server=1
server=1
  #User account settings credentials for auto login & auto create. Optionally create, login and unlock directly in the wallet.
#User account settings credentials for auto login & auto create. Optionally create, login and unlock directly in the wallet.
  username=<username>
username=<username>
  password=<password>
password=<password>
  pin=<pin>
pin=<pin>
  autocreate=1
autocreate=1
  autologin=1
autologin=1
  #Enable mining
#Enable mining
  mining=1
mining=1
  #Enable Staking
#Enable Staking
  Stake=1
Stake=1
  #The testnet flag defaults the API port to 7080, RPC to 8336 & mining port to 8325
#The testnet flag defaults the API port to 7080, RPC to 8336 & mining port to 8325
  testnet=1
testnet=1
  #To connect to the Nexus public testnet. Disable for standalone node
#To connect to the Nexus public testnet. Disable for standalone node
  #connect=node2.nexusoft.io
#connect=node2.nexusoft.io
  #To connect to another node on a local testnet
#To connect to another node on a local testnet
  #connect=192.168.2.29
#connect=192.168.2.29
  #To run as local node, disable for public node
#To run as local node, disable for public node
  nodns=1
nodns=1
  #process notifications (incoming transactions) automatically in background process
#process notifications (incoming transactions) automatically in background process
  processnotifications=1
processnotifications=1


To save the config file Ctrl+s & Ctrl+x
To save the config file Ctrl+s & Ctrl+x
Line 132: Line 137:
Install the dependencies (only required if installing miner on a separate computer):
Install the dependencies (only required if installing miner on a separate computer):


  sudo apt install build-essential libboost-all-dev libdb-dev libdb++-dev libssl-dev libminiupnpc-dev libgmp-dev -y
sudo apt install build-essential cmake libboost-all-dev libdb-dev libdb++-dev libssl-dev libminiupnpc-dev libgmp-dev -y


Clone the NexusMiner repository:
Clone the NexusMiner repository:


  git clone --branch v1.1 https://github.com/Nexusoft/NexusMiner
git clone --branch v1.5 https://github.com/Nexusoft/NexusMiner


Change into the source code folder:
Change into the source code folder:


  cd NexusMiner
cd NexusMiner


To precompile the binary use cmake. (cmake version 3.19 or higher only) <pathtosource> is the path to the NexusMiner folder and <pathtobuildfolder> is the path to NexusMiner/build.
To precompile the binary use cmake:


  cmake -S <pathtosource> -B <pathtobuildfolder> -DCMAKE_BUILD_TYPE=Release
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release


Change into the prebuilt binaries folder:
Change into the prebuilt binaries folder:


  cd build
cd build


Compile:
Compile:


  make
make


This will create the NexusMiner executable.
This will create the NexusMiner executable.
Line 160: Line 165:
For the proper functioning of the miner, it needs to be configured; create a configuration file named miner.conf in the same folder as the executable.
For the proper functioning of the miner, it needs to be configured; create a configuration file named miner.conf in the same folder as the executable.


  cd NexusMiner/build
cd NexusMiner/build


Create the miner.conf file:
Create the miner.conf file:


  nano miner.conf
nano miner.conf


Copy the miner configuration given below to the file, it uses the JSON format. Change the settings as per needs. Testnet mining will use the port 8325 as default. This config uses four workers, for a testnet just one worker can get the job done.
Copy the miner configuration given below to the file, it uses the JSON format. Change the settings as per needs. Testnet mining will use the port 8325 as default. This config uses four workers, for a testnet just one worker can get the job done.


  {
{
    "wallet_ip": "127.0.0.1",
  "wallet_ip": "127.0.0.1",
    "port": 8325,
  "port": 8325,
    "local_ip": "127.0.0.1",
  "local_ip": "127.0.0.1",
    "mining_mode": "HASH",
  "mining_mode": "HASH",
    "connection_retry_interval": 5,
  "connection_retry_interval": 5,
    "get_height_interval": 2,
  "get_height_interval": 2,
    "use_pool": false,
  "use_pool": false,
    "pool": {
  "pool": {
      "username": "Nexus_payout_address_for_pool_mining_only"
    "username": "Nexus_payout_address_for_pool_mining_only"
    },
  },
    "logfile": "miner.log",
  "logfile": "miner.log",
    "stats_printers": [
  "stats_printers": [
      {
    {
        "stats_printer": {
      "stats_printer": {
          "mode": "console"
        "mode": "console"
        }
      }
      },
    },
      {
    {
        "stats_printer": {
      "stats_printer": {
          "mode": "file",
        "mode": "file",
          "filename": "stats.log"
        "filename": "stats.log"
        }
      }
      }
    }
    ],
  ],
    "print_statistics_interval": 10,
  "print_statistics_interval": 10,
    "workers": [
  "workers": [
      {
    {
        "worker1": {
      "worker1": {
          "id": "cpu1",
        "id": "cpu1",
          "mode": {
        "mode": {
            "hardware": "cpu"
          "hardware": "cpu"
          }
        }
        },
      },
        "worker2": {
      "worker2": {
          "id": "cpu2",
        "id": "cpu2",
          "mode": {
        "mode": {
            "hardware": "cpu"
          "hardware": "cpu"
          }
        }
        },
      },
        "worker3": {
      "worker3": {
          "id": "cpu3",
        "id": "cpu3",
          "mode": {
        "mode": {
            "hardware": "cpu"
          "hardware": "cpu"
          }
        }
        },
      },
        "worker4": {
      "worker4": {
          "id": "cpu4",
        "id": "cpu4",
          "mode": {
        "mode": {
            "hardware": "cpu"
          "hardware": "cpu"
          }
        }
        }
      }
      }
    }
    ]
  ],
  }
  "version": 1
}


== Run the Miner ==
== Run the Miner ==
Line 230: Line 236:
Start the wallet. Wait for a few minutes for the wallet to be loaded:
Start the wallet. Wait for a few minutes for the wallet to be loaded:


  cd LLL-TAO
cd LLL-TAO
  ./nexus
./nexus
 
If a user account is not configured, auto create and auto login in the conf file will create it. Otherwise, an account can be created with:
 
./nexus profiles/create/master password=<password> pin=<pin> username=<username>
 
Unlock the user account for transactions:
 
./nexus sessions/unlock/local pin=<pin> transactions=1
 
Start the miner:
 
cd NexusMiner
./NexusMiner
 
Check the messages the miner prints out, every 10 secs there is a miner statistics printed on the screen (Time set in miner.config). Check for the “Submitting Block ...” and “Block Accepted By Nexus Network”
 
Stop the miner:
 
Ctrl+c
 
To check the mining information on the wallet:
 
./nexus ledger/get/info
 
To check the total wallet balance of the logged in user account:
 
./nexus finance/get/balances
 
To check the account details of the logged in user account:
 
./nexus finance.list/accounts
 
In account details the newly minted testnet coins are shown in the balance. These can be transferred similar to mainnet coins to other users for testing purposes.

Latest revision as of 16:29, 7 October 2024

This guide will help to set up a standalone nexus tesnet or join the nexus public testnet with mining. Mining is required to produce blocks on testnet as it mimics the mainnet. Testnet mining is very economical as the mining difficulty is very low.

Developers can connect their testnet node to the public testnet, which gives an opportunity to test dapps extensively on testnet before porting to the main net.

To set up a standalone testnet which will mint coins for testing, a minimum of two nodes are required with mining. After some coins are mined, they can be used to add staking to the testnet. The minted coins can be used to test dapps to mimic the mainnet and also distributed test coins to other testers. The two nodes will be set up similarly except for the connect flag in configuration which will refer to each other.

The testnet miner will use the CPU to mine the hash channel. Mining for testnet is very simple, economical and will use only a single worker with a single core CPU to make it as energy efficient as possible.

This guide assumes that each wallet and miner are on one computer, and works with the stable release 5.0.5. The steps below are given for one computer, and will have to be followed on the second one. The next version which is the Tritium++ will have a lot of changes related to API’s, but the setup process is the same.

Prerequisites

Before beginning this guide, check the things needed:

  • Two computers with dual core CPU and 2GB RAM, with a good CPU cooler and case cooling. VPS also can be used.
  • Ubuntu server 24.04 LTS for AMD/IA64 (Use any linux distribution of choice, but this guide is tailored for ubuntu).
  • USB drive or SD card to install ubuntu.
  • Etcher – To burn the OS image file to USB/SD card.

Prepare the Node

Install Ubuntu or distro of choice, Follow the below commands, copy the commands and paste it in the terminal using keys CTRL+SHIFT+v

Update and upgrade the node:

sudo apt update
sudo apt upgrade -y

Open SSH port before enabling firewall (If using SSH):

sudo ufw allow ssh

Open ports for API, RPC and mining:

sudo ufw allow 7080/tcp
sudo ufw allow 8336/tcp
sudo ufw allow 8325/tcp

Enable firewall:

sudo ufw enable

Check firewall status:

sudo ufw status

Set timezone:

sudo dpkg-reconfigure tzdata

Change the hostname – Not compulsory if already set during the install:

sudo hostnamectl set-hostname <newhostname>

Reboot node:

sudo reboot

Compile the Nexus Wallet

Installs the dependencies required for compiling nexus core CLI, It will take some time to complete depending on the internet speed.

sudo apt-get install -y build-essential libssl-dev libdb-dev libdb++-dev libminiupnpc-dev git

Download the latest nexus core source code, and should only take a few seconds to complete: (The Nexus master branch is linked to the merging branch. For stable build or specific builds refer to the github or contact telegram support).

git clone --depth 1 --branch merging https://github.com/Nexusoft/LLL-TAO

Change into the source code directory:

cd LLL-TAO

Lastly run this command to compile from source. This begins compiling the nexus core, please be patient, as this can take a very long time depending on the CPU. Replace the 1 in ‘j1’to the number of cores / threads for compiling faster:

make -f makefile.cli -j1

NOTE: compiler specifications have changed and might suggest the missing explicit header lines needed to compile from source.

Will show “Finished building nexus” on a successful compile.

Configure Nexus Wallet

To set up the testnet the wallet needs to be configured properly. The wallet configuration is stored in the Nexus data folder under the user's home directory.

Create the Nexus hidden data folder:

mkdir ~/.Nexus

Create the nexus.conf file:

nano nexus.conf

Copy the configuration below and change the values to suitable values:

#Nexus testnet with Miner config- PLEASE CHANGE THESE TO SUITABLE VALUES
#Set RPC credentials
rpcuser=<username>
rpcpassword=<password>
#Set API credentials
apiuser=<username>
apipassword=<password>
#To enable API authentication for testing
apiauth=1
#To enable API remote access
apiremote=1
#To enable debug mode
debug=1
#To enable the daemon mode
daemon=1
#To accept incoming JSON-RPC commands
server=1
#User account settings credentials for auto login & auto create. Optionally create, login and unlock directly in the wallet.
username=<username>
password=<password>
pin=<pin>
autocreate=1
autologin=1
#Enable mining
mining=1
#Enable Staking
Stake=1
#The testnet flag defaults the API port to 7080, RPC to 8336 & mining port to 8325
testnet=1
#To connect to the Nexus public testnet. Disable for standalone node
#connect=node2.nexusoft.io
#To connect to another node on a local testnet
#connect=192.168.2.29
#To run as local node, disable for public node
nodns=1
#process notifications (incoming transactions) automatically in background process
processnotifications=1

To save the config file Ctrl+s & Ctrl+x

Compile the Miner

Install the dependencies (only required if installing miner on a separate computer):

sudo apt install build-essential cmake libboost-all-dev libdb-dev libdb++-dev libssl-dev libminiupnpc-dev libgmp-dev -y

Clone the NexusMiner repository:

git clone --branch v1.5 https://github.com/Nexusoft/NexusMiner

Change into the source code folder:

cd NexusMiner

To precompile the binary use cmake:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

Change into the prebuilt binaries folder:

cd build

Compile:

make

This will create the NexusMiner executable.

Configure the Miner

For the proper functioning of the miner, it needs to be configured; create a configuration file named miner.conf in the same folder as the executable.

cd NexusMiner/build

Create the miner.conf file:

nano miner.conf

Copy the miner configuration given below to the file, it uses the JSON format. Change the settings as per needs. Testnet mining will use the port 8325 as default. This config uses four workers, for a testnet just one worker can get the job done.

{
  "wallet_ip": "127.0.0.1",
  "port": 8325,
  "local_ip": "127.0.0.1",
  "mining_mode": "HASH",
  "connection_retry_interval": 5,
  "get_height_interval": 2,
  "use_pool": false,
  "pool": {
    "username": "Nexus_payout_address_for_pool_mining_only"
  },
  "logfile": "miner.log",
  "stats_printers": [
    {
      "stats_printer": {
        "mode": "console"
      }
    },
    {
      "stats_printer": {
        "mode": "file",
        "filename": "stats.log"
      }
    }
  ],
  "print_statistics_interval": 10,
  "workers": [
    {
      "worker1": {
        "id": "cpu1",
        "mode": {
          "hardware": "cpu"
        }
      },
      "worker2": {
        "id": "cpu2",
        "mode": {
          "hardware": "cpu"
        }
      },
      "worker3": {
        "id": "cpu3",
        "mode": {
          "hardware": "cpu"
        }
      },
      "worker4": {
        "id": "cpu4",
        "mode": {
          "hardware": "cpu"
        }
      }
    }
  ],
  "version": 1
}

Run the Miner

For the miner to mine blocks, a user account is to be created, logged in and unlocked for mining, this also works to bootstrap a new network. Create two separate user accounts for the two nodes.

Start the wallet. Wait for a few minutes for the wallet to be loaded:

cd LLL-TAO
./nexus

If a user account is not configured, auto create and auto login in the conf file will create it. Otherwise, an account can be created with:

./nexus profiles/create/master password=<password> pin=<pin> username=<username> 

Unlock the user account for transactions:

./nexus sessions/unlock/local pin=<pin> transactions=1

Start the miner:

cd NexusMiner
./NexusMiner

Check the messages the miner prints out, every 10 secs there is a miner statistics printed on the screen (Time set in miner.config). Check for the “Submitting Block ...” and “Block Accepted By Nexus Network”

Stop the miner:

Ctrl+c

To check the mining information on the wallet:

./nexus ledger/get/info

To check the total wallet balance of the logged in user account:

./nexus finance/get/balances

To check the account details of the logged in user account:

./nexus finance.list/accounts

In account details the newly minted testnet coins are shown in the balance. These can be transferred similar to mainnet coins to other users for testing purposes.