1

Given that a computer must execute in a sequence, I assume the VM is also doing so before deciding the final block state. Let's say my contract calls an external function from another contract that gives the state of a storage variable in that function. Assume the VM executes the instructions from that contract updating that variable first. Will my call to this external variable on the new block represent the old state it was in at the current block (soon to be previous block) or will it represent the state it is in at the very moment the new block is being created?

Ie: Whether this occurs through broadcast order, execution order etc is irrelevant, I'm only interested to know in what block the state is read.

1

The state that is read is the state of the current block. When a transaction is included in a block, all of the opcodes have already been processed and calculated, and it is simply a matter of accepting it on the blockchain. The state, therefore, is calculated from the current block, not the block that the transaction is included in.

  • Just some clarification please - Let's say an external contract with a variable C has two different callers A and B that can both manipulate C. A increments C by 1, whilst B increments C by 5. Will the final state of C in the new block be 6, or only one of these two states? If both are executed, what happens with contradictory functions eg: Say A self destructs the contract with their address, B self destructs the contract with their address instead? Wouldn't these states be inconsistent in the future block? – Ectogold Nov 16 '18 at 21:09

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.