Skip to content
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

feat(tests): port ethereum/tests test cases (tracking issue) #972

Open
3 of 15 tasks
danceratopz opened this issue Nov 25, 2024 · 4 comments · May be fixed by #1018
Open
3 of 15 tasks

feat(tests): port ethereum/tests test cases (tracking issue) #972

danceratopz opened this issue Nov 25, 2024 · 4 comments · May be fixed by #1018
Assignees
Labels
good first issue Good for newcomers scope:tests Scope: Test cases type:feat type: Feature

Comments

@danceratopz
Copy link
Member

danceratopz commented Nov 25, 2024

This is a top-level issue for tracking the manual porting of ethereum/tests test cases to execution-spec-tests:

Contributions to manually port individual test cases are very welcome!

If you're already familiar with ethereum/tests and execution-spec-tests, jump to the issue tracker below!

Background

ethereum/tests was the repository used to define EVM test cases from Frontier up to and including The Merge. The test cases are defined as YAML (and sometimes JSON) files in the ./src/ sub-directory and the JSON "test fixtures" (fully-populated tests that can be executed against clients) are generated using ethereum/retesteth. These JSON artifacts are regenerated when required and added to the repository, for example, in the ./GeneralStateTests/ sub-directory.

From Shanghai on, new test cases (in particular for new features included in hard-forks) have been defined in Python in this repository (execution-spec-tests). The existing test cases are still important to execute against clients, however, and porting ethereum/tests to execution-spec-tests ensures that the test cases can be continually maintained and filled (generated) for newer forks. It also has the advantage that client teams will only need to obtain test fixture releases from one source.

Automated Port to Python

Although there will be an effort to automate ("transpile") the remaining test cases from YAML (respectively JSON) to Python; contributions to manually port individual test cases can be very beneficial and are welcome!

The benefits of manual porting are:

  1. Reduce the number of test cases by combing multiple YAML (resp. JSON) test cases in one Python test function (via parametrization).
  2. Potentially improve coverage by parametrizing the Python version.
  3. Code/docstrings are likely higher quality than an automated conversion.
  4. The test can be better organized within the ./tests folder in execution-spec-tests by the fork and the EIP in which the functionality was introduced.

Process

  1. Pick a single or a set of YAML test cases in ethereum/tests to port and create an issue in this repository - optional, but definitely recommended if porting tests from the tracker below to avoid duplicate work.
  2. Create a PR with the ported tests:
    a. Add the list of ported YAML files to converted-ethereum-tests.txt.
    b. If the tests can't currently be filled, please explain the issue (feel free to also open a Discussion).

Help with ethereum/tests

The test formats are described in the ethereum/tests online docs. Note that state filler test cases in YAML can be parametrized, see the docs here.

Hints to Get Started with ethereum/execution-spec-tests

  1. Start here: Getting Started → Installation.
  2. Use uv run et make test to create a template test module (currently a WIP in ✨ feat(et): add et make test for interactively creating new tests #950).
  3. Where to put the test? See how tests are organized in Writing Tests → Adding a New Test.
  4. State vs Blockchain test? If in doubt try to write a state test, see Writing Tests → Types of Tests → Deciding on a Test Type.
  5. Tests are filled via EELS by default (no further installation necessary; it's a Python dependency and got installed in Step 0), see Filling → Getting Started.
  6. Parametrizing test functions is encouraged, see Writing Tests → Writing a New Test → Parametrizing Tests.
  7. The Opcode mini-lang defined in this repository is the preferred way to define bytecode in tests (if feasible). For a very simple example, see test_chainid() - there are other examples in the tests.

Feel free to reach out for help or guidance in the Ethereum R&D discord or via DM; see Getting Help in the docs.

Test Cases

Preview Give feedback

Some Examples of Ported Tests

ethereum/tests ethereum/execution-spec-tests
src/GeneralStateTestsFiller/VMTests/vmTests/dupFiller.yml tests/frontier/opcodes/test_dup.py
GeneralStateTests/stCreate2/call_outsize_then_create2_successful_then_returndatasize.json, GeneralStateTests/stCreate2/call_then_create2_successful_then_returndatasize.json tests/constantinople/eip1014_create2/test_create_returndata.py
@winsvega
Copy link
Collaborator

I still remain quite skeptical about automated port. I would rather focus on rewriting the tests. there are not so many if you take combinations and vector tests (precompile inputs) and random tests out. (which are easy to do in python too)
then remaining are either simple cases or heavy cases.

@pacrob
Copy link
Contributor

pacrob commented Dec 4, 2024

I'll take porting swapFiller.yml if nobody's working on it yet. NM, Looking for a better option 😁

OK, how about the 3 calldata tests - copy, load, and size? @danceratopz

@bomanaps
Copy link

bomanaps commented Dec 9, 2024

Please can I take on swapFiller.yml? @danceratopz

@danceratopz
Copy link
Member Author

Please can I take on swapFiller.yml? @danceratopz

Yes, @bomanaps! Please make an issue when you get started and I can link it in the tracker here to avoid anyone else working on it :)

@felix314159 felix314159 linked a pull request Dec 12, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers scope:tests Scope: Test cases type:feat type: Feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants