Skip to content

Commit

Permalink
evm_transition_tool: Add execution-specs, ethereum-spec-evm (#200)
Browse files Browse the repository at this point in the history
* evm_transition_tool: Add execution-specs

* evm_transition_tool: Add execution-specs unsupported forks

* docstring: document how to use the execution-specs transition tool

* docstring: fix minor formatting issue

* fix: class rename

* fix: word

---------

Co-authored-by: danceratopz <danceratopz@gmail.com>
  • Loading branch information
marioevz and danceratopz authored Jul 12, 2023
1 parent 760df58 commit 1f99ad7
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/evm_transition_tool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
"""

from .evmone import EvmOneTransitionTool
from .execution_specs import ExecutionSpecsTransitionTool
from .geth import GethTransitionTool
from .transition_tool import TransitionTool, TransitionToolNotFoundInPath, UnknownTransitionTool

TransitionTool.set_default_tool(GethTransitionTool)

__all__ = (
"EvmOneTransitionTool",
"ExecutionSpecsTransitionTool",
"GethTransitionTool",
"TransitionTool",
"TransitionToolNotFoundInPath",
Expand Down
4 changes: 2 additions & 2 deletions src/evm_transition_tool/evmone.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Evmone Transition tool frontend.
Evmone Transition tool interface.
"""
import json
import os
Expand All @@ -24,7 +24,7 @@ def write_json_file(data: Dict[str, Any], file_path: str) -> None:

class EvmOneTransitionTool(TransitionTool):
"""
Evmone `evmone-t8n` Transition tool frontend wrapper class.
Evmone `evmone-t8n` Transition tool interface wrapper class.
"""

default_binary = Path("evmone-t8n")
Expand Down
67 changes: 67 additions & 0 deletions src/evm_transition_tool/execution_specs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""
Ethereum Specs EVM Transition tool interface.
https://github.com/ethereum/execution-specs
"""

from pathlib import Path
from re import compile

from ethereum_test_forks import ConstantinopleFix, Fork

from .geth import GethTransitionTool

UNSUPPORTED_FORKS = (ConstantinopleFix,)


class ExecutionSpecsTransitionTool(GethTransitionTool):
"""
Ethereum Specs `ethereum-spec-evm` Transition tool interface wrapper class.
The behavior of this tool is almost identical to go-ethereum's `evm t8n` command.
note: How to use the `ethereum-spec-evm` tool:
1. Create a virtual environment and activate it:
```
python -m venv venv
source venv/bin/activate
```
2. Clone the ethereum/execution-specs repository and change working directory to it:
```
git clone git@github.com:ethereum/execution-specs.git
cd execution-specs
```
3. Install the packages provided by the repository:
```
pip install -e .
```
Check that the `ethereum-spec-evm` command is available:
```
ethereum-spec-evm --help
```
4. Clone the ethereum/execution-specs-tests repository and change working directory to it:
```
cd ..
git clone git@github.com:ethereum/execution-spec-tests.git
cd execution-spec-tests
```
5. Install the packages provided by the ethereum/execution-spec-tests repository:
```
pip install -e .
```
6. Run the tests, specifying the `ethereum-spec-evm` command as the transition tool:
```
fill --evm-bin=ethereum-spec-evm
```
"""

default_binary = Path("ethereum-spec-evm")
detect_binary_pattern = compile(r"^ethereum-spec-evm\b")

def is_fork_supported(self, fork: Fork) -> bool:
"""
Returns True if the fork is supported by the tool.
Currently, ethereum-spec-evm provides no way to determine supported forks.
"""
return fork not in UNSUPPORTED_FORKS
4 changes: 2 additions & 2 deletions src/evm_transition_tool/geth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Go-ethereum Transition tool frontend.
Go-ethereum Transition tool interface.
"""

import json
Expand All @@ -17,7 +17,7 @@

class GethTransitionTool(TransitionTool):
"""
Go-ethereum `evm` Transition tool frontend wrapper class.
Go-ethereum `evm` Transition tool interface wrapper class.
"""

default_binary = Path("evm")
Expand Down

0 comments on commit 1f99ad7

Please sign in to comment.