If I understand Ethereum correctly, the result of a transaction is known and verified by everyone because everyone runs the code using their own copy of the blockchain. If that is indeed the case, why is it that only the miner of a block gets the gas for the transactions in that block? I would understand if it was because of the resources they used to complete the proof of work, but if that were the case then the amount of gas would not depend on the VM instructions executed. I also have heard that the main purpose of gas is not so much to reward the miner as it is to provide mitigation and/or a disincentive to infinite loops and whatnot. In this case, I can see two scenarios:
- The cost of the gas far outweighs the resources needed to execute the code, i.e. it is only there as a protection from denial of service attacks, etc.
- The cost of gas is in fact proportional to the cost of running the code, and thus is also there to provide an incentive to the miner to run it.
If scenario 1 is accurate, wouldn't miners prioritize more CPU-intensive contracts in order to get the most gas, as opposed to prioritizing contracts with the highest cost per unit of gas?
If scenario 2 is accurate, what is the incentive for non-miners to run the code?