iT邦幫忙

2025 iThome 鐵人賽

DAY 2
1

特務 K 左右望一望他所在的空間。這是一個無聊的房間,裡面只有小雨和他,一張桌子、小雨的筆電、和一些零食。他深吸一口氣,感受了一下房間的寧靜。

「你說的節點,現在有和我們在這個房間裡嗎?」特務 K 好奇了。

「還沒,」小雨習慣用行動說明。他掐指一捏快捷鍵,筆電的桌面閃出了黑黑的終端機。

特務 K 讚道:真像個駭客。

小雨一個 git clone 指令,把 https://github.com/ethereum/go-ethereum/ 拉回了本地端。

「這是以太坊的其中一個 執行層客戶端(Execution Client) ,叫做 go-ethereum ,又名 Geth

「你們有客戶?是誰?」特務 K 對客戶兩字十分敏感。

「這主要是客戶端-伺服器架構命名的慣例,雖然點對點網路中沒有中心化的伺服器,但放在使用者那邊的軟體,就會像網頁瀏覽器一樣,也被稱為客戶端」小雨回道。

筆電中早已備有吉祥物為藍皮爆眼囊鼠的 Go 語言,make 指令一下,筆電粗重的吐息聲下建置好了 Geth

初始階段

geth 執行之後,閃過了許多複雜的訊息。小雨也不一一解釋。畫面最後停在重複的字樣

Looking for peers                        peercount=2 tried=11 static=0
Looking for peers                        peercount=2 tried=26 static=0
Beacon client online, but no consensus updates received in a while. Please fix your beacon client to follow the chain!
Beacon client online, but no consensus updates received in a while. Please fix your beacon client to follow the chain!
Beacon client online, but no consensus updates received in a while. Please fix your beacon client to follow the chain!

「信標鏈上線,但一陣子沒收到共識更新。請修復信標鏈客戶端以跟隨鏈」特務 K 直譯了英文訊息,但文字沒辦法在他腦中形成任何的意義,顯然不是中文或英文的問題。

「這是 2022 大合併之後多添的一些小麻煩。光有執行層客戶端還不夠,還要有一個 共識層客戶端(Consensus Client)

小雨沉思半晌,挑了吉祥物為鏽甲紅蟹 的 Rust 語言的 Lighthouse 客戶端

一陣更新和建置之後,然後還有一陣子的除錯,對齊執行客戶端與共識層客戶端的 jwtsecret、開啟節點的 http API 等等,加上一部分深度的自我懷疑。兩邊客戶端終於緩緩吐出謎樣文字,一抹椰子口味乖乖的顏色提供了安心的感覺。

# Lighthouse 執行的指令。 bn 是信標鏈 beacon chain 的縮寫。
# 第二個參數註明共識層客戶端要同步的是主網路而非其他測試網。
# 第三和第四個是共識層客戶端和執行層客戶端溝通的方式。前者要知道後者的 API 去哪打。因為設計上兩者可以在不信任的網路溝通,所以有 JSON Web Tokens 保障通訊安全
# 第五個 checkpoint-sync-url 讓客戶端去取得狀態的檢查點。這要談到弱主觀的概念,需要一些脈絡和脈絡的脈絡,過幾天再談。
# 最後的 http 是開啟共識層客戶端的 API
lighthouse bn \
    --network mainnet \
    --execution-endpoint http://localhost:8551 \
    --execution-jwt /tmp/jwtsecret \
    --checkpoint-sync-url https://mainnet.checkpoint.sigp.io \
    --http

共識客戶端剛啟動時的一些訊息字樣。特務 K 看到了檢查點(checkpoint)、區塊(block)、狀態(state)。有些整數,有些十六進位的值。

# 共識客戶端
INFO  Starting checkpoint sync                      remote_url: https://mainnet.checkpoint.sigp.io/
INFO  Loaded checkpoint block and state             block_slot: 12421312, state_slot: 12421312, block_root: 0x15213e57ededa3c1e21d5fdbedf2dc6bc9e6c0777cd5c7ff9b707bee568fda2c

追趕階段

共識客戶端開始與其連線的同儕節點同步。這時網路的上傳和下載量漸漸被拉滿。

# 共識客戶端
INFO  Syncing                                       peers: "32", distance: "109 slots (21 mins)", est_time: "--"
INFO  Syncing                                       peers: "33", distance: "110 slots (22 mins)", est_time: "--"
INFO  Syncing                                       peers: "37", distance: "111 slots (22 mins)", est_time: "--"
INFO  Syncing                                       peers: "39", distance: "112 slots (22 mins)", est_time: "--"
INFO  Syncing                                       peers: "41", distance: "113 slots (22 mins)", est_time: "--"

執行客戶端拉回信標鏈區塊的資料頭(beacon headers)

