ミスリル署名者の設定、更新
Mithrilは、Cardanoネットワーク上にステークベースのしきい値マルチ署名を提供することを目的とした研究プロジェクトです。
一言で言えば、Mithrilは次のようにまとめることができます。
プルーフオブステークのブロックチェーンネットワークのステークホルダーが、マルチ署名に集約されたメッセージに個別に署名できるようにするプロトコルです。
これにより、それらのメッセージが総ステークの最小シェアを占めることが保証されます。公式ドキュメントは、こちらで入手できます。
2つのコンポーネントをインストールする必要があります。
- CardanoブロックプロデューサーのMithril Signer
- Cardanoリレーの1つにMithrilリレーを設置
ブロックプロデューサーにMithril Signerをインストールします。
- BP
システムのアップデート
sudo apt update -y && sudo apt upgrade -y
Rustのインストール
Rustインストール
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Proceed with installation (default) 1を入力してEnter
$HOME/.cargo の下にあるenvファイルをソースします。
source $HOME/.cargo/env
Rustバージョン確認
rustc -V
Mithrilのインストール
cd $HOME/git
git clone https://github.com/input-output-hk/mithril.git
最新バージョンを探します。
https://github.com/input-output-hk/mithril/releases/latest
このガイドはバージョンv2603.1に基づいています。Cardanoメインネットと互換性のある最新バージョンに適宜変更してください。
cd mithril
git fetch --all --prune
git checkout tags/2603.1
Mithril Signerをビルドします。
cd mithril-signer
make build
ビルドバージョンの確認
./mithril-signer -V
mithril-signer 0.3.7+567a8e8
ビルドが正しく動作していることを確認します。
./mithril-signer -h
binへコピーします。
sudo mv mithril-signer /usr/local/bin/mithril-signer
バージョンの確認
mithril-signer -V
mithril-signer 0.3.7+567a8e8
作業ディレクトリを作成します。
mkdir $NODE_HOME/mithril-signer
Mithril SignerのENV変数の設定
BPから接続するリレーIPを指定します。
relay1_ipv4=
変数を設定します。
ERA_READER_ADAPTER_PARAMS=$(jq -nc \
--arg address "$(wget -q -O - https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/release-mainnet/era.addr)" \
--arg verification_key "$(wget -q -O - https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/release-mainnet/era.vkey)" \
'{"address": $address, "verification_key": $verification_key}')
ANCILLARY_VERIFICATION_KEY=$(wget -q -O - https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/release-mainnet/ancillary.vkey)
cat > $NODE_HOME/mithril-signer/mithril-signer.env << EOF
KES_SECRET_KEY_PATH=$NODE_HOME/kes.skey
OPERATIONAL_CERTIFICATE_PATH=$NODE_HOME/node.cert
NETWORK=${NODE_NETWORK_ID}
AGGREGATOR_ENDPOINT=https://aggregator.release-mainnet.api.mithril.network/aggregator
RUN_INTERVAL=60000
DB_DIRECTORY=$NODE_HOME/db
CARDANO_NODE_SOCKET_PATH=$NODE_HOME/db/socket
CARDANO_CLI_PATH=/usr/local/bin/cardano-cli
DATA_STORES_DIRECTORY=$NODE_HOME/mithril-signer/stores
STORE_RETENTION_LIMIT=5
ERA_READER_ADAPTER_TYPE=cardano-chain
ERA_READER_ADAPTER_PARAMS='${ERA_READER_ADAPTER_PARAMS}'
ANCILLARY_VERIFICATION_KEY='${ANCILLARY_VERIFICATION_KEY}'
RELAY_ENDPOINT=http://${relay1_ipv4}:3132
ENABLE_METRICS_SERVER=true
METRICS_SERVER_IP=0.0.0.0
METRICS_SERVER_PORT=61234
EOF
サービスファイルの作成
cat > $NODE_HOME/mithril-signer/mithril-signer.service << EOF
[Unit]
Description=Mithril Signer service
BindsTo=cardano-node.service
After=cardano-node.service
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=60
User=${USER}
EnvironmentFile=$NODE_HOME/mithril-signer/mithril-signer.env
ExecStart=/usr/local/bin/mithril-signer -vvv
[Install]
WantedBy=cardano-node.service
EOF
サービスファイルを移動して権限を設定する
sudo cp $NODE_HOME/mithril-signer/mithril-signer.service /etc/systemd/system/mithril-signer.service
sudo chmod 644 /etc/systemd/system/mithril-signer.service
起動時にサービス開始を有効にします。
sudo systemctl daemon-reload
sudo systemctl enable mithril-signer
CardanoリレーにMithrilリレーをインストールします。
Mithrilリレーノードは、Mithril署名者とMithrilアグリゲータ間のトラフィックを中継するフォワードプロキシとして機能します。
適切に設定すると、ブロック生成ノードのセキュリティが向上します。
このフォワード プロキシはsquidを使用して操作できます。
このセクションでは、推奨される設定について説明します。
- リレー1
システムのアップデート
sudo apt update -y && sudo apt upgrade -y
必要ツールのインストール
sudo apt install gcc g++ make libcppunit-dev
Squidのインストール
cd $HOME
wget https://github.com/squid-cache/squid/releases/download/SQUID_7_4/squid-7.4.tar.gz
解凍
tar xzf squid-7.4.tar.gz
cd squid-7.4
configureスクリプトの実行
./configure \
--prefix=/opt/squid \
--localstatedir=/opt/squid/var \
--libexecdir=/opt/squid/lib/squid \
--datadir=/opt/squid/share/squid \
--sysconfdir=/etc/squid \
--with-default-user=squid \
--with-logdir=/opt/squid/var/log/squid \
--with-pidfile=/opt/squid/var/run/squid.pid
make
make check
Testsuite summary for Squid Web Proxy 7.4
============================================================================
# TOTAL: 5
# PASS: 5
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================
PASS: 5であること
インストールコマンドを実行します。
sudo make install
squidバージョンを確認します。
/opt/squid/sbin/squid -v | grep Version
Squid Cache: Version 7.4
インストールファイルの削除します。
cd $HOME
rm squid-7.4.tar.gz
rm -rf squid-7.4
squidのアカウントを作成します。
sudo adduser --system --no-create-home --group squid
アクセス権限の設定をします。
sudo chown squid -R /opt/squid/var/
sudo chgrp squid -R /opt/squid/var/
Squidの設定
Mithril用の新しいsquid設定ファイルを作成します。
cat > $HOME/squid.service << EOF
[Unit]
Description=Squid service
BindsTo=cardano-node.service
After=cardano-node.service
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=60
User=squid
Group=squid
ExecStart=/opt/squid/sbin/squid -f /etc/squid/squid.conf
PIDFile=/opt/squid/var/run/squid.pid
[Install]
WantedBy=cardano-node.service
EOF
サービスファイルの設定をします。
sudo cp $HOME/squid.service /etc/systemd/system/squid.service
sudo systemctl daemon-reload
sudo systemctl enable squid
リレーからBPのIPを指定します。
BP_ipv4=
squidの設定ファイル作成
cat > $HOME/squid.conf << EOF
# Listening port (port 3132 is recommended)
http_port 3132
# ACL for internal IP of your block producer node
acl block_producer_internal_ip src ${BP_ipv4}
# ACL for aggregator endpoint
acl aggregator_domain dstdomain .mithril.network
# ACL for SSL port only
acl SSL_port port 443
# Allowed traffic
http_access allow block_producer_internal_ip aggregator_domain SSL_port
# Do not disclose block producer internal IP
forwarded_for delete
# Turn off via header
via off
# Deny request for original source of a request
follow_x_forwarded_for deny all
# Anonymize request headers
request_header_access Authorization allow all
request_header_access Proxy-Authorization allow all
request_header_access Cache-Control allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Connection allow all
request_header_access All deny all
# Disable cache
cache deny all
# Deny everything else
http_access deny all
EOF
squid.confのバックアップ
sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.bak
ファイルを移動させます。
sudo mv $HOME/squid.conf /etc/squid/squid.conf
FWの設定
sudo ufw allow from ${BP_ipv4} to any port 3132 proto tcp
FWの再起動
sudo ufw reload
squidの起動
sudo systemctl start squid
squidの起動確認
sudo systemctl status squid --no-pager
Activeが active (running)になっていること
- BP
mithril-signerの起動
sudo systemctl start mithril-signer
ログ確認
journalctl -u mithril-signer -f --output=cat
エイリアス設定
echo alias mithril='"journalctl -u mithril-signer -f --output=cat"' >> $HOME/.bashrc
source $HOME/.bashrc
Mithril-Signerの動作確認
署名者が登録されており、個別の署名で貢献しているかどうかを確認できます。
- BP
署名者が登録されていることを確認します。
スクリプトをmithril-signerディレクトリにダウンロードします。
cd $NODE_HOME/mithril-signer
wget https://mithril.network/doc/scripts/verify_signer_registration.sh
スクリプトを実行可能にします。
chmod +x verify_signer_registration.sh
スクリプトを実行します。
PARTY_ID=$(cat $NODE_HOME/pool-bech32.id) AGGREGATOR_ENDPOINT=https://aggregator.release-mainnet.api.mithril.network/aggregator $NODE_HOME/mithril-signer/verify_signer_registration.sh
署名者が登録されている場合は、次のメッセージが表示されます。
>> Congrats, your signer node is registered!
それ以外の場合は、次のエラー メッセージが表示されます。
>> Oops, your signer node is not registered. Party ID not found among the signers registered at epoch XXX.
署名者が個別の署名で貢献していることを確認します。
2エポック待つと、署名者が個別の署名で貢献していることを確認できます。まず、スクリプトをmithril-signerディレクトリにダウンロードします。
cd $NODE_HOME/mithril-signer
wget https://mithril.network/doc/scripts/verify_signer_signature.sh
スクリプトを実行可能にします。
chmod +x verify_signer_signature.sh
スクリプトを実行します。
cd $NODE_HOME/mithril-signer
PARTY_ID=$(cat $NODE_HOME/pool-bech32.id) AGGREGATOR_ENDPOINT=https://aggregator.release-mainnet.api.mithril.network/aggregator $NODE_HOME/mithril-signer/verify_signer_signature.sh
署名者が貢献している場合は、次のメッセージが表示されます。
>> Congrats, you have signed this certificate: ...
それ以外の場合は、次のエラー メッセージが表示されます。
>> Oops, your party id was not found in the last 20 certificates. Please try again later.
Mithril Signerの更新
- BP
システムのアップデート
sudo apt update -y && sudo apt upgrade -y
mithril-signerの停止
sudo systemctl stop mithril-signer
既存のmithrilフォルダの削除
rm -rf $HOME/git/mithril
ビルド済みバイナリのダウンロード
release_tag=$(curl -s https://api.github.com/repos/input-output-hk/mithril/releases/latest | jq -r .tag_name)
echo "Release tag : ${release_tag}"
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/input-output-hk/mithril/refs/heads/main/mithril-install.sh | sh -s -- -c mithril-signer -d ${release_tag} -p $HOME/git/mithril
binフォルダへコピー
sudo cp $HOME/git/mithril/mithril-signer /usr/local/bin/mithril-signer
バージョンの確認
mithril-signer -V
mithril-signer 0.3.7+567a8e8
mithril-signerの起動
sudo systemctl start mithril-signer
Mithril Signerの動作確認をして確認
Squidの更新
- リレー1
バージョン確認
/opt/squid/sbin/squid -v | grep Version
squidの停止
sudo systemctl stop squid
sudo systemctl disable squid
システムのアップデート
sudo apt update -y && sudo apt upgrade -y
squidのインストール
cd $HOME
release_tag=$(curl -s https://api.github.com/repos/squid-cache/squid/releases/latest | jq -r .tag_name)
echo "Release tag : ${release_tag}"
squid_version="$(echo "${release_tag#SQUID_}" | tr '_' '.')"
echo "SQUID_Version : ${squid_version}"
wget "https://github.com/squid-cache/squid/releases/download/${release_tag}/squid-${squid_version}.tar.gz"
解凍
tar -xzvf squid-${squid_version}.tar.gz
cd squid-${squid_version}
configureスクリプトの実行
./configure \
--prefix=/opt/squid \
--localstatedir=/opt/squid/var \
--libexecdir=/opt/squid/lib/squid \
--datadir=/opt/squid/share/squid \
--sysconfdir=/etc/squid \
--with-default-user=squid \
--with-logdir=/opt/squid/var/log/squid \
--with-pidfile=/opt/squid/var/run/squid.pid
make
sudo make install
バージョンの確認
/opt/squid/sbin/squid -v | grep Version
Squid Cache: Version 7.4
squidサービスの有効化
sudo systemctl enable squid
squidの起動
sudo systemctl start squid
インストールファイルの削除
cd $HOME
rm squid-${squid_version}.tar.gz
rm -rf squid-${squid_version}