Starting a Multinode Network
Simple Proof of Work Multinode Network
A stable multinode network can currently be created with between 2 and 20 nodes. Connecting additional nodes to a network may be possible, particularly where the machines being used have more robust computing power, but for performance reasons, currently we recommend a network of no more than 20 nodes if 4-core machines are being used on the network. For the purpose of demonstrating multinode concepts in this documentation, we will use the case of a network with 4 nodes as our default example.
Linking Nodes Together
In order to create a simple multinode network (using a Proof of Work consensus mechanism), you will need to connect nodes to each other by setting a boot node parameter. A simple multinode network can be configured in such a way that either one of the nodes serves as a central hub or boot node for the remaining nodes, or all nodes (except one) connect to one other node (similar to a linked chain).
For our four node network example, with a hub configuration, the first node would be started with:
NODE_HOST=<node-IP-address-or-host-name> ./strato.sh -m 1
NODE_HOST=<node-IP-address-or-host-name> BOOT_NODE_IP=<boot-node-IP-address> ./strato.sh -m 1
This creates a multinode network with the default Proof of Work mining algorithm, and the first node serves as the hub of the connection between nodes.
With a linear configuation, the first node would again be started with:
NODE_HOST=<node-IP-address-or-host-name> ./strato.sh -m 1
After that node was successful, each node would need to be started one at a time (waiting for the one before it to boot up before the script was run). The scripts would look like the following:
NODE_HOST=<node-IP-address-or-host-name> BOOT_NODE_IP=<node#1-IP-address> ./strato.sh -m 1
NODE_HOST=<node-IP-address-or-host-name> BOOT_NODE_IP=<node#2-IP-address> ./strato.sh -m 1
NODE_HOST=<node-IP-address-or-host-name> BOOT_NODE_IP=<node#3-IP-address> ./strato.sh -m 1
Starting a Multinode Network with the PBFT consensus algorithm
PBFT Multinode Network
With a PBFT multinode network, you will need to pass the NODE_HOST and BOOT_NODE_IP variables to the
./strato.sh command, but you will need to also pass additional variables and a flag to designate the PBFT consensus mechanism ("blockstanbul"). A sample copy of this script can be seen by running
./strato.sh --scriptgen, which will output something like this:
#!/usr/bin/env sh # Address: <address> # IP: <ip_address> NODE_HOST="<host-name>" \ BOOT_NODE_IP="<boot-node-ip-address>" \ blockstanbulPrivateKey="<this-nodes-private-key>" \ validators='["<validator-for-node-1>","validator-for-node-2",....]'\ ./strato --blockstanbul
Each node on a PBFT network will have it's own private key and address that will be used in the script (in blockstanbulPrivateKey and the validators list, respectively). The blockstanbulPrivateKey variable will only be the value for the node you are running the script on. The list of validators will be an array with values for each participating node on the network. For STRATO 4.4 and above, an additional list of BlockstanbulAdmins will be needed in the script, but will contain the same array of values as the validators list contains. Finally, you'll notice the
--blockstanbul flag after the
strato command, which is used to designate the PBFT network.
Generating Private Validators and Scripts for Nodes
In some cases, you may want to create multinode scripts in a dynamic or programmatic way. In order to do this, you can follow the following steps:
Clone or copy the Strato repository onto each of the machines you are using for your multinode network.
On the first machine, ccreate a JSON file with the list of your node addresses and information. The file should be in the following format:
Generate node scripts for your nodes by running
./strato.sh --keygen=Nwhere "N' represents the number of nodes in your network. In our example, we'd use
Copy your node scripts for your nodes onto their various machines. You can do this manually, but we find that using the secure copy (
scp) command in Linux/Unix environments is more convenient. You can search the web for more formatting examples, but the general format for your
scpcommand will be:
scp [options] <your_current_username>@<current_host_address>:<current_script_file_path> <your_username_on_other_machine>@<target_destination_host_address>:<target_destination_file_path>
Connecting Your Nodes
SSH into the machine you are using as your boot_node (for a hub) or you starting_node (for a chain formation). Run your startup script on that node using
sh run.sh. Then SSH into each subsequent machine and run the startup script on each machine the same way, using
If you are using a PBFT algorithm, you can confirm your nodes are connected by navigating to the dashboard, creating an account and fauceting the account. This will create a transaction that will be sent through the network and engage the consensus mechanism. On the STRATO dashboard, you should notice that there are the correct number of peers identified. Additionally, you should be able to navigate to the dashboards for each node and verify that the block number is the same for the nodes in the chain.
If you are connecting your multinode network with existing scripts, you may want to ensure that the appropriate script is located on each machine that will be connected in the network. You can do this by validating that the IP address of the NODE_HOST variable in the script matches the IP address of the machine you are using. If you have access to the private key/address information for each node, you may also want to confirm that the private keys are each unique to the node, that the validator for that node is listed in the array of validators, and that all the validators in the list are associated with one of the nodes on the network.
Once you have verified the variables needed, you should follow the instructions for
Connecting Your Nodes in the Generated Network Section Above.
Modifying Blockstanbul Variables