How a miner can verify, that a code was executed correctly ?

What if a miner fakes contract execution and sends money to himself ?
How other miners can verify if this block is a real or a fake one ?
Do they re-calculate all contracts for the last block to verify ?

Comments

  • JasperJasper Eindhoven, the NetherlandsMember Posts: 514 ✭✭✭
    Yes all full nodes do all storage and computation, it is the no.1 problem in cryptonomics.

    A block is valid if all transactions can be paid for. I.e. max gas × gasprice + sent value ≥ balance of sender for each transaction. After doing all the contract computation, you know where all the ethers went, so you know the balances.

    It sounds bad that everything needs to be stored, but that is what happens with bitcoin too.
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    1. Yeah sure you know the balances, but would you really go into the blockchain and check these balances?

    2. What if, for example, the computation screws up, sends money all over the place, but you have 5 thousand users and you cant independently verify all the transactions are right or have been sent to the right people. Is this a possible scenario?

    3. Faking the contract execution and just sending money to some believed addresses, is that possible as well?

    4. Is there another independent actor verifying that the contract is being executed properly? How is this sort of thing, if it exists, integrated into the mining or verification?

    Cheers

  • JasperJasper Eindhoven, the NetherlandsMember Posts: 514 ✭✭✭
    All full nodes are actors verify all contract execution. Every block has a Patricia trie root, which depends on all the states, the transactions in the block completely determine the next state, and full nodes only accept the block if the root indicated in said block is correct.

    If a miner does any of those things creating a block that is invalid, he just ends up wasting his mining power. If a full node does so, it has a different definition of validity, and won't find any high-difficulty blocks. Basically, trying to use different rules is like living in an alternate reality, one that the rule-following nodes dont care about. It is a waste of effort.

    Lightweight clients are possible btw, they can receive a proof about certain statement and use block difficulty as a proxy for validity. Because it is costly to mine invalid blocks, nevermind matching the real difficulty, also if you dont control the networking of the lightweight client, it might learn about the existence of a fork.
Sign In or Register to comment.