Ethereum Execution Layer Specification

1 year ago

tl;dr

  • EELS is an execution furniture notation implementation successful Python.
  • It's up to day with mainnet.
  • It fills tests, and passes existing ones.
  • There's an illustration of an EIP implemented successful EELS below.

Introduction

After much than a twelvemonth successful development, we're pleased to publically present the Ethereum Execution Layer Specification (affectionately known arsenic EELS.) EELS is simply a Python notation implementation of the halfway components of an Ethereum execution lawsuit focused connected readability and clarity. Intended arsenic a spiritual successor to the Yellow Paper that's much programmer affable and up-to-date with post-merge forks, EELS tin capable and execute authorities tests, travel mainnet1, and is simply a large spot to prototype caller EIPs.

EELS provides implicit snapshots of the protocol astatine each fork—including upcoming ones—making it overmuch easier to travel than EIPs (which lone suggest changes) and accumulation clients (which often premix aggregate forks successful the aforesaid codepath.)

History

Beginning successful 2021, arsenic a task of ConsenSys' Quilt squad and the Ethereum Foundation, the eth1.0-spec (as it was known then) was inspired by the sheer vexation of having to decipher the cryptic notation of the Yellow Paper (Figure 1) to recognize the circumstantial behaviour of an EVM instruction.

Screenshot of formulas 2, 3, and 4 from the Yellow Paper Figure 1. arcane runes describing the ground of the blockchain paradigm

Drawing connected the palmy Consensus Layer Specification, we acceptable retired to make a akin executable specification for the execution layer.

Present

Today, EELS is consumable arsenic a traditional Python repository and arsenic rendered documentation. It's inactive a spot unsmooth astir the edges, and doesn't supply overmuch successful the mode of annotations oregon English explanations for what assorted pieces do, but those volition travel with time.

It's conscionable Python

Hopefully a side-by-side examination of the Yellow Paper and the equivalent codification from EELS tin amusement wherefore EELS is simply a invaluable complement to it:

Less-than (LT) opcode

Figure 2. Less-than (LT) EVM acquisition from Yellow Paper
def less_than(evm: Evm) -> None: # STACK near = pop(evm.stack) close = pop(evm.stack) # GAS charge_gas(evm, GAS_VERY_LOW) # OPERATION effect = U256(left < right) push(evm.stack, result) # PROGRAM COUNTER evm.pc += 1
Figure 3. Less-than (LT) EVM acquisition from EELS

While Figure 2 mightiness beryllium digestible to academics, Figure 3 is indisputably much earthy to programmers.

Here's a video walk-through of adding a elemental EVM instruction if that's your benignant of thing.

Writing Tests

It bears repeating: EELS is conscionable regular Python. It tin beryllium tested similar immoderate different Python library! In summation to the full ethereum/tests suite, we besides person a enactment of pytest tests.

With a small assistance from execution-spec-tests, immoderate tests written for EELS tin besides beryllium applied to accumulation clients!2

Showing Differences

Having snapshots astatine each fork is large for a astute declaration developer popping successful to spot the specifics of however an EVM acquisition works, but isn't precise adjuvant for lawsuit developers themselves. For them, EELS tin show the differences betwixt forks:

Screenshot of the differences successful  the apply_fork relation  betwixt  homestead and the DAO fork

Figure 4. 1 quality betwixt homestead and the DAO fork

An Example EIP

EIP-6780 is the archetypal EIP to get an EELS implementation provided by the author, Guillaume Ballet! Let's instrumentality a look.

Screenshot of EIP-6780's specification section

Figure 5. EIP-6768's specification section

First, we present a created_contracts adaptable to the EVM with transaction-level scope:

@dataclass class Environment: caller: Address block_hashes: List[Hash32] origin: Address coinbase: Address number: Uint base_fee_per_gas: Uint gas_limit: Uint gas_price: Uint time: U256 prev_randao: Bytes32 state: State chain_id: U64 + created_contracts: Set[Address]

Second, we enactment which contracts were created successful each transaction:

+ evm.env.created_contracts.add(contract_address)

Finally, we modify selfdestruct truthful it lone works for contracts noted successful created_contracts:

- # registry relationship for deletion - evm.accounts_to_delete.add(originator) - + # Only proceed if the declaration has been created successful the aforesaid tx + if originator successful evm.env.created_contracts: + + # registry relationship for deletion + evm.accounts_to_delete.add(originator) +

Future

We privation EELS to go the default mode to specify Core EIPs, the archetypal spot EIP authors spell to prototype their proposals, and the champion imaginable notation for however Ethereum works.

If you're funny successful contributing oregon prototyping your EIP, articulation america connected the #specifications transmission oregon drawback an contented from our repository.

View source