4

do smart contracts execute sequentially in each node or in parallel/simulteneously? across all nodes?

2nd question is - Does it execute on "ALL" nodes including Light nodes as well?

2 Answers2

2

1) Sequentially.

According to the order defined by the miner. Miners prefer to process transactions with higher fees first.

Once the block is mined, this order says forever. This order is called transaction index , or Position if you check it at Etherescan. Just note that Etherscan erroneously shows transactions in inverted order, the real order is backwards.

2) It executes on ALL nodes, but Light nodes do not process transactions.

Nulik
  • 4,061
  • 1
  • 18
  • 30
0

This how the flow of transaction would go

  1. Transaction would be sent to one of the nodes which then send it to other nodes in the network via flooding algorithm.
  2. Each node will validate the transaction and add them to their mempool
  3. Block Proposer ( miner (in case of PoW) or validators (in case of PoS)) would add these transactions to the block.
  4. In the case of PoW based block needs to be mined to add to the mainchain while in case of the PoS the validator of that slot will add to the mainchain.
  5. After a block is added successfully to the mainchain each node will update its mainchain and state according to block transactions.

Coming back to your question, Each node will be trying to update its state to keep up with the growing chain as they need to be updated to earn the valid rewards through mining. So each node will be executing these transactions parallely but the order in which the state changes is determined by the transaction order which is executed sequentially inorder have same state information across all the nodes.

No all nodes don't execute the transactions only full nodes need to execute these transactions as light nodes only need block header.