Deploy_EN.md - U-Network/UNetwork GitHub Wiki

How to deploy the nodes

Compilation

To successfully complie U Network, it requires the following preparations:

  • Go version has to be 1.11 and above
  • Correct Go language development environment

Clone U Network repository to $GOPATH/src directory

$ git clone https://github.com/U-Network/UNetworkDev.git

Compile source code with make

$ make

After successful compilation, two executable programs will be generated.

  • uuu: node program

Deployment

There are two methods to successfully operate U Network

  • Single node operation
  • Multi node operation

Single node operation

We can deploy it through the command line, first initialize the environment.

$ uuu node --log_level="debug" init "~/genesis.json"

genesis.json profile reference

$ cat ./genesis.json
{
  "config": {
    "chainId": 9384,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
  },
  "alloc": {
    "0xd03b5d1bf0715fffad8d821d546bd9e8aa2c9b10": {
      "balance": "1000000000000000000000000000"
    }
  },
  "nonce": "0x0000000000000042",
  "difficulty": "0x020000",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "",
  "gasLimit": "0xffffffff"
}

0xd03b5d1bf0715fffad8d821d546bd9e8aa2c9b10 The private key corresponding to the address is 52a0b3688fd46ab9ab7d62372719e3037681d5cf62e862336bc9c3c468c4a448

After initialization, run the node with the following command

$ uuu node start --log_level="debug"  --ethparam="--rpcapi db,eth,net,web3,personal"

Multi node operation

When running UNetwork on multiple nodes, we need at least 4 nodes. The configuration information of the 4 nodes is automatically generated by the following command.

$ uuu node --log_level="debug" createnode 4 "chain-test-123"

This will generate the relevant configuration file, the directory is as follows:

$ tree ~/.unetwork/

├── config
│   └── config.toml
├── config1
│   ├── ID.json
│   ├── genesis.json
│   ├── node_key.json
│   └── priv_validator.json
├── config2
│   ├── ID.json
│   ├── genesis.json
│   ├── node_key.json
│   └── priv_validator.json
├── config3
│   ├── ID.json
│   ├── genesis.json
│   ├── node_key.json
│   └── priv_validator.json
├── config4
│   ├── ID.json
│   ├── genesis.json
│   ├── node_key.json
│   └── priv_validator.json
└── data

For the subsequent configuration to work properly, we need to briefly explain the relevant configuration file.

Take config1 as example

Below is the ID number assigned to node 1

$ cat ID.json
e6c30179e0ba47bb004934355bfe728f96404b30

Below is the relevant information about each mining node in U Network

$ cat genesis.json
{
  "genesis_time": "2018-11-06T08:30:42.258885Z",
  "chain_id": "chain-test-123",
  "consensus_params": {
    "block_size_params": {
      "max_bytes": "22020096",
      "max_gas": "-1"
    },
    "evidence_params": {
      "max_age": "100000"
    }
  },
  "validators": [
    {
      "address": "51800FE9E6DD438AAA6467A229FC6B406FFD69B3",
      "pub_key": {
        "type": "tendermint/PubKeyEd25519",
        "value": "pCZ8aOE35ncgrY3ppiacvBkJRH26fKe7cGCMmZfNwVM="
      },
      "power": "10",
      "name": ""
    },
    {
      "address": "F9E1465D713C13D62BA49F1CA55489F513412CA3",
      "pub_key": {
        "type": "tendermint/PubKeyEd25519",
        "value": "VxnkqEhXC3YlRN+V7NsByTQ+A0RcOHLwtXKlA+p9bsk="
      },
      "power": "10",
      "name": ""
    },
    {
      "address": "7C3053ECFA194A90710B1813270919AC599712F1",
      "pub_key": {
        "type": "tendermint/PubKeyEd25519",
        "value": "FfzJWI2Iogoh1w/qndxsM2eZWnLyqSfh9N3wyoZViyA="
      },
      "power": "10",
      "name": ""
    },
    {
      "address": "21BA95111CD501F514144F504FD09FFF48AB5800",
      "pub_key": {
        "type": "tendermint/PubKeyEd25519",
        "value": "hUQsAk4/GUiFgwROVDD0ab5nVCTdxNQHvSVcNPFC4XA="
      },
      "power": "10",
      "name": ""
    }
  ],
  "app_hash": ""

Below is the private key information of the mining node

$ cat node_key.json
{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"jEXTYjqv2ybwAYXX+ez76JwnI8obOVUfp4yQsNxk9M8unXg5R1Wf+w9uq89Vl8i4wdtMLqRTebmkB6dkJ15aEQ=="}}

Below is the information of the node validation

$ cat priv_validator.json 
{
  "address": "51800FE9E6DD438AAA6467A229FC6B406FFD69B3",
  "pub_key": {
    "type": "tendermint/PubKeyEd25519",
    "value": "pCZ8aOE35ncgrY3ppiacvBkJRH26fKe7cGCMmZfNwVM="
  },
  "last_height": "0",
  "last_round": "0",
  "last_step": 0,
  "priv_key": {
    "type": "tendermint/PrivKeyEd25519",
    "value": "0vkuAcQhciPq9dSn3uxq6F/eczsvQHhy1nqp2R927TakJnxo4TfmdyCtjemmJpy8GQlEfbp8p7twYIyZl83BUw=="
  }
}

Next we will do the following on the target host:

  1. Copy the relevant files to the target host, including:

    • uuu.exe
    • config1 folder ( use config1/ as example)
  2. Execute the following command to initialize: $ uuu node --log_level="debug" init "~/genesis.json"

  3. Use the files in config1 to overwrite the files in target host under ~/.unetwork/config

Multi-machine configuration is completed, the directory structure of each node is as follows

$ tree ~/.unetwork/
├── config
│   ├── config.toml
│   ├── ID.json
│   ├── genesis.json
│   ├── node_key.json
│   └── priv_validator.json
├── uuu.exe
└── data

Operation

Execute commands in the following format on each host in any order

$ uuu node start
--log_level="debug"
--consensus.create_empty_blocks=true
--consensus.timeout_commit=20000
--p2p.persistent_peers="_id1@_ip1:_port1_,_id2@_ip2:_port2,_id3@_ip3:_port3,_id4@_ip4:_port4"
--ethparam="--rpcport 9148"

The parameters are explained as follows

--log_level: print log type --consensus.create_empty_blocks: whether to allow empty blocks --consensus.timeout_commit: Block interval (ms) --p2p.persistent_peers: address information of each consensus node _idx: ID number of node x (refer to ID.json) _ipx: IP address of node x _portx: port number of node x --ethparam: Ethereum parameter information