English
Wisdom Chian:AccountState
This article comes from the official Twitter of Wisdom Chain
URL:
https://twitter.com/Wisdom_Chain/status/1296335835500085248?s=20
In the current block chain world, there are mainly two ways of record preservation, UTXO mode and Account mode. Bitcoin adopts UTXO model, Ethereum/EOS adopts Account model, and WisdomChian also adopts Account model. Today we will explain in detail why WisdomChian also adopted the account model.
Before introducing the UTXO model and the Account balance model, we have to first introduce the most important concepts and data structures in their two or even all block chain applications, that is, Block. The block chain is actually made up of a list of growing chains, which contains many records, that is, blocks.
UTXO model
In the UTXO model, transactions only represent changes in the UTXO collection. The concept of accounts and balances is a higher abstraction on the UTXO collection. The concept of accounts and balances only exists in wallets. Let's look at some examples to understand the difference.
First, Bitcoin UTXO can not be partially expended. If a user wants to spend 0.5 Bitcoins, but he has 1 Bitcoins in his UTXO collection.He has to send half a Bitcoin to himself to get change at the same time as he sends half a Bitcoin to someone else. If he doesn't send it to himself, he will pay 0.5 Bitcoin to the miner.
Second, Bitcoin itself does not store account balances. Users only need to sign these UTXO with the private key to spend Bitcoins. The digital wallet makes the Bitcoin blockchain look like it has the function of user account balance. This is not the case.
How visual wallets work in Bitcoin
Bitcoin's UTXO system works well, partly because digital wallets can help to accomplish most of the work related to transactions. Including but not limited to:
a) Processing UTXO
b) Storage key
c) Set transaction costs
d) Provide change address
e) Aggregated UTXO (display available, pending and total balance)
Trading in the UTXO model is similar to paper currency. Each account shows how much money it has by calculating the sum of all the paper money (UTXO) in the wallet (corresponding to the wallet address). When we want to spend money, we need to use one or more UTXO with enough cost and we may get a new UTXO. Each UTXO can only be used once, because once UTXO is expended, it will be deleted from the UTXO pool.
All in all, we know that:
Bitcoin blockchain does not store account balance
Bitcoin Wallet Holds secret key
If it is included in the transaction, it will cost the entire UTXO (in some cases, the change is in the form of a new UTXO).
WisdomChain
WisdomChain adopts the same Account transaction structure as ETH. Unlike Ethernet, there are two very different data in Ethernet: permanent data and temporary data. An example of permanent data is a transaction, which, when fully confirmed, will be recorded in the transactiontrie and will never change. An example of temporary data is the balance on a specific Ethereum account address. The balance of the account address is stored in statetrie and will be changed whenever the transaction of the particular account changes. In Ethereum, permanent data (such as mined transactions) and temporary data (such as account balances) are stored separately. Ethereum uses trie data structure to manage data.
And about WisdomChain, when the transaction is initiated, the node will calculate the status information after transaction based on the current state information and transaction content in the virtual machine, and store the relevant hash value of the state information along with the transaction. When the transaction is packaged by a miner, the remaining nodes store data on the Merkletrees to ensure that the state information of their nodes and other nodes in the network is consistent.
So WisdomChain's records are kept like banks. Similar to using ATM / debit cards, banks track the amount of each debit card. When we need to spend money, the bank checks its records to make sure we have enough balance before confirming the transaction.
Of course, WisdomChain uses the Account transaction structure, which inevitably leads to the problems of the Account transaction structure itself. First, there is no dependency between Account model transactions, so the problem of replay attacks needs to be solved. Second, for the realization of lightning network, Plasma and so on, users need more complex Proof mechanism to produce evidence. The state transfer of sub chains to the main chain requires more complicated protocols.
簡體中文
本文來自Wisdom Chain官方Twitter
URL:
https://twitter.com/Wisdom_Chain/status/1296335835500085248?s=20
在當前區塊鏈世界中,主要有兩種記錄保存方式,UTXO模式UnspentTransactionOutput和Account模式。Bitcoin采用的是UTXO模型,Ethereum/EOS采用的是Account模型,同樣Wisdom Chian也采用了Account模型。今天我么將詳細講述為什么Wisdom Chian也采用了Account模型。
在具體介紹UTXO模型和賬戶余額模型之前,我們不得不首先介紹它們兩者、甚至所有區塊鏈應用中最重要的概念和資料結構,也就是區塊(Block)。區塊鏈其實就是由一個長度不斷增長的鏈表組成的,其中包含了很多記錄,也就是區塊。
上圖的區塊鏈網路中,實線的區塊都被包含在主鏈中,所有虛線的區塊都是孤塊(OrphanBlock),它們沒有被主鏈接受,在每一個區塊鏈網路中只能有一條主鏈,也就是最長的有效鏈,也是當前區塊鏈網路中所有節點達成的共識。
位元幣的設計初衷是點對點的電子現金系統,在位元幣的世界中,每筆交易都是在消耗之前交易生成的UTXO,然后生成新的UTXO,賬戶的余額其實就是這個屬于這個地址所有未花費的UTXO集合。而以太坊意在建立一個更為通用的協議,該協議支持圖靈完備的編程語言,在此協議上用戶可以撰寫智能合約,創建各種去中心化的應用,因此以太坊引入了Account模型。
圖靈完備意味著你的語言可以做到能夠用圖靈機能做到的所有事情,可以解決所有的可計算問題,但是圖靈完備就意味有潛在風險。
UTXO模型
UTXO模型中,交易只是代表了UTXO集合的變更。而賬戶和余額的概念是在UTXO集合上更高的抽象,賬號和余額的概念只存在于錢包中。讓我們看一些例子來理解其中差異。
首先,位元幣UTXO不能被部分花費。如果一個用戶想花0.5位元幣,然而他UTXO集合中有1位元幣,他必須在發給別人0.5位元幣的同時發送給自己0.5位元幣來找零。如果他不發送給自己,那么他將付0.5位元幣給礦工。
其次,位元幣本身不會存盤賬戶余額。用戶只需用私鑰簽名這些UTXO即可花費位元幣。數字錢包使位元幣區塊鏈看起來像是具備用戶帳戶余額等功能。事實卻并非如此。
可視化錢包如何在位元幣中作業
位元幣的UTXO系統運行良好,部分原因是數字錢包能夠幫助完成與交易相關的大多數作業。包括但不僅限于:
a)處理UTXO
b)存盤密鑰
c)設定交易費用
d)提供找零地址
e)聚合UTXO(顯示可用,待定和總余額)
在UTXO模型中交易類似于紙幣。每個帳戶通過計算錢包(對應錢包地址)中所有紙幣(UTXO)的和來表示其擁有多少錢。當我們想要花錢時,需要使用掉包含足夠費用的一個或多個UTXO并可能收到找零(新的UTXO)。每個UTXO只能花費一次,因為一旦UTXO被花費就會從UTXO池中被洗掉。
總而言之,我們知道:
位元幣區塊鏈不存盤賬戶余額
位元幣錢包持有秘鑰
如果包含在交易中,則會花費整個UTXO(在某些情況下,找零以全新UTXO形式存在)
Wisdom Chain
Wisdom Chain采用了和ETH同樣的Account交易結構,不同于以太坊的是,以太坊中有兩種截然不同的資料;永久資料和臨時資料。永久資料的例子是交易,交易被完全確認后將被記錄在transactiontrie,也將絕不會改變。臨時資料的例子是特定以太坊帳戶地址上的余額。帳戶地址的余額存盤在statetrie中并且每當該特定帳戶的交易改變時就會被更改。在以太坊中,永久資料(如被挖礦的交易)和臨時資料(如帳戶余額)被單獨存盤。以太坊使用trie資料結構來管理資料。
而Wisdom Chain當交易發起時,節點將會在虛擬機中根據目前狀態資訊和交易內容計算交易后狀態資訊,儲存在本地的同時將狀態資訊的相關哈希值隨交易一同發出。當交易被礦工打包入區塊以后,其余節點將資料保存在Merkletrees上,確保自身節點和網路中其他節點的狀態資訊一致。
因此Wisdom Chain的記錄保存就像銀行一樣。類似于使用ATM/借記卡,銀行跟蹤每張借記卡的金額。當我們需要花錢時,銀行會檢查其記錄以確保我們在確認交易前是否有足夠的余額。
當然Wisdom Chain在使用了Account交易結構,就不可避免了Account交易結構的本身的問題,一是Account模型交易之間沒有依賴性,需要解決重放攻擊(ReplayAttacks)的問題。二是對于實作閃電網路/雷電網路,Plasma等,用戶舉證需要更復雜的Proof證明機制,子鏈向主鏈進行狀態遷移需要更復雜的協議。
作者:Wisdom Chain 官方
翻譯:Diaos
責任編輯:sorafly
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/7277.html
標籤:區塊鏈技術
