In this section, we will cover the outcomes for network setup for the Quorum project, which is a permissionable variant of Ethereum. We will discuss creating genesis files, managing nodes, and setting up a bootnode.
Creating Genesis Files
A genesis file is a JSON file that contains the initial parameters for a new Ethereum blockchain. Quorum also uses genesis files to initialize new networks. The genesis file specifies the initial configuration of the blockchain, including the initial set of accounts, the difficulty of mining, and the total supply of ether.
Here’s an example of a simple genesis file for Quorum:
{
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc": {
"0x0000000000000000000000000000000000000000": { "balance": "1000000000000000000000000" }
},
"difficulty": "0x400",
"gasLimit": "0x8000000"
}
In this example, the chain ID is set to 15, and the initial difficulty is set to 0x400. The alloc
field specifies the initial set of accounts and their balances. In this case, there is only one account with a balance of 10 ether.
Managing Nodes
Quorum nodes are the individual machines that make up the blockchain network. Each node maintains a copy of the blockchain and participates in the consensus process.
To manage nodes in a Quorum network, you can use the bootnode
tool, which is included in the Quorum distribution. The bootnode
tool allows you to create and manage bootstrap nodes, which are used to discover and connect to other nodes in the network.
Here’s an example of how to start a bootnode:
$ bootnode -nodekey nodekey.secp256k1 -verbosity 9
In this example, the bootnode
tool is started with a node key file called nodekey.secp256k1
. The -verbosity
flag is set to 9 to enable debug logging.
Once the bootnode is running, other nodes can use its enode URL to connect to the network. The enode URL includes the node’s IP address, port, and public key.
Here’s an example of an enode URL:
enode://6078f6d228826123456789abcdef0123456789abcdef0123456789abcdef0123456789@[::]:30303?discport=0
In this example, the enode URL includes the node’s public key (6078f6d228826123456789abcdef0123456789abcdef0123456789abcdef0123456789
), IP address ([::]
), and port (30303
).
Setting Up a Bootnode
To set up a bootnode, you need to generate a node key and start the bootnode
tool with the node key. Here’s an example of how to generate a node key:
$ bootnode -genkey nodekey.secp256k1
In this example, the bootnode
tool is used to generate a new node key file called nodekey.secp256k1
.
Once you have generated the node key, you can start the bootnode
tool with the node key file:
$ bootnode -nodekey nodekey.secp256k1 -verbosity 9
In this example, the bootnode
tool is started with the nodekey.secp256k1
file and debug logging is enabled.
Quorum Network Setup
To set up a Quorum network, you need to create a genesis file, start the initial nodes, and connect them to the network. Here’s an example of how to set up a simple Quorum network:
- Create a genesis file:
{
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc": {
"0x0000000000000000000000000000000000000000": { "balance": "1000000000000000000000000" }
},
"difficulty": "0x400",
"gasLimit": "0x8000000"
}
- Start the initial nodes:
$ geth --datadir node1 init genesis.json
$ geth --datadir node2 init genesis.json
$ geth --datadir node3 init genesis.json
In this example, we start three nodes with different data directories (node1
, node2
, and node3
) and initialize them with the genesis file.
- Start the nodes with the bootnode URL:
$ geth --datadir node1 --bootnodes enode://6078f6d228826123456789abcdef0123456789abcdef0123456789abcdef0123456789@[::]:30303?discport=0 console
$ geth --datadir node2 --bootnodes enode://6078f6d228826123456789abcdef0123456789abcdef0123456789abcdef0123456789@[::]:30303?discport=0 console
$ geth --datadir node3 --bootnodes enode://6078f6d228826123456789abcdef0123456789abcdef0123456789abcdef0123456789@[::]:30303?discport=0 console
In this example, we start each node with the bootnode URL.
- Verify that the nodes are connected:
> admin.peers
In this example, we use the admin.peers
command to display the list of connected peers.
Conclusion
In this section, we covered the outcomes for network setup for the Quorum project. We discussed creating genesis files, managing nodes, and setting up a bootnode. By following the steps outlined in this section, you can set up a simple Quorum network.
Sources: