changed 4 years ago
Linked with GitHub

Opcode changes during the eth1/eth2 merge

Background

Given that core consensus is changing during the eth1/eth2 merge, it's valuable to understand which eth1 opcodes might change in behavior.

This document covers all of the opcodes that will change along with thoughts about how they should change given contracts running on eth1.

DIFFICULTY

DIFFICULTY is meaningless after the merge as such a notion doesn't exist in proof of stake.

Fortunately, there aren't public contracts that utilize DIFFICULTY meaningfully (i.e. see this github search). It's largely used as a seed for randomness in old lottery-style contracts.

To keep these contracts functional, we can re-name opcode 0x44 from DIFFICULTY to RANDOM and use the randao seed of a block to generate its value. This would need to be passed to the eth1-engine via RPC.

COINBASE/NUMBER/TIMESTAMP/BLOCKHASH

Each of these 3 will be handled locally within the eth1-engine:

  • COINBASE will be configured during startup (as the block producer address)
  • TIMESTAMP will be system time when the eth1-evm is processing the block
  • NUMBER will be the continuation of eth1 block number (i.e. max_pow_block_num + slot)
  • BLOCKHASH will be available within the eth1-engine during construction

So there's no change in behavior to worry about.

Two nuances to be mindful of:

  • whether or not to include empty slots in the total block number
  • the fact that BLOCKHASH is often used as a source of randomness in eth1 contracts and is much easier to grind in eth2

GASLIMIT

GASLIMIT will now be decided on by validators or will be the gas limit defined in EIP1559 (initially 2 * gas_target) if that's implemented in time. This will need to be passed to the eth1-engine via RPC.

Select a repo