逐字逐句解讀 BM 最新發布的 EOSIO Dawn 4.0 版本介紹

資訊 Ivy 2018-07-24

It has been about 1 month since block.one released EOSIO Dawn 3.0. This past month our team has been focused on cleanup and stability of the EOSIO software. A big part of this work was moving toward a proof of concept for inter-blockchain communication.

距離 block.one 發佈 EOSIO Dawn 3.0已經一個月了。 在過去的一個月裡,我們的團隊一直專注在EOSIO軟件的優化和穩定性,這其中很大一部分工作是在證明鏈間通信的可行性。

Excluding merges, 43 authors have pushed 818 commits to github. This puts EOSIO in the top 8 most active c++ projects on github in the past month. As you can see a lot is happening

不將merge操作計算在內,共有43位開發者提交818個commit到項目的github倉庫。 這讓EOSIO成為過去一個月中github中最活躍的8個C++項目之一。 正如你所看到的,許多事情正在發生。

1.Now is now Now

2.New Market-Based RAM Allocation Model

3.Rise of Inter-Blockchain-Communication

4.Upgrade DPOS Last Irreversible Block .Algorithm

5.Name Squatting

6.Header-only Validation

7.Light Weight Producer Schedule Change Proofs

8.Refined Producer Pay Model

9. Producer Vote Decay

10.Exchange Integration Support

1.時間一致性

2.新的內存分配模型

3.鏈間通信

4.DPOS不可逆確認算法

5.賬戶命名

6.塊頭驗證

7.輕量級BP調度變化證明

8.精煉BP收益模型

9.投票權重衰減

10.集成交易所合約

時間一致性

One of the biggest changes in EOSIO Dawn 4.0 is that we have changed the definition of the current time from “time of head block” to “time of current block”. This change resolves a lot of corner-cases with time-based operations in the presence of missed blocks and enables much more accurate measuring of elapsed-time within smart contracts.

EOSIO Dawn 4.0最大的變化之一是我們已將當前時間的定義從“頭塊的時間”改為“當前區塊的時間”。 這種變化使得大量包含時間操作的案例可以在存在缺失區塊的情況下執行,並且更精確地計算智能合約的運行時間。

新的內存分配模型

In our testing we determined that how the EOSIO System Contract was allocating RAM (database space) to those who staked tokens would lead to shortages down the road. We switched to a market-based allocation approach using the Bancor algorithm.

Our math indicates that if 1TB of RAM was allocated on a pro-rata basis to token holders then the cost-per-byte would be $0.018 (assuming $20/token). The reality is that most token-holders don’t actually have an active need to use the RAM they might be entitled to; therefore, we are initially pricing RAM at $0.000018 per byte (assuming $20/token). New accounts require about 4KB of RAM which means they will cost about $0.10. As RAM is reserved the price will automatically increase so that the price approaches infinity before the system runs out of RAM.

Under the Dawn 3.0 system contract, you could only sell RAM for the price you paid. The goal was to disincentivize hoarding and speculation. The downside to this approach is that those who buy RAM cheaply have no financial incentive to free RAM for other users after it gets more congested. Under Dawn 4.0 the system contract now buys and sells RAM allocations at prevailing market prices. This may result in traders buying RAM today in anticipation of potential shortages tomorrow. Overall this will result in the market balancing the supply and demand for RAM over time.

Over time Moore’s law will allow block producers to upgrade to 4TB or even 16TB of RAM and this increase in supply will trickle into the the EOSIO RAM market lowering prices.

測試中我們發現了EOSIO系統合同分配RAM(數據庫空間)的方式會導致未來資源的短缺。我們改用了一種基於市場的分配方法,使用Bancor算法。

我們的計算表明,如果1TB RAM按比例分配給token持有者,那麼每字節的成本將是0.018美元(假設每個token20美元)。事實上,大多數token持有者實際上並不需要使用他們可能擁有的RAM;因此,我們最初對RAM的定價是每字節0.000018美元(假設每個token20美元)。創建一個新帳戶需要大約4KB的RAM,這意味著將花費約0.10美元。隨著RAM被分配,價格會自動增加,這樣在系統耗盡RAM之前價格就會接近無窮大。

在Dawn 3.0系統合約中,您只能以您支付的價格出售RAM。 目的是抑制囤積和投機。 這種方法的缺點那些廉價購買RAM的人在RAM變得更緊缺後,沒有為其他用戶騰出RAM的經濟激勵。在Dawn 4.0之下,系統合約現在以當前市場價格購買和銷售RAM分配。 這可能會導致交易商在預計明天可能出現短缺的情況下購買RAM。 總的來說,這將導致市場隨著時間的推移平衡RAM的供需。

