Home > Blockchain >  UTXO account model and the advantages and disadvantages
UTXO account model and the advantages and disadvantages

Time:09-22

In the current block chain in the world, there are two main way of record keeping, UTXO mode (Unspent Transaction Output) and the Account mode, bitcoins USES is UTXO model, Ethereum Account model,

Bitcoins designed is point-to-point electronic cash system, in the currency, each transaction before consumption generated UTXO then generate new UTXO, the balance of accounts that all belong to the address not spend UTXO collection, the global state of bitcoins is the set of all current not spend UTXO, Ethereum intent to create a more general agreement, the agreement to support the Turing complete programming language, users can write intelligent contract on this agreement, create all kinds of the application of decentralization, because UTXO model in the state of the defect of the preservation and programmability, Ethereum Account model is introduced,

1. What is UTXO

In the currency, a deal "in the black box" is the way of the actual is: a collection of cost a thing, this thing is known as "the transaction output has not been spent" (namely "UTXO"), the output created by one or more before the exchange, and in making a pencil or pen more place new UTXO, can the trading costs in the future, every UTXO can be understood as a "coin (money)" : it has a face value, has an owner,

If a deal is to be effective, must meet two rules is:

1), the deal must contain a valid signature from the owner of it takes UTXO;

2) be UTXO total face value must be equal to or greater than UTXO total face value of the deal,

The balance of a user so is not stored as a number of; But with the sum of his possession UTXO calculated,

If a user wants to send a deal to send X a coin to a specific address, sometimes, they have some subset of UTXO combined value is X, in this case, they can create a deal: spend their UTXO and create a new value of X UTXO, occupied by the target address, when this perfect match is not possible, the user must be packaged and its value is greater than X UTXO input collection, and add a UTXO with the second destination address, called "change output", distribution of the remaining money to the address of a controlled by their own,

In addition to the "currency of network effects," we can put forward some technical claims for UTXO model; A particular proposition is: it allows trading of parallel processing, as a trading sender send two separate deal, they can take independent UTXO carefully, so any order can also be used to deal with such deals, invariance and the order can be parallelized attributes may benefits of extensibility, make a person's currency can be separated, there are also some benefits on privacy protection, in particular, when a user receives each UTXO using a different address, because the address of the private key can be exactly by the owner through a master seed generated; Although the privacy income is easy to break, if the user is not carefully to ensure his money from each other,

If privacy is a strong preference for funds provided by the UTXO separation is not enough for the task; This will require more complex construction such as Ring signature (Ring Signatures), extra Homomorphic Encryption (Homomorphic Value Encryption) and ZK - SNARKs,



2. The advantages and disadvantages of UTXO

UTXO model, the change in the trading just represents a collection UTXO, and is the concept of accounts and balances on UTXO set higher abstraction, account balance and the concept of exist only in the wallet,

Advantages:

Computing is outside the chain, transaction itself is the result proves that the nodes only do validation can, do not need additional calculation for the deal, and no additional state storage, the output of the transaction itself UTXO calculations are done in the wallet, this transaction computational burden borne by the purse, completely, to a certain extent reduce the burden of the chain,
Besides Coinbase trading transaction Input is always link behind a UTXO transaction cannot be replayed, and trading order and dependencies are easy to be verified, trade has been consumption is also easy to proof,
UTXO model are stateless, easier to concurrent processing,
For P2SH types of transactions, has better privacy, Input of transactions are mutually associated, you can use CoinJoin such technology, to increase some privacy,
Disadvantages:

Unable to implement some more complex logic, programmability is poor, for complex logic, or need to save the contract, implementation is difficult, and the state space utilization rate is low,
When the Input is large, to witness the script will also increase, and the signature itself is the consumption of CPU and storage space,


3. The advantages and disadvantages of ACCOUNT model

To Account model Account model to save the world state, the state of the chain in the blocks by StateRoot and ReceiptRoot form of consensus and trading is the event itself, does not contain a result, the trade state of consensus and the consensus of the essence can be isolated,



Advantages:

Contract in the form of code stored in the Account and the Account has its own state, this model has better programmability, easy to developers to understand the scene more widely,
Batch transaction cost is low, ore pool to pay the miners charges, UTXO because each Input and Out needs to be separate Witness script or Locking script, the deal itself will be very big, signature verification and trading storage needs to be valuable resource consumption chain, and the Account model can greatly reduce the cost, by means of contract
Disadvantages:

No dependencies between trading Account model, need to solve the problem of the replay,
For network/thunder lightning, Plasma, etc., the user need more complex Proof Proof mechanism of Proof, the substring to state transition to the main chain require more complex agreement,


