5
2

commandを使用した、bootstrapNodeの nodeAccounts(transport以外)を移入した shoestringNodeを作成する方法

Last updated at Posted at 2024-09-08

※shymbol-shoestringの導入方法については、他の記事を参照して下さい
この検証は、ubuntu22.04上に anacondaを導入し、python3.9環境上で行いました。
nodeを建てている networkは、testnet:saiです

bootstrapから投票(voting) ローカルハーベスティングを インポートする手順

以下に解説するものは、symbol-bootstrapで建てた nodeから、
mainAccountremoteAccountvrfAccountを移入する手順です。

検証に使用した ディレクトリ構造

試した ディレクトリ構造は、
home直下のb-stestディレクトリの下に、
bootstrapNodeのsymbolNodeディレクトリと
shoestringNodeのcom3ディレクトリを、並列に並べて配置してあります。
今回はこの様な配置にしましたが、bootstrapNodeが別の場所にあっても、以下に解説する操作は出来ます。

ディレクトリ配置の概念図①
image.png

ディレクトリ配置の概念図②
image.png
今回の作業は、/b-stest/com3の中で行います。

shoestring.wizardでの mainAccount,remoteAccount,vrfAccountの設定方法

shoestring.wizardでは、nodeAccountsの設定は、以下の図の様に設定が出来ます。
mainAccountの設定画面
image.png

remoteAccountvrfAccountの設定画面
image.png

以上の様に、mainAccountremoteAccountvrfAccountが設定出来ますが、

commandで nodeを作成する場合でも、これらの nodeAccounts設定が出来ます。

以下に、commandでのnodeAccountsの設定方法を解説します。

commandを使用して、mainAccountremoteAccountvrfAccountを設定する

① mainAccountca.key.pemを作成する(秘密鍵が使える)

mainAccountを作成します。
pemtool命令では、mainAccountの作成を行います。
bootstrapNodeのmainAccountの秘密鍵が必要です。

pemtool実行命令

python3 -m shoestring pemtool --output ca.key.pem
subcommands 設定 意味
--output ca.key.pem 出力場所と名前
--input 今回は使用しません 秘密鍵を記入した fileの場所と名前

Enter private Key (in hex):と聞いて来ますので、ここで mainAccountの秘密鍵を入力して下さい。

pemtool実行画面
image.png
ca.key.pemと言う fileが出来ました。これが、mainAccountになります。

② configFileshoestring.iniを作成する

init命令では、configFileshoestring.iniを作成します。

先にmkdir命令でshoestringディレクトリを作成し、その中にinit命令で、shoestring.iniを作成します。

shoestringディレクトリ作成及びinit実行命令

mkdir shoestring
python3 -m shoestring init --package sai shoestring/shoestring.ini
subcommands 設定 意味
--package sai networkを指定する。mainnetでは不要
----- configFileの出力場所と名前 -----

実行画面
Screenshot from 2024-09-08 09-42-02.png
shoestringディレクトリ内にshoestring.iniが出来ました。これが、configFileのshoestring.iniです。

shoestring.iniの設定編集前の内容
image.png

③ configFileの nodeの設定の部分を変更する(features apiHttps caCommonName nodeCommonName等)

で作成した configFileshoestring.iniを編集します。

shoestring.ini編集命令

vi shoestring/shoestring.ini

変更箇所

変更箇所 変更内容
features = API|HARVESTER|VOTER ノードの種類を選んで変更する
apiHttps = false httpsを使うか? trueか falseにする
caCommonName = CA CAと入れる
nodeCommonName = tekitou 適当
↑nodeCommonNameは overrides.iniで上書きされる為 'a'でも良い

編集後の shoestring.iniの内容
image.png

④ overrides.iniを作成する(hostと friendlyName)

shoestring/overrides.iniを作成します。

overrides.ini編集命令

vi shoestring/overrides.ini

以下を コピー& ペーストします。
以下は コピー& ペースト用の テンプレです。

コピー& ペースト用の テンプレ

[user.account]
enableDelegatedHarvestersAutoDetection = true

[harvesting.harvesting]
maxUnlockedAccounts = 5
beneficiaryAddress = 

[node.node]
minFeeMultiplier = 100

[node.localnode]
host = 
friendlyName = 

上記の内容を ペーストしたら、そのまま編集、保存します。

以下は編集後のshoestring/overrides.iniの内容です。
編集後の overrides.ini
image.png

※import-bootstrapを使用する場合では、overrides.iniの beneficiaryAddressの項目に アドレスを入れないと、bootstrapNodeの設定が入らないで、beneficiaryAddressの値が空になるので注意して下さい。
※import-bootstrapを使わない setupでは beneficiaryAddressには mainAccountの アドレスが入ります。