# 執行客戶端
INFO Syncing beacon headers                   downloaded=1,214,464 left=21,983,322 eta=51m1.602s
INFO Syncing beacon headers                   downloaded=1,279,488 left=21,918,298 eta=50m51.373s
INFO Syncing beacon headers                   downloaded=1,349,632 left=21,848,154 eta=50m20.870s
INFO Syncing beacon headers                   downloaded=1,410,048 left=21,787,738 eta=50m10.502s
INFO Syncing beacon headers                   downloaded=1,479,168 left=21,718,618 eta=49m47.639s
INFO Syncing beacon headers                   downloaded=1,538,048 left=21,659,738 eta=49m38.369s

偶爾會有那麼一下下,共識客戶端的分岔選擇規則(Forkchoice)要求執行客戶端換到另一個鏈頭。

# 執行客戶端
INFO Syncing beacon headers                   downloaded=1,759,232 left=21,440,090 eta=49m58.398s
INFO Forkchoice requested sync to new head    number=23,197,884 hash=41b7ac..4155fd finalized=23,197,819
WARN Fetching the unknown forkchoice head from network hash=a82c29..32b5d3
INFO Forkchoice requested sync to new head    number=23,197,888 hash=a82c29..32b5d3 finalized=23,197,819

執行客戶端會顯示鏈(chain)和狀態(state)分別下載到什麼進度了。

# 執行客戶端
Syncing: chain download in progress      synced=29.82% chain=63.97GiB   headers=6,919,162@2.65GiB    bodies=6,919,162@43.69GiB   receipts=6,919,162@17.63GiB   eta=13h0m28.795s
Forkchoice requested sync to new head    number=23,200,395 hash=d750e9..e65d00 finalized=23,200,304
Syncing: state download in progress      synced=28.54% state=112.81GiB accounts=93,758,014@20.71GiB  slots=445,132,327@88.83GiB codes=567,114@3.27GiB    eta=13h48m13.950s
Syncing: chain download in progress      synced=29.83% chain=63.99GiB   headers=6,920,019@2.65GiB    bodies=6,920,019@43.70GiB   receipts=6,920,019@17.63GiB   eta=13h0m44.095s

更多新的生字出現,比較關鍵的是敲定(finalized)和資料泡(blob)。
偶爾,共識客戶端會從同儕收到八卦來的新區塊或新的資料泡。

# 共識客戶端
INFO  Gossipsub blob processed - imported fully available block  block_root: 0x5309f0874d41c37ebbd1dbe727c0cc4d36e6894e67e65c448a29eb6fbca90893
INFO  Downloading historical blocks                 distance: "997792 slots (19 weeks 5 days)", est_time: "--"
WARN  Head is optimistic                            info: "chain not fully verified, block and attestation production disabled until execution engine syncs", execution_block_hash: 0x3c396aae167f048d5b67f7ff0810b1e404e6516c1a3d26501b66813247cdc675
INFO  Synced                                        peers: "80", exec_hash: "0x3c396aae167f048d5b67f7ff0810b1e404e6516c1a3d26501b66813247cdc675 (unverified)", finalized_root: 0x6bb9c9a7949e6660643d5f65523e600b395d534172098b645650f4e6836d2c2b, finalized_epoch: 388250, epoch: 388252, block: "0x5309f0874d41c37ebbd1dbe727c0cc4d36e6894e67e65c448a29eb6fbca90893", slot: 12424081
INFO  New block received                            slot: 12424082, root: 0x762e4e51be0a946fbbcafe89dc01df1d8c3354f0a2f2f8d15c0521c58fa49bca
WARN  Head is optimistic                            info: "chain not fully verified, block and attestation production disabled until execution engine syncs", execution_block_hash: 0x81f110e822097d9a61681ecc0f007c5230fa78a677da9338b6e37ccb0975d45a
INFO  Synced                                        peers: "80", exec_hash: "0x81f110e822097d9a61681ecc0f007c5230fa78a677da9338b6e37ccb0975d45a (unverified)", finalized_root: 0x6bb9c9a7949e6660643d5f65523e600b395d534172098b645650f4e6836d2c2b, finalized_epoch: 388250, epoch: 388252, block: "0x762e4e51be0a946fbbcafe89dc01df1d8c3354f0a2f2f8d15c0521c58fa49bca", slot: 12424082

完成階段

過了 20 多小時後,客戶端上面的訊息看起來不太一樣

Geth 上面的訊息

