Skip to content

Commit 834e482

Browse files
spencer-tbclaude
andauthored
feat(test-client-clis): add stream-mode opcode count support for geth (#2170)
* feat(client_clis): add stream-mode opcode count support for geth t8n * fix(test-types): strip geth blockTimestamp from transaction logs * fix(test-types): ignore extra geth fields in FixtureTransactionLog * fix(test-types): address review feedback for geth opcode count support Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fc58fdd commit 834e482

4 files changed

Lines changed: 33 additions & 3 deletions

File tree

packages/testing/src/execution_testing/client_clis/clis/geth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ class GethTransitionTool(GethEvm, TransitionTool):
258258
subcommand: Optional[str] = "t8n"
259259
trace: bool
260260
t8n_use_stream = True
261+
supports_opcode_count: ClassVar[bool] = True
261262

262263
def __init__(
263264
self,

packages/testing/src/execution_testing/client_clis/transition_tool.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,23 @@ def _evaluate_stream(
643643
},
644644
)
645645

646+
if self.supports_opcode_count:
647+
opcode_count_file_path = Path(temp_dir.name) / "opcodes.json"
648+
if opcode_count_file_path.exists():
649+
opcode_count = OpcodeCount.model_validate_json(
650+
opcode_count_file_path.read_text()
651+
)
652+
output.result.opcode_count = opcode_count
653+
654+
if debug_output_path:
655+
with profiler.pause():
656+
dump_files_to_directory(
657+
debug_output_path,
658+
{
659+
"opcodes.json": opcode_count.model_dump(),
660+
},
661+
)
662+
646663
if self.trace:
647664
output.result.traces = self.collect_traces(
648665
output.result.receipts, temp_dir, debug_output_path
@@ -694,8 +711,12 @@ def safe_t8n_args(
694711
f"--state.reward={reward}",
695712
]
696713

697-
if self.trace and temp_dir:
698-
args.extend([trace_flag, f"--output.basedir={temp_dir.name}"])
714+
if temp_dir and (self.trace or self.supports_opcode_count):
715+
args.append(f"--output.basedir={temp_dir.name}")
716+
if self.trace:
717+
args.append(trace_flag)
718+
if self.supports_opcode_count and temp_dir:
719+
args.extend(["--opcode.count", "opcodes.json"])
699720

700721
return args
701722

packages/testing/src/execution_testing/fixtures/common.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
from typing import Any, ClassVar, Dict, List
44

5-
from pydantic import AliasChoices, Field, computed_field, model_validator
5+
from pydantic import (
6+
AliasChoices,
7+
Field,
8+
computed_field,
9+
model_validator,
10+
)
611

712
from execution_testing.base_types import (
813
BlobSchedule,
@@ -102,6 +107,8 @@ def sign(self) -> None:
102107
class FixtureTransactionLog(CamelModel, RLPSerializable):
103108
"""Fixture variant of the TransactionLog type."""
104109

110+
model_config = CamelModel.model_config | {"extra": "ignore"}
111+
105112
address: Address | None = None
106113
topics: List[Hash] | None = None
107114
data: Bytes | None = None

packages/testing/src/execution_testing/test_types/receipt_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class TransactionLog(CamelModel):
2626
block_hash: Hash | None = None
2727
log_index: HexNumber | None = None
2828
removed: bool | None = None
29+
block_timestamp: HexNumber | None = None
2930

3031

3132
class ReceiptDelegation(CamelModel):

0 commit comments

Comments
 (0)