EIPs Explained

EIP-698 · Stagnant · Core · 2017-08-28

EIP-698: OPCODE 0x46 BLOCKREWARD

Proposed a BLOCKREWARD opcode at 0x46 that would let contracts read a block's total reward, for trust-minimized mining pools; it is Stagnant and 0x46 later went to CHAINID.

What problem does it solve?

Mining pools combine hash power and split block rewards among members. Common payout schemes include pay-per-share, proportional and pay-per-last-N-shares. All of them depend on B, the reward paid for a block. A pool that wants to run its payouts as a smart contract has no way to read B from inside the EVM. The pool has to supply the number itself, and members have to trust it.

The proposal also notes that block rewards were set to change over time (EIP-649 had just cut them). A hard-coded value in a contract would become wrong. It also suggests tokens "merge-mined" in proportion to block rewards as another use.

How it works

The 0x40 range of opcodes provides block information (BLOCKHASH, COINBASE, TIMESTAMP, NUMBER, DIFFICULTY, GASLIMIT at 0x40–0x45 at the time). EIP-698 adds the next slot:

Field Value
Opcode 0x46
Mnemonic BLOCKREWARD
Stack in / out 0 / 1
Gas G_base (2)
Returns The reward for a finalized block: base reward, uncle payments and gas fees

Clients that do not know the opcode would reject blocks that use it, so it would need a coordinated hard fork.

Sample code

How a pool contract might have used it (hypothetical; this opcode does not exist with this meaning):

// EVM assembly
BLOCKREWARD          // 0x46: push the block's reward (base + uncles + gas)
PUSH1 0x00
SSTORE               // record it for later payout calculations

Pay-per-share payout from the spec's rationale, as pseudocode:

B = block_reward() - pool_fee   # what BLOCKREWARD would have supplied
p = 1 / difficulty              # chance that one share is a real block
payout_per_share = B * p

Things to know

  • This proposal is Stagnant and was never adopted. No network ships a BLOCKREWARD opcode.
  • Opcode 0x46 was later assigned to CHAINID by EIP-1344 (Istanbul). A contract using 0x46 today gets the chain ID, not a reward.
  • The spec does not define exactly how gas fees and uncle rewards are measured for the "current" block, which is not finalized during execution. Implementations would have had to settle this.
  • After The Merge, Ethereum has no proof-of-work block reward. Validator rewards are paid on the consensus layer, so the original motivation no longer applies on mainnet.
  • See also EIP-858 for another reward-related proposal from the same period.

#opcode #evm #mining #rewards #stagnant

Details

Authors
Cody Burns <[email protected]>
Status
Stagnant
Type
Standards Track / Core
Created
2017-08-28

Machine-readable: Markdown · JSON