### Install 'uv' via curl Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/installation.md Installs the latest version of 'uv' using a curl command. This method is recommended as it allows 'uv' to self-update. It may also download a compatible Python version if not found locally. ```console curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Install 'uv' via pip Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/installation.md Installs 'uv' using pip. This method requires an existing Python installation and does not support self-updating. ```console pip install uv ``` -------------------------------- ### Install Execution-Spec-Tests Dependencies (All Platforms) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/installation.md Clones the execution-spec-tests repository and installs its dependencies using 'uv'. It specifically configures Python 3.12 as the project's Python version and synchronizes all dependencies, including extras. ```console git clone https://github.com/ethereum/execution-spec-tests cd execution-spec-tests uv python install 3.12 uv python pin 3.12 uv sync --all-extras ``` -------------------------------- ### View Generated Ethereum Test Fixture File Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/filling_tests/getting_started.md This command displays the beginning of a generated JSON fixture file for an Ethereum state test. It uses the `head` command to show the initial lines of the file, allowing for a quick verification of the fixture's content and structure. ```console head fixtures/state_tests/shanghai/eip3855_push0/push0/push0_contract_during_call_contexts.json ``` -------------------------------- ### Setup Commands for Project Environment Source: https://github.com/ethereum/execution-spec-tests/blob/main/CLAUDE.md Installs project dependencies and sets up pre-commit hooks. Ensures the development environment is correctly configured. ```bash uv sync --all-extras uvx pre-commit install ``` -------------------------------- ### Install Dependencies Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/docs.md Installs all necessary dependencies for the project, including extras. This command is typically run once to set up the development environment. ```console uv sync --all-extras ``` -------------------------------- ### Installing Markdownlint CLI Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/code_standards_details.md Commands to install markdownlint-cli2 globally, which is required for the markdownlint tox environment. It suggests using apt for nodejs installation and npm for installing a specific version of markdownlint-cli2. ```bash sudo apt install nodejs sudo npm install -g markdownlint-cli2@0.17.2 ``` -------------------------------- ### Build Solidity (solc) from source on Ubuntu ARM64 Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/installation_troubleshooting.md Provides a comprehensive set of commands to clone, build, and install the Solidity compiler (solc) from source on Ubuntu 24.04.2 LTS ARM64. This is a solution for 'solc' installation issues and 'failed to compile yul source' errors on ARM platforms when using the ethereum/execution-spec-tests. ```bash git clone --branch v0.8.28 --depth 1 https://github.com/ethereum/solidity.git cd solidity && mkdir build && cd build sudo apt install build-essential libboost-all-dev z3 cmake .. make mv $HOME/Documents/execution-spec-tests/.venv/bin/solc $HOME/Documents/execution-spec-tests/.venv/bin/solc-x86-64 cp ./solc/solc $HOME/Documents/execution-spec-tests/.venv/bin/ chmod +x $HOME/Documents/execution-spec-tests/.venv/bin/solc ``` -------------------------------- ### Install CA certificates on macOS Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/installation_troubleshooting.md Executes a Python script on macOS to install necessary CA certificates, addressing potential SSL certificate verification failures during the setup or use of the ethereum/execution-spec-tests project. This command assumes Python 3.11 is installed. ```bash /Applications/Python\ 3.11/Install\ Certificates.command ``` -------------------------------- ### Install Execution Spec Tests Dependencies (Console) Source: https://github.com/ethereum/execution-spec-tests/blob/main/README.md Installs the execution-spec-tests project and its dependencies using 'uv'. This involves cloning the repository, installing Python 3.11, pinning the version, and syncing all extras. ```console git clone https://github.com/ethereum/execution-spec-tests cd execution-spec-tests uv python install 3.11 uv python pin 3.11 uv sync --all-extras ``` -------------------------------- ### Start IPython with EEST Packages Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/interactive_usage.md Launches an ipython shell with EEST Python packages installed in editable mode. This allows source code changes to be immediately reflected in the interactive session. It requires the 'uvx' tool. ```console uvx --with-editable . ipython ``` -------------------------------- ### Installing Pre-commit Hooks Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/code_standards_details.md Command to install git pre-commit hooks, which automatically run certain tox environments before each commit to ensure code standards are met. Further information is available in the Pre-commit Hooks Documentation. ```console uvx pre-commit install ``` -------------------------------- ### Install libsecp256k1-dev on Ubuntu Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/installation_troubleshooting.md This command installs the libsecp256k1-dev library on Ubuntu systems, which is required to resolve build issues with the 'coincurve' Python package when installing ethereum/execution-spec-tests. ```bash sudo apt update sudo apt-get install libsecp256k1-dev ``` -------------------------------- ### Example CLI Documentation with MkDocs-Click (Python) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/documenting_clis.md This example demonstrates how to document a CLI command using Python's Click library and MkDocs-Click. It shows the structure of Click commands and the use of short_help for sub-commands, which is essential for MkDocs-Click to generate concise documentation. ```python import click @click.group() def cli(): """Root command group.""" pass @cli.command(short_help="A short help string for evm_bytes.") def evm_bytes(): """This is a more detailed docstring for the evm_bytes command.""" click.echo("Running evm_bytes command...") if __name__ == '__main__': cli() ``` -------------------------------- ### Production Image Client Configuration Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/hive/client_config.md Example of configuring a client using a pre-built production Docker image. This is useful for specifying a known stable version of a client. ```yaml - client: besu nametag: pectra build_args: baseimage: hyperledger/besu tag: 25.4.1 ``` -------------------------------- ### Install Pre-Commit Hooks (Console) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/precommit.md Installs the pre-commit hooks for the repository. This command should be run once to set up the necessary checks that will run automatically before each commit. ```console uvx pre-commit install ``` -------------------------------- ### Collect Ethereum Execution Spec Tests with Pytest Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/filling_tests/getting_started.md This command collects test cases from the specified directory (`tests/shanghai/`) using pytest filtering (`-k`) and without executing them (`--collect-only`). It's useful for exploring available tests, especially those related to specific EVM functionalities like PUSH0 and DELEGATECALL. ```console uv run fill --collect-only -k "push0 and delegatecall" tests/shanghai/ ``` -------------------------------- ### Fill Ethereum State Test Fixtures with Pytest Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/filling_tests/getting_started.md This command fills `state_test` fixtures for collected test cases, identified by the marker `state_test` (`-m state_test`). It uses pytest filtering (`-k`) to target specific tests and enables verbose output (`-v`) for detailed logging during the fixture generation process. ```console uv run fill -k "push0 and delegatecall" tests/shanghai/ -m state_test -v ``` -------------------------------- ### Example Block Structure (Python) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/tutorials/blockchain.md An example demonstrating the structure of generated blocks based on a sample `tx_per_block` list. It shows how blocks are created with varying numbers of transactions, from empty to multiple. ```python blocks = [ Blocks(txs=[]), Blocks(txs=[next(tx_generator), next(tx_generator)]), Blocks(txs=[next(tx_generator), next(tx_generator), next(tx_generator), next(tx_generator)]) ] ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/docs.md Starts a local web server to host the documentation. The site automatically re-generates upon modifications to files in the 'docs' or 'tests' directories. ```console uv run mkdocs serve ``` -------------------------------- ### Add/Update Source Dependencies with uv Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/deps_and_packaging.md Command-line examples for adding or updating source dependencies from Git repositories using `uv add`. ```console uv add "ethereum-spec-evm-resolver @ git+https://github.com/petertdavies/ethereum-spec-evm-resolver@623ac4565025e72b65f45b926da2a3552041b469" ``` -------------------------------- ### Setup Client Under Test Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/test_formats/blockchain_test_sync.md Configures the client under test by defining the execution fork schedule, pre-execution state, and genesis block header. It then processes engine_newPayloadVX directives to build the chain. -------------------------------- ### Copy Recommended Debug Launch Configuration for VS Code Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/setup_vs_code.md This command copies the recommended launch configuration file to `.vscode/launch.json`. This enables useful debugging configurations for the project. Ensure you are in the root directory of the cloned repository before running this command. ```bash cp .vscode/launch.recommended.json .vscode/launch.json ``` -------------------------------- ### Example Environment Configuration File Structure Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/configurations.md An example of the 'env.yaml' file structure used for storing environment configurations. It includes settings for remote nodes, such as their names, RPC node URLs, and optional headers for authentication. ```yaml remote_nodes: - name: mainnet_archive # Replace with your Ethereum RPC node URL node_url: http://example.com # Optional: Headers for RPC requests rpc_headers: client-secret: ``` -------------------------------- ### Install CA certificates on Ubuntu Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/installation_troubleshooting.md Updates the system's CA certificates on Ubuntu, which can resolve SSL certificate verification errors encountered during the installation or operation of the ethereum/execution-spec-tests project. ```bash sudo apt-get update sudo apt-get install ca-certificates ``` -------------------------------- ### Install nektos/act via Github CLI (Bash) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/test_actions_locally.md This command installs the nektos/act tool as a Github CLI extension. This allows you to run Github Actions workflows locally. Ensure you have the Github CLI installed and authenticated first. ```bash gh extension install https://github.com/nektos/gh-act ``` -------------------------------- ### Add/Update Direct Dependencies with uv Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/deps_and_packaging.md Command-line examples for adding or updating direct package dependencies using the `uv add` command. ```console uv add "requests>=2.31,<2.33" ``` -------------------------------- ### Set up Python Environment with uv Source: https://github.com/ethereum/execution-spec-tests/blob/main/CONTRIBUTING.md Configures the Python environment using the uv package manager. It installs Python version 3.12, pins it for consistency, and synchronizes all project extras, ensuring all necessary dependencies are met. ```bash uv python install 3.12 uv python pin 3.12 uv sync --all-extras ``` -------------------------------- ### Install uv Python Package Manager Source: https://github.com/ethereum/execution-spec-tests/blob/main/README.md This snippet shows how to install the 'uv' package manager, which is used by the execution-spec-tests framework for dependency management and virtual environment creation. It offers both a curl-based installation (recommended for self-updating) and a pip-based installation. ```console curl -LsSf https://astral.sh/uv/install.sh | sh ``` ```console pip install uv ``` -------------------------------- ### Fuzzing Framework Example for EVM Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/checklist_templates/eip_testing_checklist_template.md An example of a fuzzing framework for the Ethereum Virtual Machine (EVM). Fuzzing is recommended for EIPs that introduce new cryptography primitives to uncover potential vulnerabilities and edge cases. ```go See [holiman/goevmlab](https://github.com/holiman/goevmlab) for an example of a fuzzing framework for the EVM. ``` -------------------------------- ### Start Full Node Configuration Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/test_formats/blockchain_test_engine.md Configures a full node for testing using network fork schedules, pre-execution state allocation, and genesis block headers. ```bash Start a full node using: - network to configure the execution fork schedule according to the Fork type definition. - pre as the starting state allocation of the execution environment for the test and calculate the genesis state root. - genesisBlockHeader as the genesis block header. ``` -------------------------------- ### Start Hive Development Server Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/library/cli/extract_config.md This command starts the Hive development server, which is a prerequisite for using the `extract_config` tool. Hive manages the spawning and simulation of Ethereum clients. ```bash ./hive --dev ``` -------------------------------- ### Define Source Dependencies in pyproject.toml Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/deps_and_packaging.md Shows how to define dependencies installed directly from a Git repository using the `[tool.uv.sources]` section in `pyproject.toml`. ```toml [tool.uv.sources] ethereum-spec-evm-resolver = { git = "https://github.com/petertdavies/ethereum-spec-evm-resolver", rev = \ ... ``` -------------------------------- ### Execute eth-config Command: Standalone Usage (Bash) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/execute/eth_config.md This command demonstrates how to run the 'execute eth-config' sub-command directly after installing uv. It connects to a Mainnet RPC endpoint to validate the client's configuration. ```bash uv run --with git+https://github.com/ethereum/execution-spec-tests.git execute eth-config --network Mainnet --rpc-endpoint http:// ``` -------------------------------- ### Execute `eest/consume-engine` in Hive Development Mode Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/running.md This method involves running the `eest/consume-engine` simulator natively after cloning and installing EEST, and starting a Hive server in development mode. It communicates with the client via the Hive API and is ideal for local test development, allowing for easier debugging. ```bash uv run consume engine ``` -------------------------------- ### Text: Documenting Not Applicable Items Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/eip_checklist.md Example of a text file used to document why certain checklist items are not applicable, providing a justification. ```text # eip_checklist_not_applicable.txt precompile/ = EIP-9999 introduces an opcode, not a precompile ``` -------------------------------- ### Example Test ID Structure Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/filling_tests/test_ids.md This example demonstrates a concrete test ID, mapping its components to the general format. It shows how parameters like fork and test type are integrated into the ID. ```text tests/istanbul/eip1344_chainid/test_chainid.py::test_chainid[fork_Cancun-blockchain_test] ``` -------------------------------- ### Build Hive Command with Go Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/hive/index.md This snippet demonstrates how to clone the Hive repository and build the executable command-line tool using Go. Ensure Docker and Go are installed. ```bash git clone https://github.com/ethereum/hive cd hive go build . ``` -------------------------------- ### Show Docker Build Output Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/hive/client_config.md Command to display the detailed output from the Docker build process for a client. This is crucial for diagnosing build failures. ```bash ./hive --docker.buildoutput --sim ethereum/eest/consume-engine ``` -------------------------------- ### Execute eth-config Command: Using Genesis JSON URL (Bash) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/execute/eth_config.md This example shows how to test an Ethereum client's configuration by providing a URL to a genesis JSON file. The '--genesis-config-url' option is used for this purpose. ```bash uv run execute eth-config --genesis-config-url https://example.com/genesis.json --rpc-endpoint http://localhost:8545 ``` -------------------------------- ### Quick Start Template for LLM Task Initiation Source: https://github.com/ethereum/execution-spec-tests/blob/main/HUMANS.md This template provides a structured way to initiate complex tasks with an LLM, ensuring all necessary context is provided. It helps the LLM understand the goal, working directory, current status, and references, leading to more accurate and comprehensive assistance for new development efforts. ```console I'm working on [describe task] in the Ethereum execution-spec-tests repository. **Context**: - Working directory: [tests/shanghai/, src/ethereum_test_tools/, etc.] - Trying to: [specific goal] - Current status: [what you've tried, any errors] **References**: - Checked CLAUDE.md section: [which sections you've read] - Related documentation: [any other docs you've reviewed] **Specific question**: [exactly what you need help with] ``` -------------------------------- ### Execute eth-config Command: Testing Mainnet Client (Bash) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/execute/eth_config.md Example of running the 'execute eth-config' command to test a Mainnet Ethereum client's configuration. It specifies 'Mainnet' as the network and a local RPC endpoint. ```bash uv run execute eth-config --network Mainnet --rpc-endpoint http://localhost:8545 ``` -------------------------------- ### Text: Documenting External Coverage Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/eip_checklist.md Example of a text file used to document external test coverage for specific checklist items, linking to external proofs or reasons. ```text # eip_checklist_external_coverage.txt general/code_coverage/eels = Covered by ethereum/execution-specs PR #1234 ``` -------------------------------- ### Git Dockerfile Client Configuration Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/hive/client_config.md Configures a client to be built from source by cloning a specified GitHub repository and branch. This allows for testing unreleased versions or custom forks. ```yaml - client: go-ethereum nametag: experimental dockerfile: git build_args: github: your-username/go-ethereum tag: experimental-branch ``` -------------------------------- ### Execute Remote Command Basic Setup Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/execute/remote.md This command initiates remote test execution on a live network. It requires specifying the active fork and the RPC endpoint of the client connected to the network. The `--fork` flag ensures compatibility with the network's current state, while `--rpc-endpoint` provides the connection point. ```bash uv run execute remote --fork=Prague --rpc-endpoint=https://rpc.endpoint.io ``` -------------------------------- ### Python Regex Exception Mapper Example - EEST Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/consume/exceptions.md Python code example demonstrating the use of regular expressions in exception mappings for the Besu client in EEST. It shows how to handle different error message formats across client versions. ```python # Besu v24.1.0+ changed gas limit error format BESU_EXCEPTIONS = { # Old format (pre-24.1.0) "Transaction gas limit exceeds block gas limit": ExceptionType.GAS_LIMIT_EXCEEDED, # New format (24.1.0+) r"block gas limit \(\d+\) exceeded by transaction": ExceptionType.GAS_LIMIT_EXCEEDED, } ``` -------------------------------- ### Python Imports for EVM Bytecode Testing Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/tutorials/state_transition.md Imports essential components from `ethereum_test_tools` and `ethereum_test_vm` for writing EVM bytecode tests. The `Opcodes` class, aliased as `Op`, provides a Python minilang for generating EVM instructions. ```python import pytest from ethereum_test_tools import Account, Alloc, Environment, StateTestFiller, Transaction from ethereum_test_vm import Opcodes as Op ``` -------------------------------- ### Deploy Contract with Opcodes Minilang in Python Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/tutorials/state_transition.md Deploys a smart contract using Opcodes minilang to the pre-state. The contract stores a value at a specified storage slot. It returns the address of the deployed contract. ```python contract_address = pre.deploy_contract( code=Op.PUSH1(0x03) + Op.PUSH1(0x00) + Op.SSTORE + Op.STOP ) ``` -------------------------------- ### Pre-Allocation Group File Structure Example Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/test_formats/blockchain_test_engine_x.md Demonstrates the JSON structure of a pre-allocation group file, which contains information about the tests, network, environment, and initial account states for a specific pre-allocation group. ```json { "test_count": 88, "pre_account_count": 174, "testIds": ["test1", "test2", ...], "network": "Prague", "environment": { ... }, "pre": { ... } } ``` -------------------------------- ### Get Project Information Source: https://github.com/ethereum/execution-spec-tests/blob/main/CONTRIBUTING.md Retrieves detailed information about the execution-spec-tests repository and its tool versions. This output is useful for debugging and reporting issues. ```console uv run eest info ``` -------------------------------- ### Building and Serving Local Documentation Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/code_standards_details.md Commands to build and serve the project's HTML documentation locally using mkdocs. The `FAST_DOCS` environment variable controls the build scope, with `True` for a quick build and `False` to include the 'Test Case Reference' section. ```bash export FAST_DOCS=True uv run mkdocs serve ``` -------------------------------- ### Fork Compatibility Example Source: https://github.com/ethereum/execution-spec-tests/blob/main/CLAUDE.md Illustrates how to handle fork-specific logic within a single test function using pytest markers and conditional checks. ```python @pytest.mark.valid_from("Cancun") def test_example(pre: Alloc, state_test: StateTestFiller): if fork >= Fork.Cancun: # Cancun-specific logic else: # Pre-Cancun logic ``` -------------------------------- ### Consume Cache Command Example Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/consume/cache.md Demonstrates the basic usage of the 'consume cache' command to resolve, download, and cache fixture releases. This command is fundamental for obtaining necessary fixture data for testing. ```console consume cache --input=stable@v4.5.0 ``` -------------------------------- ### Copy Local Client Source Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/hive/client_config.md Command to copy local client source code into the Hive directory structure, a prerequisite for using the 'local Dockerfile' build variant. ```bash cp -r /path/to/your/go-ethereum ./clients/go-ethereum/go-ethereum-local ``` -------------------------------- ### Get Local IP Address (macOS) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/hive/dev_mode.md Command to retrieve the local IP address of the primary network interface (en0) on a macOS system, needed for Hive development mode setup. ```bash ipconfig getifaddr en0 ``` -------------------------------- ### Run Hive in Dev Mode with Go-Ethereum Client Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/execute/hive.md This command initiates the Hive framework in development mode, specifically configuring it to use the 'go-ethereum' client. This setup is a prerequisite for running certain `execute` tests. ```bash ./hive --dev --client go-ethereum ``` -------------------------------- ### Start Hive in Development Mode (Linux) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/hive/dev_mode.md Initiates the Hive simulator in development mode, specifying the client and output configuration. This command is typically run on a Linux system. ```bash ./hive --dev --client go-ethereum --client-file clients.yaml --docker.output ``` -------------------------------- ### Execute State Test Wrapper in Python Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/tutorials/state_transition.md Executes the state test wrapper function with environment, pre-state, post-state, and transaction configurations. This function generates various test fixtures including StateTest, BlockchainTest, BlockchainTestEngine, and BlockchainTestEngineX. ```python state_test(env=env, pre=pre, post=post, tx=tx) ``` -------------------------------- ### Local Dockerfile Client Configuration Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/hive/client_config.md Enables building a client from local source code modifications. This is ideal for developers testing changes to a client directly. ```yaml - client: go-ethereum nametag: local-dev dockerfile: local build_args: local_path: ./clients/go-ethereum/go-ethereum-local ``` -------------------------------- ### Block Creation with Lambda and Map (Python) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/tutorials/blockchain.md Provides a conceptual Python example of block creation using `map` and `lambda`. The outer lambda takes a length and constructs a `Block` object with that many transactions, generated by the inner `map` function. ```python blocks = map( lambda len: Block( txs=list of len transactions ), tx_per_block, ) ``` -------------------------------- ### Fill Tests using EELS CLI Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/porting_legacy_tests.md This shell command demonstrates how to use the `uv run fill` CLI command to run tests against EELS (an EVM implementation for testing). It specifically shows how to fill tests for the PUSH opcode in the frontier fork. ```shell uv run fill tests/frontier/opcodes/test_push.py ``` -------------------------------- ### Example: Finding Ignored Forks with ethereum_test_forks Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/interactive_usage.md Demonstrates how to import and use the `ethereum_test_forks` library to identify forks that are currently ignored. It iterates through available forks and prints those with the 'ignore()' method returning true. ```python from ethereum_test_forks import forks, get_forks forks = set([fork for fork in get_forks() if fork.ignore()]) print(forks) ``` -------------------------------- ### Generate Test Fixtures with `--from` Flag Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/filling_tests/filling_tests_dev_fork.md Generates test fixtures starting from a specified development fork using the `--from` command-line flag. Ensures the `evm` and `solc` tools support the feature. ```console uv run fill -k 4844 --from=Cancun -v ``` -------------------------------- ### Download Latest Fixture Release using uvx and consume cache Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/consume/cache.md This example shows how to download the latest fixture release without manually cloning the repository. It utilizes `uv` (a Python package manager) and `uvx` to run the `consume cache` command from the execution-spec-tests Git repository, caching the fixtures locally. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` ```bash uvx --from git+https://github.com/ethereum/execution-spec-tests \ consume cache --input=stable@latest ``` -------------------------------- ### Bash: Test Directory Structure and Generation Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/eip_checklist.md Illustrates the command-line operations for setting up test directories and generating checklists using the `checklist` tool. ```bash mkdir -p tests/prague/eip9999_new_feature/ cd tests/prague/eip9999_new_feature/ # Document external coverage: cat < eip_checklist_external_coverage.txt general/code_coverage/eels = Covered by ethereum/execution-specs PR #1234 EOF # Mark non-applicable items: cat < eip_checklist_not_applicable.txt precompile/ = EIP-9999 introduces an opcode, not a precompile EOF # Generate and review checklist: checklist --eip 9999 ``` -------------------------------- ### Getting and Using a Logger in Python Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/logging.md Demonstrates how to obtain a logger instance using the custom `get_logger` function and log messages at various standard and custom levels, including VERBOSE and FAIL. ```python from pytest_plugins.logging import get_logger # Create a logger with your module's name logger = get_logger(__name__) # Standard log levels logger.debug("Detailed debug information") logger.info("General information") logger.warning("Warning message") logger.error("Error message") logger.critical("Critical failure") # Custom log levels logger.verbose("More detailed than INFO, less than DEBUG") logger.fail("Test failure or similar issue") ``` -------------------------------- ### State Test Fixture Consumption in Go Ethereum Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/releases.md Go-ethereum clients can consume State Tests directly via a `statetest`-like command. The example shows the integration point within the `go-ethereum/cmd/evm/staterunner.go` file. ```go https://github.com/ethereum/go-ethereum/blob/4bb097b7ffc32256791e55ff16ca50ef83c4609b/cmd/evm/staterunner.go ``` -------------------------------- ### Building and Serving Local Documentation (fish) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/getting_started/code_standards_details.md Commands to build and serve the project's HTML documentation locally using mkdocs within a fish shell environment. The `FAST_DOCS` environment variable controls the build scope. ```fish set -x FAST_DOCS True uv run mkdocs serve ``` -------------------------------- ### Testing Utilities and Tools Source: https://github.com/ethereum/execution-spec-tests/blob/main/whitelist.txt This category covers various utilities and tools used for testing within the Ethereum execution specification tests project. It includes file manipulation, test environment setup, logging, and data formatting tools. ```Python subcontainer substring substrings teardown tempdir testdir teststatus tmpdir toc tryfirst trylast usefixtures verifier verifiers writelines xfail ZeroPaddedHexNumber P7692 stop fi url gz tT istanbul berlin 0A 0B 0C 0D 0E 0F 1A 1B 1C 1D 1E 1F 2A 2B 2C 2D 2E 2F 3A 3B 3C 3D 3E 3F 4A 4B 4C 4D 4E 4F 5A 5B 5C 5D 5E 5F 6A 6B 6C 6D 6E 6F 7A 7B 7C 7D 7E 7F 8A 8B 8C 8D 8E 8F 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DE DF DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF ef01 uv EthereumCLI TransitionTool rebase deps datatables jinja templating EOFv subcontainers ize nectos fibonacci CPython legacytests pycryptodome pytest_sessionfinish levelname pytest_runtest_logstart pytest_runtest_logreport pytest_runtest_logfinish eestloglevel caplog workerinput dockerenv stderr EESTLogger Formatters UI asctime petertdavies cofactor cofactors coeffs uncomp isogeny codomain nametag CFI'd opcode's rf buildarg buildoutput nocache checktimelimit loglevel ci netstat tlnp golang newPayload baseimage nametags liveness paradigmxyz lightclient PreviousFork NewFork ps forkchoiceUpdated ps ufw benchmarking validium rollup JWT WebSocket Prysm xargs ghcr Erigon Dockerfiles dockerized tgz reth http PID xml junit dockerfile args PowerShell pectra uname Zsh usermod newgrp systemctl backticked Typecheck autoformat Typechecking groupstats SharedPreStateGroup qube aspell codespell nagydani guido marcin codespell peerdas ckzg CLZ Fujisan zkevm jsign Glamsterdam ``` -------------------------------- ### Displaying Directory Structure of EVMTest Coverage Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/porting_legacy_tests.md This command displays the hierarchical structure of the 'evmtest_coverage' directory, showing the organization of coverage reports, test sets (BASE, PATCH), and difference logs. It helps in navigating and understanding the generated coverage artifacts. ```console ❯ tree evmtest_coverage -L 2 evmt est_coverage └── coverage ├── BASE ├── BASE_TESTS ├── coverage_BASE.lcov ├── coverage_PATCH.lcov ├── DIFF ├── difflog.txt ├── PATCH └── PATCH_TESTS ``` -------------------------------- ### Blockchain Test Fixture Consumption in Go Ethereum Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/releases.md Go-ethereum clients can consume Blockchain Tests directly via a `blocktest`-like command. The example points to the integration in `go-ethereum/cmd/evm/blockrunner.go`. ```go https://github.com/ethereum/go-ethereum/blob/4bb097b7ffc32256791e55ff16ca50ef83c4609b/cmd/evm/blockrunner.go ``` -------------------------------- ### Execute Remote Command with Seed Key Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/execute/remote.md This command extends the basic setup by including a seed account for deploying contracts and funding accounts. The `--rpc-seed-key` flag requires a private key that will be used to sign necessary transactions. This is crucial for tests involving contract deployments or account creations. ```bash uv run execute remote --fork=Prague --rpc-endpoint=https://rpc.endpoint.io --rpc-seed-key 0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f ``` -------------------------------- ### Python Example: Using Stubbed Contracts Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/execute/remote.md Illustrates how to use stubbed contracts in Python tests. When a stub name matches, the test framework uses the pre-deployed contract instead of deploying a new one, saving resources. ```python my_stubbed_contract = pre.deploy_contract(code, stub="uniswap") pre[my_stubbed_contract].nonce # Actual nonce of the contract on chain pre[my_stubbed_contract].balance # Actual balance of the contract on chain ``` -------------------------------- ### Example of BlockException Usage Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/exception_tests.md Illustrates the use of BlockException to signify an invalid block based on a block header property. The example focuses on the INCORRECT_EXCESS_BLOB_GAS scenario. ```python from ethereum_test_exceptions import BlockException # Example usage within a test case (conceptual) # Assuming a test setup where block validation is being performed try: # Code that creates or validates a block with incorrect excess blob gas validate_block_with_incorrect_excess_blob_gas() except BlockException.INCORRECT_EXCESS_BLOB_GAS: # This block is executed if the exception is raised as expected print("Successfully caught INCORRECT_EXCESS_BLOB_GAS exception.") else: # This block is executed if no exception is raised (unexpected) assert False, "Expected INCORRECT_EXCESS_BLOB_GAS but no exception was raised." ``` -------------------------------- ### Basic Simulator Build - Bash Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/hive/common_options.md Runs an EEST simulator with specified fixtures and branch, building the simulator at a specific tag. Requires 'ethereum/eest/consume-engine' simulator and 'go-ethereum' client. ```bash ./hive --sim ethereum/eest/consume-engine \ --sim.buildarg fixtures=stable@v4.3.0 \ --sim.buildarg branch=v4.3.0 \ --client go-ethereum ``` -------------------------------- ### Example of TransactionException Usage Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/exception_tests.md Demonstrates how TransactionException is used to indicate an invalid transaction, leading to an expected invalid block. This example specifically targets the INITCODE_SIZE_EXCEEDED scenario. ```python from ethereum_test_exceptions import TransactionException # Example usage within a test case (conceptual) # Assuming a test setup where transaction creation is being validated try: # Code that attempts to create a transaction with oversized initcode create_transaction_with_oversized_initcode() except TransactionException.INITCODE_SIZE_EXCEEDED: # This block is executed if the exception is raised as expected print("Successfully caught INITCODE_SIZE_EXCEEDED exception.") else: # This block is executed if no exception is raised (unexpected) assert False, "Expected INITCODE_SIZE_EXCEEDED but no exception was raised." ``` -------------------------------- ### Execute eth-config Command: Custom Network Configuration (Bash) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/execute/eth_config.md This example shows how to use 'execute eth-config' with a custom network configuration file. It specifies a custom network name and points to a local YAML file for network details. ```bash uv run execute eth-config --network MyCustomNet --rpc-endpoint http://localhost:8545 --network-config-file ./my-networks.yml ``` -------------------------------- ### Deploy Main Branch Version with Mike Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/docs.md Deploys the documentation generated from the current state of the main branch. It's important to be on the HEAD of the main branch before executing this command. ```console uv run mike deploy --rebase --push main ``` -------------------------------- ### Execute `eest/consume-engine` Standalone Command Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/running.md This command executes the `eest/consume-engine` simulator as a standalone process managed by Hive. It installs EEST and the consume command within a Docker container, suitable for CI environments and generating public test results. ```bash ./hive --sim=eest/consume-engine ``` -------------------------------- ### Deploy Documentation Version with Mike Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/dev/docs.md Builds a new version of the documentation and deploys it to the remote repository. The '--rebase' option ensures a clean commit history, and '--push' uploads changes to the remote. ```console uv run mike deploy -rebase --push v1.2.3 ``` -------------------------------- ### EIPChecklist Partial ID Matching (Python) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/eip_checklist.md Illustrates using partial IDs with the EIPChecklist marker. This allows a single marker to match and cover all checklist items that start with the specified prefix, simplifying test coverage marking for broad categories. ```python @EIPChecklist.TransactionType.Test.Signature.Invalid() def test_all_invalid_signatures(state_test: StateTestFiller): """Test covering all invalid signature scenarios.""" pass ``` -------------------------------- ### Python Exception Mapper Example - EEST Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/consume/exceptions.md A simplified Python example demonstrating the structure of an exception mapper in the EEST codebase. It shows a dictionary mapping specific error strings to standardized exception types. ```python # Simplified example GETH_EXCEPTIONS = { "invalid block: gas limit reached": ExceptionType.GAS_LIMIT_EXCEEDED, "block gas cost exceeds gas limit": ExceptionType.GAS_LIMIT_EXCEEDED, "insufficient balance for transfer": ExceptionType.INSUFFICIENT_BALANCE, } ``` -------------------------------- ### Start Hive with Custom Local IP (macOS) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/hive/dev_mode.md Starts Hive in development mode, specifying a custom local IP address and port for the development server to listen on. Replace with your actual IP. ```bash ./hive --dev --dev.addr :3000 --client go-ethereum --client-file clients.yaml ``` -------------------------------- ### Conventional Commit Examples for PRs Source: https://github.com/ethereum/execution-spec-tests/blob/main/CONTRIBUTING.md Examples of conventional commit messages used for pull requests in the execution-spec-tests repository. These follow the format '(): ' and are used to generate clear and consistent commit histories. ```console # adds new EVM tests to tests/prague/eip7702_set_code_tx/ feat(tests): add test cases for EIP-7702 # a pure EVM test code refactor; no changes to test fixture JSON (at least not to fixture hashes, IDs might change if it's too difficult to preserve them). refactor(tests): split test setup across several fixtures # improve EVM test docstrings (these are included in HTML documentation): docs(tests): improve EIP-7623 docstrings # fix an EVM test fix(tests): EIP-7702 test authorization list nonce/gas # add unit tests for the `execute` command test(execute): add tests for output dir arguments # fix a broken unit test test(fill): fix broken unit test ``` ```console Examples of messages and titles for other types and scopes: feat(eest): add new test generator command fix(forks): resolve `Cancun` initialization issue docs(fill): describe new command-line args refactor(tools): improve code organization in bytecode helpers test(pytest): add tests for logging plugin chore(deps): update dependency versions ``` -------------------------------- ### Example JSON Output from t8n Server Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/filling_tests/debugging_t8n_tools.md This JSON object represents a typical response from a `t8n-server` when called via the `t8n.sh` script. It includes details about the account allocations ('alloc'), the transaction body ('body'), and the resulting state root ('result.stateRoot'), providing crucial data for debugging EVM transitions. ```json { "alloc" : { "0x000000000000000000000000000000000000aaaa" : { "code" : "0x5854505854", "balance" : "0x4", "nonce" : "0x1" }, "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { "balance" : "0x1bc16d674ecb26ce" }, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "0x2cd931", "nonce" : "0x1" } }, "body" : "0xf8a0b89e01f89b0180078304ef0094000000000000000000000000000000000000aaaa0180f838f7940000000000000000000000000000000000000000e1a0000000000000000000000000000000000000000000000000000000000000000001a02e16eb72206c93c471b5894800495ee9c64ae2d9823bcc4d6adeb5d9d9af0dd4a03be6691e933a0816c59d059a556c27c6753e6ce76d1e357b9201865c80b28df3", "result" : { "stateRoot" : "0x51799508f764047aee6606bc6a00863856f83ee5b91555f00c8a3cbdfbec5acb", ... ... } } ``` -------------------------------- ### Reproducing a t8n Command Call with t8n.sh Script Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/filling_tests/debugging_t8n_tools.md This example shows how to use the `t8n.sh` script, generated by the `--evm-dump-dir` flag, to reproduce a specific `t8n` command call. By providing a port number (e.g., `3001` for a Besu t8n-server), the script sends the request to the specified server and prints the response to standard output, facilitating debugging and analysis. ```console /tmp/besu/test_access_list_fork_Berlin/0/t8n.sh 3001 ``` -------------------------------- ### Execute Remote Command with Engine Endpoint and JWT Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/running_tests/execute/remote.md This command enables manual chain progression by specifying an Engine RPC endpoint and JWT secret. The `--engine-endpoint` allows connection to a beacon node for block creation, while `--engine-jwt-secret` provides authentication. This setup offers granular control over the test environment. ```bash uv run execute remote --fork=Prague --rpc-endpoint=https://rpc.endpoint.io --rpc-seed-key 0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f --rpc-chain-id 12345 --engine-endpoint=https://engine.endpoint.io --engine-jwt-secret "your-jwt-secret-here" ``` -------------------------------- ### Implementing a New Fork Method (Python) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/fork_methods.md Provides examples of implementing a new fork method in different fork classes. The first example shows a default implementation returning `False`, and the second shows an updated implementation returning `True`. ```python @classmethod def supports_new_feature(cls, block_number: int = 0, timestamp: int = 0) -> bool: """Return whether the given fork supports the new feature.""" return False # Frontier doesn't support this feature ``` ```python @classmethod def supports_new_feature(cls, block_number: int = 0, timestamp: int = 0) -> bool: """Return whether the given fork supports the new feature.""" return True # This fork does support the feature ``` -------------------------------- ### Generate All Fixture Formats Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/filling_tests/filling_tests_command_line.md Enables the generation of all supported fixture formats, including optimized ones like 'BlockchainEngineXFixture', in a single command. This performs a two-phase execution for optimization. ```console uv run fill --generate-all-formats tests/shanghai/ ``` -------------------------------- ### Generating Checklists via Command Line (Bash) Source: https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/eip_checklist.md Provides bash commands for generating EIP checklists using the 'uv run checklist' command. It shows how to generate for all EIPs, specific EIPs, and multiple EIPs, as well as specifying an output directory. ```bash # Generate checklists for all EIPs uv run checklist # Generate checklist for specific EIP uv run checklist --eip 7702 # Specify output directory uv run checklist --output ./my-checklists # Multiple EIPs uv run checklist --eip 7702 --eip 2930 ```