When a miner evaluate operations on VM there might be a case when there is not enough gas to fulfill operation.

In such cases

"The miner will stop processing the transaction, revert any changes it made, but still include it in the blockchain as a "failed transaction", collecting the fees for it. This may seem harsh, but when you realise that the real work for the miner was in performing the computation, you can see that they will never get those resources back either. So it's only fair that you pay them for the work they did, even though your badly designed transaction ran out of gas."

Suppose there is a fraud miner who does not execute operations at all but marks any transaction as failed and takes all the gas.

What stops the miners from such behavior? Mining is faster (because no operations are executed at all), fraud miner took all the gas (and ether).

Could somebody explain or show a place in the docs or client where the case is prevented?

2 Answers 2


All nodes on the network execute all contract operations in each block to verify that the miner did it correctly.

If miners transmit a block where they did something like you described, it will be considered invalid by all nodes who receive it. They will ignore it and they will not relay it to other nodes. They may even break their connection to the miner and temporarily locally ban their IP.

There isn't a page in the docs about this specific case, because it is part of the general case of invalid blocks. The mechanisms that deal with this are the same ones for when:

  • A miner tries to mint more Ether than is allowed

  • A miner tries to mine an invalid transaction

  • A miner creates a larger block than is allowed

  • A miner transmits a block with an invalid hash

  • etc... (any case in which a block is invalid under the consensus rules)

  • How to verify the particular case? Rerun all the operations? What happens if there are multiple such fraud nodes?
    – StanislavL
    Dec 22, 2017 at 5:50
  • @StanislavL The nodes receiving a block always run all the operations themselves to verify that they were done correctly. If there are multiple 'fraud nodes' then nodes will simply receive more invalid blocks. The fact that there are many of them doesn't change the fact that they are invalid and will be rejected. If the 'fraud nodes' start cooperating, they can hardfork the blockchain and mine their own fork. Normal nodes will still reject this fork, even if it has more hash power, because the blocks in it are invalid. Invalid blocks are always rejected by normal nodes.
    – Jesbus
    Dec 22, 2017 at 11:12

Because Ethereum contracts are deterministic, that means that all miners (and non-mining nodes) can perform the exact same steps as the "winning" miner was supposed to. Thus, when a miner submits a block, every other properly-functioning node checks that the miner adhered to the rules governing the Ethereum blockchain/protocol. The fact that Ethereum contracts are deterministic enable all this to happen. This is a reason, for example, that Ethereum cannot have random numbers as part of the virtual machine.

If a miner fails to follow the rules the result is a block that may not be accepted (in the case that you described, it shall not be accepted because everyone else sees the transaction should not have run out of gas) by the rest of the network: the node is marked as invalid.

In the real world, most people agree that US dollar bills have value and that Monopoly money has very little value. A malicious (but very bad) counterfeiter could try to pass off Monopoly money as real money. Right now, normal people would reject the Monopoly money as payment for goods and services. But if the world were suddenly taken over by Parker Brothers (51% attack), the norm might be Monopoly money and US dollars would have no value. Similarly, on the blockchain, anyone trying to pass of Monopoly money (ether obtained by not following the Ethereum blockchain) would end up on their own hard-fork of the network. In the blockchain, the difference is that it is very easy to see when someone is counterfeiting.

Some of the rules for consensus are described in the Ethereum Yellow Paper. See section 2. These rules are also the same one that stop a miner from submitting a random nonce and claiming a block reward for doing no work: if other people do the same work and arrive at a different answer from the miner (or an answer that violates the protocol), the block is rejected.

  • Submitting a random nonce case is easy to check but for the case I described how to confirm/reject this? Recalculate the same operations? But something could change e.g. size/values of the storage of contract or date or oracle results or something else. How to distinguish properly executed operation when there is not enough gas and the non evaluated case?
    – StanislavL
    Dec 22, 2017 at 5:49
  • I'm not sure I understand your question. The malicious miner claims that block data B (transactions, nonce, etc., by following protocol rules) applied to the blockchain's state S at block N will result in state S' at block N + 1. To verify that the miner is honest, miners apply B to S and see if they also get S'. If not, they reject B as a solution to get to block N+1. If someone said "I bought a pencil on your behalf at Dollarama. Here's the receipt for $100", you could go to Dollarama and try to buy a pencil. If you found that it cost $1, you'd simply not reimburse the other person.
    – lungj
    Dec 22, 2017 at 6:06
  • So suppose I run transaction operations and somewhere in the mid e.g. 100th op I am run out of gas. Then I rollback all, mark the transaction as invalid and take all the gas and add a block with the info. Then another miner verify this - run the all same 100 operations for the second time and checks that 101th operation has no gas. Right?
    – StanislavL
    Dec 22, 2017 at 6:11
  • The honest node probably already did all that work for themselves; I'm guessing (but don't know) that nodes cache that kind of information. Also, IIRC, nodes can get blacklisted (at least by Parity) for behaving badly.
    – lungj
    Dec 22, 2017 at 6:25
  • Blacklisting for the question does not matter. Suppose some pool of miners uses the fraud node. They get pool of transactions, take all the gas without executing steps, mark all the transactions as invalid and use the gained ether. They are banned later but ether of the transactions are lost. What if the network has 51% of such nodes. It's just potential vulnerability and I'd like to know how the system is protected.
    – StanislavL
    Dec 22, 2017 at 6:42

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.