Skip to content

Commit 646ce03

Browse files
feat(clis,pytest-plugins): allow pytest commands from package, addexecute eth-config command (#1863)
* feat(execute): `execute eth-config` command * feat(forks): Add required forkid forks * feat(rpc): Add forkid to eth_config * feat(plugins/eth_config): Fixes and add fork id * refactor(rpc): Move unit tests file * refactor(execute): Use pytest_configure * fix(execute,rpc): Update to latest spec version * fix(execute,rpc): Update again to latest spec version * pyproject: Add execute eth-config networks file * refactor(pytest_commands): Work without having to clone repository * fix: tests, tox * refactor: Rename pytest command files * refactor: Move pytest-fill.ini, refactor PytestCommand * refactor: Move and package eels_resolutions.json file * fix: All unit tests * fix: review comments * feat(execute): add more granular eth_config testing * feat(rpc): Add chainId * fix: Help of all execute commands * docs: Add eth-config command * fix(tox.ini): Update commands (sneakily lower benchmark block-gas-limit) * fix: tox * docs: Changelog * docs(execute): minor improvements to docs --------- Co-authored-by: danceratopz <[email protected]>
1 parent c631bf4 commit 646ce03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1785
-276
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Users can select any of the artifacts depending on their testing needs for their
6464

6565
- ✨ Added new `Blob` class which can use the ckzg library to generate valid blobs at runtime ([#1614](https://github.com/ethereum/execution-spec-tests/pull/1614)).
6666
- ✨ Added `blob_transaction_test` execute test spec, which allows tests that send blob transactions to a running client and verifying its `engine_getBlobsVX` endpoint behavior ([#1644](https://github.com/ethereum/execution-spec-tests/pull/1644)).
67+
- ✨ Added `execute eth-config` command to test the `eth_config` RPC endpoint of a client, and includes configurations by default for Mainnet, Sepolia, Holesky, and Hoodi ([#1863](https://github.com/ethereum/execution-spec-tests/pull/1863)).
6768

6869
### 📋 Misc
6970

@@ -91,6 +92,7 @@ Users can select any of the artifacts depending on their testing needs for their
9192
- 🔀 Add fixture comparison check to optimize coverage workflow in CI ([#1833](https://github.com/ethereum/execution-spec-tests/pull/1833)).
9293
- 🔀 Move `TransactionType` enum from test file to proper module location in `ethereum_test_types.transaction_types` for better code organization and reusability ([#1763](https://github.com/ethereum/execution-spec-tests/pull/1673)).
9394
- ✨ Opcode classes now validate keyword arguments and raise `ValueError` with clear error messages ([#1739](https://github.com/ethereum/execution-spec-tests/pull/1739), [#1856](https://github.com/ethereum/execution-spec-tests/pull/1856)).
95+
- ✨ All commands (`fill`, `consume`, `execute`) now work without having to clone the repository, e.g. `uv run --with git+https://github.com/ethereum/execution-spec-tests.git consume` now works from any folder ([#1863](https://github.com/ethereum/execution-spec-tests/pull/1863)).
9496

9597
### 🧪 Test Cases
9698

docs/filling_tests/debugging_t8n_tools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,4 @@ where the `verify_fixtures.sh` script can be used to reproduce the `evm blocktes
178178
This means, by default, that the feedback is not as granular as for test case execution. To improve granularity, and get feedback per parametrized test case use `--single-fixture-per-file`.
179179

180180
[^1]: <!-- markdownlint-disable MD053 (53=link-image-reference-definitions) -->
181-
This limitation is required to enable support of the [`pytest-xdist` plugin](https://github.com/pytest-dev/pytest-xdist) for concurrent test execution across multiple CPUs. To achieve this we use the we apply the `--dist loadscope` xdist flag in our `pytest.ini`.
181+
This limitation is required to enable support of the [`pytest-xdist` plugin](https://github.com/pytest-dev/pytest-xdist) for concurrent test execution across multiple CPUs. To achieve this we use the we apply the `--dist loadscope` xdist flag in our `pytest-fill.ini`.

docs/navigation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
* [Execute Commands](./running_tests/execute/index.md)
6262
* [Execute Hive](./running_tests/execute/hive.md)
6363
* [Execute Remote](./running_tests/execute/remote.md)
64+
* [Execute Eth Config](./running_tests/execute/eth_config.md)
6465
* [Useful Pytest Options](running_tests/useful_pytest_options.md)
6566
* [Developer Doc](dev/index.md)
6667
* [Managing Configurations](dev/configurations.md)
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Execute eth-config Command
2+
3+
The `execute eth-config` command is a specialized testing tool that validates an Ethereum client's configuration against expected network parameters using the `eth_config` RPC endpoint as specified by [EIP-7910](https://eips.ethereum.org/EIPS/eip-7910).
4+
5+
The goal is to test baked-in configurations primarily but it can be used to test that genesis and config files were successfully parsed, in devnets for example.
6+
7+
## Overview
8+
9+
This command verifies that a client is correctly configured for a specific network by checking:
10+
11+
- Current fork configuration.
12+
- Fork activation times.
13+
- Chain ID.
14+
- Precompile addresses.
15+
- System contract addresses.
16+
- Fork hashes and IDs.
17+
18+
## Usage
19+
20+
### Standalone, Direct Usage
21+
22+
The `eth-config` sub-command can be ran directly, without cloning @ethereum/execution-spec-tests, by [installing uv](https://docs.astral.sh/uv/getting-started/installation/) and running:
23+
24+
```bash
25+
uv run --with git+https://github.com/ethereum/execution-spec-tests.git execute eth-config --network Mainnet --rpc-endpoint http://<ETH_RPC_ENDPOINT>
26+
```
27+
28+
### From within the EEST Repository
29+
30+
```bash
31+
uv run execute eth-config --network <NETWORK_NAME> --rpc-endpoint <RPC_URL> [OPTIONS]
32+
```
33+
34+
### Required Arguments
35+
36+
- `--network`: Name of the network to verify (e.g., `Mainnet`, `Sepolia`, `Holesky`, `Hoodi`)
37+
- `--rpc-endpoint`: RPC endpoint URL of the execution client to test
38+
39+
### Optional Arguments
40+
41+
- `--network-config-file`: Path to a custom YAML file containing network configurations (defaults to `src/pytest_plugins/execute/eth_config/networks.yml`)
42+
43+
## Examples
44+
45+
### Testing a Mainnet Client
46+
47+
```bash
48+
uv run execute eth-config --network Mainnet --rpc-endpoint http://localhost:8545
49+
```
50+
51+
### Testing a Sepolia Client
52+
53+
```bash
54+
uv run execute eth-config --network Sepolia --rpc-endpoint http://localhost:8545
55+
```
56+
57+
### Using a Custom Network Configuration
58+
59+
```bash
60+
uv run execute eth-config --network MyCustomNet --rpc-endpoint http://localhost:8545 --network-config-file ./my-networks.yml
61+
```
62+
63+
## Network Configuration File Format
64+
65+
The network configuration file is a YAML file that defines the parameters for each network. Here's the structure:
66+
67+
```yaml
68+
MyCustomNet:
69+
chainId: 0xabcd # Chain ID in hex
70+
genesisHash: 0xd4e5674... # Genesis block hash
71+
forkActivationTimes: # Fork activation block numbers/times
72+
0: Cancun # Genesis fork, it must be the latest fork activated in the genesis
73+
1742999832: Prague
74+
1742999833: Osaka
75+
bpoForkActivationTimes: # Optional: Blob parameter only fork definitions
76+
1742999834:
77+
target: 9
78+
max: 12
79+
base_fee_update_fraction: 5007716
80+
1742999835:
81+
target: 12
82+
max: 15
83+
base_fee_update_fraction: 5007716
84+
addressOverrides: # Optional: Override addresses for precompiles/contracts
85+
0x00000000219ab540...: 0x7f02c3e3c98b133...
86+
```
87+
88+
### Supported Networks
89+
90+
The default configuration file includes:
91+
92+
- **Mainnet**: Ethereum mainnet.
93+
- **Sepolia**: Public testnet.
94+
- **Hoodi**: Public testnet.
95+
- **Holesky**: Public testnet.
96+
97+
## How It Works
98+
99+
1. **Configuration Loading**: The command loads the network configuration from the YAML file.
100+
2. **RPC Connection**: Connects to the specified client RPC endpoint.
101+
3. **eth_config Call**: Calls the `eth_config` RPC method to get the client's current configuration.
102+
4. **Validation**: Compares the client's response against the expected configuration based on:
103+
- Current system timestamp.
104+
- Fork activation schedule.
105+
- Address overrides (if any).
106+
107+
## `eth_config` Expected Response Details
108+
109+
See [EIP-7910](https://eips.ethereum.org/EIPS/eip-7910) for the expected response description.

docs/running_tests/execute/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ See:
66

77
- [Execute Hive](./hive.md) for help with the `execute` simulator in order to run tests on a single-client local network.
88
- [Execute Remote](./remote.md) for help with executing tests on a remote network such as a devnet, or even mainnet.
9+
- [Execute Eth Config](./eth_config.md) for help verifying client configurations on a remote network such as a devnet, or even mainnet.
910

1011
The rest of this page describes how `execute` works and explains its architecture.
1112

docs/scripts/generate_fill_help.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import subprocess
1313
import sys
1414
import textwrap
15-
from pathlib import Path
1615

1716
import mkdocs_gen_files
1817

@@ -21,17 +20,12 @@
2120

2221
def get_fill_help_output() -> str:
2322
"""Run 'fill --help' and capture its output."""
24-
# Get the repository root (assuming script is in docs/scripts/)
25-
script_dir = Path(__file__).parent
26-
repo_root = script_dir.parent.parent
27-
2823
try:
2924
result = subprocess.run(
3025
["uv", "run", "fill", "--help"],
3126
capture_output=True,
3227
text=True,
3328
check=True,
34-
cwd=repo_root, # Run from repo root where pytest.ini exists
3529
)
3630
return result.stdout
3731
except subprocess.CalledProcessError as e:

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ exclude = ["tests/static/**"]
116116

117117
[tool.setuptools.package-data]
118118
ethereum_test_forks = ["forks/contracts/*.bin"]
119+
"pytest_plugins.execute" = ["eth_config/networks.yml"]
120+
"pytest_plugins" = [
121+
"eels_resolutions.json"
122+
]
119123
"cli.eest.make" = ["templates/*.j2"]
124+
"cli.pytest_commands" = ["pytest_ini_files/*.ini"]
120125

121126
[tool.ruff]
122127
line-length = 99

pytest-framework.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,4 @@ addopts =
1010
-p pytest_plugins.eels_resolver
1111
--ignore=src/pytest_plugins/consume/test_cache.py
1212
--ignore=src/pytest_plugins/consume/direct/
13-
--ignore=src/pytest_plugins/consume/direct/test_via_direct.py
1413
--ignore=src/pytest_plugins/consume/simulators/
15-
--ignore=src/pytest_plugins/consume/simulators/engine/test_via_engine.py
16-
--ignore=src/pytest_plugins/consume/simulators/rlp/test_via_rlp.py
17-
--ignore=src/pytest_plugins/execute/test_recover.py

src/cli/gentest/tests/test_cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ def get_mock_context(self: StateTestProvider) -> dict:
116116
## Fill ##
117117
with open(generated_py_file, "r") as f:
118118
pytester.makepyfile(f.read())
119-
pytester.copy_example(name="pytest.ini")
119+
pytester.copy_example(name="src/cli/pytest_commands/pytest_ini_files/pytest-fill.ini")
120120

121121
args = [
122+
"-c",
123+
"pytest-fill.ini",
122124
"-m",
123125
"state_test",
124126
"--fork",

0 commit comments

Comments
 (0)