隨著時間的推移,摩爾定律將允許超級節點升級到4TB甚至16TB的內存,並且這種供應增長將逐漸降低EOSIO RAM市場價格。

對智能合約開發者的影響

As a smart contract developer, RAM is a precious resource which is consumed by the database records you store. Due to the cost of RAM it will be important to minimize the amount of data that you store in the in-memory database and design your applications with the ability to free RAM after your users are done. For example, Steem only stores 1 weeks worth of content in RAM so that the total size doesn’t grow much over time.

作為一名智能合約開發者,RAM是一項寶貴的資源,數據庫記錄需要消耗RAM。考慮到RAM的成本,將存儲在內存數據庫中的數據量減到最小,並且設定你的應用程序在用戶使用完後釋放RAM將是非常重要的。例如,Steem僅在RAM中存儲了1周的內容,因此總體的量大小不會隨著時間增長而增長。

儘量遏制投機

Now that there is a RAM market, speculators may want to trade RAM price-volatility for profit. The EOSIO system contract makes RAM non-transferrable and charges a 1% fee on trades. The result of this fee is to offset the natural inflation of tokens by taking them out of the market. If annual trading volume of RAM equals the token supply then 100% of all block producer rewards will be covered by the RAM market fees.

那麼現在形成了一個RAM市場,投機者或許想要利用RAM價格的波動性獲取盈利。而 EOSIO 系統合約設定RAM不可轉讓,並收取1%的交易費用。這筆費用的結果是通過將其退出市場來抵消Token 的自然通貨膨脹。如果RAM的年度交易量等於 Token 供應量,則所有塊生產者獎勵的100%將由 RAM 市場費用支付。

鏈間通信

High performance blockchains need all data in RAM because the time to access disk will quickly drop transaction throughput to just a couple hundred transactions per second. In order to scale RAM usage we need multiple chains with independent memory regions running on independent hardware.

EOSIO block producers can operate many different chains that all use the same token for buying RAM and staking bandwidth. The producer elections will happen on the main chain and all related side-chains will be operated by the same set of producers. Each chain can have its own 1 TB+ of RAM and decentralized applications can send messages between chains with just a couple seconds of latency.

The price of RAM will be different on all chains which will inform DAPP developers where it is cheapest to operate.

高性能區塊鏈需要RAM中的所有數據,因為訪問磁盤的時間會使事務吞吐量迅速下降到幾百TPS。 為了擴展RAM使用量,我們需要在獨立硬件上運行獨立內存區域的多個鏈。

EOSIO區塊生產者可以運行許多不同的鏈,它們都使用相同的token來購買RAM和持有帶寬。超級節點選舉將在主鏈上進行,所有相關的側鏈將由同一組超級節點維護。 每個鏈可以擁有1 TB以上的RAM,DAPP可以在鏈間發送消息,僅需幾秒鐘的延遲。

RAM的價格在所有的鏈上都會有所不同,這會告訴DAPP開發者哪裡運行起來最便宜。

鏈間通信

Inter Blockchain Communication (IBC) involves both chains validating merkle proofs that are 1KB+ in size and involve dozens of cryptographic hash functions and/or 15+ signature verifications. In other words, the cost of validating a message from another chain is about 15x to 30x higher than the cost of validating normal transactions.

Fortunately, validating these proofs is trivial to parallelize as they do not depend upon blockchain state. A blockchain that only processed messages from other chains could easily consume 30 CPU cores while only sustaining a couple thousand transactions per second.

It is our belief that scaling via Inter Blockchain Communication will give almost unlimited scaling potential. This approach scales RAM, network, and CPU at the same time. Considering that signature verification, context-free-action validation and IBC proofs will already saturate most CPUs with high-single-threaded throughput, optimizing for multi-threaded WASM execution will likely be bottlenecked by other resource constraints.

Under EOSIO Dawn 3.0 we made a lot of design decisions around the potential for future multi-threaded WASM execution. Unfortunately, until you actually implement a full multi-threaded implementation it is impossible to know whether we have all the corner cases covered. This means that EOSIO Dawn 3.0 had a lot of architecture complexity that was not giving any immediate benefit.

We now believe that the path of upgrading from single-threaded to multi-threaded execution is to launch a new chain with multi-threaded support run by the same block producers and staking the same native tokens. This gives the new chain complete freedom to make design tweaks as necessary to support multi-threaded operation without risking an in-place upgrade to a live chain.

With this roadmap to parallelism we can simplify EOSIO 1.0 and optimize it for maximum single-threaded performance and ease-of-development. We anticipate that the single-threaded version of EOSIO may one day achieve 5,000–10,000 TPS. We also anticipate that many applications will prefer the many-chain approach to scaling as it will lower overall costs and scale faster.

