-
Notifications
You must be signed in to change notification settings - Fork 167
chore(deps): create eels t8n transition tool #1807
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
""" | ||
EELS T8N transition tool. | ||
|
||
https://github.com/ethereum/execution-specs | ||
""" | ||
|
||
from abc import ABC, abstractmethod | ||
from typing import List | ||
|
||
from ethereum_clis import TransitionTool, TransitionToolOutput | ||
from ethereum_test_base_types import BlobSchedule | ||
from ethereum_test_forks import Fork | ||
from ethereum_test_types import Alloc, Environment, Transaction | ||
|
||
|
||
class EELST8NWrapper(TransitionTool, ABC): | ||
""" | ||
Abstract base class for EELS T8N wrapper implementations. | ||
|
||
This class provides an interface for calling the EELS T8N entrypoint directly | ||
without going through a binary. It implements a registration mechanism for | ||
concrete implementations to be set as the default wrapper. | ||
|
||
Attributes: | ||
_default (class): The registered default subclass to use for instantiation. | ||
Should be set via `set_default()`. | ||
|
||
Usage: | ||
1. Create a concrete subclass implementing all abstract methods | ||
2. Register it using `EELST8NWrapper.set_default(YourSubclass)` | ||
3. Instantiate via `EELST8NWrapper.default()` | ||
|
||
""" | ||
|
||
_default = None | ||
|
||
@classmethod | ||
def set_default(cls, default_cls): | ||
""" | ||
Register a default subclass for instantiation. | ||
|
||
Args: | ||
default_cls: The subclass to register as default | ||
|
||
Raises: | ||
TypeError: If `default_cls` is not a subclass of EELST8NWrapper | ||
|
||
""" | ||
if not issubclass(default_cls, cls): | ||
raise TypeError(f"{default_cls.__name__} is not a subclass of {cls.__name__}") | ||
cls._default = default_cls | ||
|
||
@classmethod | ||
def default(cls, *args, **kwargs): | ||
""" | ||
Instantiate the registered default implementation. | ||
|
||
Returns: | ||
Instance of the registered default subclass | ||
|
||
Raises: | ||
RuntimeError: If no default implementation has been registered | ||
|
||
""" | ||
if cls._default is None: | ||
raise RuntimeError("Default subclass not set!") | ||
return cls._default(*args, **kwargs) | ||
|
||
@abstractmethod | ||
def version(self): | ||
"""Return the version string of the transition tool implementation.""" | ||
pass | ||
|
||
@abstractmethod | ||
def is_fork_supported(self, fork) -> bool: | ||
"""Check if a specific fork is supported by the tool.""" | ||
pass | ||
|
||
@abstractmethod | ||
def _evaluate_eels_t8n( | ||
self, | ||
*, | ||
t8n_data: TransitionTool.TransitionToolData, | ||
debug_output_path: str = "", | ||
) -> TransitionToolOutput: | ||
""" | ||
Execute the transition tool implementation (core functionality). | ||
|
||
This must be implemented by concrete subclasses to provide the actual | ||
transition tool evaluation logic. | ||
|
||
Args: | ||
t8n_data: Input data for the state transition | ||
debug_output_path: Optional path for writing debug output | ||
|
||
Returns: | ||
TransitionToolOutput: Result of the state transition | ||
|
||
""" | ||
pass | ||
|
||
def evaluate( | ||
self, | ||
*, | ||
alloc: Alloc, | ||
txs: List[Transaction], | ||
env: Environment, | ||
fork: Fork, | ||
chain_id: int, | ||
reward: int, | ||
blob_schedule: BlobSchedule | None, | ||
debug_output_path: str = "", | ||
state_test: bool = False, | ||
slow_request: bool = False, | ||
) -> TransitionToolOutput: | ||
""" | ||
Execute the relevant evaluate method as required by the `t8n` tool. | ||
|
||
If a client's `t8n` tool varies from the default behavior, this method | ||
can be overridden. | ||
""" | ||
fork_name = fork.transition_tool_name( | ||
block_number=env.number, | ||
timestamp=env.timestamp, | ||
) | ||
if env.number == 0: | ||
reward = -1 | ||
t8n_data = self.TransitionToolData( | ||
alloc=alloc, | ||
txs=txs, | ||
env=env, | ||
fork_name=fork_name, | ||
chain_id=chain_id, | ||
reward=reward, | ||
blob_schedule=blob_schedule, | ||
state_test=state_test, | ||
) | ||
|
||
return self._evaluate_eels_t8n(t8n_data=t8n_data, debug_output_path=debug_output_path) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.