Quorum Wizard
Quorum Wizardというローカル環境でノードを立てるのに便利なツールがリリースされました。
今までは複数ノードを立てるには7nodes exampleくらいしかなくて、台数を変更したりコンセンサスアルゴリズムを変更したりする設定変更がとても大変でした。Quorum Wizardを使うことで、そういった大変さを無くすことができます。すごい!
以下で使い方の手順を解説します。
インストール
code:install.sh
# NPMプロジェクト内なら
yarn add -D quorum-wizard
# グローバルインストール
yarn global add quorum-wizard
以下、プロジェクト内にインストールした前提で使い方を解説
code:run.sh
yarn quorum-wizard
すると、以下のようにガイダンス+選択肢が出てくる
code:_
?
Welcome to Quorum Wizard!
This tool allows you to easily create bash and docker files to start up a quorum network.
You can control consensus, privacy, network details and more for a customized setup.
Additionally you can choose to deploy our chain explorer, Cakeshop, to easily view and monitor your network.
We have 3 options to help you start exploring Quorum:
1. Quickstart - our 1 click option to create a 3 node raft network with tessera and cakeshop
2. Simple Network - using pregenerated keys from quorum 7nodes example,
this option allows you to choose the number of nodes (7 max), consensus mechanism, transaction manager, and the option to deploy cakeshop
3. Custom Network - In addition to the options available in #2, this selection allows for further customization of your network. Choose to generate keys, customize ports for both bash and docker, or change the network id
Quorum Wizard will generate your startup files and everything required to bring up your network.
All you need to do is go to the specified location and run ./start.sh
Quickstart (3-node raft network with tessera and cakeshop)
Simple Network
❯ Custom Network
Exit
上下キーでCustom Networkを選択し、Enter
なお、Quickstartを選択すれば、以下のようなたくさんのオプション入力しなくても3台のRaftノードが立ち上がります。
今回は2台のIBFTノードを立ち上げたいのでCustom Networkを選択してみます。
(IBFTは4台で起動するのが原則ですが、ローカル環境なので2台で起動します)
code:_
? Would you like to generate bash scripts or a docker-compose file to bring up your network?
bash
❯ docker-compose
bashスクリプトかdocker-compose設定ファイルか、生成したいファイルを選択する。ここではdocker-composeを選択。
code:_
? Select your consensus mode - istanbul is a pbft inspired algorithm with transaction finality while raft provides faster blocktimes, transaction finality and on-demand block creation (Use arrow keys)
❯ istanbul
raft
コンセンサスアルゴリズムを聞かれるので選択する。ここではistanbul (IBFT) を選択。
code:_
? Input the number of nodes (2-7) you would like in your network - a minimum of 4 is recommended (4)
何台のノードを立てるか聞かれる。IBFTでは4台が基本だが、ローカル環境なので2を入力してEnter
code:_
? Which version of Quorum would you like to use?
❯ Quorum 2.5.0
Quorumバージョンを聞かれる。2020.4.16現在では1つしか選択肢が無いので2.5.0を選ぶ。
code:_
? Choose a version of tessera if you would like to use private transactions in your network, otherwise choose "none"
❯ Tessera 0.10.4
Tessera 0.10.2
none
Tessera (プライベートトランザクションで使うやつ) のバージョンを聞かれるので、2020.4.16現在では上記選択肢が現れた。0.10.4を選んでEnter
code:_
? Do you want to run Cakeshop (our chain explorer) with your network? (Use arrow keys)
No
❯ Yes
Cakeshopを起動するか聞かれる。便利なのでYesを選択してEnter
code:_
? Would you like to generate keys for your network? (selecting 'no' will use insecure keys that are not suitable for Production use) (Y/n)
鍵を生成するか。ローカル環境なのでデフォルトで良いのでnを入力してEnter
code:_
? 10 is the default network id in quorum but you can use a different one (10)
network idをいくつにするか聞かれる。Quorumのデフォルトで良いので10のままEnter
code:_
? Would you like to customize your node ports? (y/N)
ポートをカスタマイズするか聞かれる。衝突すると面倒なのでカスタマイズしておく。yを入力してEnter
code:_
? input quorum node 1 rpc port 21001
? input quorum node 1 ws port 21101
? input tessera node 1 third party port 21201
? input quorum node 2 rpc port 22001
? input quorum node 2 ws port 22101
? input tessera node 2 third party port 22201
? input cakeshop port 8999
ポート番号を順番に聞かれるので、任意の番号を入力していく。
ここまで完了すると、以下のようにダウンロードが走り、利用できるようになる。
code:_
Downloading dependencies...
Saving to /Users/shun.takagiwa/workspace/cordage/minimal-ethereum-env/node_modules/quorum-wizard/bin/istanbul/1.0.1/istanbul
Done
Building docker-compose file...
Writing start script...
Done
--------------------------------------------------------------------------------
Tessera Node 1 public key:
BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=
Tessera Node 2 public key:
QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=
--------------------------------------------------------------------------------
Quorum network created. Run the following commands to start your network:
cd network/2-nodes-istanbul-tessera-docker-compose
./start.sh
A sample simpleStorage contract is provided to deploy to your network
To use run ./runscript.sh public-contract.js from the network folder
A private simpleStorage contract was created with privateFor set to use Node 2's public key: QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=
To use run ./runscript private-contract.js from the network folder
✨ Done in 967.31s.
上記ガイドに書かれている通り、
code:run.sh
cd network/2-nodes-istanbul-tessera-docker-compose
./start.sh
のように実行するとノードが起動する。
今回の設定だと、新たに以下のようなファイルが生成された。
https://gyazo.com/18a42242961633073ad06762fea68631