Convert Figma logo to code with AI

ethereum logoexecution-specs

Specification for the Execution Layer. Tracking network upgrades.

1,103
414
1,103
388

Top Related Projects

Go implementation of the Ethereum protocol

2,361

A Python implementation of the Ethereum Virtual Machine

DEPRECATED! Java implementation of the Ethereum yellowpaper. For JSON-RPC and other client features check Ethereum Harmony

1,724

An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu

Quick Overview

The ethereum/execution-specs repository contains formal specifications for the Ethereum execution layer. It aims to provide a comprehensive and precise description of Ethereum's execution semantics, written in Python for clarity and executability. This project serves as a reference implementation and testing framework for Ethereum clients.

Pros

  • Provides a clear, executable specification of Ethereum's execution layer
  • Facilitates easier understanding and implementation of Ethereum protocols
  • Serves as a valuable resource for developers and researchers in the Ethereum ecosystem
  • Enables automated testing and verification of Ethereum client implementations

Cons

  • May require frequent updates to keep pace with Ethereum's evolving protocol
  • The Python implementation might not be as performant as optimized client implementations
  • Could be challenging for non-technical users to understand and utilize
  • Might not cover all edge cases or real-world scenarios encountered by full node implementations

Code Examples

This repository is not primarily a code library for direct use in other projects, but rather a specification and reference implementation. However, here are a few examples of how the code in this repository is structured and used:

  1. Defining block structure:
@dataclass
class Block:
    header: BlockHeader
    transactions: Tuple[Transaction, ...]
    ommers: Tuple[BlockHeader, ...]
  1. Implementing state transitions:
def state_transition(state: State, block: Block) -> None:
    validate_block(state, block)
    execute_block(state, block)
    finalize_block(state, block)
  1. Specifying transaction execution:
def execute_transaction(state: State, tx: Transaction) -> None:
    validate_transaction(state, tx)
    apply_transaction(state, tx)
    update_state(state, tx)

Getting Started

As this is a specification repository, there's no traditional "getting started" guide. However, to explore and use the specifications:

  1. Clone the repository:

    git clone https://github.com/ethereum/execution-specs.git
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Explore the specifications in the src/ethereum directory.

  4. Run tests using pytest:

    pytest tests
    

Competitor Comparisons

Go implementation of the Ethereum protocol

Pros of go-ethereum

  • Production-ready implementation widely used in the Ethereum network
  • Highly optimized for performance and efficiency
  • Extensive documentation and community support

Cons of go-ethereum

  • More complex codebase, potentially harder for newcomers to understand
  • Less focused on readability and educational purposes
  • May diverge from the latest Ethereum specifications in some cases

Code Comparison

execution-specs (Python):

def apply_message(state: State, message: Message) -> Optional[MessageResult]:
    sender = message.sender
    gas = message.gas

    if not state.account_exists(sender):
        state.create_account(sender)

go-ethereum (Go):

func ApplyMessage(evm *EVM, msg Message, gp *GasPool) (*ExecutionResult, error) {
    return NewStateTransition(evm, msg, gp).TransitionDb()
}

func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
    msg := st.msg
    sender := vm.AccountRef(msg.From())
    contractCreation := msg.To() == nil

The execution-specs code is more readable and closely follows the Ethereum specifications, while go-ethereum's implementation is more optimized for production use.

2,361

A Python implementation of the Ethereum Virtual Machine

Pros of py-evm

  • More mature and established project with a longer history
  • Includes a full Ethereum Virtual Machine (EVM) implementation
  • Provides a complete Ethereum client implementation in Python

Cons of py-evm

  • May be less focused on specification and more on implementation
  • Potentially more complex due to its broader scope
  • Could be slower to update with the latest Ethereum changes

Code Comparison

py-evm:

class BaseVM:
    chain_id: int
    _state: StateDB

    def apply_transaction(self, transaction):
        # Implementation of transaction application

execution-specs:

def apply_transaction(state: State, transaction: Transaction) -> None:
    # Specification of transaction application
    # More focused on defining the process rather than implementation

Summary

py-evm is a comprehensive Ethereum implementation in Python, including a full EVM. It offers a complete client but may be more complex and slower to update. execution-specs, on the other hand, focuses on providing clear specifications for Ethereum execution, which can be easier to understand and maintain. The code comparison shows py-evm's implementation-focused approach versus execution-specs' specification-oriented style.

DEPRECATED! Java implementation of the Ethereum yellowpaper. For JSON-RPC and other client features check Ethereum Harmony

Pros of ethereumj

  • Written in Java, which may be more familiar to some developers
  • More mature project with longer history and established codebase
  • Includes a full Ethereum client implementation

Cons of ethereumj

  • Less actively maintained compared to execution-specs
  • May not reflect the latest Ethereum protocol changes as quickly
  • Potentially more complex due to its full client implementation

Code Comparison

execution-specs (Python):

def apply_message(state: State, message: Message) -> MessageResult:
    snapshot = state.snapshot()
    try:
        gas_cost, remaining_gas = calculate_message_gas_consumption(message)
        state.delta_balance(message.sender, -gas_cost)
        # ... (additional code)
    except InsufficientFunds:
        state.revert(snapshot)
        return MessageResult(1, b'', message.gas, [])

