Ethereum - Transaction to Package Process Overview

Original address: https://www.cnblogs.com/qingpingseo/p/8875463.html

Can blockchain open the door to trust?

A friend asked me a question about Ethereum: How does Ethereum ensure the consistency of the execution results of transactions? To answer this question, take a look at the source code of Ethereum:

1
http: //www.300gu.com/supermarket.html  

Simply draw a diagram to describe the flow of Ethereum from a transaction to packaging:


1) TxPool receives a transaction from the network and sends a TxPreEvent event.

2) After receiving the TxPreEvent event, the worker calls update->commitTransactions to submit the currently received transaction.

3) The commitTransaction in the Work is responsible for calling the EVM virtual machine to execute the transaction, and returns the Receipt (execution list) of the transaction to the Work.

4) Miner calls commitNewWork of Work, selects a transaction from the transaction list, and assembles the block structure.

5) Work calls CpuAgent to complete POW workload proof (packaging).

6) Once the block is packaged successfully, the worker broadcasts the NewMinedBlockEvent event.

Answer the question: How does Ethereum ensure the consistency of the execution results of transactions?

After each transaction is executed in the EVM virtual machine, an "execution list" is generated. The "execution list" of all transactions in a block forms a Merkle-PatriciaTrie (MPT) tree. The root of the tree will be saved in the block header of the block. That is, logically, in a block, a transaction "execution list" is kept. In this way, all nodes can verify the "execution list" of these transactions, and update the status from these "execution lists".


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325444270&siteId=291194637