首页 > 世链号 > 深度 |《Wisdom Chain文档知识库》之账户模型
链趣  

深度 |《Wisdom Chain文档知识库》之账户模型

摘要: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

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
 

 

 

关注Wisdom Chain动态

  • Twitter:@Wisdom_Chain
  • 微博:WisdomChain
  • 知乎:智慧链技术社区
  • Facebook:WisdomChain
  • Telegram:@WisdomPublicChain

 

 

相关资源

https://docs.wisdchain.com/#/
https://wisdchain.io/
http://tech.wisdchain.io/

https://github.com/WisedomChainGroup

https://scan.wisdchain.com
 
  • WIsdom Chain公链文档知识库:
  • Wisdom Chain官网:
  • Wisdom Chain技术论坛:
  • Wisdom Chain开源代码库:
  • Wisdom Chain区块浏览器:
 
Tags:
免责声明
世链财经作为开放的信息发布平台,所有资讯仅代表作者个人观点,与世链财经无关。如文章、图片、音频或视频出现侵权、违规及其他不当言论,请提供相关材料,发送到:2785592653@qq.com。
风险提示:本站所提供的资讯不代表任何投资暗示。投资有风险,入市须谨慎。
世链粉丝群:提供最新热点新闻,空投糖果、红包等福利,微信:juu3644。