execution-spec-tests icon indicating copy to clipboard operation
execution-spec-tests copied to clipboard

feat: allow dynamic evm fork definitions via pytest plugin

Open danceratopz opened this issue 6 months ago • 0 comments

🗒️ Description

This adds a new fork_registry and a chain_selector plugin (although not strictly required) that enables a pytest plugin (there's temporary and very simple example in ./src/pytest_plugins/optimism.py) to dynamically register fork class definitions. This allows evm implementations that deviate from Ethereum mainnet to use EEST.

Example

Register the optimism plugin (--chain flag likely superfluous) and execute test_withdrawing_to_precompiles which uses the with_all_precompiles test parametrizer:

fill -p pytest_plugins.optimism --chain=optimism --fork=OptimismCancun tests/shanghai/eip4895_withdrawals/ -k "test_withdrawing_to_precompiles and amount_0" -m blockchain_test --collect-only -q

to additionally parametrize the test with the secp256r1 precompile that's deployed at 0x100:

tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles[fork_OptimismCancun-precompile_256-blockchain_test-amount_0]
tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles[fork_OptimismCancun-precompile_10-blockchain_test-amount_0]
tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles[fork_OptimismCancun-precompile_9-blockchain_test-amount_0]
tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles[fork_OptimismCancun-precompile_5-blockchain_test-amount_0]
tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles[fork_OptimismCancun-precompile_6-blockchain_test-amount_0]
tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles[fork_OptimismCancun-precompile_7-blockchain_test-amount_0]
tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles[fork_OptimismCancun-precompile_8-blockchain_test-amount_0]
tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles[fork_OptimismCancun-precompile_1-blockchain_test-amount_0]
tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles[fork_OptimismCancun-precompile_2-blockchain_test-amount_0]
tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles[fork_OptimismCancun-precompile_3-blockchain_test-amount_0]
tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_withdrawing_to_precompiles[fork_OptimismCancun-precompile_4-blockchain_test-amount_0]

The main magic is using the correct fork class definitions via forks plugin.

TODO

This is a very rough POC and hasn't been properly tested. The forks plugin is probably very broken.

🔗 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: All converted JSON/YML tests from ethereum/tests have been added to converted-ethereum-tests.txt.
  • [ ] Tests: A PR with removal of converted JSON/YML tests from ethereum/tests have been opened.
  • [ ] 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 avatar Aug 19 '24 13:08 danceratopz