鏈間通信(IBC)涉及到兩條鏈的merkle證明驗證,這些證明大小在1KB以上,還涉及數十個密碼散列函數以及15個以上的簽名驗證。換句話說,驗證來自另一個鏈的消息的成本比驗證正常事務的成本高出大約15到30倍。

幸運的是,驗證這些證明很容易並行化,因為它們不依賴於區塊鏈狀態。一條鏈僅僅只處理來自其他鏈的消息就很輕易需要消耗30核CPU,同時只能維持幾千TPS。

我們相信,通過鏈間通信的擴展,幾乎可以釋放無限的性能擴展潛能。這種方法同時擴展RAM、網絡和CPU。考慮到簽名驗證、無上下文操作驗證和IBC證明已經滿足了大多數CPU的高單線程吞吐量,對多線程WASM執行的優化可能會受到其他資源限制的阻礙。

在EOSIODaw3.0下,我們圍繞未來多線程WASM執行的潛力做出了許多設計決策。不幸的是,在您真正實現一個完整的多線程實現之前,不可能知道我們是否涵蓋了所有的個例。這意味著EOSIODaw3.0具有許多架構複雜性,而這些複雜性並沒有立即帶來任何好處。

我們現在認為,從單線程升級到多線程執行的途徑是啟動一個具有多線程支持的新鏈,由相同的區塊生產者運行,並使用相同的本地token。這使得新鏈可以完全自由地進行必要的設計調整,以支持多線程操作,而無需對現有活躍鏈進行就地升級。

通過這個並行性路線圖,我們可以簡化EOSIO 1.0並優化它以實現最高的單線程性能和易於開發。 我們預計EOSIO的單線程版本有一天可能達到5,000-10,000 TPS。 我們也預計,許多應用程序將更傾向於多鏈方法來擴展,因為它會降低總體成本並加快擴展。

DPOS不可逆確認算法

Those of you who have followed consensus algorithm debates may have heard that DPOS with the last irreversible block (LIB) algorithm (as it exists in Steem & BitShares) has the potential to fall out of consensus in certain extreme network connectivity disruptions. In the past I have dismissed this potential failure mode due to its purely theoretical nature and the relatively minimal costs and downtime. The LIB algorithm was just a metric, like the 6-block rule for Bitcoin. Pure DPOS always relied on longest-chain rule which will always reach eventual consensus. The LIB algorithm was a short-cut designed to optimize undo-history and give a confidence measure to exchanges.

EOSIO’s IBC algorithm depends upon the DPOS LIB in order to be certain of finality. The costs associated with a LIB failure and the difficulty in fixing it are much higher once you introduce IBC. Our team, specifically Bart and Arhag, have come up with an elegant improvement to the LIB algorithm which guarantees that it is impossible for two nodes to reach a different LIB without more than ⅓ of them being byzantine. Furthermore, it is possible to detect byzantine behavior of a single peer. Read more about it here.

It is the lack of finality of Bitcoin and Ethereum blocks that make inter blockchain communication with legacy chains difficult and/or very high latency. The new tweak to DPOS brings it up to a new level of byzantine fault-tolerant finality and robust in all network environments.

參與過共識算法討論的人可能聽說過,使用最後一個不可逆塊(LIB)算法(如 Steem&BitShares 中存在的算法)的DPOS在某些極端網絡連接中斷時有可能失去共識。在過去,由於其純粹的理論性質以及相對最低的成本和停機時間,我已經駁回了這種潛在的失敗模式。LIB算法只是一個度量標準,就像比特幣的6區塊規則。純粹的DPOS總是依賴最長鏈規則,這將永遠達到最終的一致。LIB算法是一種捷徑,旨在優化還原歷史併為交易提供可信度度量。

EOSIO的IBC算法依賴於DPOS LIB以確定最終結果。一旦你引入IBC,與LIB失敗相關的成本和修復它的難度都會變高。我們的團隊,特別是 Bart 和 Arhag,對LIB算法進行了優化改進,以保證不超過其中的1/3是拜占庭式的時,兩個節點不可能達到不同的LIB。此外,有可能檢測單個對等體的拜占庭行為。關於此的更多信息見:https://github.com/EOSIO/eos/issues/2718

比特幣和以太坊區塊的缺限導致區塊鏈與傳統鏈之間的溝通困難和/或非常高的延遲。對DPOS的新調整將其帶到全新的拜占庭容錯水平,並且在所有網絡環境中都具有強大的可靠性。

賬戶命名

Some users have expressed concern over the 12 character name limit imposed on EOSIO accounts. These 12 character names are derived from base-32 encoding of a 64 bit integer. The 64 bit integer is the native machine word size and is therefore very efficient. Within a transaction we refer to account names many times, (code, scope, permissions, etc), and our database indexes are also based around these 64 bit integers. Increasing the length of an account name would have far-reaching impact on performance and architecture.

