1

The transaction and smart contract code is re-run by every validating node upon receipt of the block. Wouldn't this occur a contract to run multiple times?

How does this execution work without duplicating the transactions in a contract?

2

You're right that each transaction is executed by every validating node. However, they don't do this sequentially like you suggest, but rather in parallel and independently from each other. All (honest) nodes start at the same pre-state and consequently arrive at the same post-state. That's why it's called validating--they validate that the result they get from their peers is correct.

  • I have another small clarification. On which node does the actual contract execute? Does this happen on all nodes locally? Or one node executes it and broadcasts the result? – Viduni Wickramarachchi Apr 24 '18 at 16:15
  • All validating nodes execute the transactions locally. They may send the result to light clients on request. Miners (who are validating nodes as well) broadcast the post-state root (a finger print of the result) which can then be checked against by other validating nodes. – Jannik Apr 24 '18 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.