diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0d7924d679..29a3e301cb 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -58,6 +58,7 @@ Test fixtures for use by clients are available for each release on the [Github r - ✨ Fill test fixtures using EELS by default. EEST now uses the [`ethereum-specs-evm-resolver`](https://github.com/petertdavies/ethereum-spec-evm-resolver) with the EELS daemon ([#792](https://github.com/ethereum/execution-spec-tests/pull/792)). - 🔀 Move the `evm_transition_tool` package to `ethereum_clis` and derive the transition tool CL interfaces from a shared `EthereumCLI` class that can be reused for other sub-commands ([#894](https://github.com/ethereum/execution-spec-tests/pull/894)). +- ✨ Pass `state_test` property to T8N tools that support it (Only EELS at the time of merge) ([#943](https://github.com/ethereum/execution-spec-tests/pull/943)). ### 📋 Misc diff --git a/src/ethereum_clis/clis/besu.py b/src/ethereum_clis/clis/besu.py index 708d5b949f..840c8f8082 100644 --- a/src/ethereum_clis/clis/besu.py +++ b/src/ethereum_clis/clis/besu.py @@ -108,6 +108,7 @@ def evaluate( reward: int = 0, eips: Optional[List[int]] = None, debug_output_path: str = "", + state_test: bool = False, ) -> TransitionToolOutput: """ Executes `evm t8n` with the specified arguments. diff --git a/src/ethereum_clis/clis/execution_specs.py b/src/ethereum_clis/clis/execution_specs.py index 85ff426d64..335123bf53 100644 --- a/src/ethereum_clis/clis/execution_specs.py +++ b/src/ethereum_clis/clis/execution_specs.py @@ -9,7 +9,7 @@ from pathlib import Path from re import compile from tempfile import TemporaryDirectory -from typing import Optional +from typing import Dict, List, Optional from ethereum_test_exceptions import ( EOFException, @@ -111,6 +111,16 @@ def is_fork_supported(self, fork: Fork) -> bool: """ return (fork.transition_tool_name() + "\n") in self.help_string + def _generate_post_args( + self, t8n_data: TransitionTool.TransitionToolData + ) -> Dict[str, List[str] | str]: + """ + Generate the arguments for the POST request to the t8n-server. + + EELS T8N expects `--state-test` when running a state test. + """ + return {"arg": "--state-test"} if t8n_data.state_test else {} + class ExecutionSpecsExceptionMapper(ExceptionMapper): """ diff --git a/src/ethereum_clis/transition_tool.py b/src/ethereum_clis/transition_tool.py index 47c53e6409..1306e3e93e 100644 --- a/src/ethereum_clis/transition_tool.py +++ b/src/ethereum_clis/transition_tool.py @@ -13,6 +13,7 @@ from dataclasses import dataclass, field from pathlib import Path from typing import Any, Dict, List, Mapping, Optional, Type +from urllib.parse import urlencode from requests import Response from requests.exceptions import ConnectionError @@ -147,6 +148,7 @@ class TransitionToolData: fork_name: str chain_id: int = field(default=1) reward: int = field(default=0) + state_test: bool = field(default=False) def to_input(self) -> TransitionToolInput: """ @@ -271,14 +273,23 @@ def _evaluate_filesystem( return output - def _server_post(self, data: Dict[str, Any], retries: int = 10) -> Response: + def _server_post( + self, + data: Dict[str, Any], + url_args: Dict[str, List[str] | str] = {}, + retries: int = 5, + ) -> Response: """ Send a POST request to the t8n-server and return the response. """ post_delay = 0.1 while True: try: - response = Session().post(self.server_url, json=data, timeout=20) + response = Session().post( + f"{self.server_url}?{urlencode(url_args, doseq=True)}", + json=data, + timeout=20, + ) break except ConnectionError as e: retries -= 1 @@ -294,6 +305,12 @@ def _server_post(self, data: Dict[str, Any], retries: int = 10) -> Response: ) return response + def _generate_post_args(self, t8n_data: TransitionToolData) -> Dict[str, List[str] | str]: + """ + Generate the arguments for the POST request to the t8n-server. + """ + return {} + def _evaluate_server( self, *, @@ -332,7 +349,7 @@ def _evaluate_server( }, ) - response = self._server_post(post_data) + response = self._server_post(data=post_data, url_args=self._generate_post_args(t8n_data)) output: TransitionToolOutput = TransitionToolOutput.model_validate(response.json()) if debug_output_path: @@ -478,6 +495,7 @@ def evaluate( reward: int = 0, eips: Optional[List[int]] = None, debug_output_path: str = "", + state_test: bool = False, ) -> TransitionToolOutput: """ Executes the relevant evaluate method as required by the `t8n` tool. @@ -500,6 +518,7 @@ def evaluate( fork_name=fork_name, chain_id=chain_id, reward=reward, + state_test=state_test, ) if self.t8n_use_server: diff --git a/src/ethereum_test_specs/state.py b/src/ethereum_test_specs/state.py index a39add940e..4595d2f6bb 100644 --- a/src/ethereum_test_specs/state.py +++ b/src/ethereum_test_specs/state.py @@ -6,6 +6,7 @@ from typing import Any, Callable, ClassVar, Dict, Generator, List, Optional, Type import pytest +from pydantic import Field from ethereum_clis import TransitionTool from ethereum_test_exceptions import EngineAPIError @@ -39,7 +40,7 @@ class StateTest(BaseTest): Filler type that tests transactions over the period of a single block. """ - env: Environment + env: Environment = Field(default_factory=Environment) pre: Alloc post: Alloc tx: Transaction @@ -149,6 +150,7 @@ def make_state_test_fixture( reward=0, # Reward on state tests is always zero eips=eips, debug_output_path=self.get_next_transition_tool_output_path(), + state_test=True, ) try: diff --git a/whitelist.txt b/whitelist.txt index 4d1ac828e9..1344a15896 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -113,6 +113,7 @@ discordapp dockerdocs docstring docstrings +doseq dunder dup EEST