Skip to main content

Add and remove IBFT 2.0 validators

This example walks through adding and removing an IBFT 2.0 validator.

Prerequisites

Add a validator

1. Create directories

Create a working directory and a data directory for the new node that needs to be added:

mkdir -p Node-5/data

2. Start the node

Change into the working directory for the new Node-5 and start the node, specifying the Node-1 enode URL as the bootnode:

besu --data-path=data --genesis-file=../genesis.json --bootnodes=<Node-1 Enode URL> --p2p-port=30307 --rpc-http-enabled --rpc-http-api=ETH,NET,IBFT --host-allowlist="*" --rpc-http-cors-origins="all" --rpc-http-port=8549

The command line specifies:

  • The data directory for Node-5 using the --data-path option.
  • A different port to Node-1 for P2P discovery using the --p2p-port option.
  • A different port to Node-1 for HTTP JSON-RPC using the --rpc-http-port option.
  • The enode URL of Node-1 using the --bootnodes option.
  • Other options as for Node-1.

3. Copy the address of the node

Copy the address of the node. You can find the address in the logs when starting the new node:

2021-05-28 09:49:00.881+10:00 | main | INFO  | DefaultP2PNetwork | Node address 0x90626e6a67445aabf1c0615410d108d4733aa90b

Or use the public-key export-address subcommand:

besu --data-path=IBFT-Network/Node-5/data public-key export-address

4. Propose adding the new validator

Propose adding the new validator from more than half the number of current validators, using ibft_proposeValidatorVote, specifying the address of the proposed validator and true:

curl -X POST --data '{"jsonrpc":"2.0","method":"ibft_proposeValidatorVote","params":["0x90626e6a67445aabf1c0615410d108d4733aa90b", true], "id":1}' http://127.0.0.1:8545

Repeat the proposal process for this candidate node from at least two of the other nodes.

5. Verify the addition of the new validator

Verify that the new validator is now in the list of validators using ibft_getValidatorsByBlockNumber:

curl -X POST --data '{"jsonrpc":"2.0","method":"ibft_getValidatorsByBlockNumber","params":["latest"], "id":1}' http://127.0.0.1:8545