Skip to content

Commit

Permalink
refactor[test]: bypass eth-tester and interface with evm backend di…
Browse files Browse the repository at this point in the history
…rectly (#3846)

Refactor the test suite to use the EVM backend directly. Get rid of
`eth-tester` and `web3`, add support for pyrevm.

How:
- Create a `BaseEnv` abstraction which has both `py-evm` and `pyrevm`
  backends
- Implementing multiple backends gives us flexibility between EVM
  backends (especially if there is feature disparity between backends,
  e.g. regarding EIP implementation), and additionally serves as a form
  of differential testing by using different backend implementations.
- Add `ABIContract` abstraction to interface between EVM and contracts
- `BaseEnv` and `ABIContract` are substantially "inspired by" titanoboa,
  but we did not introduce titanoboa as a dependency because it
  increases the coupling between `vyper` and `titanoboa` repos.
- Install pyrevm and update tests
- Remove `eth-tester` and `web3` dependencies

Misc/refactoring:
- Prune a bunch of unneeded functionality in `tests/conftest.py`
  - `tx_failed()` does not need to snapshot (that is handled by
    reverting)
  - Protect every test with `env.anchor()`
  - Remove unneeded `get_contract*` duplicate implementations
  • Loading branch information
DanielSchiavini authored May 2, 2024
1 parent 2e6fbe7 commit 097aecf
Show file tree
Hide file tree
Showing 138 changed files with 4,024 additions and 3,341 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
evm-version: [shanghai]
experimental-codegen: [false]
memorymock: [false]
evm-backend: [revm]

# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#expanding-or-adding-matrix-configurations
include:
Expand All @@ -79,6 +80,7 @@ jobs:
debug: false
opt-mode: gas
evm-version: london

- python-version: ["3.11", "311"]
debug: false
opt-mode: gas
Expand All @@ -95,6 +97,19 @@ jobs:
opt-mode: gas
evm-version: cancun

# py-evm rules
- python-version: ["3.11", "311"]
debug: false
opt-mode: codesize
evm-version: london
evm-backend: py-evm

- python-version: ["3.11", "311"]
debug: false
opt-mode: gas
evm-version: cancun
evm-backend: py-evm

# test experimental pipeline
- python-version: ["3.11", "311"]
opt-mode: gas
Expand Down Expand Up @@ -123,8 +138,13 @@ jobs:
debug: false
evm-version: shanghai


name: py${{ matrix.python-version[1] }}-opt-${{ matrix.opt-mode }}${{ matrix.debug && '-debug' || '' }}${{ matrix.memorymock && '-memorymock' || '' }}${{ matrix.experimental-codegen && '-experimental' || '' }}-${{ matrix.evm-version }}
name: "py${{ matrix.python-version[1] }}\
-opt-${{ matrix.opt-mode }}\
${{ matrix.debug && '-debug' || '' }}\
${{ matrix.memorymock && '-memorymock' || '' }}\
${{ matrix.experimental-codegen && '-experimental' || '' }}\
-${{ matrix.evm-version }}\
${{ matrix.evm-backend && format('-{0}', matrix.evm-backend) || '' }}"

steps:
- uses: actions/checkout@v4
Expand All @@ -150,6 +170,7 @@ jobs:
-m "not fuzzing" \
--optimize ${{ matrix.opt-mode }} \
--evm-version ${{ matrix.evm-version }} \
${{ matrix.evm-backend && format('--evm-backend {0}', matrix.evm-backend) || '' }} \
${{ matrix.debug && '--enable-compiler-debug-mode' || '' }} \
${{ matrix.memorymock && '--memorymock' || '' }} \
${{ matrix.experimental-codegen && '--experimental-codegen' || '' }} \
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"pytest-instafail>=0.4,<1.0",
"pytest-xdist>=3.0,<3.4",
"pytest-split>=0.7.0,<1.0",
"eth-tester[py-evm]>=0.11.0b1,<0.12",
"eth_abi>=5.0.0,<6.0.0",
"py-evm>=0.10.1b1,<0.11",
"web3>=7.0.0b4,<8.0",
"lark==1.1.9",
"hypothesis[lark]>=6.0,<7.0",
"eth-stdlib==0.2.7",
"eth-account==0.12.2",
"setuptools",
"hexbytes>=1.2",
"pyrevm>=0.3.2",
],
"lint": [
"black==23.12.0",
Expand Down
Loading

0 comments on commit 097aecf

Please sign in to comment.