V: Chạy Midnight Node Validator
1. Yêu Cầu:
DB_SYNC và POSTGRES cần có cổng truy cập được dành cho Midnight Node và đã đồng bộ đầy đủ Thiết lập các phụ thuộc của chuỗi đối tác.
SEED_PHRASE của khóa cross-chain được tạo ở Bước Đăng ký làm Validator node..
NODE_KEY được tạo ở Bước Đăng ký làm Validator node.
Midnight Node hiện có sẵn dưới dạng một image Docker, do đó cần cài đặt Docker/Docker Compose.
2. Chạy Midnight Node validator với docker compose
Một kho lưu trữ docker-compose được cung cấp để dễ dàng khởi động midnight-node trên testnet
git clone https://github.com/midnight-ntwrk/partner-chain-deps-docker.git
cd midnight-node-docker
ls .
Folder dự án này bao gồm tệp .env chứa các biến môi trường quan trọng cần chỉnh sửa.
3. Cập nhập biến môi trường.
– Mở tệp .env bằng trình soạn thảo nano hoặc vi
– Cập nhập DB_SYNC_POSTGRES_CONNECTION_STRING với địa chỉ IP/host và mật khẩu chính xác của bạn.
– Tạo NODE_KEY bằng lệnh bên dưới sau đó cập nhập vào tệp .env
docker run --rm -it docker.io/parity/subkey:latest generate-node-key
– Sao chép SEED_PHRASE được tạo ở bước “Đăng ký làm Validator node” của bạn vào container
docker cp /home/YOUR_USER/partner-chains-cli/data/chains/partner_chains_template/keystore/ midnight-node-docker-midnight-node-testnet-1:./node/chain/chains/testnet
4. Khởi động Midnight Node bằng docker-compose:
Trong cùng thư mục với tệp compose.yml, thực thi lệnh sau để bắt đầu chạy node:
docker-compose up
– Node sẽ bắt đầu kết nối với testnet đồng bộ và thực hiện xác thực các block.
Ví dụ về logs đúng khi khởi chạy thành công:
midnight-node-testnet-1 | 2024-09-24 19:19:03 💻 Target environment: gnu
midnight-node-testnet-1 | 2024-09-24 19:19:03 💻 Memory: 7837MB
midnight-node-testnet-1 | 2024-09-24 19:19:03 💻 Kernel: 6.10.4-linuxkit
midnight-node-testnet-1 | 2024-09-24 19:19:03 💻 Linux distribution: Debian GNU/Linux trixie/sid
midnight-node-testnet-1 | 2024-09-24 19:19:03 💻 Virtual machine: no
midnight-node-testnet-1 | 2024-09-24 19:19:03 📦 Highest known block at #8936
midnight-node-testnet-1 | 2024-09-24 19:19:03 〽️ Prometheus exporter started at 127.0.0.1:9615
midnight-node-testnet-1 | 2024-09-24 19:19:03 Running JSON-RPC server: addr=127.0.0.1:9944, allowed origins=["http://localhost:*", "http://127.0.0.1:*", "https://localhost:*", "https://127.0.0.1:*", "https://polkadot.js.org"]
midnight-node-testnet-1 | 2024-09-24 19:19:03 💔 The bootnode you want to connect to at `/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWCp4EyKBtHjYTjUaNBauuE944KtDguFbRmQbXQprD5DmP` provided a different peer ID `12D3KooWA6xLufBTmT5vnW1uaKN1My2UsLeWDVS9MvLgbfrD5S4L` than the one you expect `12D3KooWCp4EyKBtHjYTjUaNBauuE944KtDguFbRmQbXQprD5DmP`.
midnight-node-testnet-1 | 2024-09-24 19:19:08 ⚙️ Syncing, target=#79809 (6 peers), best: #8960 (0xb3c1…a312), finalized #8704 (0x0012…390d), ⬇ 710.7kiB/s ⬆ 6.7kiB/s
midnight-node-testnet-1 | 2024-09-24 19:19:11 ✅ Validated Midnight transaction 48ad3bdfa2be837a7abde0ad3fc7badb24f32cd8f97beec4e5d2a05b62d21adb
midnight-node-testnet-1 | 2024-09-24 19:19:12 ✅ Validated Midnight transaction e0fe7c184a6512fe48bb2494cc60ea4583c7be1b10b8100b1be65966894c6191
midnight-node-testnet-1 | 2024-09-24 19:19:12 ✅ Validated Midnight transaction 43f15469e7e4a12db60627c11554b912b84620d1c76f9ce765cdfee26b4c08df
midnight-node-testnet-1 | 2024-09-24 19:19:13 ⚙️ Syncing 19.9 bps, target=#79810 (9 peers), best: #9060 (0x3c59…c88f), finalized #8704 (0x0012…390d), ⬇ 81.5kiB/s ⬆ 0.9kiB/s
midnight-node-testnet-1 | 2024-09-24 19:19:13 ✅ Validated Midnight transaction 82d11c6280c0ef43d50f6d38fc760425af5d39c84e1d2f2fd7a637c88c7783be
midnight-node-testnet-1 | 2024-09-24 19:19:13 ✅ Validated Midnight transaction 20e4c4f60db1a549379bb4ac37720be95fa5e1e8e174aaf4112f93ddc72154b9
midnight-node-testnet-1 | 2024-09-24 19:19:15 💼 Selected 540 validators for epoch 239829, from 12 permissioned candidates and 6 trustless candidates
midnight-node-testnet-1 | 2024-09-24 19:19:15 ⏳ New epoch 239828 starting at block 9216
midnight-node-testnet-1 | 2024-09-24 19:19:15 New session 8
midnight-node-testnet-1 | 2024-09-24 19:19:15 Committee rotated: Returning 540 validators, stored in epoch 239828
midnight-node-testnet-1 | 2024-09-24 19:19:15 Start session 8, epoch 239828
midnight-node-testnet-1 | 2024-09-24 19:19:15 💼 Storing committee of size 540 for epoch 239829
midnight-node-testnet-1 | 2024-09-24 19:19:16 ✅ Validated Midnight transaction ecc8eab39435383a5efb505cee746119f2e1ae19dbf36dba496a878124f17526
midnight-node-testnet-1 | 2024-09-24 19:19:17 ✅ Validated Midnight transaction 67183e9a12d25d2b58856388918a892a52009ea7d6767df6c1f7af9a8eccd4a9
midnight-node-testnet-1 | 2024-09-24 19:19:17 ✅ Validated Midnight transaction bcbdba7aa7546331b143d2e7d434a7b285ed18ef42a334529dd7d5ba5f969bde
midnight-node-testnet-1 | 2024-09-24 19:19:17 ✅ Validated Midnight transaction
Ví dụ về logs đúng khi node đã đóng block thành công, lưu ý cần chờ n+2 epoch khi đăng ký làm validator thành công.
Trong cùng thư mục với tệp compose.yml, thực thi lệnh sau để kiểm tra logs.
docker compose logs 2>&1 | grep 'block for pro'
Ví dụ về logs đúng khi node đã đóng block thành công:
midnight-node-testnet-1 | 2024-11-23 20:19:06 🔖 Pre-sealed block for proposal at 810962. Hash now 0xcbb3c7a050822926a7c2c04cd5ab59da737e7da60d54e9c50c9e28c0323c08e3, previously 0x25f9a5becfef17ca1ae21577d0cad9b3a1e2cc013920131f3208318ae398c54d.
midnight-node-testnet-1 | 2024-11-23 20:54:33 🎁 Prepared block for proposing at 811283 (27181 ms) [hash: 0x036e0a0828403a5d2a25548fd7fd7c14579c8f5e32a73b0a2aa7b6ddc46c1d1d; parent_hash: 0x6b68…e0c3; extrinsics (3): [0xaca5…7a32, 0x39d8…84fb, 0xbe17…dda9]
midnight-node-testnet-1 | 2024-11-23 20:54:33 🔖 Pre-sealed block for proposal at 811283. Hash now 0xb90e0b31af737f60abebc992cd6f46e2386a34b3c07d7ab40b56a7525129ce5c, previously 0x036e0a0828403a5d2a25548fd7fd7c14579c8f5e32a73b0a2aa7b6ddc46c1d1d.
midnight-node-testnet-1 | 2024-11-23 22:41:12 🎁 Prepared block for proposing at 812287 (2 ms) [hash: 0xe53fc2479ce215738f93bd25b7d4fcb5bd41e67656d55dacddbb1a772fa61484; parent_hash: 0x779c…b18f; extrinsics (2): [0x4c8c…ea56, 0x39d8…84fb]
midnight-node-testnet-1 | 2024-11-23 22:41:12 🔖 Pre-sealed block for proposal at 812287. Hash now 0x96f686e381e25b35466a03fc30d11ee04d4e896b4cd2f9d90f2ed28233583252, previously 0xe53fc2479ce215738f93bd25b7d4fcb5bd41e67656d55dacddbb1a772fa61484.
midnight-node-testnet-1 | 2024-11-23 23:51:45 🎁 Prepared block for proposing at 812935 (15094 ms) [hash: 0xbb43b0677fd7d280dffcc1d7c9f77d29bb6b3c945829912c599328ea72ce1f88; parent_hash: 0xb77b…cc19; extrinsics (3): [0x9cc5…505c, 0x39d8…84fb, 0x3df3…b5db]
midnight-node-testnet-1 | 2024-11-23 23:51:45 🔖 Pre-sealed block for proposal at 812935. Hash now 0x57969de37bcdbf0e2bb325776c437908490a6e6339b980ef16a0fa28d7bfc9de, previously 0xbb43b0677fd7d280dffcc1d7c9f77d29bb6b3c945829912c599328ea72ce1f88.
midnight-node-testnet-1 | 2024-11-24 02:08:48 🎁 Prepared block for proposing at 814232 (2 ms) [hash: 0x2d10f7f3808c5a0856093116e68c60c6eb46ba2041eafcd231bfe7f032c2fc83; parent_hash: 0xf68e…d984; extrinsics (2): [0x054a…aa0f, 0x39d8…84fb]
midnight-node-testnet-1 | 2024-11-24 02:08:48 🔖 Pre-sealed block for proposal at 814232. Hash now 0xf7e0094516795b08874d8bb8687f85d43cc604a01394ce292dca75efb88559b3, previously 0x2d10f7f3808c5a0856093116e68c60c6eb46ba2041eafcd231bfe7f032c2fc83.
midnight-node-testnet-1 | 2024-11-24 05:14:00 🎁 Prepared block for proposing at 815897 (2 ms) [hash: 0x0f197db0a031c576ce6b82b2c7753a4d350bee73d0da7b104d99a580cc23376b; parent_hash: 0x47e3…c537; extrinsics (2): [0x8344…ac11, 0x39d8…84fb]
midnight-node-testnet-1 | 2024-11-24 05:14:00 🔖 Pre-sealed block for proposal at 815897. Hash now 0xb2bcd1ab020b5e914478590ae07fd7e119268a61a755d4255eb3cc4351b2815c, previously 0x0f197db0a031c576ce6b82b2c7753a4d350bee73d0da7b104d99a580cc23376b.
midnight-node-testnet-1 | 2024-11-24 05:30:30 🎁 Prepared block for proposing at 816047 (5 ms) [hash: 0x1373f42446bb6905bc558f588ac04c0d6068606bca692320ba2ce552b275bb09; parent_hash: 0x51ad…d510; extrinsics (2): [0x2e19…d279, 0x39d8…84fb]
midnight-node-testnet-1 | 2024-11-24 05:30:30 🔖 Pre-sealed block for proposal at 816047. Hash now 0x0947fca367bf58b4a782b55c428571f28a96e647316a198940815770d2ec729c, previously 0x1373f42446bb6905bc558f588ac04c0d6068606bca692320ba2ce552b275bb09.
midnight-node-testnet-1 | 2024-11-24 11:08:00 🎁 Prepared block for proposing at 819109 (1 ms) [hash: 0x35ba9c9efeede5423bc6a023b1c93e50ac77ca5db79c8405236623fd6f16efd0; parent_hash: 0x6f39…5c7b; extrinsics (2): [0xe568…b153, 0x39d8…84fb]
midnight-node-testnet-1 | 2024-11-24 11:08:00 🔖 Pre-sealed block for proposal at 819109. Hash now 0x76c14c766cca3d1b8d88d3363c656c704307b938b9b51daafee8af73f566967b, previously 0x35ba9c9efeede5423bc6a023b1c93e50ac77ca5db79c8405236623fd6f16efd0.