4. UTXO VS ACCOUNT

For more than a few advantages and disadvantages, we do some analysis and comparison,

First, about the problem of calculation of,

UTXO transaction itself and no complex calculation for block chain, speak so simple actually not entirely accurate, reason has two, one is trading mostly P2SH bitcoins itself, and Witness the script is turing-complete, there is no loop statement, for the Account model, such as Ethereum, due to the calculation on the chain, and is turing-complete, general calculation is more complicated, at the same time contract security is likely to become a big problem, of course if turing-complete model is not directly related to whether Account, but after model into Account, contracts can be as a separate entity is not controlled by anybody, it is of great significance,

Second, about UTXO more concurrent,

In UTXO model, the state, which is a collection of UTXO nodes in order to validate transactions faster, need to be stored in the memory all the UTXO index, thus UTXO is very expensive, for long time, consumption of UTXO will always occupy the node's memory, so for this model, theoretical UTXO should encourage users to reduce production, consumption UTXO more, but if you want to use UTXO parallel trading requires more UTXO as input, at the same time, to produce more UTXO to ensure concurrency, it is essentially a dust of network attacks, and because the deal is the structure inside the wallet, so you need to purse more complex designs, in contrast, the Account model, each Account can be regarded as a separate each other state machine, communicate through messages between accounts, so in theory user initiated deals, when these transactions will not call each other between the same Account, the transaction is complete can execute concurrently,

Third, on the issue of the trading Account model replay,

Ethereum increase nonce ways used in the Account, corresponding to every transaction a nonce, nonce increments, although this way to solve the problem of the replay, but at the same time introduced the sequential problem, prevented trading in parallel at the same time, for example, in Ethereum users to send deals, if pack first deal fails, will cause the follow-on deals are packaged is not successful, we use the random nonce in CITA solution, so that users of trading between order depend on, don't cause series failure, while making trade has the potential of parallel processing,

Fourth, the storage problem,

Because UTXO model, the state can only be kept in A transaction, and Account model state is preserved in the node, using MPT in Ethereum stored, you just need to consensus StateRoot etc, in the Block such data for chain, Account model actually smaller, less the amount of network transmission, status in local node using MPT way, at the same time, also more efficient on space use, such as A to B transfer, if in UTXO suppose there are two Input and two Output, you need two Witness script and 2 Locking script; The Account in the model only need a signature, trading content contains only amount can, in the latest isolation Witness after implementation, the amount of transaction data of bitcoins also greatly reduced, but in fact to verify the node and all nodes need to Witness the script for transmission and verification,

Fifth, for the light node to obtain a certain address, UTXO more complex,

Wallet, for example, need all about a request to the node address all UTXO, all nodes can send partial UTXO, purse to verify whether this UTXO has been spending, has the certain difficulty, and it's hard to prove UTXO wallet is complete and is not part of the collection, and for the Account model is much simpler, according to the address to find corresponding State in the State, the current State of the State Proof can prove the authenticity of a contract data, of course for UTXO can also be validated in each block of UTXO root, it is associated with the current implementation of bitcoins, not UTXO characteristics,



5. Don't use UTXO reason

Is the core of opposition UTXO has the following two parts:

1) UTXO complexity is not necessary, and its complexity in the actual operation will be larger than in theory,

2) UTXO are stateless (stateless), therefore is not very good for issue than asset and save more complex applications, complex applications in general is a state, such as different types of intelligent contracts,

View the first claim, consider how you will implement a purse - especially UTXO mode, generate a trading function, this function is not only requires an account of the private key as input, and some trivial data, such as an orderly Numbers, rather than to the account of UTXO corpora, this function must also accept the collection, and to determine a value greater than the need as input, the output of the amount of subset in some cases, if there are multiple minimum subset, and will produce some cost to decide which subset of complex tasks,

In addition, if a purse really want from mentioned above, the parallelization UTXO benefit transaction processing properties, the wallet must be carefully cutting output "change" that the purse is always have more than one change of output can be used as a source of funds; If a wallet only one big change in the output control, always takes out a small amount to do the next payout, the whole thing into a continuous again, this is not a purely theoretical problem; Most COINS the wallet still can't make it optimization, compared with the accounts and continuous digital model, which in essence making it can be parallelized UTXO returns void,

In the case of the currency (realistically, any public chain is), the transaction cost per thousand bytes, while UTXO selection algorithm must be extra careful to optimize every UTXO long-term average trade consumption; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related