EOS創(chuàng)始人BM:帶寬速率限制和存儲使用限制(第二篇)

For example, Alice may run her transfer from her alice account to the bob account in the simulated node and determine that the only scopes required are {alice, bob} since the bob account already has a currency balance. But between broadcasting her transfer transaction and having it processed by a block producer, Bob may have sent his entire currency balance to someone else. If the currency contract was designed to free up database objects (for the sake of reclaiming memory) if an account's balance went to 0, then the bob account would not have a currency balance by the time Alice's transfer transaction was processed. Then when Alice's transfer transaction was actually being processed, it would be rejected because EOS.IO would determine that the memory usage of the currency contract needed to increase and yet the transaction had not declared currency as part of the scope.

例如,Alice可能會將她的Alice帳戶轉(zhuǎn)移到模擬節(jié)點中Bob的帳戶,并確定{Alice, Bob}成立,唯一的要求是Bob帳戶上有余額。但是,在廣播她的轉(zhuǎn)賬交易并由一個區(qū)塊打包的時候,Bob可能已經(jīng)將他的全部余額轉(zhuǎn)給別人了。如果貨幣合約設(shè)計為釋放數(shù)據(jù)庫對象(為了回收內(nèi)存),賬戶的余額變?yōu)?,那在Alice轉(zhuǎn)賬交易完成后,Bob賬戶上將沒有余額。到了Alice的轉(zhuǎn)賬交易實際上正在處理中的時候,它將會被拒絕。因為EOS.IO確定了合同的內(nèi)存使用內(nèi)容需要增加,但交易沒有收到currency,這會成為其中一部分的信息。


Perhaps the currency contract designer will choose to not remove database objects even if an account's balance goes to 0. In this case the required scope determined by the simulated node may be over-conservative (requiring the currency when it was actually not necessary by the time the transaction was processed), but it would be far less likely to lead to the poor user-experience of having a broadcast transaction unexpectedly fail due to missing scopes. So, in that case the currency contract designer would trade better user-experience forincreased memory usage(and therefore more EOS tokens locked).

也許貨幣合約設(shè)計者在賬戶的余額變?yōu)?的情況下,也不選擇刪除數(shù)據(jù)庫對象,這時模擬節(jié)點需要確定的范圍可能過于保守(要求currency在不是真的有必要的時候處理交易),但是由于范圍縮小,讓廣播失敗而引起差的用戶體驗反饋將會大大減少。因此,在這種情況下,貨幣合約設(shè)計者會迭代出更好的用戶體驗以增加內(nèi)存使用量(因此鎖定更多的EOS代幣)。


But the point is that this design of database memory usage limits requires contract developers to make these sorts of trade-offs. Also, the previous example only looked at a currency contract. Other contracts may have more difficulty avoiding memory usage changes with most of their transactions. For example, it is highly unlikely that most transactions for an exchange contract will lead to no net change in memory usage (bid/asks need to be created and zero or more of existing bids/asks may need to be removed as orders are filled). In the case of an exchange contract, this design adds no additional overhead because all the transactions require the exchange account in the scope anyway (bids/asks are stored within the database of the exchange account). But there may be many other contracts we have not thought of that will be burdened with much less concurrency (and thus less transaction throughput) because of this design of database memory usage limits.

但重要的是,這種數(shù)據(jù)庫內(nèi)存使用限制的設(shè)計,要求合同開發(fā)者需要權(quán)衡這些問題。另外,前面的示例只能查看貨幣合約,其他合約避免可能在大部分交易中的內(nèi)存使用變化時會遇到更多困難。例如,在交易合約中的大多數(shù)交易,都極不可能讓內(nèi)存使用情況沒有變化(需要創(chuàng)建出價/詢價,當(dāng)訂單被填滿時,可能需要刪除現(xiàn)有的出價/詢價) 。在交易合同的情況下,這種設(shè)計不會增加額外的開銷,因為所有的交易都需要交易賬戶在其數(shù)據(jù)庫中(出價/詢價將會被存儲在交易賬戶的數(shù)據(jù)庫中)。但是,由于這種數(shù)據(jù)庫內(nèi)存使用限制的設(shè)計,可能會有許多其他我們沒有想到的合約會被更少的并發(fā)性(以及更少的交易吞吐量)所拖累。

(本文未完待續(xù))

本文鏈接:https://github.com/EOSIO/eos/issues/353

翻譯:Lochaiching

校正:Sheldon

極客網(wǎng)企業(yè)會員

免責(zé)聲明:本網(wǎng)站內(nèi)容主要來自原創(chuàng)、合作伙伴供稿和第三方自媒體作者投稿,凡在本網(wǎng)站出現(xiàn)的信息,均僅供參考。本網(wǎng)站將盡力確保所提供信息的準(zhǔn)確性及可靠性,但不保證有關(guān)資料的準(zhǔn)確性及可靠性,讀者在使用前請進(jìn)一步核實,并對任何自主決定的行為負(fù)責(zé)。本網(wǎng)站對有關(guān)資料所引致的錯誤、不確或遺漏,概不負(fù)任何法律責(zé)任。任何單位或個人認(rèn)為本網(wǎng)站中的網(wǎng)頁或鏈接內(nèi)容可能涉嫌侵犯其知識產(chǎn)權(quán)或存在不實內(nèi)容時,應(yīng)及時向本網(wǎng)站提出書面權(quán)利通知或不實情況說明,并提供身份證明、權(quán)屬證明及詳細(xì)侵權(quán)或不實情況證明。本網(wǎng)站在收到上述法律文件后,將會依法盡快聯(lián)系相關(guān)文章源頭核實,溝通刪除相關(guān)內(nèi)容或斷開相關(guān)鏈接。

2018-03-02
EOS創(chuàng)始人BM:帶寬速率限制和存儲使用限制(第二篇)
For example, Alice may run her transfer from her alice account to the bob accoun

長按掃碼 閱讀全文