How to setup a network

The network consists of nodes, decent daemons that interact with each other using p2p connectivity. The network has a specially configured miner nodes, which generate blocks and keep the network running. The document describes how to do the configuration. This special node is called miner node.

Config.ini

We can start by running decentd simply to create the default configuration in ~/.decent. Then we can delete all the contents of ~/.decent, except ~/.decent/data/decentd/config.ini file. To prepare the config.ini we need to:

  1. Set seed-node = 127.0.0.1:40000 entry.

  2. Set "p2p-endpoint = 0.0.0.0:40000". Here we specify the port that the other nodes will use to connect to the seed node, which in turn will be configured as "seed-node = 192.168.1.1:40000" for those nodes.

  3. There is configuration for private key generated by default, which we need to change it as is shown below. This seems to be hardcoded key in c++ code, required to start a new chain.

    private-key = ["DCT82MTCQVa9TDFmz3ZwaLzsFAmCLoJzrtFugpF72vsbuE1CpCwKy","5JuJbrKZgAATcouJnwpaxPbHMAMDXSgUpQSfxTXzkSUuf cnpTUa"].
    

    The key is actually used by default generated genesis.json file, as the key of init accounts. Also "decent" account has the same key.

  4. Add miner ids, in the section "ID of miner controlled by this node". Add 11 entries:

    miner-id = "1.4.1"
    miner-id = "1.4.2"
    ...
    miner-id = "1.4.10" 
    miner-id = "1.4.11"
    
  5. Set enable-stale-production = true.

Create genesis file for the testnet with following command ./decentd --create-genesis-json ~/genesis-test.json. This will create a genesis file, that lists initial miner accounts with corresponding public keys. This is the key that has to be specified in config.ini. The default generated genesis file defines the following account - decent 5JuJbrKZgAATcouJnwpaxPbHMAMDXSgUpQSfxTXzkSUufcnpTUa

Start the network

Simply run the decent daemon.

 ./decentd --genesis-json ~/genesis-test.json

This greets with big title, telling that it is starting a new chain. On the successful start we see lines such as following:

 “Generated block #100 with timestamp 2017-05-25T13:36:05 at ... .”

Seed node decent daemon throws some red errors from time to time, but mostly it's temporary.

 "not producing blocks because node didn’t wake up within 500ms of the slot time".

It sometimes hangs up in ntp on this initial start - if there is no progress in like minute or two kill and start again.

Testing

Start another node (decentd) on the network, configure --seed-node=192.168.1.1:40000, where 192.168.1.1 is the IP address of the host running previously configured node and 40000 is the port that seed node is listening to. It's configured with --p2p-endpoint parameter. Start cli_wallet, run the command head_block_time.

Up and running

Right after the network is started we have a network with a single account.

 decent, 5JuJbrKZgAATcouJnwpaxPbHMAMDXSgUpQSfxTXzkSUufcnpTUa