Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix add QBFT/IBFT validator pages: #213 #215

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 45 additions & 96 deletions docs/tutorials/private-network/adding-removing-qbft-validators.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,61 +13,26 @@ description: Adding and removing QBFT validators
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 `qbft setup`:
1. Generate one new validator in the artifacts:

```bash
cd node5
../istanbul-tools/build/bin/qbft 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,
"testQBFTBlock": 0
},
"isQuorum": true
},
"nonce": "0x0",
"timestamp": "0x5cffc942",
"extraData": "0xf87aa00000000000000000000000000000000000000000000000000000000000000000f8549493917cadbace5dfce132b991732c6cda9bcc5b8a9427a97c9aaf04f18f3014c32e036dd0ac76da5f1894ce412f988377e31f4d0ff12d74df73b51c42d0ca9498c1334496614aed49d2e81526d089f7264fed9cc080c0",
"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 @@ -156,9 +121,8 @@ description: Adding and removing QBFT validators

```bash
cd node5
mkdir -p data/geth
cp ../node0/static-nodes.json data
cp ../node0/genesis.json .
cp ../node0/genesis.json data
```

1. Edit `static-nodes.json` and add the new validator's node info to the end of the file.
Expand All @@ -177,18 +141,12 @@ description: Adding and removing QBFT validators
]
```

1. Copy the node key that was generated by the `qbft 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
geth --datadir data init data/genesis.json
```

=== "Result"
Expand All @@ -205,56 +163,36 @@ description: Adding and removing QBFT validators
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. Start node 5

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,qbft \
--ws.api admin,trace,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,istanbul,qbft \
--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,qbft --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 @@ -328,6 +266,17 @@ description: Adding and removing QBFT 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
10 changes: 5 additions & 5 deletions docs/tutorials/private-network/create-qbft-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ Update the IP and port numbers for all initial validator nodes in `static-nodes.
Copy `static-nodes.json`, `genesis.json`, and `permissioned-nodes.json` (if applicable) to the data directory for each node:

```bash
cp static-nodes.json genesis.json ./../Node-0/data/
cp static-nodes.json genesis.json ./../Node-1/data/
cp static-nodes.json genesis.json ./../Node-2/data/
cp static-nodes.json genesis.json ./../Node-3/data/
cp static-nodes.json genesis.json ./../Node-4/data/
cp static-nodes.json genesis.json ../../Node-0/data/
cp static-nodes.json genesis.json ../../Node-1/data/
cp static-nodes.json genesis.json ../../Node-2/data/
cp static-nodes.json genesis.json ../../Node-3/data/
cp static-nodes.json genesis.json ../../Node-4/data/
alexandratran marked this conversation as resolved.
Show resolved Hide resolved
```

In each validator directory, copy the `nodekey` files and `address` to the data directory:
Expand Down