⑤ bootstrapNodeから 投票と ローカルハーベスティングを インポートする(shoestring.iniの import欄の harvesterと voterに bootstrapの パスを追記する )

import-bootstrap命令では、bootstrapNodeの harvesting設定とvotingKeyを移入する為に、configFileshoestring.iniに設定を書き込みます。

[imports]項目の
harvester欄に、bootstrapNodeのtarget/nodes/node/server-config/resources/config-harvesting.propertiesの場所を、
voter欄に、bootstrapNodeのtarget/nodes/node/votingkeysの場所を書き込みます。

import-bootstrap実行前のshoestring.ini
image.png

import-bootstrap実行命令

python3 -m shoestring import-bootstrap --config shoestring/shoestring.ini --bootstrap ~/b-stest/symbolNode/target
subcommands 設定 意味
--config shoestring/shoestring.ini configFileshoestring.iniの場所
--bootstrap ~/b-stest/symbolNode/target bootstrapNodeのtargetの場所

import-bootstrap実行画面
image.png

import-bootstrap実行後のshoestring.ini
image.png

⑥ node作成をする

ではいよいよ、nodeを作ります。

setup命令では、ca.key.pemshoestring.inioverrides.iniの設定を基に、
nodeを構成する残りの file群を作成します。

setup実行命令

python3 -m shoestring setup --ca-key-path ca.key.pem --config shoestring/shoestring.ini --overrides shoestring/overrides.ini --directory ~/b-stest/com3 --package sai
subcommands 設定 意味
--ca-key-path ca.key.pem ca.key.pemの場所
--config shoestring/shoestring.ini configFileの場所
--overrides shoestring/overrides.ini overrides.iniの場所
--directory ~/b-stest/com3 nodeを作成する ディレクトリ
--package sai networkを指定する。mainnetでは不要

setup実行画面
image.png

この手順で、出来上がった shoestringNodeは、
bootstrapNodeと
mainAccountremoteAccountvrfAccountが、同一になります。 又、keys/votingに、votingKeyも入って来ます。

ちょっと確かめて見ましょう

bootstrapNodeの方の nodeAccountsを見てみましょう
b-stest/symbolNodetarget/addresses.yml
image.png

では、今出来上がった shoestringNodeの...アドレス...は.......

実は、shoestringNodeの nodeAccountsは、すぐには見れません!
keys/以下に nodeKeyFilesがあるんですが、秘密鍵はすぐに判るんですが、
そこから アドレスを出すのが超面倒くさいんです!

なので、以前に作った、これを使います。

↑これは何かと言うと、
shoestringNodeと同じ nodeAccountsと votingkeyを持った bootstrapNodeを作成する
シェルスクリプトです。

これを使って 今作った shoestringNodeと同じ nodeAccountと votingKeyを持った bootstrapNodeを作成して、
そこに出来たtarget/addresses.ymlと、移入元の bootstrapNodeのtarget/addresses.yml
見比べよう!と言う魂胆ですね。

やり方は上記の記事を参照して下さい。

...で、出来上がった addresses.ymlを見てみましょう。
b-stest/com3の nodeAccounts
image.png

どうです!?transportAccount以外の bootstrapNodeの
nodeAccountsが、同じになっています!
votingKeyも同じになってます!

おさらい

symbol-shoestringでは、shoestring.wizardを使わなくても、
元になる bootstrapNodeがあれば、
commandだけで、(transport以外の)bootstrapNodeの nodeAccounts及び、votingKeyの復元が出来ます。

上記はかなり長々とした説明になったので、短くしますと、こうです。

import-bootstrap手順
① ca.key.pem作成
python3 -m shoestring pemtool --output ca.key.pem
これで mainAccountの秘密鍵を入力 又は 別に秘密鍵を記述した ファイルを作成、--inputで指定
② shoestring.ini作成
python3 -m shoestring init --package sai shoestring/shoestring.iniで作成
③ shoestring.iniの編集
vi shoestring/shoestring.iniで編集
④ overrides.ini作成
vi shoestring/overrides.iniで、テンプレを コピーして、編集
⑤ import-bootstrap実行
bootstrapから情報取り込み先を shoestring.iniに追記述する
shoestring.iniの [imports]項目の harvester,voterに追記述される
⑥ setup実行
この時点で、shoestring.iniを読んで bootstrapの remote,vrfと votingKeyが設定される

以上です。貴重なお時間を割いて頂きまして誠にありがとうございます。

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2