Skip to content

feat(pytest): add two commands that consume blockchain test fixtures#339

Merged
danceratopz merged 94 commits intoethereum:mainfrom
danceratopz:feat/pytest/add-a-verify-fixtures-as-a-separate-pytest-command
May 8, 2024
Merged

feat(pytest): add two commands that consume blockchain test fixtures#339
danceratopz merged 94 commits intoethereum:mainfrom
danceratopz:feat/pytest/add-a-verify-fixtures-as-a-separate-pytest-command

Conversation

@danceratopz
Copy link
Copy Markdown
Member

@danceratopz danceratopz commented Oct 25, 2023

🗒️ Description

This PR:

  1. Adds a new command: consume, which acts as a base command with sub-commands corresponding to the different way clients can consume json test fixtures.
  2. Adds a consume direct command that takes a directory containing JSON fixture files and an evm tool as command-line arguments (currently geth evm tool only).
    For example:
    fill --output fixtures-no-paris -n auto -k "not Paris"  # geth master evm tool expects "Merge" not "Paris"
    consume direct --input=fixtures-no-paris -n auto
    
  3. Adds a consume rlp command that implements the hive/simulators/ethereum/consensus simulator as a pytest plugin. If a hive server is started in --dev mode, such as:
    ./hive --dev --client go-ethereum --client-file configs/cancun.yaml --docker.output --sim.loglevel 4
    
    then the python port of the consensus simulator can be executed (not the HIVE_SIMULATOR evn var must be set) as: example:
    export HIVE_SIMULATOR=http://127.0.0.1:3000
    # then, e.g., run on a release with the `consume_via_rlp` simulator:
    consume rlp --input=https://github.com/ethereum/execution-spec-tests/releases/download/v2.1.1/fixtures.tar.gz -k selfdestruct -n auto
    # or, e.g., run fill and then execute the result in the `consume_via_rlp` simulator:
    fill --output=fixtures --fork Shanghai -n auto -k "not hive and warm_coinbase";
    consume rlp --input=fixtures -v -n auto
    # or
    fill --output=stdout --fork Shanghai -k "not hive and warm_coinbase" | consume rlp -v  # piping doesn't support -n auto
    

The skeleton is there to add a re-write of the "pyspec" (consume-via-engine-api) simulator, but this is currently not implemented.

consume direct

This is another pytest-based command that dynamically generates test cases for every fixture in the fixture files located in the fixture directory. Each test case executes the blocktest command using --single-test (see ethereum/go-ethereum#28421) to execute the tests on a per-fixture level:
image

If --run/--single-fixture is not available in blocktest, it falls back to the usual blocktest behaviour of executing all fixtures within the provided json file:
image

Further ideas:

  • Write metadata to fixtures' _info sections using fill that can be used when generating the tests in fill, for example, which eips are required to run the test; xfail if not supported.
  • In CI/CD this can be used with pytest's --junit-xml=test_results.xml option and the publish-test-results Github Action, for example. Can also be combined with xdist to get parallelisation out of the box.

This is how consume fits in within execution-spec-tests and alongside other ways of consuming fixtures:
image

consume rlp

Requires: https://github.com/danceratopz/hive.py/tree/fix/client/files-def-in-post-with-files

A re-write of the hive/simulators/ethereum/consensus simulator as a pytest plugin.

Lots to talk about and still lots to fix 😄

Currently works with go-ethereum and besu. This is also possible:

./hive --dev --client go-ethereum,besu

then consume rlp will parametrize each blockchain test by client_type.

Dockerized Usage with Hive

The simulator be ran (without --dev mode) in Hive with:

./hive --sim ethereum/eest-block-rlp  --client-file configs/cancun.yaml --client go-ethereum --docker.output

using this Dockerfile:
https://github.com/danceratopz/hive/blob/mek-it-snek/simulators/ethereum/eest-block-rlp/Dockerfile#L1-L15

This currently has no testing and no docs.

TODO:

🔗 Related Issues

✅ Checklist

  • All: Set appropriate labels for the changes.
  • All: Considered squashing commits to improve commit history.
  • All: Added an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • Tests: Included the type and version of evm t8n tool used to locally execute test cases: e.g., ref with commit hash or geth 1.13.1-stable-3f40e65.
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.

@danceratopz danceratopz added scope:evm Scope: evm_transition_tool package scope:pytest Scope: Changes EEST's pytest plugins type:feat type: Feature labels Oct 25, 2023
Copy link
Copy Markdown
Collaborator

@spencer-tb spencer-tb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really appreciate this PR - its going to be very useful in the future once every client has a blocktest-like sub-command! Let's get this CI up and running :D

All further ideas are great as well! We should add the coverage to this weekly testing report for each client team

Comment thread setup.cfg Outdated
Comment thread setup.cfg Outdated
Comment thread src/entry_points/cli.py Outdated
Comment thread whitelist.txt
@danceratopz danceratopz changed the title feat(pytest): add a consume command that acts as a test runner for client statetest/blocktest commands feat(pytest): add two commands that consume blockchain test fixtures Nov 25, 2023
Copy link
Copy Markdown
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments, but overall it's really impressive!

Comment thread src/pytest_plugins/pytest_hive/pytest_hive.py
Comment thread src/ethereum_test_tools/common/types.py Outdated
Comment thread tests_consume/test_via_rlp.py Outdated
Comment thread tests_consume/test_via_rlp.py Outdated
Comment thread tests_consume/test_via_rlp.py Outdated
Comment thread src/pytest_plugins/consume_via_engine_api/consume_via_engine_api.py Outdated
@danceratopz danceratopz marked this pull request as ready for review May 7, 2024 15:41
Copy link
Copy Markdown
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I think we should be able to merge directly to main.

Comment thread src/ethereum_test_tools/spec/consume/types.py Outdated
@danceratopz danceratopz changed the base branch from feat/consume to main May 7, 2024 19:45
@danceratopz danceratopz merged commit 54ac85a into ethereum:main May 8, 2024
kclowes pushed a commit to kclowes/execution-spec-tests that referenced this pull request Oct 20, 2025
Co-authored-by: spencer <spencer.taylor-brown@ethereum.org>
Co-authored-by: Mario Vega <marioevz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:evm Scope: evm_transition_tool package scope:pytest Scope: Changes EEST's pytest plugins type:feat type: Feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants