Skip to content

Commit

Permalink
fix add QBFT/IBFT validator pages: #213 (#215)
Browse files Browse the repository at this point in the history
* fix #213

* edit QBFT content and update IBFT content to match

* fix padding

Co-authored-by: Alexandra Tran <alexandratran@protonmail.com>
  • Loading branch information
baptiste-b-pegasys and alexandratran authored Apr 27, 2022
1 parent 93dda1f commit 2a51bba
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 220 deletions.
168 changes: 59 additions & 109 deletions docs/tutorials/private-network/adding-removing-ibft-validators.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,34 @@ description: Adding and removing IBFT validators

## Prerequisites

* An IBFT network as configured in the [IBFT tutorial](create-ibft-network.md).
An IBFT network as configured in the [IBFT tutorial](create-ibft-network.md).

## Add a validator

1. Create a working directory for the new node that needs to be added:

```bash
mkdir node5
mkdir -p Node-5/data/keystore
```

1. Change into the working directory for the new node 5 and run `istanbul setup`:
1. In the `artifacts` directory, generate one new validator using the
[Quorum Genesis Tool](https://www.npmjs.com/package/quorum-genesis-tool):

```bash
cd node5
../istanbul-tools/build/bin/istanbul setup --num 1 --verbose --quorum --save
npx quorum-genesis-tool \
--validators 1 \
--members 0 \
--bootnodes 0 \
--outputPath artifacts
```

This will generate the validator details including `Address`, `NodeInfo` and `genesis.json`.

!!! example "Example files"
1. Copy the latest generated artifacts:

```json
validators
{
"Address": "0x2aabbc1bb9bacef60a09764d1a1f4f04a47885c1",
"Nodekey": "25b47a49ef08f888c04f30417363e6c6bc33e739147b2f8b5377b3168f9f7435",
"NodeInfo": "enode://273eaf48591ce0e77c800b3e6465811d6d2f924c4dcaae016c2c7375256d17876c3e05f91839b741fe12350da0b5a741da4e30f39553fe8790f88503c64f6ef9@0.0.0.0:30303?discport=0"
}
genesis.json
{
"config": {
"chainId": 10,
"eip150Block": 1,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 1,
"eip158Block": 1,
"byzantiumBlock": 1,
"istanbul": {
"epoch": 30000,
"policy": 0
},
"isQuorum": true
},
"nonce": "0x0",
"timestamp": "0x5cffc942",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f85ad5942aabbc1bb9bacef60a09764d1a1f4f04a47885c1b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0",
"gasLimit": "0xe0000000",
"difficulty": "0x1",
"mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"2aabbc1bb9bacef60a09764d1a1f4f04a47885c1": {
"balance": "0x446c3b15f9926687d2c40534fdb564000000000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
```
```bash
cd artifacts/2022-04-21-08-10-29/validator0
cp nodekey* address ../../../Node-5/data
cp account* ../../../Node-5/data/keystore
```

1. Copy the address of the validator and propose it from more than half the number of current validators.

Expand Down Expand Up @@ -176,84 +143,56 @@ description: Adding and removing IBFT validators
]
```
1. Copy the node key that was generated by the `istanbul setup` command to the `geth` directory inside the working directory:
```bash
cp 0/nodekey data/geth
```
1. Initialize the new node with the following command:
=== "geth command"
```bash
geth --datadir data init genesis.json
```
```bash
geth --datadir data init data/genesis.json
```
=== "Result"
```text
INFO [06-11|16:42:27.120] Maximum peer count ETH=25 LES=0 total=25
INFO [06-11|16:42:27.130] Allocated cache and file handles database=/Users/username/fromscratchistanbul/node5/data/geth/chaindata cache=16 handles=16
INFO [06-11|16:42:27.138] Writing custom genesis block
INFO [06-11|16:42:27.138] Persisted trie from memory database nodes=6 size=1.01kB time=163.024µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [06-11|16:42:27.139] Successfully wrote genesis state database=chaindata hash=b992be…533db7
INFO [06-11|16:42:27.139] Allocated cache and file handles database=/Users/username/fromscratchistanbul/node5/data/geth/lightchaindata cache=16 handles=16
INFO [06-11|16:42:27.141] Writing custom genesis block
INFO [06-11|16:42:27.142] Persisted trie from memory database nodes=6 size=1.01kB time=94.57µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [06-11|16:42:27.142] Successfully wrote genesis state database=lightchaindata hash=b992be…533db7
```
```text
INFO [06-11|16:42:27.120] Maximum peer count ETH=25 LES=0 total=25
INFO [06-11|16:42:27.130] Allocated cache and file handles database=/Users/username/fromscratchistanbul/node5/data/geth/chaindata cache=16 handles=16
INFO [06-11|16:42:27.138] Writing custom genesis block
INFO [06-11|16:42:27.138] Persisted trie from memory database nodes=6 size=1.01kB time=163.024µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [06-11|16:42:27.139] Successfully wrote genesis state database=chaindata hash=b992be…533db7
INFO [06-11|16:42:27.139] Allocated cache and file handles database=/Users/username/fromscratchistanbul/node5/data/geth/lightchaindata cache=16 handles=16
INFO [06-11|16:42:27.141] Writing custom genesis block
INFO [06-11|16:42:27.142] Persisted trie from memory database nodes=6 size=1.01kB time=94.57µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [06-11|16:42:27.142] Successfully wrote genesis state database=lightchaindata hash=b992be…533db7
```
1. Copy `startall.sh` to a new `start5.sh` and execute it to start the node:
1. In the `Node-5` directory, start the first node:
```bash
cd ..
cp startall.sh start5.sh
export ADDRESS=$(grep -o '"address": *"[^"]*"' ./data/keystore/accountKeystore | grep -o '"[^"]*"$' | sed 's/"//g')
export PRIVATE_CONFIG=ignore
geth --datadir data \
--networkid 1337 --nodiscover --verbosity 5 \
--syncmode full --nousb \
--istanbul.blockperiod 5 --mine --miner.threads 1 --miner.gasprice 0 --emitcheckpoints \
--http --http.addr 127.0.0.1 --http.port 22005 --http.corsdomain "*" --http.vhosts "*" \
--ws --ws.addr 127.0.0.1 --ws.port 32005 --ws.origins "*" \
--http.api admin,trace,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,istanbul \
--ws.api admin,trace,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,istanbul \
--unlock ${ADDRESS} --allow-insecure-unlock --password ./data/keystore/accountPassword \
--port 30305
```
Edit `start5.sh` with the following:
1. Check that node 5 is validator:
```bash
#!/bin/bash
cd node5
PRIVATE_CONFIG=ignore nohup geth --datadir data --nodiscover --istanbul.blockperiod 5 --syncmode full --mine --minerthreads 1 --verbosity 5 --networkid 10 --http --http.addr 0.0.0.0 --http.port 22005 --http.api admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,istanbul --emitcheckpoints --port 30305 2>>node.log &
geth attach http://localhost:22005
```
!!! important
Update IP and port number matching for this node decided on step 6.
Run node 5:
```bash
./start5.sh
> istanbul.isValidator()
true
```
Check that the node is started:
=== "Command"
```bash
ps
```
=== "Result"
```text
PID TTY TIME CMD
10554 ttys000 0:00.11 -bash
21829 ttys001 0:00.03 -bash
9125 ttys002 0:00.93 -bash
36432 ttys002 0:24.48 geth --datadir data --nodiscover --istanbul.blockperiod 5 --syncmode full --mine --minerthreads 1 --verbosity 5 --networkid 10 --http --http.addr 0.0.0.0 --http.port 22000 --http.api admin,
36433 ttys002 0:23.36 geth --datadir data --nodiscover --istanbul.blockperiod 5 --syncmode full --mine --minerthreads 1 --verbosity 5 --networkid 10 --http --http.addr 0.0.0.0 --http.port 22001 --http.api admin,
36434 ttys002 0:24.32 geth --datadir data --nodiscover --istanbul.blockperiod 5 --syncmode full --mine --minerthreads 1 --verbosity 5 --networkid 10 --http --http.addr 0.0.0.0 --http.port 22002 --http.api admin,
36435 ttys002 0:24.21 geth --datadir data --nodiscover --istanbul.blockperiod 5 --syncmode full --mine --minerthreads 1 --verbosity 5 --networkid 10 --http --http.addr 0.0.0.0 --http.port 22003 --http.api admin,
36436 ttys002 0:24.17 geth --datadir data --nodiscover --istanbul.blockperiod 5 --syncmode full --mine --minerthreads 1 --verbosity 5 --networkid 10 --http --http.addr 0.0.0.0 --http.port 22004 --http.api admin,
36485 ttys002 0:00.15 geth --datadir data --nodiscover --istanbul.blockperiod 5 --syncmode full --mine --minerthreads 1 --verbosity 5 --networkid 10 --http --http.addr 0.0.0.0 --http.port 22005 --http.api admin,
36455 ttys003 0:00.04 -bash
36467 ttys003 0:00.32 geth attach node3/data/geth.ipc
```
## Remove a validator
1. Attach a `geth` console to a running validator, run [`istanbul.getValidators`](../../reference/api-methods.md#istanbul_getvalidators),
Expand Down Expand Up @@ -327,6 +266,17 @@ description: Adding and removing IBFT validators
The validator `0x2aabbc1bb9bacef60a09764d1a1f4f04a47885c1` was removed and the validators list now only has five addresses.
1. Check that node 5 is not validator:
```bash
geth attach http://localhost:22005
```
```bash
> istanbul.isValidator()
false
```
1. Stop the `geth` process corresponding to the validator that was removed:
=== "Command"
Expand Down Expand Up @@ -360,8 +310,8 @@ description: Adding and removing IBFT validators
## Add a non-validator node
Same instructions as [adding a validator](#add-a-validator) **excluding** step 3, which proposes the node as validator.
Same instructions as [adding a validator](#add-a-validator) excluding step 4, which proposes the node as validator.
## Remove a non-validator node
Just execute **step 4** from [removing a validator](#remove-a-validator).
Just execute step 5 from [removing a validator](#remove-a-validator).
Loading

0 comments on commit 2a51bba

Please sign in to comment.