That said, our vision for blockchains is to separate the concept of accounts from identity and to establish a dynamic on-chain mapping between account names and more readable display names.

It is best to view account names as license plates where users can pick vanity plates that are easier to remember. That said, the vast majority of people should be able to find an attractive 12-character (or less) name.

Due to the potential high-value of certain names, we believe that the EOSIO system should offer a dynamic pricing model for account names. Furthermore, the ability to namespace accounts such as *.com can provide an extra layer of security for users and/or groups.

Due to the limited development time between now and the release of version 1.0 of the EOSIO software, we are going to recommend that all account names be forced to 12 characters and not contain any ‘.’ characters. The community can then upgrade the system contract (without hard fork) once a viable pricing and anti-name-squatting policy is identified. We will likely provide a model similar to BitShares where account names are priced by length and character content.

一些用戶對EOSIO帳戶上的12個字符名稱限制表示擔憂。 這12個字符名稱是從64位整數的base-32編碼派生的。 64位整數是本地機器字大小,因此非常有效。 在一個事務中,我們多次引用帳戶名(代碼,範圍,權限等),而我們的數據庫索引也是以這些64位整數為基礎的。 增加帳戶名稱的長度將對性能和架構產生深遠影響。

也就是說,我們關於區塊鏈的願景是將帳戶的概念與身份分開,並在帳戶名稱和更易讀的顯示名稱之間建立動態鏈上映射。

最好將帳戶名稱視為牌照,用戶可以選擇容易記住的個性名稱。也就是說,絕大多數人應該能夠找到一個有吸引力的12個字符(或更少)的名字。

由於某些名稱潛在的高價值,我們認為EOSIO系統應為帳戶名稱提供動態定價模式。 此外,諸如* .com之類的命名空間帳戶的能力可以為用戶或者群體提供額外的安全保護。

由於從現在到EOSIO軟件1.0版的開發時間有限,我們將建議所有帳戶名都強制為12個字符,而不包含任何“.”字符。一旦確定了可行的定價和反名稱搶佔政策,社區就可以升級系統合約(不是通過硬分叉)。我們可能會提供一個類似於Bitshare的模式,其中帳戶名的定價是根據長度和字符內容。

塊頭驗證

On Steem, BitShares, and EOS Dawn 3.0 and earlier it was not possible to validate a block-header without applying the full block. With EOS Dawn 4.0 we now support header-only validation. This feature is the basis of light clients and IBC and also prevents a range of attack vectors while allowing blocks to propagate across the network without waiting for each node to do full verification.

The simplest form of IBC for high-frequency communication involves light clients processing all headers and then users providing simple merkle-proofs of actions relative to a known block.

在Steem, BitShares和 EOS Dawn 3.0以及更早的版本中,如果不使用整個區塊是不能驗證區塊頭的。在EOS Dawn 4.0中,我們支持了只需要對區塊頭進行驗證。這個功能是輕客戶端和鏈間通信的基礎,同時還可以阻止一系列攻擊媒介,同時無需等待每個節點進行全節點驗證的情況下,區塊數據也可以在網絡中傳播。

用於高頻通信的鏈間通信的最簡單的形式需要輕客戶端處理所有頭信息,然後用戶提供與已知區塊相關行為的最簡單的merkle證明。

區塊重構和應用結構

We spent significant time cleaning up the process by which blocks are built and applied. Under the new model a block is created with the same sequence of API calls that are used to apply the block. This ensures the same code-paths are followed and minimizes the potential for inconsistencies between what a producer thinks is valid and what a validator thinks is valid. This cleanup makes the process of applying the block as little more than a script that replays what the producer did.

我們花費了大量時間來優化區塊構建和應用的過程。在新的模型中,區塊由應用於該區塊的API序列創建。這樣做保證了遵循相同的代碼路徑,並且能夠最小化生產者和驗證者在確認是否有效時發生不一致性的可能。這次優化讓應用區塊的過程相當於是重新執行了生產者的腳本。

輕量級BP調度變化證明

As we were implementing the IBC proof-of-concept we realized that Dawn 3.0 had a few edge cases where simple signature proofs were impossible. We wanted to make light-weight sparse-header validation as simple as possible which necessitated a refactor of how blocks are signed.

在我們實施IBC概念驗證時,我們意識到Dawn 3.0有一些極端情況,在這些情況下簡單的簽名證明是不可能的。我們希望儘可能簡化輕量級稀疏頭驗證,這需要對區塊的簽名方式進行重構。

相關推薦

推薦中...