Skip to content

Commit

Permalink
Update index.md
Browse files Browse the repository at this point in the history
Signed-off-by: Matt-RUN-CKB <matt@nervos.community>
  • Loading branch information
Matt-RUN-CKB authored Jul 12, 2024
1 parent b619376 commit 80168fc
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
title: 'The Difference Between Parallel and Sequential Transaction Execution in Crypto'
coverImage: 'images/image1.png'
category:
subtitle: ' The mechanisms that underpin transaction processing play a crucial role in defining the performance and scalability of blockchains.'
subtitle: ' The mechanisms that underpin transaction processing play a critical role in defining the performance and scalability of blockchains.'
date: '2024-07-05 T23:00:00.000Z'
author:
- github:explainCKBot
---

Two primary execution models—parallel and sequential—dictate how transactions are validated and appended to the blockchain. This article delves into these models, using Bitcoin and Ethereum as examples of parallel and sequential execution, respectively, and explores Solana's innovative approach to parallel processing.
Two primary execution models—parallel and sequential—dictate how transactions are validated and appended to the blockchain. This article examines these models, using Bitcoin and Ethereum as examples of parallel and sequential execution respectively, and explores Solana's innovative approach to parallel processing.


## **Blockchain Data Models: UTXOs vs. Accounts**
Expand Down Expand Up @@ -38,11 +38,17 @@ After this transaction, the original 1 BTC and 1.5 BTC UTXOs are "spent" (destro

The UTXO model's design in Bitcoin allows for several significant advantages, particularly in transaction processing, verification, and privacy.

First and foremost, the independence of UTXOs facilitates parallel processing. In Bitcoin, each UTXO can be considered a distinct unit of value, much like individual coins or bills in physical currency. Because these units are self-contained and do not depend on one another, multiple transactions involving different UTXOs can be processed simultaneously without conflicts. This capability enhances the network's overall capacity and efficiency, as it enables nodes to validate and add multiple transactions to the blockchain concurrently. This parallelism is a key factor in Bitcoin's ability to handle high volumes of transactions efficiently, even under significant network load.
First and foremost, the independence of UTXOs facilitates parallel processing. In Bitcoin, each UTXO can be considered a distinct unit of value, much like individual coins or bills in physical currency. Because these units are self-contained and do not depend on one another, multiple transactions involving different UTXOs can be processed simultaneously without conflicts.

Regarding verification, the UTXO model offers a streamlined process for nodes. When a node validates a transaction, it simply checks that the UTXOs being spent have not already been used in other transactions and are, therefore, still "unspent." This check is straightforward and requires nodes to verify only the validity of the UTXOs involved in the current transaction without needing to sift through the entire transaction history. This approach reduces the computational burden on the network and speeds up the transaction verification process, contributing to Bitcoin's robust and efficient transaction handling capabilities.
This capability enhances the network's overall capacity and efficiency, as it enables nodes to validate and add multiple transactions to the blockchain concurrently. This parallelism is a key factor in Bitcoin's ability to handle high volumes of transactions efficiently, even under significant network load.

Furthermore, the UTXO model provides substantial privacy and flexibility benefits for users. Because each UTXO is a separate unit, users have the ability to structure transactions in various ways to manage their funds. They can split larger UTXOs into smaller ones, merge smaller UTXOs into a larger amount, or even combine multiple UTXOs from different sources into a single transaction. This flexibility allows users to optimize how they handle their Bitcoin, whether for consolidating their holdings, facilitating smaller payments, or enhancing privacy. Each transaction can be designed to obscure the total amount and the flow of funds more effectively than with other models, thus offering users greater control over their transaction privacy.
Regarding verification, the UTXO model offers a streamlined process for nodes. When a node validates a transaction, it simply checks that the UTXOs being spent have not already been used in other transactions and are, therefore, still "unspent."

This check is straightforward and requires nodes to verify only the validity of the UTXOs involved in the current transaction without needing to sift through the entire transaction history. This approach reduces the computational burden on the network and speeds up the transaction verification process.

Furthermore, the UTXO model provides substantial privacy and flexibility benefits for users. Because each UTXO is a separate unit, users have the ability to structure transactions in various ways to manage their funds. They can split larger UTXOs into smaller ones, merge smaller UTXOs into a larger amount, or even combine multiple UTXOs from different sources into a single transaction.

This flexibility allows users to optimize how they handle their Bitcoin, whether for consolidating their holdings, facilitating smaller payments, or enhancing privacy. Each transaction can be designed to obscure the total amount and the flow of funds more effectively than with other models, thus offering users greater control over their transaction privacy.


### **Account-Based Model: Ethereum’s Execution Method**
Expand All @@ -51,9 +57,9 @@ In contrast to Bitcoin, Ethereum utilizes an account-based model, which can be c

Imagine you have a checking account at a bank. Your account has a balance, and every time you make a transaction—whether depositing, withdrawing, or transferring money—the bank updates your balance accordingly.

In Ethereum, each account behaves similarly. An Ethereum account has an Ether (ETH) balance, and transactions between accounts update these balances directly. For example, when Alice sends one ETH to Bob, Ethereum’s blockchain records this transaction by subtracting one ETH from Alice's account and adding one ETH to Bob's account, just as a bank would debit and credit two accounts.
In Ethereum, each account behaves similarly. An Ethereum account has an Ether (ETH) balance, and transactions between accounts update these balances directly. For example, when Alice sends 1 ETH to Bob, Ethereum’s blockchain records this transaction by subtracting 1 ETH from Alice's account and adding 1 ETH to Bob's account, just as a bank would debit and credit two accounts.

The simplicity of this model is apparent in how it directly adjusts account balances. When Alice’s transaction is processed, Ethereum's system ensures that her balance decreases by one ETH while Bob’s increases by the same amount. This straightforward updating mechanism facilitates easy balance tracking and enables complex interactions, such as those involving smart contracts, where the direct manipulation of account states is necessary.
The simplicity of this model is apparent in how it directly adjusts account balances. When Alice’s transaction is processed, Ethereum's system ensures that her balance decreases by 1 ETH while Bob’s increases by the same amount. This straightforward updating mechanism facilitates easy balance tracking and enables complex interactions, such as those involving smart contracts, where the direct manipulation of account states is necessary.

However, this model also makes it difficult to process many transactions in parallel. If multiple transactions were to modify the same account simultaneously, it could result in conflicts similar to what might happen if two clerks tried to update the same bank account at the same time without coordinating. One transaction might not correctly account for changes made by another, leading to errors such as double-spending or inaccurate balances.

Expand All @@ -77,15 +83,15 @@ To understand how Ethereum's sequential execution works, envision the network as
1. **Transaction Queue**: Users submit transactions to the Ethereum network, which are then placed in a so-called "mempool," where they await confirmation by miners or validators.
2. **Order of Processing**: Transactions in the mempool are typically prioritized based on factors like the transaction fees the sender offers. Miners select transactions from this pool, often starting with those that offer higher fees, and order them sequentially in the block they are mining.
3. **Validation and Execution**: Each transaction is picked from the block in the order it appears and then validated. Validation ensures the transaction adheres to the protocol rules, such as checking that the sender’s account has enough Ether to cover the transaction and fees.
4. **State Transition**: Upon validation, the transaction is executed. Execution involves updating the account balances and any relevant contract states. For example, if Alice transfers 2 Ether to Bob, Alice’s balance decreases by 2 Ether, and Bob’s balance increases by 2 Ether. If the transaction involves a smart contract, the contract’s state is updated accordingly.
4. **State Transition**: Upon validation, the transaction is executed. Execution involves updating the account balances and any relevant contract states. For example, if Alice transfers 2 ETH to Bob, Alice’s balance decreases by 2 ETH, and Bob’s balance increases by 2 ETH. If the transaction involves a smart contract, the contract’s state is updated accordingly.
5. **Updating the Global State**: After a transaction is executed, its effects are integrated into the current global state of the blockchain. This new state reflects all the cumulative changes brought about by all previous transactions in the block.
6. **Block Completion**: Once all transactions in the block have been validated and executed in sequence, the block is completed and proposed to the network. Other nodes then verify the block's transactions and the resulting state.
7. **Consensus and Finalization**: If the block is accepted by the network through the consensus mechanism (proof-of-work or proof-of-stake), it is added to the blockchain. This ensures that all nodes update their records to reflect the same global state.


### **Advantages of Sequential Execution**

The primary advantage of sequential execution is its simplicity and the ease with which it maintains a consistent and accurate state across the blockchain. By processing transactions one at a time, Ethereum can straightforwardly manage account balances and contract states, ensuring each transaction is valid and conflict-free.
The primary advantage of sequential execution is its simplicity and the ease with which it maintains a consistent and accurate state across the blockchain. By processing transactions one at a time, Ethereum can manage account balances and contract states in a straighforward way, ensuring each transaction is valid and conflict-free.

This approach is also well-suited to Ethereum’s support for smart contracts. These contracts can involve intricate and interdependent operations that require a consistent and ordered execution to function correctly. Sequential processing simplifies the implementation and verification of these contracts, making it easier to build and deploy complex decentralized applications (dApps).

Expand Down

0 comments on commit 80168fc

Please sign in to comment.