題外話: ETH1 & ETH2 名稱不再

根據 Ethereum Blog,現在 ETH1 應該叫 Execution layer, 而 ETH2 叫 Consensus layer. 不過為求方便,標題還是稱之作 ETH2 吧。

Untitled

Lighthouse 可以加入 Redundant nodes

我有一部 server 裝了 ETH2 client Lighthouse 用作 ETH2 validation. Lighthouse 有個好處就是可以加入冗餘的 fallback endpoints.

你可以添加 Redundant Beacon Nodes (lighthouse vc --beacon-nodes),

以及 Redundant Execution Nodes (lighthouse bn --eth1-endpoints).

最近在官方文檔發現原來可加入 Redundant Beacon Nodes, 所以今天打算試用 Infura 提供的 beacon node.

申請 Infura ETH2 Project

https://infura.io/

點選 Create new project. PRODUCT 選擇 ETH2; 而 PROJECT NAME 隨意。

點選 Create new project. PRODUCT 選擇 ETH2; 而 PROJECT NAME 隨意。

CREATE 後便得到待會需要用到的 <PROJECT_ID><PROJECT_SECRET> :

待會需要用到的 <PROJECT_ID><PROJECT_SECRET>

測試 Request

替換 <PROJECT_ID><PROJECT_SECRET> 後執行 request:

curl -X GET "<https://<PROJECT_ID>:<PROJECT_SECRET>@eth2-beacon-mainnet.infura.io/eth/v1/beacon/genesis>"

若得到的 result 為以下的樣子便是成功了。

{"data":{"genesis_time":"1606824023","genesis_validators_root":"0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95","genesis_fork_version":"0x00000000"}}

在 lighthouse 加入 --beacon-nodes

然後在執行 lighthouse vc 後面加入:

--beacon-nodes <https://<PROJECT_ID>:<PROJECT_SECRET>@eth2-beacon-mainnet.infura.io>,http://localhost:5052 即可。

lighthouse vc <existing_param> --beacon-nodes <https://<PROJECT_ID>:<PROJECT_SECRET>@eth2-beacon-mainnet.infura.io>,<http://localhost:5052>

注:

  1. 如果沒有 --beacon-nodes, 就會自動用 http://localhost:5052; 而現在加上了 --beacon-nodes, 要使用本地的就必須明確加上 http://localhost:5052.
  2. 我這裡直接在 mainnet 裡用,你可以先在 testnet 試用。

確認成功

運行時 log 表示有 connected 至 https://eth2-beacon-mainnet.infura.io/ 之類的字眼:

INFO Connected to beacon node                endpoint: <https://eth2-beacon-mainnet.infura.io/>

Local 和 Infura 的 Beacon nodes 都成功連接:

INFO Connected to beacon node(s)             synced: 2, available: 2, total: 2, service: notifier

https://infura.io/dashboard 裡也確認有 request 便是成功了。

若你用 Infura 只是為了備用,依舊運行 local beacon node 的話。

那就把 --beacon-nodes 的次序改為 local 先, Infura 後:

--beacon-nodes <http://localhost:5052>,<https://<PROJECT_ID>:<PROJECT_SECRET>@eth2-beacon-mainnet.infura.io>

References

https://lighthouse-book.sigmaprime.io/redundancy.html

https://docs.infura.io/infura/networks/eth2-consensus-layer/getting-started/create-requests

Recommended Posts

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments