How to setup an EOSIO test network

in #howto7 years ago (edited)

Hello EOS Community :)

My name is Basit Raza and I'm the Engineering Lead for EOSVibes

We have been playing around with EOS DAWN 3.0 and we would like to share our experience with you.

With the help of this guide, you will able to setup your own network.

We are working on the EOS testnet monitoring platform, which will help you to keep track of the activities of the nodes in the network.

Let's start by building EOS from source, which is made simple by the script in the codebase.

mkdir /opt/eosio-dawn-v3

sudo chown <user>:<group> /opt/eosio-dawn-v3
cd /opt/eosio-dawn-v3

git clone -b dawn-v3.0.0 --depth 1 https://github.com/EOSIO/eos.git -- recursive
cd eos/

./eos_build.sh

cd build && make install

Having completed the build process, let's verify the installation of EOS binaries, by executing the following command from the terminal.

nodeos --version

Output:

3652030188


Your version number will be different if you are building EOS from another branch.

Setup bios-node

mkdir -p /opt/eosio-testnet/bios-node

Create keypair for bios-node

cleos create key

Output:

You will get something like:

Private key: 5J1rGCTGkmrhvUnNgTWzi4hyZ9Rdk8kFVHHjpfZADgdzQHzhnAw
Public key: EOS8RGweLVckTmqR4VbWrZtF4rUcc9unsErqKamTzDWT8hbh3uJsB

Create genesis file

Let's create the genesis file. This genesis (genesis.json) file remains the same for all nodes in a network.

Location: /opt/eosio-testnet/genesis.json

{
"initial_timestamp": "2018-03-01T12:00:00.000",
"initial_key": "EOS8RGweLVckTmqR4VbWrZtF4rUcc9unsErqKamTzDWT8hbh3uJsB",
"initial_configuration": {
"base_per_transaction_net_usage": 100,
"base_per_transaction_cpu_usage": 500,
"base_per_action_cpu_usage": 1000,
"base_setcode_cpu_usage": 2097152,
"per_signature_cpu_usage": 100000,
"per_lock_net_usage": 32,
"context_free_discount_cpu_usage_num": 20,
"context_free_discount_cpu_usage_den": 100,
"max_transaction_cpu_usage": 10485760,
"max_transaction_net_usage": 104857,
"max_block_cpu_usage": 104857600,
"target_block_cpu_usage_pct": 1000,
"max_block_net_usage": 1048576,
"target_block_net_usage_pct": 1000,
"max_transaction_lifetime": 3600,
"max_transaction_exec_time": 0,
"max_authority_depth": 6,
"max_inline_depth": 4,
"max_inline_action_size": 4096,
"max_generated_transaction_count": 16
},
"initial_chain_id":
"0000000000000000000000000000000000000000000000000000000000000000"
}

Create config.ini for bios-node

Location: /opt/eosio-testnet/bios-node/config.ini

get-transaction-time-limit = 3
genesis-json = "/opt/eosio-testnet/genesis.json"
block-log-dir = "blocks"
http-server-address = 127.0.0.1:8888
p2p-listen-endpoint = 127.0.0.1:18771
p2p-server-address = 127.0.0.1:18771
enable-stale-production = true
allowed-connection = any
required-participation = 33
private-key =
["EOS8RGweLVckTmqR4VbWrZtF4rUcc9unsErqKamTzDWT8hbh3uJsB","5J1rGCTGkmrhvUnNg
TWzi4hyZ9Rdk8kFVHHjpfZADgdzQHzhnAw"]
producer-name= eosio
plugin = eosio::producer_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::account_history_api_plugin
plugin = eosio::wallet_api_plugin

Prepapre config for other BPs

Create directory for node-01

mkdir /opt/eosio-testnet/node-01

Generate node-01 Keypair

cleos create key

Output:

You will get something like this

Private key: 5K8gejDxPLsZUbfDvAhffJ9kSQ9MoMnebNwTqwRgspdwfwuZQzu
Public key: EOS8L8jc65g8qS5xfYZ8fNVw2fx6t9STiwHndSEy91YkUVvAWf7zQ

Create config.ini for node-01

Location: /opt/eosio-testnet/node-01/config.ini

get-transaction-time-limit = 3
genesis-json = "/opt/eosio-testnet/genesis.json"
block-log-dir = "blocks"
http-server-address = 127.0.0.1:8889
p2p-listen-endpoint = 127.0.0.1:18772
p2p-server-address = 127.0.0.1:18772
enable-stale-production = false
required-participation = 33
allowed-connection = any
p2p-peer-address = 127.0.0.1:18771
private-key =
["EOS8L8jc65g8qS5xfYZ8fNVw2fx6t9STiwHndSEy91YkUVvAWf7zQ","5K8gejDxPLsZUbfDv
AhffJ9kSQ9MoMnebNwTqwRgspdwfwuZQzu"]
producer-name = nodeone
plugin = eosio::producer_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::account_history_api_plugin
plugin = eosio::wallet_api_plugin

Note: Genesis file remains the same for all other nodes.

Start the bios-node

nodeos --config /opt/eosio-testnet/bios-node/config.ini --data-dir
/opt/eosio-testnet/bios-node

Create a wallet

Let's now create a default wallet by using following command.

cleos wallet create

Output

Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5KbMPR78kiLUPDsHcasC2cU4FHFmA75MxQ9rVfVu3MmKsHfNpeF"

Please save the generated password, since it will be required to unlock the wallet.

Unlock Wallet

cleos wallet unlock

This command will prompt for the password we generated in the previous step.

Import private key into wallet

cleos wallet import <private-key>

<private-key>: 5J1rGCTGkmrhvUnNgTWzi4hyZ9Rdk8kFVHHjpfZADgdzQHzhnAw

Install the bios contract

cleos set contract eosio /opt/eosio-testnet/eos/build/contracts/eosio.bios
-p eosio

Create account for node-01

cleos create account eosio nodeone <eosio_public_key> <nodea_public_key>

<eosio_public_key>: EOS8RGweLVckTmqR4VbWrZtF4rUcc9unsErqKamTzDWT8hbh3uJsB
<nodea_public_key>: EOS8L8jc65g8qS5xfYZ8fNVw2fx6t9STiwHndSEy91YkUVvAWf7zQ

Create setprods.json file

Location: /opt/eosio-testnet/setprods.json

{
"version": 1,
"producers": [
{
"producer_name": "eosio",
"block_signing_key":
"EOS8RGweLVckTmqR4VbWrZtF4rUcc9unsErqKamTzDWT8hbh3uJsB"
},

{
"producer_name": "nodeone",
"block_signing_key":
"EOS8L8jc65g8qS5xfYZ8fNVw2fx6t9STiwHndSEy91YkUVvAWf7zQ"
}
]
}

Any node that wants to join your network as a producer will be added to this file.

Register blockproducer to the bios contract

cleos push action eosio setprods "$(cat /opt/eosiotestnet/setprods.json)" -p eosio

Run the node-01

nodeos --config /opt/eosio-testnet/node-01/config.ini --data-dir
/opt/eosio-testnet/node-01


This will create a EOSIO test network, on which you can add more block producers, deploy smart contracts and generally run your experiments. You can download the guide relevant material from eosvibes github

cheers! :)