-
Notifications
You must be signed in to change notification settings - Fork 323
STEEL Merge #1280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STEEL Merge #1280
Changes from all commits
3e8894c
e26438f
55c4463
b34ba1b
0d075e8
5e937ba
7fe99f5
50166de
1cd0725
b71ea2e
2cc5672
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,3 +58,5 @@ pip-delete-this-directory.txt | |
tests/execution-spec-generated-tests | ||
tests/fixtures | ||
tests/t8n_testdata | ||
|
||
fixtures |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "eest_tests/execution-spec-tests"] | ||
path = eest_tests/execution-spec-tests | ||
url = https://github.com/ethereum/execution-spec-tests.git |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import pytest | ||
from ethereum_spec_tools.evm_tools.t8n.transition_tool import EELST8N | ||
from ethereum_clis import TransitionTool | ||
|
||
|
||
@pytest.hookimpl(tryfirst=True) | ||
def pytest_configure(config): | ||
TransitionTool.set_default_tool(EELST8N) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
""" | ||
Implementation of the EELS T8N for execution-spec-tests. | ||
""" | ||
|
||
import json | ||
import tempfile | ||
from io import StringIO | ||
from typing import Any, Dict, Optional | ||
|
||
from ethereum_clis.clis.execution_specs import ExecutionSpecsExceptionMapper | ||
from ethereum_clis.file_utils import dump_files_to_directory | ||
from ethereum_clis.transition_tool import TransitionTool, model_dump_config | ||
from ethereum_clis.types import TransitionToolOutput | ||
from ethereum_test_forks import Fork | ||
|
||
import ethereum | ||
|
||
from .. import create_parser | ||
from ..utils import get_supported_forks | ||
from . import T8N | ||
|
||
|
||
class EELST8N(TransitionTool): | ||
"""Implementation of the EELS T8N for execution-spec-tests.""" | ||
|
||
def __init__( | ||
self, | ||
*, | ||
trace: bool = False, | ||
): | ||
"""Initialize the EELS Transition Tool interface.""" | ||
self.exception_mapper = ExecutionSpecsExceptionMapper() | ||
self.trace = trace | ||
self._info_metadata: Optional[Dict[str, Any]] = {} | ||
|
||
def version(self) -> str: | ||
"""Version of the t8n tool.""" | ||
return ethereum.__version__ | ||
|
||
def is_fork_supported(self, fork: Fork) -> bool: | ||
"""Return True if the fork is supported by the tool.""" | ||
return fork.transition_tool_name() in get_supported_forks() | ||
|
||
def evaluate( | ||
self, | ||
*, | ||
transition_tool_data: TransitionTool.TransitionToolData, | ||
debug_output_path: str = "", | ||
slow_request: bool = False, # noqa: U100, F841 | ||
) -> TransitionToolOutput: | ||
""" | ||
Evaluate using the EELS T8N entry point. | ||
""" | ||
request_data = transition_tool_data.get_request_data() | ||
request_data_json = request_data.model_dump( | ||
mode="json", **model_dump_config | ||
) | ||
|
||
t8n_args = [ | ||
"t8n", | ||
"--input.alloc=stdin", | ||
"--input.env=stdin", | ||
"--input.txs=stdin", | ||
"--output.result=stdout", | ||
"--output.body=stdout", | ||
"--output.alloc=stdout", | ||
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") | ||
|
||
temp_dir = tempfile.TemporaryDirectory() | ||
if self.trace: | ||
t8n_args.extend( | ||
[ | ||
"--trace", | ||
"--trace.memory", | ||
"--trace.returndata", | ||
f"--output.basedir={temp_dir.name}", | ||
] | ||
) | ||
|
||
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) | ||
t8n.run() | ||
|
||
output_dict = json.loads(out_stream.getvalue()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We really should make this interface less... insane 🤣 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. For EELS, we can make this much more simple and native. However, EEST has to have this interface to be able to work with the other clients. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean specifically our t8n interface. We don't need a JSON round trip here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah. I see. Yes. That is definitely the long term plan |
||
output: TransitionToolOutput = TransitionToolOutput.model_validate( | ||
output_dict, context={"exception_mapper": self.exception_mapper} | ||
) | ||
|
||
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/txs.json": [ | ||
tx.model_dump(mode="json", **model_dump_config) | ||
for tx in request_data.input.txs | ||
], | ||
}, | ||
) | ||
|
||
dump_files_to_directory( | ||
debug_output_path, | ||
{ | ||
"output/alloc.json": output.alloc, | ||
"output/result.json": output.result, | ||
}, | ||
) | ||
|
||
if self.trace: | ||
self.collect_traces( | ||
output.result.receipts, temp_dir, debug_output_path | ||
) | ||
temp_dir.cleanup() | ||
|
||
return output |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tox] | ||
min_version = 2.0 | ||
envlist = py3,pypy3,static | ||
envlist = py3,pypy3,py3_eest,static | ||
|
||
[testenv:static] | ||
extras = | ||
|
@@ -30,22 +30,52 @@ commands = | |
--no-cov-on-fail \ | ||
--cov-branch \ | ||
--ignore-glob='tests/fixtures/*' \ | ||
--basetemp="{temp_dir}/pytest" | ||
--basetemp="{temp_dir}/pytest" \ | ||
tests | ||
|
||
[testenv:py3_eest] | ||
extras = | ||
test | ||
commands = | ||
fill \ | ||
-m "not slow and not zkevm and not benchmark" \ | ||
-n auto --maxprocesses 6 \ | ||
--basetemp="{temp_dir}/pytest" \ | ||
--clean \ | ||
SamWilsn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
eest_tests/execution-spec-tests/tests | ||
fill \ | ||
-m "not slow and not zkevm and not benchmark" \ | ||
-n auto --maxprocesses 6 \ | ||
--basetemp="{temp_dir}/pytest" \ | ||
--clean \ | ||
--fork Osaka \ | ||
eest_tests/execution-spec-tests/tests/osaka | ||
|
||
[testenv:pypy3] | ||
extras = | ||
test | ||
passenv = | ||
PYPY_GC_MAX | ||
commands = | ||
pytest \ | ||
fill \ | ||
--tb=no \ | ||
--show-capture=no \ | ||
--disable-warnings \ | ||
-m "not slow" \ | ||
-n auto --maxprocesses 5 \ | ||
--ignore-glob='tests/fixtures/*' \ | ||
--basetemp="{temp_dir}/pytest" | ||
-m "not slow and not zkevm and not benchmark" \ | ||
-n auto --maxprocesses 3 \ | ||
--basetemp="{temp_dir}/pytest" \ | ||
--clean \ | ||
eest_tests/execution-spec-tests/tests | ||
fill \ | ||
--tb=no \ | ||
--show-capture=no \ | ||
--disable-warnings \ | ||
-m "not slow and not zkevm and not benchmark" \ | ||
-n auto --maxprocesses 3 \ | ||
--basetemp="{temp_dir}/pytest" \ | ||
--clean \ | ||
--fork Osaka \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned on Discord, we should single source fork information. |
||
eest_tests/execution-spec-tests/tests/osaka | ||
|
||
[testenv:optimized] | ||
extras = | ||
|
@@ -60,7 +90,8 @@ commands = | |
--ignore-glob='tests/fixtures/*' \ | ||
--ignore-glob='tests/test_t8n.py' \ | ||
--basetemp="{temp_dir}/pytest" \ | ||
--optimized | ||
--optimized \ | ||
tests | ||
|
||
[testenv:doc] | ||
basepython = python3 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -494,4 +494,7 @@ SECP256R1P | |
secp256r1 | ||
sig | ||
|
||
CLZ | ||
CLZ | ||
EELST8N | ||
clis | ||
T8 |
Uh oh!
There was an error while loading. Please reload this page.