Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,3 @@ def test_eest_bytes_keccak256_matches_eels() -> None:
from_eest = bytes(Bytes(buffer).keccak256())
from_eels = bytes(keccak256(buffer))
assert from_eest == from_eels


def test_eest_trie_keccak256_matches_eels() -> None:
"""`trie.keccak256` and EELS `keccak256` return identical digests."""
from ethereum.crypto.hash import keccak256 as eels

from ...test_types.trie import keccak256 as trie

for buffer in (b"", b"hashme", bytes(range(256))):
assert bytes(trie(buffer)) == bytes(eels(buffer))
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,12 @@ def model_dump(self, mode: str, **model_dump_config: Any) -> Any:
class TransitionToolOutput:
"""Transition tool output."""

alloc: LazyAlloc
# External t8ns return JSON; the testing framework wraps them in a
# ``LazyAlloc`` subclass so the multi-MB alloc isn't parsed until a
# consumer asks. The in-process EELS path materializes ``Alloc``
# eagerly and hands it through directly — no lazy wrapper needed.
# Consumers iterate via ``.get()``, which both branches satisfy.
alloc: LazyAlloc | Alloc
result: Result
body: Bytes | None = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def _evaluate(
dump_files_to_directory(
debug_output_path,
{
"output/alloc.json": output.alloc.raw,
"output/alloc.json": output.alloc,
"output/result.json": output.result.model_dump(
mode="json", **model_dump_config
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
Ethereum Specs EVM Transition Tool Interface.
"""

import json
import tempfile
from io import StringIO
from pathlib import Path
from typing import Any, ClassVar, Dict, Optional

import ethereum
from ethereum_spec_tools.evm_tools import create_parser
from ethereum_spec_tools.evm_tools.t8n import T8N, ForkCache
from ethereum_spec_tools.evm_tools.t8n.evm_trace.eip3155 import Eip3155Tracer
from ethereum_spec_tools.evm_tools.t8n.evm_trace.group import GroupTracer
from ethereum_spec_tools.evm_tools.utils import get_supported_forks
from typing_extensions import override

from execution_testing.client_clis.cli_types import TransitionToolOutput
from execution_testing.client_clis.cli_types import (
TransitionToolOutput,
)
from execution_testing.client_clis.file_utils import (
dump_files_to_directory,
)
Expand Down Expand Up @@ -72,72 +73,53 @@ def _evaluate(
profiler: Profiler,
) -> TransitionToolOutput:
"""
Evaluate using the EELS T8N entry point.
Evaluate using the EELS T8N entry point in-process.

``transition_tool_data`` is handed to ``T8N`` as-is — fork,
chain_id, reward, state_test, blob_schedule all flow through
— and ``T8N.run()`` returns the ``TransitionToolOutput``
directly.
"""
del slow_request, profiler
request_data = transition_tool_data.get_request_data()
request_data_json = request_data.model_dump(
mode="json", **model_dump_config
)

temp_dir = tempfile.TemporaryDirectory()
t8n_args = [
"t8n",
"--input.alloc=stdin",
"--input.env=stdin",
"--input.txs=stdin",
"--output.result=stdout",
"--output.body=stdout",
"--output.alloc=stdout",
f"--output.basedir={temp_dir.name}",
f"--state.fork={request_data_json['state']['fork']}",
f"--state.chainid={request_data_json['state']['chainid']}",
f"--state.reward={request_data_json['state']['reward']}",
]

if transition_tool_data.state_test:
t8n_args.append("--state-test")

if transition_tool_data.blob_params:
fork = transition_tool_data.fork
if fork.bpo_fork() and fork != fork.non_bpo_ancestor():
# Only send this information for BPO forks.
# TODO: This should be optimized by the t8n tool instead.
t8n_args.append("--input.blobParams=stdin")

tracers = None
if self.trace:
t8n_args.extend(
[
"--trace",
"--trace.memory",
"--trace.returndata",
]
# TODO: Eip3155 traces still round-trip through tempfile
# JSON — the tracer writes one ``trace-<i>.jsonl`` per tx
# to ``output_basedir`` and ``collect_traces`` reads them
# back. Same JSON round-trip we eliminated for alloc /
# result / body; a follow-up should wire the tracer
# output through memory like the rest of the in-process
# path.
tracers = GroupTracer()
tracers.add(
Eip3155Tracer(
trace_memory=True,
trace_stack=True,
trace_return_data=True,
output_basedir=temp_dir.name,
Comment thread
gurukamath marked this conversation as resolved.
)
)

parser = create_parser()
t8n_options = parser.parse_args(t8n_args)

out_stream = StringIO()

in_stream = StringIO(json.dumps(request_data_json["input"]))

t8n = T8N(t8n_options, out_stream, in_stream, self.fork_cache)
t8n.run()

output_dict = json.loads(out_stream.getvalue())
output: TransitionToolOutput = TransitionToolOutput.model_validate(
output_dict, context={"exception_mapper": self.exception_mapper}
t8n = T8N(
transition_tool_data,
cache=self.fork_cache,
tracers=tracers,
exception_mapper=self.exception_mapper,
)
output = t8n.run()

if debug_output_path:
dump_files_to_directory(
debug_output_path,
{
"input/alloc.json": request_data.input.alloc,
"input/env.json": request_data.input.env,
"input/alloc.json": transition_tool_data.alloc,
"input/env.json": transition_tool_data.env,
"input/txs.json": [
tx.model_dump(mode="json", **model_dump_config)
for tx in request_data.input.txs
for tx in transition_tool_data.txs
],
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def _evaluate_server(
dump_files_to_directory(
debug_output_path,
{
"output/alloc.json": output.alloc.raw,
"output/alloc.json": output.alloc,
"output/result.json": output.result,
"output/txs.rlp": str(output.body),
"response_info.txt": response_info,
Expand Down
2 changes: 1 addition & 1 deletion packages/testing/src/execution_testing/specs/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class BuiltBlock(CamelModel):

header: FixtureHeader
env: Environment
alloc: LazyAlloc
alloc: LazyAlloc | Alloc
state_root: Hash
txs: List[Transaction]
ommers: List[FixtureHeader]
Expand Down
Loading
Loading