feat(test-consume): initial implementation of the enginex simulator #1964
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🗒️ Description
Adds a
consume enginexsimulator that reuses client instances across tests sharing the same pre-allocation state. This simulator significantly reduces test execution time compared toconsume engineby avoiding per-test client startup overhead.Includes basic
pytest-xdistsupport via--dist=loadgroup, with further optimizations planned in subsequent PRs.Architecture
The
enginexsimulator groups tests bypre_hash(hash of genesis + pre-state). Tests in the same group run against a single client instance instead of starting/stopping per test.New Files
simulators/enginex/conftest.pysimulators/multi_test_client.pyMultiTestClientManagerfor client lifecyclesimulators/helpers/test_tracker.pyModified
consume.pyxdist_groupmarker based onpre_hashfor enginex fixturestest_via_engine.pyengineandenginexmodespytest_hive.pyshared_hive_testfixture for cross-test client sharingprocessors.py--dist=loadgroupdefault for enginex with xdistExecution Flow
pytest_collection_modifyitemscounts tests per group, sorts bypre_hash.mark_test_completedtriggers client shutdown.Fixture Chain
flowchart LR subgraph "Per Group (cached)" PAG[pre_alloc_group] --> CG[client_genesis] PAG --> GH[genesis_header] CG --> BG[buffered_genesis] BG --> CF[client_files] end subgraph "Client (reused)" CF --> C[client] C --> ETH[eth_rpc] C --> ENG[engine_rpc] end subgraph "Per Test" TC[test_case] --> F[fixture] F --> P[payloads] end subgraph "Test Execution" GH --> TEST[test_blockchain_via_engine] ENG --> TEST P --> TEST endTesting
For testing, use this custom release which keeps tests marked as
@pytest.mark.slowin the same pre-alloc group as their non-slow counterparts (greatly reduces the number of groups):https://github.com/danceratopz/execution-specs/releases/tag/v0.1.0a1
🔗 Related Issues or PRs
N/A.
✅ Checklist
toxchecks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx tox -e statictype(scope):.[ ] All: Considered adding an entry to CHANGELOG.md.skippedCute Animal Picture