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: allow dynamic evm fork definitions via pytest plugin #753

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

danceratopz
Copy link
Member

🗒️ 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.

This adds a fork registry to allow dynamic fork class definitions. This enables non-mainnet evm implementations to add/modify their fork definitions.
@danceratopz danceratopz added type:feat type: Feature scope:fw Scope: Framework (evm|tools|forks|pytest) labels Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:fw Scope: Framework (evm|tools|forks|pytest) type:feat type: Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant