Skip to content

Commit c6b99ee

Browse files
pdobaczspencer-tb
andauthored
feat(fill): pass blobParams into t8n binary (#2264)
* feat(fill): pass blobSchedule into t8n binary * fix(fill): pass entire config containing blobSchedule instead * fix(fill): pass resolved blobParams and non-bpo fork to t8n * chore: pr review comments. * chore: fix evmone filling. * chore: alternative fix evmone filling. * fix(fill): Fix `evmone` filling EIP-7825 * Apply suggestions from code review Co-authored-by: spencer <[email protected]> --------- Co-authored-by: spencer-tb <[email protected]> Co-authored-by: spencer <[email protected]>
1 parent 87cf310 commit c6b99ee

File tree

5 files changed

+60
-4
lines changed

5 files changed

+60
-4
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ This release additionally includes fixes for tests in hive, as well as new test
4141
- ✨ Added `--watch` flag that monitors test files for changes and automatically re-runs the fill command when developing tests ([#2173](https://github.com/ethereum/execution-spec-tests/pull/2173)).
4242
- 🔀 Upgraded ckzg version to 2.1.3 or newer for correct handling of points at infinity ([#2171](https://github.com/ethereum/execution-spec-tests/pull/2171)).
4343
- 🔀 Move pytest marker registration for `fill` and `execute-*` from their respective ini files to the shared `pytest_plugins.shared.execute_fill` pytest plugin ([#2110](https://github.com/ethereum/execution-spec-tests/pull/2110)).
44+
- ✨ Added an `--input.blobParams` CLI argument to the transition tool (`t8n`) invocation ([#2264](https://github.com/ethereum/execution-spec-tests/pull/2264)).
4445

4546
#### `consume`
4647

src/ethereum_clis/cli_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
from pydantic import Field, PlainSerializer, PlainValidator
88

99
from ethereum_test_base_types import (
10-
BlobSchedule,
1110
Bloom,
1211
Bytes,
1312
CamelModel,
1413
EthereumTestRootModel,
1514
Hash,
1615
HexNumber,
1716
)
17+
from ethereum_test_base_types.composite_types import ForkBlobSchedule
1818
from ethereum_test_exceptions import (
1919
BlockException,
2020
ExceptionMapperValidator,
@@ -259,6 +259,7 @@ class TransitionToolInput(CamelModel):
259259
alloc: Alloc
260260
txs: List[Transaction]
261261
env: Environment
262+
blob_params: ForkBlobSchedule | None = None
262263

263264

264265
class TransitionToolOutput(CamelModel):
@@ -275,7 +276,6 @@ class TransitionToolContext(CamelModel):
275276
fork: str
276277
chain_id: int = Field(..., alias="chainid")
277278
reward: int
278-
blob_schedule: BlobSchedule | None
279279

280280

281281
class TransitionToolRequest(CamelModel):

src/ethereum_clis/clis/evmone.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class EvmOneTransitionTool(TransitionTool):
4040
cached_version: Optional[str] = None
4141
trace: bool
4242
supports_opcode_count: ClassVar[bool] = True
43+
supports_blob_params: ClassVar[bool] = True
4344

4445
def __init__(
4546
self,
@@ -329,6 +330,7 @@ class EvmoneExceptionMapper(ExceptionMapper):
329330
),
330331
TransactionException.NONCE_MISMATCH_TOO_LOW: "nonce too low",
331332
TransactionException.NONCE_MISMATCH_TOO_HIGH: "nonce too high",
333+
TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM: "max gas limit exceeded",
332334
# TODO EVMONE needs to differentiate when the section is missing in the
333335
# header or body
334336
EOFException.MISSING_STOP_OPCODE: "err: no_terminating_instruction",

src/ethereum_clis/transition_tool.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from requests_unixsocket import Session # type: ignore
2020

2121
from ethereum_test_base_types import BlobSchedule
22+
from ethereum_test_base_types.composite_types import ForkBlobSchedule
2223
from ethereum_test_exceptions import ExceptionMapper
2324
from ethereum_test_forks import Fork
2425
from ethereum_test_forks.helpers import get_development_forks, get_forks
@@ -75,6 +76,7 @@ class TransitionTool(EthereumCLI):
7576
supports_opcode_count: ClassVar[bool] = False
7677

7778
supports_xdist: ClassVar[bool] = True
79+
supports_blob_params: ClassVar[bool] = False
7880

7981
@abstractmethod
8082
def __init__(
@@ -175,6 +177,36 @@ def fork_name(self) -> str:
175177
timestamp=self.env.timestamp,
176178
)
177179

180+
@property
181+
def fork_name_if_supports_blob_params(self) -> str:
182+
"""Return the fork name."""
183+
fork = self.fork.fork_at(
184+
block_number=self.env.number,
185+
timestamp=self.env.timestamp,
186+
)
187+
188+
# For tools that support blob_params, return base fork for BPO
189+
# forks.
190+
if fork.bpo_fork():
191+
return fork.non_bpo_ancestor().transition_tool_name()
192+
else:
193+
return self.fork.transition_tool_name(
194+
block_number=self.env.number,
195+
timestamp=self.env.timestamp,
196+
)
197+
198+
@property
199+
def blob_params(self) -> ForkBlobSchedule | None:
200+
"""Return the blob parameters for the current fork."""
201+
if self.blob_schedule:
202+
fork_name = self.fork.fork_at(
203+
block_number=self.env.number, timestamp=self.env.timestamp
204+
).name()
205+
# Only return blob params if this fork has them
206+
if fork_name in self.blob_schedule.root:
207+
return self.blob_schedule[fork_name]
208+
return None
209+
178210
def __post_init__(self) -> None:
179211
"""Modify the reward if the environment number is 0."""
180212
if self.env.number == 0:
@@ -186,6 +218,7 @@ def to_input(self) -> TransitionToolInput:
186218
alloc=self.alloc,
187219
txs=self.txs,
188220
env=self.env,
221+
blob_params=self.blob_params,
189222
)
190223

191224
def get_request_data(self) -> TransitionToolRequest:
@@ -195,7 +228,6 @@ def get_request_data(self) -> TransitionToolRequest:
195228
fork=self.fork_name,
196229
chain_id=self.chain_id,
197230
reward=self.reward,
198-
blob_schedule=self.blob_schedule,
199231
),
200232
input=self.to_input(),
201233
)
@@ -231,7 +263,9 @@ def _evaluate_filesystem(
231263
args = [
232264
str(self.binary),
233265
"--state.fork",
234-
t8n_data.fork_name,
266+
t8n_data.fork_name_if_supports_blob_params
267+
if self.supports_blob_params
268+
else t8n_data.fork_name,
235269
"--input.alloc",
236270
input_paths["alloc"],
237271
"--input.env",
@@ -258,6 +292,13 @@ def _evaluate_filesystem(
258292
"opcodes.json",
259293
]
260294
)
295+
if self.supports_blob_params and input_paths.get("blobParams"):
296+
args.extend(
297+
[
298+
"--input.blobParams",
299+
input_paths["blobParams"],
300+
]
301+
)
261302

262303
if self.trace:
263304
args.append("--trace")
@@ -419,6 +460,7 @@ def _evaluate_server(
419460
tx.model_dump(mode="json", **model_dump_config)
420461
for tx in request_data.input.txs
421462
],
463+
"input/blob_params.json": request_data.input.blob_params,
422464
"request_info.txt": request_info,
423465
},
424466
)

src/ethereum_test_forks/base_fork.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,17 @@ def parent(cls) -> Type["BaseFork"] | None:
828828
return None
829829
return base_class
830830

831+
@classmethod
832+
def non_bpo_ancestor(cls) -> Type["BaseFork"]:
833+
"""Return the nearest non-BPO ancestor fork."""
834+
ancestor = cls
835+
while ancestor.bpo_fork():
836+
parent = ancestor.parent()
837+
if parent is None:
838+
break
839+
ancestor = parent
840+
return ancestor
841+
831842
@classmethod
832843
def children(cls) -> Set[Type["BaseFork"]]:
833844
"""Return the children forks."""

0 commit comments

Comments
 (0)