From 589ab4ef1daaf97dfa60856ca0bed83891a684f9 Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Fri, 13 Sep 2024 17:30:34 +0200 Subject: [PATCH] feat(ci,evm_transition_tool): Add EthereumJS (#752) * Add EthereumJS wrapper * Change binary name for EthereumJS * add ethereumjs action * Correctly setup EthJS EVM action * config/feature: update to not run slow and 2537 tests * docs: add ethereumjs support to readme/index * Update .github/actions/build-evm-client/ethjs/action.yml Co-authored-by: Mario Vega * Update .github/actions/build-evm-client/ethjs/action.yml Co-authored-by: Mario Vega --------- Co-authored-by: danceratopz Co-authored-by: Mario Vega --- .github/actions/build-evm-base/action.yaml | 6 +++ .../actions/build-evm-client/ethjs/action.yml | 37 +++++++++++++++++ .github/configs/evm-impl.yaml | 5 ++- .github/configs/evm.yaml | 6 ++- .github/configs/feature.yaml | 4 ++ README.md | 1 + docs/index.md | 1 + src/evm_transition_tool/__init__.py | 2 + src/evm_transition_tool/ethereumjs.py | 40 +++++++++++++++++++ whitelist.txt | 1 + 10 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 .github/actions/build-evm-client/ethjs/action.yml create mode 100644 src/evm_transition_tool/ethereumjs.py diff --git a/.github/actions/build-evm-base/action.yaml b/.github/actions/build-evm-base/action.yaml index 20f444686f..f58e33f979 100644 --- a/.github/actions/build-evm-base/action.yaml +++ b/.github/actions/build-evm-base/action.yaml @@ -62,3 +62,9 @@ runs: with: repo: ${{ steps.config-evm-reader.outputs.repo }} ref: ${{ steps.config-evm-reader.outputs.ref }} + - name: Build the EVM using EthJS action + if: steps.config-evm-reader.outputs.impl == 'ethjs' + uses: ./.github/actions/build-evm-client/ethjs + with: + repo: ${{ steps.config-evm-reader.outputs.repo }} + ref: ${{ steps.config-evm-reader.outputs.ref }} \ No newline at end of file diff --git a/.github/actions/build-evm-client/ethjs/action.yml b/.github/actions/build-evm-client/ethjs/action.yml new file mode 100644 index 0000000000..f4d39d9809 --- /dev/null +++ b/.github/actions/build-evm-client/ethjs/action.yml @@ -0,0 +1,37 @@ +name: 'Build EthereumJS monorepo' +description: 'Builds the EthereumJS monorepo' +inputs: + repo: + description: 'Source repository to use to build EthereumJS' + required: true + default: 'ethereumjs/ethereumjs-monorepo' + ref: + description: 'Reference to branch, commit, or tag to use to build EthereumJS' + required: true + default: 'master' +runs: + using: "composite" + steps: + - name: Checkout EthereumJS monorepo + uses: actions/checkout@v4 + with: + repository: ${{ inputs.repo }} + ref: ${{ inputs.ref }} + path: ethereumjs + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Build monorepo + shell: bash + run: | + cd $GITHUB_WORKSPACE/ethereumjs + npm ci + + - name: Add t8ntool to $PATH + shell: bash + run: | + echo $GITHUB_WORKSPACE/ethereumjs/packages/vm/test/t8n/ >> $GITHUB_PATH + echo $GITHUB_WORKSPACE/ethereumjs/node_modules/.bin >> $GITHUB_PATH \ No newline at end of file diff --git a/.github/configs/evm-impl.yaml b/.github/configs/evm-impl.yaml index 06d00137e5..31aaa3ebfb 100644 --- a/.github/configs/evm-impl.yaml +++ b/.github/configs/evm-impl.yaml @@ -6,4 +6,7 @@ evmone: x-dist: auto besu: evm-bin: evmtool - x-dist: 0 \ No newline at end of file + x-dist: 0 +ethjs: + evm-bin: ethereumjs-t8ntool.sh + x-dist: auto \ No newline at end of file diff --git a/.github/configs/evm.yaml b/.github/configs/evm.yaml index 301d225fb0..a8e4549596 100644 --- a/.github/configs/evm.yaml +++ b/.github/configs/evm.yaml @@ -13,4 +13,8 @@ eip7692: eip7692-prague: impl: besu repo: hyperledger/besu - ref: main \ No newline at end of file + ref: main +pectra-devnet-3: + impl: ethjs + repo: ethereumjs/ethereumjs-monorepo + ref: t8ntool \ No newline at end of file diff --git a/.github/configs/feature.yaml b/.github/configs/feature.yaml index a4b3caa9af..4446086ff0 100644 --- a/.github/configs/feature.yaml +++ b/.github/configs/feature.yaml @@ -17,4 +17,8 @@ eip7692: eip7692-prague: evm-type: eip7692-prague fill-params: --fork=PragueEIP7692 ./tests/prague -k "not slow" + solc: 0.8.21 +pectra-devnet-3: + evm-type: pectra-devnet-3 + fill-params: --fork=Prague -m "not slow and not 2537" ./tests/prague/ solc: 0.8.21 \ No newline at end of file diff --git a/README.md b/README.md index a96dd83947..c2688d1643 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ The following transition tools are supported by the framework: | [ethereum/evmone](https://github.com/ethereum/evmone) | `evmone-t8n` | Yes | | [ethereum/execution-specs](https://github.com/ethereum/execution-specs) | `ethereum-spec-evm` | Yes | | [ethereum/go-ethereum](https://github.com/ethereum/go-ethereum) | [`evm t8n`](https://github.com/ethereum/go-ethereum/tree/master/cmd/evm) | Yes | +| [ethereumjs](https://github.com/ethereumjs/ethereumjs-monorepo) | [`ethereumjs-t8ntool.sh`](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/vm/test/t8n) | No | | [hyperledger/besu](https://github.com/hyperledger/besu/tree/main/ethereum/evmtool) | [`evm t8n-server`](https://github.com/hyperledger/besu/tree/main/ethereum/evmtool) | Yes | | [status-im/nimbus-eth1](https://github.com/status-im/nimbus-eth1) | [`t8n`](https://github.com/status-im/nimbus-eth1/blob/master/tools/t8n/readme.md) | Yes | diff --git a/docs/index.md b/docs/index.md index f98bd1d54c..6429923e87 100644 --- a/docs/index.md +++ b/docs/index.md @@ -66,6 +66,7 @@ The following transition tools are supported by the framework: | -------| ---------- | --------------- | | [ethereum/evmone](https://github.com/ethereum/evmone) | `evmone-t8n` | Yes | | [ethereum/execution-specs](https://github.com/ethereum/execution-specs) | `ethereum-spec-evm` | Yes | +| [ethereumjs](https://github.com/ethereumjs/ethereumjs-monorepo) | [`ethereumjs-t8ntool.sh`](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/vm/test/t8n) | No | | [ethereum/go-ethereum](https://github.com/ethereum/go-ethereum) | [`evm t8n`](https://github.com/ethereum/go-ethereum/tree/master/cmd/evm) | Yes | | [hyperledger/besu](https://github.com/hyperledger/besu/tree/main/ethereum/evmtool) | [`evmtool t8n-server`](https://github.com/hyperledger/besu/tree/main/ethereum/evmtool) | Yes | | [status-im/nimbus-eth1](https://github.com/status-im/nimbus-eth1) | [`t8n`](https://github.com/status-im/nimbus-eth1/blob/master/tools/t8n/readme.md) | Yes | diff --git a/src/evm_transition_tool/__init__.py b/src/evm_transition_tool/__init__.py index 6d9937fad9..6faadb1941 100644 --- a/src/evm_transition_tool/__init__.py +++ b/src/evm_transition_tool/__init__.py @@ -3,6 +3,7 @@ """ from .besu import BesuTransitionTool +from .ethereumjs import EthereumJSTransitionTool from .evmone import EvmOneTransitionTool from .execution_specs import ExecutionSpecsTransitionTool from .geth import GethTransitionTool @@ -14,6 +15,7 @@ __all__ = ( "BesuTransitionTool", + "EthereumJSTransitionTool", "EvmOneTransitionTool", "ExecutionSpecsTransitionTool", "GethTransitionTool", diff --git a/src/evm_transition_tool/ethereumjs.py b/src/evm_transition_tool/ethereumjs.py new file mode 100644 index 0000000000..03db217b61 --- /dev/null +++ b/src/evm_transition_tool/ethereumjs.py @@ -0,0 +1,40 @@ +""" +EthereumJS Transition tool interface. +""" +from pathlib import Path +from re import compile +from typing import Optional + +from ethereum_test_forks import Fork + +from .transition_tool import TransitionTool + + +class EthereumJSTransitionTool(TransitionTool): + """ + EthereumJS Transition tool interface wrapper class. + """ + + default_binary = Path("ethereumjs-t8ntool.sh") + detect_binary_pattern = compile(r"^ethereumjs t8n\b") + version_flag: str = "--version" + t8n_use_stream = False + + binary: Path + cached_version: Optional[str] = None + trace: bool + + def __init__( + self, + *, + binary: Optional[Path] = None, + trace: bool = False, + ): + super().__init__(binary=binary, trace=trace) + + def is_fork_supported(self, fork: Fork) -> bool: + """ + Returns True if the fork is supported by the tool. + Currently, EthereumJS-t8n provides no way to determine supported forks. + """ + return True diff --git a/whitelist.txt b/whitelist.txt index ccbe250a34..32b722b8c6 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -270,6 +270,7 @@ NOP NOPs nPython nSHA +t8ntool num number ommer