6

How are contracts executed on full nodes?

Do they run one by one on first-in first-served basis, or simultaneously in the isolated environments? If they run in parallel, I guess it may exhaust the resources quite quickly.

If they run in isolated sandboxes, is the stored data isolated as well? If so, how are data modifications shared among them, or they're not?

9

When a node is validating a block, transactions are executed sequentially, in the order specified by the block; this is necessary, since a block might contain multiple transactions that call the same contract, and the contract's execution might depend on state modified by previous callers.

When a miner is mining a block, it chooses which transactions to include and in what order; they're still executed sequentially as above.

Each contract runs in its own instance of the EVM; it has access only to the input data, its own storage, and various blockchain data (such as code of other contracts, and recent block hashes). It can also call out to other contracts. A contract can't directly access another contract's storage.

  • Note that the other contract that can be called from the currently mined contract have to be validated on the chain already. – Nicolas Massart May 20 '16 at 17:21

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.