Multi Node
You may use Docker to run a localnet setup that consists of a 4-node local chain by following the instructions on this page. Developers can test their applications and protocol features on a multi-node system using this setup.
Build & Start
Run the following command to create and launch a four-node testnet using docker:
make localnet-start
The humansdnode
Docker image is used to construct a 4-node network with this command.
This table contains the ports for each node:
Node ID | P2P Port | Tendermint RPC Port | REST/ Ethereum JSON-RPC Port | WebSocket Port |
---|---|---|---|---|
humansnode0 | 26656 | 26657 | 8545 | 8546 |
humansnode1 | 26659 | 26660 | 8547 | 8548 |
humansnode2 | 26661 | 26662 | 8549 | 8550 |
humansnode3 | 26663 | 26664 | 8551 | 8552 |
To update the binary, just rebuild it and restart the nodes:
make localnet-start
Using Docker compose, the previous command will run containers in the background. You will observe the development of the network:
...
Creating network "humans_localnet" with driver "bridge"
Creating humansdnode0 ... done
Creating humansdnode2 ... done
Creating humansdnode1 ... done
Creating humansdnode3 ... done
Stop Localnet
Once finished, execute:
make localnet-stop
Configuration
By using the humansd testnet
command, the make localnet-start
builds files for a 4-node testnet in ./build
. This creates the following files in the directory ./build
:
tree -L 3 build/
build/
├── humansd
├── humansd
├── gentxs
│ ├── node0.json
│ ├── node1.json
│ ├── node2.json
│ └── node3.json
├── node0
│ ├── humansd
│ │ ├── key_seed.json
│ │ └── keyring-test-cosmos
│ └── humansd
│ ├── config
│ ├── data
│ └── humansd.log
├── node1
│ ├── humansd
│ │ ├── key_seed.json
│ │ └── keyring-test-cosmos
│ └── humansd
│ ├── config
│ ├── data
│ └── humansd.log
├── node2
│ ├── humansd
│ │ ├── key_seed.json
│ │ └── keyring-test-cosmos
│ └── humansd
│ ├── config
│ ├── data
│ └── humansd.log
└── node3
├── humansd
│ ├── key_seed.json
│ └── keyring-test-cosmos
└── humansd
├── config
├── data
└── humansd.log
The /humansd
directory in each container is mounted to each ./build/nodeN
directory.
Logging
You can use the following command to view the logs of a specific node:
# node 0: daemon logs
docker exec humansdnode0 tail humansd.log
# node 0: REST & RPC logs
docker exec humansdnode0 tail humansd.log
The daemon's logs will seem as follows:
I[2020-07-29|17:33:52.452] starting ABCI with Tendermint module=main
E[2020-07-29|17:33:53.394] Can't add peer's address to addrbook module=p2p err="Cannot add non-routable address 272a247b837653cf068d39efd4c407ffbd9a0e6f@192.168.10.5:26656"
E[2020-07-29|17:33:53.394] Can't add peer's address to addrbook module=p2p err="Cannot add non-routable address 3e05d3637b7ebf4fc0948bbef01b54d670aa810a@192.168.10.4:26656"
E[2020-07-29|17:33:53.394] Can't add peer's address to addrbook module=p2p err="Cannot add non-routable address 689f8606ede0b26ad5b79ae244c14cc67ab4efe7@192.168.10.3:26656"
I[2020-07-29|17:33:58.828] Executed block module=state height=88 validTxs=0 invalidTxs=0
I[2020-07-29|17:33:58.830] Committed state module=state height=88 txs=0 appHash=90CC5FA53CF8B5EC49653A14DA20888AD81C92FCF646F04D501453FD89FCC791
I[2020-07-29|17:34:04.032] Executed block module=state height=89 validTxs=0 invalidTxs=0
I[2020-07-29|17:34:04.034] Committed state module=state height=89 txs=0 appHash=0B54C4DB1A0DACB1EEDCD662B221C048C826D309FD2A2F31FF26BAE8D2D7D8D7
I[2020-07-29|17:34:09.381] Executed block module=state height=90 validTxs=0 invalidTxs=0
I[2020-07-29|17:34:09.383] Committed state module=state height=90 txs=0 appHash=75FD1EE834F0669D5E717C812F36B21D5F20B3CCBB45E8B8D415CB9C4513DE51
I[2020-07-29|17:34:14.700] Executed block module=state height=91 validTxs=0 invalidTxs=0
The warning that says Can't add peer's address to addrbook
can be ignored. There shouldn't be any problems as long as the blocks are being generated and the app hashes are consistent across all nodes.
Whereas the REST & RPC server's logs would appear as follows:
I[2020-07-30|09:39:17.488] Starting application REST service (chain-id: "5678392741098275635")... module=rest-server
I[2020-07-30|09:39:17.488] Starting RPC HTTP server on 127.0.0.1:8545 module=rest-server
...
Follow Logs
With the --follow
(-f
) command, you can also monitor logs as they are generated by Docker, like in the following example:
docker logs -f humansdnode0
Interact with the Localnet
Ethereum JSON-RPC & Websocket Ports
Sending your request to the appropriate ports will allow you to communicate with the testnet using WebSockets or RPC/API:
EVM JSON-RPC | Eth Websocket |
---|---|
8545 | 8546 |
You might send a curl command like:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" 192.162.10.1:8545
The docker container's public IP address will be used as the IP address.
The events documentation contains more instructions on how to interact with the WebSocket.
Keys & Accounts
You utilize the humansd
directory of any given node as your home
to communicate with humansd
and begin creating txs or querying status, for instance:
humansd keys list --home ./build/node0/humansd
You can now create new accounts and transfer funds to them since accounts already exist.
Note: The key_seed.json
file for each node may be found at ./build/nodeN/humansd/key_seed.json
, and the command humansd keys add --restore
can be used to restore it to the CLI.
Special Binaries
The BINARY environment variable can be used to determine which binary to run if you have several binaries with various names. The binary's path is in relation to the volume that is attached. For instance:
# Run with custom binary
BINARY=humans make localnet-start