Top Related Projects
Go implementation of the Ethereum protocol
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
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:
- Defining block structure:
@dataclass
class Block:
header: BlockHeader
transactions: Tuple[Transaction, ...]
ommers: Tuple[BlockHeader, ...]
- Implementing state transitions:
def state_transition(state: State, block: Block) -> None:
validate_block(state, block)
execute_block(state, block)
finalize_block(state, block)
- 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:
-
Clone the repository:
git clone https://github.com/ethereum/execution-specs.git -
Install dependencies:
pip install -r requirements.txt -
Explore the specifications in the
src/ethereumdirectory. -
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.
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.
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
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Ethereum Execution Client Specifications
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
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:
| EIP | Block No. |
|---|---|
| EIP-2681 | 0 |
| EIP-3607 | 0 |
| EIP-7523 | 15537394 |
| EIP-7610 | 0 |
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.
Top Related Projects
Go implementation of the Ethereum protocol
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
An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot