Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Ethereum 技術 FAQ

robkuo edited this page Aug 12, 2017 · 9 revisions

撰寫風格

發問者

  • 可直接編輯文章。

回答者

  • 這份清單設計給需要簡短回答某些常見問題的情境。
  • 因此撰寫時提供簡潔的答案,並提供較易閱讀的長文或原始出處。

現在以太幣的發行量有明確下來了嗎?

目前在Ethereum上有辦法做到offline transaction嗎? 如何在沒有網際網路下進行交易?

在播散的時候, Ethereum node 在接收到不同長度區塊鏈的情況, 怎樣確認其中ㄧ個是真的?並且接上自己原有的鏈?

比特幣有區塊容量 1 MB 限制, 以太坊的區塊容量是多大?

以太坊不用區塊容量做限制,而用瓦斯上限 (gas limit) 做限制。比特幣用容量做上限,可以避免網路節點所需要的儲存容量不會增長太快。在以太坊,則是比較擔心網路節點所需負擔的運算太多,因此用運算資源的單位瓦斯做限制。

注意,在以太坊提到瓦斯上限有兩個意思,一個是交易中的瓦斯上限,另一個才是這裡提到的區塊瓦斯上限。

詳細說明可見這篇: What is Gas Limit in Ethereum?

比特幣的交易平均需要 10 分鐘,以太坊平均 15 秒,為何差距這麼多?

在礦工產生區塊後,必須讓區塊有充分時間擴散到整個網路。否則若在 A 區塊還沒擴散到網路時, B 區塊就又已產生,競爭之下 A 或 B 區塊只有一個進到最長鏈。被放棄的其中一個區塊,內含的交易便因此不會發生。以太坊的協定中,獎勵礦工納入上一輪被丟失的區塊,因此交易不會丟失。

被丟失的區塊稱作孤塊 (Orphaned block),這些被納入的孤塊稱作叔塊 (Uncle block) ,這套獎勵機制名為 GHOST 演算法。

詳細說明: On Slow and Fast Block Times

比特幣的工作量證明,若某次區塊計算難度很高,有沒有可能找不到滿足目標難度 hash 值所對應的 nonce?

詳細問題敘述:比特幣的工作量證明(PoW)區塊裡,其 header 中的 nonce 欄位長度為 32 位元,能表示的最大無號數為 4294967296 ,若某次區塊計算難度很高,有沒有可能導致 header 加上所有 nonce 的嘗試都無法達到共識演算法所要求的特殊 hash ?

回答:不會的,此時程式會更改 header 中的其他欄位,例如 timestamp 會改為重新計算時當前的時間戳,或者修改區塊內的所有交易順序,導致 header 中的 merkle root 數值變動,如此就可以解決 nonce 嘗試數量不足的問題。

32 bits 的 nonce 用光了, nonce 還找不到 PoW 的解怎麼辦?

  1. 調整 coinbase 裡面的 nExtraNonce 欄位, 重新計算
  2. 調整 blocktimestamp, 重新計算
  3. 調整 tx_list 達到變動 merkle root's hash, 重新計算

Bitcoin Protocol 沒有硬性規定要怎麼做

What is the extranonce?

A solo miner increments Nonce until it overflows. Then it increments extraNonce and resets Nonce. extraNonce is located in the coinbase transaction, so changing it alters the Merkle root. extraNonce is reset based on the time.

example:

礦工獎勵來自 coinbase transaction, 而 a coinbase transaction, 長得像這樣

{
   ...
    "vin" : [
        {
            "coinbase" : "03443b0403858402062f503253482f",
            "sequence" : 4294967295
        }
    ],
   ...
}

coinbase 可以拆解如下

03 = push 3 bytes onto the stack
443b04 = 3 bytes pushed onto the stack <-- Block index
03 = push 3 bytes onto the stack
858402 = 3 bytes pushed onto the stack <-- The extranonce
06 = push 6 bytes onto the stack
2f503253482f = 6 bytes pushed onto the stack <-- arbitrary data

不過在每一版的 extranonce 都有變異, 所以要確認版號

原始碼參考: https://github.com/bitcoin/bitcoin/blob/00350bd6db91545c9d307733448af9432ee151c7/src/rpc/mining.cpp