Skip to content

Commit

Permalink
Update: Quorum network add node (#70)
Browse files Browse the repository at this point in the history
* Fix quorum network setting and path while creating

* Modify gas setting & Add error handler

* Fix: superuser privileges not allow

* Fix: update blockscout and quorum to lastest

* Feat: update genesis.json config

* Fix: uid and gid enviroment variable

* Fix: blockscout url is nil

* Feat: ora spinner in command

* Feat: default of explorer creating

* Feat: default of network creating

* Fix: quorum explorer can not be deleted

* Fix: modify Validator/Member expose port

* Fix: eslint & package audit update

* Feat: add local validator

* Fix: modify add validator

* Feat: add local member

* Fix: add trytime for adding node in quorum network

* Feat: add downOneService in quorum network

* Feat: add check command

* Feat: add check chainId

* Fix: modify ports of node connections

* Feat: add generate & addValidatorRemote & joinValidator

* Fix: modify json file & send empty transaction

* Feat: add get command to get Quorum network information

* Fix: modify addValidatorRemote parameter requirement & get validator enode information

* Feat: add addMemberRemote & modify join/generate

* Doc: new example of adding remote node & Modify document introduction

* Doc: unified quorum Example.md format

* fix: backup dockerCompose file according to node

* Doc: upgrade 2.0.2 README.md and CHANGELOG.md

---------

Co-authored-by: kidneyweak <[email protected]>
  • Loading branch information
Pianochicken and kidneyweakx authored Mar 8, 2023
1 parent 4751732 commit 3e61e9b
Show file tree
Hide file tree
Showing 39 changed files with 1,659 additions and 1,465 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@ All notable changes to BDK project will be documented here.

[2.0.1]: https://github.com/cathayddt/bdk/releases/tag/v2.0.1

[2.0.2]: https://github.com/cathayddt/bdk/releases/tag/v2.0.2

## [2.0.2][2.0.2] - 2023-03-

### new
1. New Package: `ora`
2. New Command: `bdk quorum network add`
3. New Command: `bdk quorum network generate`
4. New Command: `bdk quorum network join`
5. New Command: `bdk quorum network check`
6. New Command: `bdk quorum network get`
7. New Example: add remote node

### changed
1. Fix: path not found, provide `PathError` notification
2. Fix: superuser privilege, not provide su execute
3. Fix: `bdk quorum network delete` cannot delete image
4. Upgrade: quorum (22.7.4) and blockscout (v4.1.5-beta)
5. Modify: `gasLimit` from `0xFFFFFF` to `0xE0000000`
6. Modify: `emptyBlockPeriodSeconds` from 60 to 3600
7. Modify: `requestTimeoutSeconds` from 4 to 60
8. Modify: `bdk quorum network create` member node default value 0

## [2.0.1][2.0.1] - 2022-12-

### new
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ bdk fabric network create -i

| Latest | Stable |
| ---------------- | ---------------- |
| [v2.0.1][v2.0.1] | [v1.0.4][v1.0.4] |
| [v2.0.2][v2.0.2] | [v2.0.2][v2.0.2] |

[v1.0.4]: https://github.com/cathayddt/bdk/releases/tag/v1.0.4
[v2.0.1]: https://github.com/cathayddt/bdk/releases/tag/v2.0.1
[v2.0.2]: https://github.com/cathayddt/bdk/releases/tag/v2.0.2

[更新內容 (Changelog)](CHANGELOG.md)

Expand Down
68 changes: 59 additions & 9 deletions docs/quorum/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,29 @@

## Network

### `bdk quorum network add`

Description: 新增 Quorum Node

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ------------------------------ | :------: | ------- |
| --help | boolean | Show help | | |
| --version | boolean | Show version number | | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | | |

### `bdk quorum network check`

Description: 確認 Quorum Node 資訊

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ------------------------------ | :------: | ------- |
| --help | boolean | Show help | | |
| --version | boolean | Show version number | | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | | |

### `bdk quorum network create`

Description: 產生 Quorum network 所需的相關設定檔案
Description: 產生 Quorum Network 所需的相關設定檔案並建立網路

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ------------------------------ | :------: | ------- |
Expand All @@ -22,32 +42,62 @@ Description: 產生 Quorum network 所需的相關設定檔案

### `bdk quorum network delete`

Description: 刪除現有的 Quorum Network.
Description: 刪除現有的 Quorum Network

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ------------------------------ | :------: | ------- |
| --help | boolean | Show help | | |
| --version | boolean | Show version number | | |

### `bdk quorum network up`
### `bdk quorum network down`

Description: 停止現有的 Quorum Network

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ------------------------------ | :------: | ------- |
| --help | boolean | Show help | | |
| --version | boolean | Show version number | | |

### `bdk quorum network generate`

Description: 啟動現有的 Quorum Network.
Description: 產生 Quorum Network 所需的相關設定檔案

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ------------------------------ | :------: | ------- |
| --help | boolean | Show help | | |
| --version | boolean | Show version number | | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | | |
| -a, --all | boolean | 是否啟動所有節點 | | |

### `bdk quorum network down`
### `bdk quorum network get`

Description: 取得 Quorum 檔案資訊

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ------------------------------ | :------: | ------- |
| --help | boolean | Show help | | |
| --version | boolean | Show version number | | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | | |

### `bdk quorum network join`

Description: 停止現有的 Quorum Network.
Description: 選擇現有節點加入 Quorum Network

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ------------------------------ | :------: | ------- |
| --help | boolean | Show help | | |
| --version | boolean | Show version number | | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | | |

### `bdk quorum network up`

Description: 啟動現有的 Quorum Network

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ------------------------------ | :------: | ------- |
| --help | boolean | Show help | | |
| --version | boolean | Show version number | | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | | |
| -a, --all | boolean | 是否啟動所有節點 | | |

## Explorer

Expand All @@ -74,7 +124,7 @@ Description: 刪除現有的 Quorum Explorer.

### `bdk quorum backup export`

Description: 匯出現有的 Quorum Network.
Description: 匯出現有的 Quorum Network

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ------------------------------ | :------: | ------- |
Expand All @@ -85,7 +135,7 @@ Description: 匯出現有的 Quorum Network.

### `bdk quorum backup import`

Description: 匯入現有的 Quorum Network.
Description: 匯入現有的 Quorum Network

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ------------------------------ | :------: | ------- |
Expand Down
89 changes: 71 additions & 18 deletions docs/quorum/EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,118 @@
(English version)(Work In Progress)

## 目錄
- [建立 Blockchain network](#建立-blockchain-network)
- [確認 BDK 安裝狀態](#確認-bdk-安裝狀態)
- [建立 Quorum Network](#建立-quorum-network)
- [建立 Blockscout Explorer](#建立-blockscout-explorer)
- [加入 Remote 節點](#加入-remote-節點)
- [備份還原 Node](#備份還原-node)

## 建立 Blockchain network

Quorum 無須做過多的前置設定,只需確認 BDK 套件是否安裝完成即可
## 確認 BDK 安裝狀態

```bash
# 確認 BDK 套件是否安裝完成
bdk hello
```

如果指令已順利安裝,你會看到 `You have installed bdk successfully!!!`

### 建立 Network
## 建立 Quorum Network

```bash
# 輸入指令,啟動 Quorum 網路互動式介面
bdk quorum network create -i
```

依序輸入 `chain id`(預設為 81712)、`validator` 以及 `member` 的數量,並填入自己的錢包,如無錢包則選擇 `false`,會提供一組公私鑰來作為使用 Quorum 網路的帳號,該組帳號將在創始區塊擁有代幣

## 建立 Blockscout Explorer

```bash
# 輸入指令,啟動 Blockscout 區塊鏈瀏覽器
bdk quorum explorer create -i
```

輸入 `port`,並稍待片刻,即可使用區塊鏈瀏覽器

## 加入 Remote 節點

範例情境:建立擁有三個 Validator 節點的 Quorum 網路,且三個節點分別建置在不同機器。

> `需確認機器的 IP Address 以及 Port 30303 (Validator) 或 Port 30403 (Member) 有互相開放`
Validator 以及 Member 節點的加入流程相同,此處以 Validator 為例。

輸入指令,啟動 Quorum 網路互動式介面
### Step 0: 建立 Network

```bash
# 於第一台機器上建立 Validator 數量為 1,Member 數量為 0 的 Quorum 網路。
bdk quorum network create -i
```

依序輸入 chain id (預設為1337)、validator 以及 member 的數量,以及填入自己的錢包,如無填入(選擇 false ),則會提供一組公私鑰來作為使用 Quorum 網路的帳號,該組帳號會在創始區塊擁有代幣
### Step 1:產生 Node 設定檔,取得 enodeInfo

### 建立 Blockscout Explorer
```bash
# 分別於第二台及第三台機器產生 Node 設定檔, Validator 數量填入 1,Member 數量填入 0。
bdk quorum network generate -i

# 選擇 node,選擇剛產生的節點,選擇 enodeInfo 保留下來。
bdk quorum network get -i
```

輸入指令,啟動 Blockscout 區塊鏈瀏覽器
### Step 2:新增節點

```bash
bdk quorum explorer create -i
# 從第一台機器輸入指令,選擇 remote、validator,填入要加入節點的 enodeInfo、IP Address。
bdk quorum network add -i

# 選擇 network,取得 genesis.json、static-nodes.json 保留下來。
bdk quorum network get -i
```

### Step 3:加入網路

```bash
# 從要加入的機器輸入指令,選擇要加入的節點,並依序輸入以下資訊,填入要加入網路的 IP Address、genesis.json、static-nodes.json。
bdk quorum network join -i
```

輸入 port ,並稍待片刻,即可使用區塊鏈瀏覽器
> 欲加入第三台機器的節點,則需在第一台及第二台機器完成前述 `Step 2:新增節點` 的動作,再於第三台機器完成 `Step 3:加入網路`,第三個節點便可順利加入網路。
### Step 4:確認節點狀態

```bash
# 輸入指令,可確認以下節點狀態
bdk quorum network check -i
```
- `isValidator`: 確認節點是否為 Validator,此處三個節點都應回傳 `true`
- `getValidator`: 獲取 Validator 清單,此處應回傳包含三個 Validator 的地址。
- `peerCount`: 確認節點連接數,此處每個節點應回傳 `2`
- `chainId`:鏈 ID,此處預設應回傳 `81712`

## 備份還原 Node

Quorum 網路各節點啟動後,即可做備份的動作,BDK 備份工具可根據使用者的需求備份個別或全部節點,並將備份壓縮檔存入 `~/.bdk/quorum/backup` 資料夾中,達成多台機器還原環境的功能

### 備份現有的 Node (擇一備份)
### 備份 Node

```bash
# 備份現有的 Node (擇一備份)
bdk quorum backup export --interactive
```

### 備份所有的 Node

```bash
# 備份所有的 Node
bdk quorum backup export --all
```

### 還原 Node

透過 `bdk backup` 指令還原節點,可在清單中選擇需要還原的備份檔

```bash
# 透過指令還原節點,可在清單中選擇需要還原的備份檔
bdk quorum backup import -i
```

還原後需透過以下指令,來啟動該備份的節點

```bash
# 還原後需透過以下指令,來啟動該備份的節點
bdk quorum network up --all
```
Loading

0 comments on commit 3e61e9b

Please sign in to comment.