Mithril Signerノードの設定、更新
このマニュアルは、Stake Pool Operator(SPO)がCardano メインネット上で Mithril Signer を安全に運用するための設定および更新手順をまとめたものです。
インストールバージョン
| Node | Mithril-signer | squid |
|---|---|---|
| 11.0.1 | 1.0.0 | 7.6 |
1. Mithril Signerの設定
BPにMithril Signerのインストール
補足
Mithril Signerは、ブロック生成ノード(BP)が保持するKES鍵を用いて署名を行うため、BP上で稼働させる必要があります。
ビルド済みバイナリファイルダウンロード
システムのアップデート
sudo apt update && sudo apt upgrade -y作業ディレクトリの作成
mkdir -p $HOME/mithrilビルド済みバイナリのダウンロード
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 2617.0 -p $HOME/git/mithrilbinディレクトリへコピー
sudo cp $HOME/git/mithril/mithril-signer /usr/local/bin/mithril-signerバージョン確認
mithril-signer -Vmithril-signer 1.0.0+2478748ENV変数の設定
パラメータ値算出
era_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}')BPから接続するリレーIPを指定
relay_ip=xx.xxx.xx.xxenvファイル作成
cat > $HOME/mithril/mithril-signer.env << EOF
KES_SECRET_KEY_PATH=$NODE_HOME/kes.skey
OPERATIONAL_CERTIFICATE_PATH=$NODE_HOME/node.cert
NETWORK=mainnet
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=$HOME/mithril/stores
STORE_RETENTION_LIMIT=5
ERA_READER_ADAPTER_TYPE=cardano-chain
ERA_READER_ADAPTER_PARAMS=$era_params
RELAY_ENDPOINT=http://${relay_ip}:3132
ENABLE_METRICS_SERVER=true
METRICS_SERVER_IP=0.0.0.0
METRICS_SERVER_PORT=61234
EOFサービスファイル作成
cat > $HOME/mithril/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=$HOME/mithril/mithril-signer.env
ExecStart=/usr/local/bin/mithril-signer -vvv
[Install]
WantedBy=cardano-node.service
EOFsudo cp $HOME/mithril/mithril-signer.service /etc/systemd/system/mithril-signer.servicesudo chmod 644 /etc/systemd/system/mithril-signer.servicesudo systemctl daemon-reloadsudo systemctl enable mithril-signerMithrilリレーのセットアップ
説明
Mithril Signer はアグリゲーターとの通信を行いますが、セキュリティおよびネットワーク分離の観点から、BP から直接インターネット通信を行わず、Relay ノード上で Squid をフォワードプロキシとして動作させ、中継通信を行います。
システムのアップデート
sudo apt update && sudo apt upgrade -ysquidのインストール
cd $HOME
wget https://github.com/squid-cache/squid/releases/download/SQUID_7_6/squid-7.6.tar.gztar xzf squid-7.6.tar.gz
cd squid-7.6squidのビルド
./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.pidmakeインストールコマンドの実行
sudo make installsquidのバージョン確認
/opt/squid/sbin/squid -vSquid Cache: Version 7.6
Service Name: squid
configure options: '--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' 'PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:'インストールファイルの削除
cd $HOME
rm squid-7.6.tar.gz
rm -rf squid-7.6squidのアカウント作成
sudo adduser --system --no-create-home --group squidアクセス権限の付与
sudo chown squid -R /opt/squid/var/sudo chgrp squid -R /opt/squid/var/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.servicesudo systemctl daemon-reloadsudo systemctl enable squidリレーから接続するBPIPを指定
bp_ip=xx.xxx.xx.xxsquidの設定ファイル作成
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_ip
# 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
EOFsudo mv $HOME/squid.conf /etc/squid/squid.confファイアウォール設定
sudo ufw allow from $bp_ip to any port 3132 proto tcpファイアウォールの再起動
sudo ufw reloadsquidの起動
sudo systemctl start squidsquidの起動確認
sudo systemctl status squid --no-pager● squid.service - Squid service
~~
Active: active (running) mithril-signerの起動
sudo systemctl start mithril-signerログの確認
journalctl -u mithril-signer -f --output=cat以上で、署名者登録が完了しました。
スナップショットに署名するのは2エポック後からとなります。
Mithril-Signerの動作確認
インストール後にアグリゲーターに正常に登録されているかを確認します。
cd $HOME/mithril
wget https://mithril.network/doc/scripts/verify_signer_registration.shchmod +x verify_signer_registration.shPARTY_ID=$(cat $NODE_HOME/pool.id-bech32) AGGREGATOR_ENDPOINT=https://aggregator.release-mainnet.api.mithril.network/aggregator $HOME/mithril/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 ***.便利なエイリアス設定
エイリアス設定
BP上で、短いコマンドでMithril Signerのログをリアルタイム確認できるようにします。
echo alias mithril='"journalctl -u mithril-signer -f --output=cat"' >> $HOME/.bashrc
source $HOME/.bashrc設定後は、以下のコマンドを実行するだけで、Mithril Signerの起動状態(ログ)をリアルタイムで確認できます。
mithril ・・・ログ表示Grafanaダッシュボード設定
xxx.xxx.xxx.xxをGrafana導入サーバーのIPに置き換えて実行
sudo ufw allow from xxx.xxx.xxx.xx to any port 61234sudo ufw reloadPrometheus設定ファイルの編集
sudo nano /etc/prometheus/prometheus.yml以下のxxx.xxx.xxx.xxxをMithril-signerが稼働しているBPのIPに置き換えてprometheus.ymlファイルの最後の行に追加
- targets: ['xxx.xxx.xxx.xxx:61234']
labels:
alias: 'BP-signer'
type: 'Mithril-signer'prometheus.ymlの構文チェック
sudo promtool check config /etc/prometheus/prometheus.yml戻り値確認
構文エラーなしの場合
Checking /etc/prometheus/prometheus.yml
SUCCESS: 0 rule files found構文エラーの場合(一例)
Checking /etc/prometheus/prometheus.yml
FAILED: parsing YAML file /etc/prometheus/prometheus.yml: yaml: line XX: did not find expected '-' indicator/etc/prometheus/prometheus.ymlファイルを開いて余分なスペースや記号の有無などを確認してください。
Prometheusサービスの再起動
sudo systemctl restart prometheus.serviceMithril-signer用のダッシュボードファイルをダウンロード
curl -s -o $NODE_HOME/Mithril-Signer-on-SJG-Grafana-dashboard.json https://raw.githubusercontent.com/akyo3/Extends-SJG-Knowledge/refs/heads/main/Mithril-Signer-on-SJG-Grafana-dashboard.jsonファイル内容の置換
sed -i $NODE_HOME/Mithril-Signer-on-SJG-Grafana-dashboard.json \
-e "s/bech32_id_of_your_pool/$(cat $NODE_HOME/pool.id-bech32)/g"ファイル転送
BPのcnodeディレクトリに取得したMithril-Signer-on-SJG-Grafana-dashboard.jsonをローカルのホストマシンにダウンロードします。
Grafanaの左メニューから「Dashboards」を開き、「New」→「Import」→「Upload dashboard JSON file」を選択し、ダウンロードした Mithril-Signer-on-SJG-Grafana-dashboard.json を指定します。
データソースの割り当て画面では、
PrometheusにはPrometheusyesoreyeram-infinity-datasourceにはyesoreyeram-infinity-datasource
をそれぞれ選択してください。
設定内容を確認後、「Import」を選択するとダッシュボードが読み込まれます。
2. Mithril Signerの更新
BPのMithril Signer更新
システムのアップデート
sudo apt update && sudo apt upgrade -ymithril-signerの停止
sudo systemctl stop mithril-signer既存ファイルの削除
rm -rf $HOME/git/mithril/*ビルド済みバイナリファイルのダウンロード
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 2617.0 -p $HOME/git/mithrilbinディレクトリへコピー
sudo cp $HOME/git/mithril/mithril-signer /usr/local/bin/mithril-signerバージョン確認
mithril-signer -Vmithril-signer 1.0.0+2478748mithril-signerの起動
sudo systemctl start mithril-signer起動から約3分後にSignerの登録を確認
curl -s localhost:61234/metrics | grep ^mithril_signer_signer_registration_successSigner登録成功の戻り値
mithril_signer_signer_registration_success_last_epoch (現在のエポック)
mithril_signer_signer_registration_success_since_startup 1上記の戻り値が確認できない場合は5分後にログを確認
journalctl -u mithril-signer -f --output=catリレーのMithril Signer更新
Squidのアップデート
バージョン確認
/opt/squid/sbin/squid -v | grep Versionヒント
Squid Cache: Version 7.6 の戻り値がある場合、以降実施不要です。
squidの停止
sudo systemctl stop squidsudo systemctl disable squidシステムアップデート
sudo apt update && sudo apt upgrade -ysquid7.6のインストール
cd $HOME
wget https://github.com/squid-cache/squid/releases/download/SQUID_7_6/squid-7.6.tar.gztar xzf squid-7.6.tar.gz
cd squid-7.6squidのビルド
./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.pidmakesudo make installsquidのバージョン確認
/opt/squid/sbin/squid -v | grep Version戻り値
Squid Cache: Version 7.6squidのサービス有効化
sudo systemctl enable squidsquidサービスの起動
sudo systemctl start squidインストールファイルの削除
cd $HOME
rm squid-7.6.tar.gz
rm -rf squid-7.6Last updated on