In the current blockchain world, there are two main record-keeping modes, THE Unspent Transaction Output mode and the Account mode. Bitcoin uses the UTXO model, Ethereum uses the Account model, and CITA uses the Account model.

Bitcoin was originally designed as a peer-to-peer electronic cash system. In Bitcoin, each transaction consumes the UTXOs generated by previous transactions and generates new UTXOs. The account balance is the set of all unspent UTXOs belonging to that address. Ethereum aims to create a more general protocol that supports a Turing-complete programming language on which users can write smart contracts to create a variety of decentralized applications. Due to the UTXO model’s shortcomings in state preservation and programmability, Ethereum introduced the Account model. Let’s expand on the advantages and disadvantages of the two models.

UTXO model?

In the UTXO model, a transaction simply represents a change to the UTXO set. While the concepts of account and balance are higher abstractions on UTXO collections, the concepts of account and balance exist only in wallets.

Advantages:

  1. The calculation is off the chain, and the transaction itself is both the result and the proof. Nodes only do validation, no additional computation of transactions is required, and no additional state storage is required. The computation of the output UTXO of the transaction itself is done in the wallet, so the computation burden of the transaction is completely borne by the wallet, reducing the burden of the chain to some extent.

  2. Except for Coinbase transactions, the Input of a transaction is always linked after a UTXO. Transactions cannot be replayed, the order and dependencies of transactions can be easily verified, and whether transactions were consumed or not can be proved.

  3. The UTXO model is stateless and easier to process concurrently.

  4. For P2SH type transactions, there is greater privacy. Inputs in transactions are unrelated, and a technique like CoinJoin can be used to add some privacy.

Disadvantages:

  1. Unable to achieve some more complex logic, poor programmability. For complex logic or contracts that require state preservation, implementation is difficult and state space utilization is low.

  2. Witness scripts also increase when Input is large. The signature itself consumes CPU and storage space.

ACCOUNT model

As for the Account model, the Account model keeps the world state, and the chain state is generally agreed in the block in the form of StateRoot and ReceiptRoot. A transaction is only the event itself, not the result, and the consensus of the transaction and the consensus of the state are essentially separable.

Advantages:

  1. Contracts are stored in code in an Account, and the Account has its own state. This model is more programmable, easier for developers to understand, and has a wider range of scenarios.

  2. The cost of bulk trading is lower. Imagine that the mining pool pays the handling fee to the miners. In UTXO, because each Input and Out requires separate Witness script or Locking script, the transaction itself will be very large, and the signature verification and transaction storage will consume precious resources on the chain. The Account model can greatly reduce the cost through contract.

Disadvantages:

  1. There are no dependencies between Account model transactions and replay issues need to be addressed.

  2. For the realization of lightning network/lightning network, Plasma, etc., more complex Proof Proof mechanism is needed for user Proof Proof, and more complex protocols are needed for state transfer from sub-chain to main chain.

UTXO VS ACCOUNT

For the above advantages and disadvantages, let’s do some analysis and comparison.

First, the problem of calculation.

UTXO transaction itself does not have complex calculation for blockchain, so such a simple statement is not completely accurate, for two reasons. First, Bitcoin transaction is mostly P2SH, and Witness Script is non-Turing-complete, and there is no loop statement. For the Account model, such as Ethereum, because the computation is mostly on the chain and is Turing complete, the general calculation is more complex, and the security of the contract is likely to become a big problem. Of course, turing-complete is not directly related to the account model. But with the introduction of the account model, the fact that a contract can exist as a separate entity beyond anyone’s control is significant.

Second, there is the issue of UTXO’s greater concurrency.

In the UTXO model, the state of the world is a set of UTXOs. Nodes need to store all the indexes of UTXOs in memory in order to verify transactions faster, so UTXOs are very expensive. A UTXO that is not consumed for a long time occupies the memory of the node. Therefore, for this model, users should be encouraged to produce less UTXO and consume more UTXO in theory. However, if utXOs are used for parallel transactions, more UTXOs are needed as input and more UTXOs are generated to ensure concurrency, which is essentially a dust attack on the network. And because transactions are constructed within the wallet, a more complex design of the wallet is required. In contrast to the Account model, each Account can be regarded as a separate, non-affecting state machine, and the accounts communicate with each other through messages. So in theory, when a user initiates multiple transactions, it’s perfectly possible to execute them concurrently when they don’t call each other on the same Account.

Third, the transaction replay of Account model.

Ethereum uses the method of adding nonce to the Account, one for each transaction, with the nonce incrementing each time. This approach, while intended to solve the replay problem, introduces sequential problems and makes transactions impossible to be done in parallel. In Ethereum, for example, users send multiple transactions, and if the first transaction fails to be packaged, subsequent transactions will fail to be packaged. In CITA, we use the scheme of random Nonce, so that there is no sequential dependence between users’ transactions, so that serial failure will not be caused, and the transaction can be processed in parallel.

Fourth, storage.

Because in the UTXO model, state can only be saved in a transaction. The state of the Account model is stored on nodes, MPT in Ethereum, and consensus StateRoot in blocks. In this way, for on-chain data, the Account model is actually smaller, the amount of network transmission is smaller, and the state is saved locally by MPT on the node, which is also more efficient in space use. For example, A transfers money to B. If two inputs and two outputs are assumed in UTXO, two Witness scripts and two Locking scripts are required. In the Account model, only a signature is required and the transaction content only contains the amount. The amount of Bitcoin transaction data is also significantly reduced with the latest isolated Witness implementation, but in practice transfers and validations against Witness Script are still required for both validation nodes and full nodes.

Fifth, UTXO is more complex for light nodes to obtain an address state.

For example, in the wallet, it is necessary to request all UTXOs of a certain address from the full node, and the full node can send some UTXOs. It is difficult for the wallet to verify whether the UTXOs have been consumed, and it is difficult for the wallet to prove that the UTXOs are the complete set rather than the partial set. However, the Account model is much simpler. The corresponding State in the State can be found according to the address, and the State Proof of the current State can prove the authenticity of the contract data. Of course, UTXO root can also be verified in each block, which is related to the current Bitcoin implementation and not a feature of UTXO.

conclusion

To sum up, Account model has more advantages in programmability and flexibility. UTXO has its unique and pioneering advantages in simple business and cross-chain. The choice of model should be based on the specific business scenario.

reference

[1] : Thoughts on UTXOs by Vitalik Buterin

[2] : What are the pros and cons of Ethereum balances vs. UTXOs?

[3] : Mastering Bitcoin 2nd Edition — Programming the Open Blockchain

[4] : Accounts and not UTXOs

[5] : What is the function of a nonce in a transaction?

[6] : Why is evM-on-plasma hard?

Author: Zhang Yaning

Source: Ethereum enthusiast, original link (ethfans.org/posts/compa…)