-
Notifications
You must be signed in to change notification settings - Fork 416
feat(test-execute): Implement pre.deterministic_deploy_contract
#1934
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(test-execute): Implement pre.deterministic_deploy_contract
#1934
Conversation
|
One open question is that, in execute, we will not be able to run two different tests that use the same contract without causing issues. |
|
I've verified this locally using fill and kurtosis, the test can be run over and over and the deployment only happens once. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #1934 +/- ##
================================================
Coverage 86.33% 86.33%
================================================
Files 538 538
Lines 34557 34557
Branches 3222 3222
================================================
Hits 29835 29835
Misses 4148 4148
Partials 574 574
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CPerezz
left a comment
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.
Important things also:
- Missing max code size validation in execute mode. The filler implementation checks max_code_size (line 176), but execute mode doesn't. This should be patched.
- DETERMINISTIC_DEPLOYMENT_CONTRACT_ADDRESS is defined multiple times.
packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/pre_alloc.py
Outdated
Show resolved
Hide resolved
packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/pre_alloc.py
Outdated
Show resolved
Hide resolved
LouisTsai-Csie
left a comment
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.
Leave some comments! I now have a better understanding of the big picture, will revisit CPerezz' PR to see how to integrate.
packages/testing/src/execution_testing/cli/pytest_commands/plugins/filler/pre_alloc.py
Show resolved
Hide resolved
packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/pre_alloc.py
Outdated
Show resolved
Hide resolved
packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/pre_alloc.py
Outdated
Show resolved
Hide resolved
f968266 to
7566504
Compare
7bebfa3 to
b488fe8
Compare
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.
This flow is quite elegant, love this. I left some tiny nits (take or leave them) but also some things to think about when it comes to the proxy deployment.
- We can put the proxy deploy in a parent batch for safety so that at least the first contract that depends on it uses the
requires_predecessorflag to start a new batch and to make sure the proxy deploy is confirmed first. - We could have an internal flag that only deploys the proxy once, in the case that a test deploys multiple contracts using this API. They can still be in the same batch, whose parent is the proxy deployment and is only triggered to deploy one time.
I still haven't tested this in execute so I will take a pass at that next but it seems like it should work well. Great addition 👍🏼
packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/pre_alloc.py
Outdated
Show resolved
Hide resolved
packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/pre_alloc.py
Outdated
Show resolved
Hide resolved
packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/pre_alloc.py
Outdated
Show resolved
Hide resolved
packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/pre_alloc.py
Outdated
Show resolved
Hide resolved
fselmo
left a comment
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.
Really cool feature! And really elegant implementation 👌🏼
lgtm 🚀!
packages/testing/src/execution_testing/cli/pytest_commands/plugins/execute/pre_alloc.py
Show resolved
Hide resolved
CPerezz
left a comment
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.
Thanks for adding this!!
All comments addressed and other reviewers approved.
🗒️ Description
pre.deterministic_deploy_contractImplements a new function in the
preobject calleddeterministic_deploy_contract, which uses https://github.com/Arachnid/deterministic-deployment-proxy to deploy contracts at deterministic addresses usingCREATE2.The function takes the following parameters:
keccak256( 0xff ++ 0x4E59B44847B379578588920CA78FBF26C0B4956C ++ salt ++ keccak256(init_code))[12:]CREATE2opcode. Defaults to zero.deploy_codeuntil the transactions is sent to the network usingexecute. Can be skipped and the initcode will be auto-generated.EIP-7997
EIP-7997 includes a predeploy that is meant to replace contracts like the one in
0x4E59B44847B379578588920CA78FBF26C0B4956C.To account for this and to be future compatible with the EIP, all added functions check the new
fork.deterministic_factory_predeploy_address()method to check whether the currently active fork already has a deployment factory before deploying/using0x4E59B44847B379578588920CA78FBF26C0B4956C.execute deploy-required-contractsNew execute command that deploys all execute pre-requisite contracts to the given chain.
At the moment it only deploys
0x4E59B44847B379578588920CA78FBF26C0B4956C, but we will add more useful contracts in the future.🔗 Related Issues or PRs
Closes #1933
✅ Checklist
toxchecks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx tox -e statictype(scope):.mkdocs servelocally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.@ported_frommarker.Cute Animal Picture