-
Notifications
You must be signed in to change notification settings - Fork 7
fix - shutdown anvil-zksync
zombies, review tests and fork method for latest anvil-zksync
#46
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
base: main
Are you sure you want to change the base?
Conversation
- Removed deprecated anvil-zksync arguments - Updated test to use "safe" block_identifier by default - Updated environment.py to use new fork_rpc method - Updated node.py to handle new fork mode arguments - Ensured compatibility with latest anvil-zksync changes Now anvil-zksync can be shut down gracefully without leaving zombie processes. And the tests are updated to reflect the new behavior of the fork method. Everything has been adapted to pytest xdist workers with detection of env variable to run tests in parallel, without port conflicts. Suggested anvil port is now by default 8011 to allow adding the network to MetaMask. If 8011 is already in use, then we apply free port logic.
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
"<unknown>).get_name_of(address) -> ['string'])", | ||
" <Unknown contract 0x0000000000000000000000000000000000008009>", | ||
" <Unknown contract 0x000000000000000000000000000000000000800b>", | ||
# " <Unknown contract 0x000000000000000000000000000000000000800b>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I let this here, but maybe we can remove it if we follow along with the latest?
# @dev deprecated in boa, use AnvilZKsync fork mode | ||
# return super().fork(url, reset_traces, block_identifier, debug, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove it after the review
# @dev deprecated in boa, use AnvilZKsync fork mode | |
# return super().fork(url, reset_traces, block_identifier, debug, **kwargs) |
Related issue: #45
What I did
The main goal was to kill the remaining
anvil-zksync
process, since they were not garbage collected. But I ended up adaptingboa-zksync
to the latestanvil-zksync
and reviewed the fork system.Key changes include the refactoring of environment setup functions, enhancements to the
AnvilZKsync
class for managing test nodes (lifecycle), and updates to dependencies and test configurations.I tried at first to go for a context manager method inside
AnvilZKsync
but it was not adapted to our need, and it would have brought too many changes in other tools like Moccasin.How I did it
Improvements to
AnvilZKsync
test node management:WeakSet
to track activeAnvilZKsync
instances and ensure proper cleanup using anatexit
handler. (boa_zksync/node.py
, boa_zksync/node.pyR1-R31)pytest-xdist
and fallback to a suggested port when available. (boa_zksync/node.py
, boa_zksync/node.pyR76-R221)_build_command
method for constructing commands and improved error handling during node shutdown. (boa_zksync/node.py
, boa_zksync/node.pyR76-R221)Enhancements to zkSync environment setup:
set_zksync_env
,set_zksync_test_env
, andset_zksync_fork
to improve clarity and ensure consistent environment initialization. Added detailed docstrings for better documentation. (boa_zksync/__init__.py
, boa_zksync/init.pyR12-R48)node_args
inset_zksync_fork
and updated the default behavior forblock_identifier
. (tests/conftest.py
, tests/conftest.pyL33-R35)Updates to forking and RPC handling:
fork
andfork_rpc
methods to improve handling of RPC connections, ensure proper cleanup of existing nodes, and support new configurations. (boa_zksync/environment.py
, [1] [2]is_port_free
to check port availability, improving the robustness of test node setup. (boa_zksync/util.py
, boa_zksync/util.pyR23-R47)Dependency and configuration updates:
pyproject.toml
temporarily sincezkvyper
does not supportvyper>=0.4.2
(I'll go handle this).Test updates:
zksync_sepolia_fork
fixture. (tests/conftest.py
, tests/conftest.pyL33-R35)test_boa_loads.py
to reflect changes in error messages and contract behavior. (tests/test_boa_loads.py
, tests/test_boa_loads.pyL134-R151)How to verify it
Run
make test
and see it all pass. You should have the latest anvil-zksync, and it should pass with the latest blocks.You can also run
make lint
to be sure that the code complies.Description for the changelog
Enhanced AnvilZKsync Management: implemented automatic cleanup of test nodes, enabled dynamic port allocation for parallel testing, and improved overall node startup/shutdown robustness.
Streamlined zkSync Environment: refactored environment setup functions (set_zksync_env, set_zksync_fork, etc.) for clearer usage and updated forking defaults.
Improved Forking Logic: enhanced fork and fork_rpc methods for better RPC connection handling and more reliable node setup.
Dependency & Test Adjustments: included a temporary dependency fix for zkvyper and updated test configurations/assertions to match the new system.
Cute Animal Picture