Settings

以太坊 The Merge 合併之技術面懶人包 (2022-04 version)

A Brief Technical Summary of The Merge Upgrade on Ethereum



Hsiao-Wei Wang

GitHub @hwwhww | Twitter @icebearhww

Ethereum Foundation | Researcher

2022-04-11 Taipei Ethereum Meetup


Abstract

萬眾期待以太坊的共識演算法主網大升級,隨著近期的規格書與程式碼迭代、測試鏈如火如荼展開,今年有高機率主鏈會有一次大改版。
以下介紹以太坊合併協議、客戶端(client)技術架構以及對以太坊開發者有什麼影響。


所謂合併 The Merge

  1. 將以太坊的共識演算法(Consensus algorithm)從工作量證明(Proof-of-Work, PoW)切換到 權益證明(Proof-of-Stake, PoS)
  2. 將以太坊 EVM 主鏈 與 信標鏈(Beacon chain)合併
  3. 將未來以太坊系統分成 共識層(Consensus Layer) 以及 執行層(Execution Layer)

前情提要:信標鏈 Beacon Chain


Components


Execution Layer (EL) 執行層

目前的 PoW chain

Execution Layer 的 ExecutionPayload

Image: When Merge by Danny Ryan

Consensus Layer (CL) 共識層

合併後的 BeaconBlock

Image: When Merge by Danny Ryan

相關 APIs

Image: When Merge by Danny Ryan

Engine API usecase example

Created with Raphaël 2.2.0CLCLELELBeacon block B arrivesengine_newPayload(B.payload)B.payload validationPayloadStatus: VALIDB becomes the headengine_forkchoiceUpdated(forkchoiceState, payloadAttributes)PayloadStatus: VALID

EL/CL Separation

EL CL
主要功能 執行 EVM Proof-of-Stake 共識
Fork choice rule 由 CL 告知 head block LMD-Ghost
EVM transaction pool 不變 N/A
Networking 以 devp2p 和其他 EL 節點連線 以 libp2p 和其他 CL 節點連線
Network serialization RLP SSZ
Endianness Big-endian Little-endian
Identity of “block” Execution block header keccak256 hash Beacon block SSZ root

協議如何決定何時觸發合併? (1/2)


協議如何決定何時觸發合併? (2/2)


Merge Transition

Image: When Merge by Danny Ryan

相關規格及文件


對以太坊應用層的影響

1. EVM

Ref: How The Merge Impacts Ethereum’s Application Layer

2. Block time 區塊時間


3. Finality 最終確定性


4. Safe Head

Block Type Consensus Mechanism JSON-RPC Conditions for reorg
head Proof of Work latest reorg 的發生是可預期的,要謹慎使用
safe head Proof of Stake safe 有可能發生,可能是來自大規模的網路延遲或是攻擊
confirmed Proof of Work N/A 不太可能,需要多數的 hashrate 參與挖一條長度大於特定確認數的鏈
finalized Proof of Stake finalized 極不可能,需要大於 2/3 的驗證者參與競爭鏈且至少 1/3 的驗證者會被處以罰金(slashed)

近期開發進度 (2022年4月)


其他 “longer-term extras”

Image: roadmap diagram by Vitalik Buterin

Post-merge 硬分岔


Single secret leader election (SSLE)


Single slot finality


Better signature aggregation


補充資料


Thank you!

🐼