Tuesday, October 1, 2024

Ethereum Execution Layer Specification | Ethereum Basis Weblog

tl;dr

  • EELS is an execution layer reference implementation in Python.
  • It is updated with mainnet.
  • It fills exams, and passes present ones.
  • There’s an instance of an EIP applied in EELS beneath.

Introduction

After greater than a 12 months in improvement, we’re happy to publicly introduce the Ethereum Execution Layer Specification (affectionately generally known as EELS.) EELS is a Python reference implementation of the core parts of an Ethereum execution consumer centered on readability and readability. Meant as a non secular successor to the Yellow Paper that is extra programmer pleasant and up-to-date with post-merge forks, EELS can fill and execute state exams, comply with mainnet1, and is a good place to prototype new EIPs.

EELS gives full snapshots of the protocol at every fork—together with upcoming ones—making it a lot simpler to comply with than EIPs (which solely suggest adjustments) and manufacturing shoppers (which frequently combine a number of forks in the identical codepath.)

Historical past

Starting in 2021, as a venture of ConsenSys’ Quilt workforce and the Ethereum Basis, the eth1.0-spec (because it was recognized then) was impressed by the sheer frustration of getting to decipher the cryptic notation of the Yellow Paper (Determine 1) to know the precise habits of an EVM instruction.

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

Drawing on the profitable Consensus Layer Specification, we got down to create an analogous executable specification for the execution layer.

Current

Right this moment, EELS is consumable as a conventional Python repository and as rendered documentation. It is nonetheless a bit tough across the edges, and does not present a lot in the best way of annotations or English explanations for what numerous items do, however these will include time.

It is simply Python

Hopefully a side-by-side comparability of the Yellow Paper and the equal code from EELS can present why EELS is a invaluable complement to it:

Less-than (LT) opcode

Determine 2. Much less-than (LT) EVM instruction from Yellow Paper

def less_than(evm: Evm) -> None:
    # STACK
    left = pop(evm.stack)
    proper = pop(evm.stack)

    # GAS
    charge_gas(evm, GAS_VERY_LOW)

    # OPERATION
    consequence = U256(left < proper)

    push(evm.stack, consequence)

    # PROGRAM COUNTER
    evm.computer += 1

Determine 3. Much less-than (LT) EVM instruction from EELS

Whereas Determine 2 is perhaps digestible to lecturers, Determine 3 is indisputably extra pure to programmers.

This is a video walk-through of including a easy EVM instruction if that is your type of factor.

Writing Exams

It bears repeating: EELS is simply common Python. It may be examined like another Python library! Along with your complete ethereum/exams suite, we even have a collection of pytest exams.

With slightly assist from execution-spec-tests, any exams written for EELS will also be utilized to manufacturing shoppers!2

Displaying Variations

Having snapshots at every fork is nice for a sensible contract developer popping in to see the specifics of how an EVM instruction works, however is not very useful for consumer builders themselves. For them, EELS can show the variations between forks:

Screenshot of the differences in the apply_fork function between homestead and the DAO fork

Determine 4. one distinction between homestead and the DAO fork

An Instance EIP

EIP-6780 is the primary EIP to get an EELS implementation offered by the writer, Guillaume Ballet! Let’s have a look.

Screenshot of EIP-6780's specification section

Determine 5. EIP-6768’s specification part

First, we introduce a created_contracts variable to the EVM with transaction-level scope:

 @dataclass
 class Setting:
     caller: Handle
     block_hashes: Checklist[Hash32]
     origin: Handle
     coinbase: Handle
     quantity: 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 notice which contracts have been created in every transaction:

+    evm.env.created_contracts.add(contract_address)

Lastly, we modify selfdestruct so it solely works for contracts famous in created_contracts:

-    # register account for deletion
-    evm.accounts_to_delete.add(originator)
-
+    # Solely proceed if the contract has been created in the identical tx
+    if originator in evm.env.created_contracts:
+
+        # register account for deletion
+        evm.accounts_to_delete.add(originator)
+

Future

We wish EELS to turn out to be the default approach to specify Core EIPs, the primary place EIP authors go to prototype their proposals, and the very best reference for a way Ethereum works.

In case you’re focused on contributing or prototyping your EIP, be part of us on the #specs channel or seize a problem from our repository.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles