コンテンツにスキップ

Mithril Signerノードの設定、更新

このマニュアルは、Stake Pool Operator(SPO)がCardano メインネット上で Mithril Signer を安全に運用するための設定および更新手順をまとめたものです。

インストールバージョン

Node Mithril-signer squid
10.5.3 0.2.276 7.3

1. Mithril Signerの設定

1-1. BPにMithril Signerのインストール

補足

Mithril Signerは、ブロック生成ノード(BP)が保持するKES鍵を用いて署名を行うため、BP上で稼働させる必要があります。

ビルド済みバイナリファイルダウンロード

システムのアップデート

sudo apt update -y && 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 2543.1-hotfix -p $HOME/git/mithril

binディレクトリへコピー

sudo cp $HOME/git/mithril/mithril-signer /usr/local/bin/mithril-signer

バージョン確認

mithril-signer -V

mithril-signer 0.2.276+5d5571e

ENV変数の設定

パラメータ値算出

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.xx

envファイル作成

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
EOF
sudo cp $HOME/mithril/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

1-2. Mithrilリレーノードのセットアップ

説明

Mithril Signer はアグリゲーターとの通信を行いますが、セキュリティおよびネットワーク分離の観点から、BP から直接インターネット通信を行わず、Relay ノード上で Squid をフォワードプロキシとして動作させ、中継通信を行います。

システムのアップデート

sudo apt update -y && sudo apt upgrade -y

squidのインストール

cd $HOME
wget https://github.com/squid-cache/squid/releases/download/SQUID_7_3/squid-7.3.tar.gz

tar xzf squid-7.3.tar.gz
cd squid-7.3

squidのビルド

./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

squidのバージョン確認

/opt/squid/sbin/squid -v

戻り値

Squid Cache: Version 7.3
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.3.tar.gz
rm -rf squid-7.3

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

リレーから接続するBPIPを指定

bp_ip=xx.xxx.xx.xx

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_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
EOF
sudo mv $HOME/squid.conf /etc/squid/squid.conf

ファイアウォール設定

sudo ufw allow from $bp_ip to any port 3132 proto tcp
ファイアウォールの再起動
sudo ufw reload
squidの起動
sudo systemctl start squid
squidの起動確認
sudo systemctl status squid --no-pager

Activeが active (running) になっていること

mithril-signerの起動

sudo systemctl start mithril-signer
ログの確認
journalctl -u mithril-signer -f --output=cat

以上で、署名者登録が完了しました。
スナップショットに署名するのは2エポック後からとなります。

1-3. Mithril-Signerの動作確認

インストール後にアグリゲーターに正常に登録されているかを確認します。

cd $HOME/mithril
wget https://mithril.network/doc/scripts/verify_signer_registration.sh
chmod +x verify_signer_registration.sh
PARTY_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 ***.

1-4. 便利なエイリアス設定

エイリアス設定

ブロックプロデューサー(BP)上で、短いコマンドでMithril Signerのログをリアルタイム確認できるようにします。

echo alias mithril='"journalctl -u mithril-signer -f --output=cat"' >> $HOME/.bashrc
source $HOME/.bashrc

設定後は、以下のコマンドを実行するだけで、Mithril Signerの起動状態(ログ)をリアルタイムで確認できます。

mithril ・・・ログ表示

1-5. Grafanaダッシュボード設定

xxx.xxx.xxx.xxをGrafana導入サーバーのIPに置き換えて実行

sudo ufw allow from xxx.xxx.xxx.xx to any port 61234
sudo ufw reload

Prometheus設定ファイルの編集

sudo nano /etc/prometheus/prometheus.yml

以下のxxx.xxx.xxx.xxxMithril-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.service

Mithril-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をローカルのホストマシンにダウンロードします。

graph LR
    A[BP] -->|**Mithril-Signer-on-SJG-Grafana-dashboard.json**| B[ローカルのホストマシン];

Grafanaの左メニューから「Dashboards」を開き、「New」→「Import」→「Upload dashboard JSON file」を選択し、ダウンロードした Mithril-Signer-on-SJG-Grafana-dashboard.json を指定します。

データソースの割り当て画面では、

  • Prometheus には Prometheus
  • yesoreyeram-infinity-datasource には yesoreyeram-infinity-datasource

をそれぞれ選択してください。

設定内容を確認後、「Import」を選択するとダッシュボードが読み込まれます。

2. Mithril Signerの更新

2-1. BPのMithril Signer更新

システムのアップデート

sudo apt update -y && sudo apt upgrade -y

mithril-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 2543.1-hotfix -p $HOME/git/mithril

binディレクトリへコピー

sudo cp $HOME/git/mithril/mithril-signer /usr/local/bin/mithril-signer

バージョン確認

mithril-signer -V

mithril-signer 0.2.276+5d5571e

mithril-signerの起動

sudo systemctl start mithril-signer

起動から約3分後にSignerの登録を確認

curl -s localhost:61234/metrics | grep ^mithril_signer_signer_registration_success

Signer登録成功の戻り値

mithril_signer_signer_registration_success_last_epoch  (現在のエポック)
mithril_signer_signer_registration_success_since_startup 1

上記の戻り値が確認できない場合は5分後にログを確認

journalctl -u mithril-signer -f --output=cat

2-2. リレーノードのMithril Signer更新

Squidのアップデート

バージョン確認

/opt/squid/sbin/squid -v | grep Version

ヒント

Squid Cache: Version 7.3 の戻り値がある場合、以降実施不要です。

squidの停止

sudo systemctl stop squid
sudo systemctl disable squid

システムアップデート

sudo apt update -y && sudo apt upgrade -y

squid7.3のインストール

cd $HOME
wget https://github.com/squid-cache/squid/releases/download/SQUID_7_3/squid-7.3.tar.gz

tar xzf squid-7.3.tar.gz
cd squid-7.3

squidのビルド

./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

squidのバージョン確認

/opt/squid/sbin/squid -v | grep Version

戻り値

Squid Cache: Version 7.3

squidのサービス有効化

sudo systemctl enable squid

squidサービスの起動

sudo systemctl start squid

インストールファイルの削除

cd $HOME
rm squid-7.3.tar.gz
rm -rf squid-7.3