ethereumj (Java):

public void applyMessage(Transaction tx, Block block) {
    Repository track = repository.startTracking();
    try {
        TransactionExecutor executor = new TransactionExecutor(tx, block.getCoinbase(),
                track, blockStore, programInvokeFactory, block, listener, 0)
                .withCommonConfig(commonConfig);
        executor.init();
        executor.execute();
        executor.go();
        executor.finalization();
        // ... (additional code)
    } finally {
        track.rollback();
    }
}

Both repositories aim to implement Ethereum specifications, but execution-specs focuses on a clear, readable reference implementation in Python, while ethereumj provides a full Java-based Ethereum client.

1,724

An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu

Pros of Besu

  • Production-ready Ethereum client with enterprise features
  • Supports both public and private networks
  • Extensive documentation and active community support

Cons of Besu

  • Larger codebase, potentially more complex to contribute to
  • May have slower update cycles for new Ethereum features

Code Comparison

Besu (Java):

public class MainnetProtocolSchedule {
  public static ProtocolSchedule create(
      GenesisConfigOptions config,
      PrivacyParameters privacyParameters,
      boolean isRevertReasonEnabled) {
    // Implementation details
  }
}

Execution-specs (Python):

def mainnet() -> Tuple[Dict[str, Any], Dict[str, Any]]:
    """
    Returns the chain configuration and genesis state for Mainnet.
    """
    return {
        # Configuration details
    }, {
        # Genesis state details
    }

The Execution-specs repository focuses on providing a clear, readable specification of Ethereum's execution layer, while Besu is a full-featured Ethereum client implementation. Execution-specs uses Python for its specifications, making it more accessible for a wider range of developers to understand the protocol. Besu, being a production client, is implemented in Java and offers a more comprehensive set of features for running Ethereum nodes in various environments.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Ethereum Execution Client Specifications

GitPOAP Badge

Description

This repository contains the specifications related to the Ethereum execution client, specifically the pyspec and specifications for network upgrades. The JSON-RPC API specification can be found in a separate repository.

Ethereum Protocol Releases

Version and Code NameBlock No.ReleasedIncl EIPsSpecsBlog
CancunTBDTBDEIP-1153
EIP-4788
EIP-4844
EIP-5656
EIP-6780
EIP-7516
SpecificationTBD
Shanghai170348702023-04-12
(1681338455)
EIP-3651
EIP-3855
EIP-3860
EIP-4895
SpecificationBlog
Paris155373942022-09-15EIP-3675
EIP-4399
SpecificationBlog
Gray Glacier150500002022-06-30EIP-5133SpecificationBlog
Arrow Glacier137730002021-12-09EIP-4345SpecificationBlog
London129650002021-08-05EIP-1559
EIP-3198
EIP-3529
EIP-3541
EIP-3554
SpecificationBlog
Berlin122440002021-04-15EIP-2565
EIP-2929
EIP-2718
EIP-2930
HFM-2070
Specification
Blog
Muir Glacier92000002020-01-02EIP-2384HFM-2387Blog
Istanbul90690002019-12-07EIP-152
EIP-1108
EIP-1344
EIP-1884
EIP-2028
EIP-2200
HFM-1679Blog
Petersburg72800002019-02-28EIP-145
EIP-1014
EIP-1052
EIP-1234
HFM-1716Blog
Constantinople72800002019-02-28EIP-145
EIP-1014
EIP-1052
EIP-1234
EIP-1283
HFM-1013Blog
Byzantium43700002017-10-16EIP-100
EIP-140
EIP-196
EIP-197
EIP-198
EIP-211
EIP-214
EIP-649
EIP-658
HFM-609Blog
Spurious Dragon26750002016-11-22EIP-155
EIP-160
EIP-161
EIP-170
HFM-607Blog
Tangerine Whistle24630002016-10-18EIP-150HFM-608Blog
DAO Fork19200002016-07-20HFM-779Blog
DAO WarsabortedabortedBlog
Homestead11500002016-03-14EIP-2
EIP-7
EIP-8
HFM-606Blog
Frontier Thawing2000002015-09-07Blog
Frontier12015-07-30Blog

Note: Starting with Paris, updates are no longer rolled out based on block numbers. Paris was enabled once proof-of-work Total Difficulty reached 58750000000000000000000. As of Shanghai (at 1681338455), upgrade activation is based on timestamps.

Some clarifications were enabled without protocol releases:

EIPBlock No.
EIP-26810
EIP-36070
EIP-752315537394
EIP-76100

Execution Specification (work-in-progress)

The execution specification is a python implementation of Ethereum that prioritizes readability and simplicity. It will accompanied by both narrative and API level documentation of the various components written in markdown and rendered using docc...

Usage

The Ethereum specification is maintained as a Python library, for better integration with tooling and testing.

Requires Python 3.10+

Building

Building the documentation is most easily done through tox:

$ tox -e doc

The path to the generated HTML will be printed to the console.

License

The Ethereum Execution Layer Specification code is licensed under the Creative Commons Zero v1.0 Universal.