INFO Syncing: chain download in progress      synced=100.00% chain=956.35GiB  headers=23,222,976@11.22GiB  bodies=23,222,976@677.97GiB receipts=23,222,976@267.16GiB eta=277.815ms
INFO Syncing: state healing in progress       accounts=335,451@16.51MiB     slots=566,029@42.65MiB        codes=552@2.56MiB        nodes=2,976,599@758.17MiB pending=12106
INFO Forkchoice requested sync to new head    number=23,223,065 hash=61dc80..c9ebf7 finalized=23,222,985
INFO State healing phase is completed         elapsed=39m56.729s
INFO Opened ancient database                  database=/home/ubuntu/.ethereum/geth/chaindata/ancient/state readonly=false
INFO Started snapshot generation              root=4293fc..959a90
INFO Resuming snapshot generation             root=4293fc..959a90 accounts=0                    slots=0                       storage=0.00B dangling=0 elapsed=18.546ms
INFO Rebuilt trie database                    root=4293fc..959a90
INFO Committed new head block                 number=23,222,977 hash=8d997e..6430e0
INFO Generating snapshot                      root=4293fc..959a90 accounts=256,752              slots=708,019                 storage=63.74MiB dangling=0 elapsed=8.003s
INFO Imported new chain segment               number=23,222,981 hash=60bd0e..7e6ad1 blocks=4 txs=941 mgas=116.446 elapsed=8.452s        mgasps=13.777 age=17m13s   triediffs=9.73MiB t
riedirty=0.00B

而 Lighthouse 上,(unverified) 的字樣變成 (verified)

WARN  Head is optimistic                            info: "chain not fully verified, block and attestation production disabled until execution engine syncs", execution_block_hash: 0x2
b67aec6231d43441809537ca6b98ef135b97d6df66f9f7680987c03c64550bc
INFO  Synced                                        peers: "100", exec_hash: "0x2b67aec6231d43441809537ca6b98ef135b97d6df66f9f7680987c03c64550bc (unverified)", finalized_root: 0x91e05
b0e1faaabbce48c193fd49b75ee394b92bbc7b357b6490974db8d1c06f9, finalized_epoch: 388957, epoch: 388959, block: "0xee36d32e633c4ca81aa4a30861f64e64c34812f652c4724171ea3d939bbc1eea", slot: 12446719
INFO  New block received                            slot: 12446720, root: 0xb8040db2ecbb740c23801fd219cfc7422b5d37a45813ed620186fa41bc8c3e2b
INFO  Synced                                        peers: "105", exec_hash: "0x2b67aec6231d43441809537ca6b98ef135b97d6df66f9f7680987c03c64550bc (verified)", finalized_root: 0x5d5d479
40cfd9a921a546857ea6da0fa16098f97044acd2572649994c080dce5, finalized_epoch: 388958, epoch: 388960, block: "   …  empty", slot: 12446720

「這台筆電,已經變成以太坊的一部分了」小雨說道。

兩個客戶端仍然忙碌的運作著,吐出一條條的日誌。小雨用 du 指令檢查了一下硬碟的使用量:

$ du -h ~/.ethereum/
4.0K    /home/ubuntu/.ethereum/keystore
5.5M    /home/ubuntu/.ethereum/geth/nodes
13M     /home/ubuntu/.ethereum/geth/chaindata/ancient/state
958G    /home/ubuntu/.ethereum/geth/chaindata/ancient/chain
958G    /home/ubuntu/.ethereum/geth/chaindata/ancient
1.3T    /home/ubuntu/.ethereum/geth/chaindata
8.0K    /home/ubuntu/.ethereum/geth/triedb
71M     /home/ubuntu/.ethereum/geth/blobpool/limbo
45M     /home/ubuntu/.ethereum/geth/blobpool/queue
116M    /home/ubuntu/.ethereum/geth/blobpool
1.3T    /home/ubuntu/.ethereum/geth
1.3T    /home/ubuntu/.ethereum/
$ du -h ~/.lighthouse/
472M    /home/ubuntu/.lighthouse/mainnet/beacon/logs
25M     /home/ubuntu/.lighthouse/mainnet/beacon/freezer_db
6.4G    /home/ubuntu/.lighthouse/mainnet/beacon/chain_db
70G     /home/ubuntu/.lighthouse/mainnet/beacon/blobs_db
16K     /home/ubuntu/.lighthouse/mainnet/beacon/network
77G     /home/ubuntu/.lighthouse/mainnet/beacon
77G     /home/ubuntu/.lighthouse/mainnet
77G     /home/ubuntu/.lighthouse/

特務 K 回想了一下剛剛發生了什麼事。這台筆電在剛剛 24 小時左右的時間,飢渴用飽了網路頻寬、CPU 核心、以及 1.3 TB 的儲存空間。大量謎樣的生字與數字流過他的眼前。 這就是以太坊的節點嗎!?

「我都蠻羨慕前端社群的,他們的實機展示都能在幾秒鐘搞定,然後說 "works like a charm"」小雨說「反觀以太坊,要完整體驗去中心化的儀式就得這麼痛苦。」

特務 K 是個擅長獲取情報的人,但往往那是人們喜歡藏匿資訊。現在的情況是大量的資訊呈現在他面前,他知道小雨每件事情大概都能找到公開文件,說出個所以然來。瓶頸在於他現在乾涸的腦漿再也消化不了更多的資訊。

特務 K 驚覺自己也是個人類節點,正在慢慢的和同儕同步資訊,但他需要給自己更多耐心、多點時間。


上一篇
關不掉的電腦
下一篇
靠朋友的電腦
系列文
那個有好多好多節點的電腦調查報告8
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言