2

For what I understand unlike with bitcoin, the ethereum network has some kind of state, and all the virtual machine bytecode does is to execute some commands to create transitions between these states.

But does it mean that when I start a full node from scratch it will have to essentially re-run all code specified by all smart contracts published ever?

2 Answers 2

5

Sync is a key point in Etehreum blockchain. The goal is to defined the current state of block i. 2 ways are possible: - archive mode: geth downloads all the bloc since the genesis block and define the state of all the blocks. You'll be able to have the balance of a specific account at any time in the history of the blockchain. - fast mode: geth downloads all the headers of the blocks and set a pivot point (1500 blocks in the past from now), a specific block in the past. Starting from this specific block, it downloads the entire state of the blockchain up to now.

4
  • 1
    Ok I think I get the difference. So I guess it would be safe to say that in the fast mode only those transactions sent after that pivot pint would actually be executed by my node. On the other hand when syncing in the archive mode my node is actually executing everything that happened since the genesis block. Am I right?
    – Bilthon
    Commented Jun 11, 2016 at 23:04
  • 1
    Yes, that's it.
    – yoregis
    Commented Jun 12, 2016 at 7:56
  • Is it true if this is not a mining node ? Commented Jun 12, 2016 at 14:25
  • I think so, mining is just an option you can activate, or not.
    – yoregis
    Commented Jun 12, 2016 at 14:58
1

While you are syncing, your client does many things but essentially it downloads & shares blocks and it also validates blocks. To validate a block, the client essentially executes locally all the transactions declared in the block and check the result. If the result is equal to the state of the received block (the hash matches, and so on) then the block is validated and the client go forward.

Because of this, a node actually executes a contract code only if in that block there are transactions that are contract calls (both creation and method calls).

So it's not the EVM that executes code to generate transactions, but on the contrary, the EVM manages all transactions sent by clients to be mined by a miner and all transactions already present into a block to validate it.

3
  • Your answer is confusing and somewhat contradictory. Because if you extend what you said here: "to validate a block, the client essentially executes locally all the transactions declared in the block and check the result." to all blocks in the chain, then it would seem that you're answering my question with a YES. But then on your last paragraph you say that "it's not the EVM that executes code to generate transactions". Which is not what I said to begin with, and seems to contradict the answer I extract from your first paragraph.
    – Bilthon
    Commented Jun 11, 2016 at 23:00
  • Sorry, probably sometimes I mess a bit with English. You asked "when I start a full node from scratch it will have to essentially re-run all code specified by all smart contracts published ever?" The answer is NO. During block validation, the code specified inside the smart contract is executed ONLY when a transaction involving that contract is present inside that block. So the node will execute all the contract creation transactions? YES. The node will execute all the contract code? NO. Commented Jun 11, 2016 at 23:09
  • Ok, I see what you mean now. If a contract has methods that were never called, then those methods will not have to be executed. I understand that, I guess I should re-phrase the question to to say something like "re-run all previously executed code".
    – Bilthon
    Commented Jun 12, 2016 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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