2.2.6.5. mijin Catapult(v.2) How to update a node’s voting rights file

This chapter describes how to deal with the expiration of node voting rights on a mijin Catapult(v.2) node on AWS.
Voting rights for a node expire approximately 547~3285 days, depending on the block generation interval.

Warning

When the voting rights file expires, the finalization block stops.
Therefore, if you are using finalize blocks, you must update them.
creation-day:

January 26, 2023

update date:

January 26, 2023

2.2.6.5.1. How to calculate the expiration date of a voting node

The expiration date of a single voting file can be determined by the following formula

Warning

Note that blockGenerationTargetTime (block generation interval) is an approximate value, for example, setting 15s does not mean that a block will be generated in a certain amount of time.

(VotingSetGroup * maxVotingKeyLifetime) / ( 60 / blockGenerationTargetTime * 60 * 24)
VotingSetGroup and maxVotingKeyLifetime are fixed values, so the value of blockGenerationTargetTime
The expiration date will vary depending on the value of blockGenerationTargetTime.
# blockGenerationTargetTime 10s
(180 * 26280) / (60 /10 * 60 * 24) = 547 days
# blockGenerationTargetTime 15s
(180 * 26280) / (60 /15 * 60 * 24) = 821 days
# blockGenerationTargetTime 60s
(180 * 26280) / (60 /60 * 60 * 24) = 3285 days

2.2.6.5.2. Log in to AWS Management Console

Log in at the AWS Managed Console.

https://aws.amazon.com/jp/console/

2.2.6.5.3. Move to EC2 Service

1.上部「サービス」をクリックします
2.表示されたメニューから「コンピューティング」をクリックします
3.「EC2」をクリックします。
../../_images/aws_ssm_login1.en.png

2.2.6.5.4. Select the instance you wish to log in to and connect

1.左側メニューから「インスタンス」をクリックします
2.インスタンス一覧からログインしたいノードのチェックをクリックします。
3.「接続」を押します。
../../_images/aws_ssm_login2.en.png

2.2.6.5.5. Select Session Manager and connect

1.「セッションマネージャー」であることを確認します。(選択されていなければクリック)
2.「接続」を押します。
3.コンソール画面のウィンドウが別で開きます。
../../_images/aws_ssm_login3.en.png

2.2.6.5.6. Console screen operation

  1. Confirm that ‘$’ appears in the console screen window.

    $
    

2.2.6.5.7. Installing mijin-catapult-tools

  1. If nodejs is not installed, install it.

    $ curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - && sudo apt-get install -y nodejs
    
  2. Switch to the catapult user and install mijin-catapult-tools.

    $ yarn global add  @tech-bureau/mijin-catapult-tools
    $ echo 'export PATH="$HOME/.yarn/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
    

2.2.6.5.8. Check status of current voting rights file

Refers to the public key.
Here it is 402B6ECE0D1CF99A7F07B832477048C56F213A4F54ED4AEB35AE829507FBC4A6.
We can confirm that this voting file is valid from 1 to 26280.
$ mijin-catapult-tools votingkey info -u http://localhost:3000 -d mijin-catapult-package/package/api/catapult/userconfig/resources/votingkey
2023-01-26T05:22:29.833Z [info] : Start Voting Key Check Dir... mijin-catapult-package/package/api/catapult/userconfig/resources/votingkey
2023-01-26T05:22:29.836Z [info] : votingfile: index0:  {"publicKey":"402B6ECE0D1CF99A7F07B832477048C56F213A4F54ED4AEB35AE829507FBC4A6","startEpoch":1,"endEpoch":26280,"filename":"private_key_tree1.dat"}

Note

Note that the finalizationEpoch must be updated before it reaches 26280.
{
“scoreHigh”: “0”,
“scoreLow”: “16875391960469924”,
“height”: “310”,
“latestFinalizedBlock”: {
“finalizationEpoch”: 3,
“finalizationPoint”: 7,
“height”: “296”,
“hash”: “AC19CA6C89F87F70470BD84649A31E4FA0E0C5DD71A55E9ADAE25C1AED47882F”
}
}

2.2.6.5.9. Voting Rights File Update

The private key is retrieved from the public key obtained above, and a voting rights file is created.
A sequentially numbered file private_key_tree2.dat is created.
$ mijin-catapult-tools votingkey update \
    -u http://localhost:3000 \
    -d mijin-catapult-package/package/api/catapult/userconfig/resources/votingkey \
    -p $(cat /mnt/mijin/shares/nemesis_addresses_harvesting_voting.json | jq -r '.[]|.[]|select(.public_key == "402B6ECE0D1CF99A7F07B832477048C56F213A4F54ED4AEB35AE829507FBC4A6")|.private_key')

2023-01-26T06:06:16.472Z [info] : Start Voting Key Update...
2023-01-26T06:06:16.476Z [info] : votingSetGroup: 160
2023-01-26T06:06:16.476Z [info] : votingMaxEpoch: 26280
2023-01-26T06:06:16.477Z [info] : votingStartEpoch: 26281
2023-01-26T06:06:16.477Z [info] : votingEndEpoch: 52560
2023-01-26T06:06:16.477Z [info] : blockGenerationTargetTime: 15
2023-01-26T06:06:42.716Z [info] : Voting Key file Create: SUCCESS mijin-catapult-package/package/api/catapult/userconfig/resources/votingkey/private_key_tree2.dat

2.2.6.5.10. Check status of voting rights file again.

If you see a voting rights file (private_key_tree2.dat) created with the same public key, the update file has been created.
Next time you need to update the finalizationEpoch before it reaches 52560.
$ mijin-catapult-tools votingkey info -u http://localhost:3000 -d mijin-catapult-package/package/api/catapult/userconfig/resources/votingkey
2023-01-26T06:10:00.625Z [info] : Start Voting Key Check Dir... mijin-catapult-package/package/api/catapult/userconfig/resources/votingkey
2023-01-26T06:10:00.630Z [info] : votingfile: index0:  {"publicKey":"402B6ECE0D1CF99A7F07B832477048C56F213A4F54ED4AEB35AE829507FBC4A6","startEpoch":1,"endEpoch":26280,"filename":"private_key_tree1.dat"}
2023-01-26T06:10:00.630Z [info] : votingfile: index1:  {"publicKey":"402B6ECE0D1CF99A7F07B832477048C56F213A4F54ED4AEB35AE829507FBC4A6","startEpoch":26281,"endEpoch":52560,"filename":"private_key_tree2.dat"}