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.
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.
LouisTsai-Csie
left a comment
There was a problem hiding this comment.
Leave some comments! I now have a better understanding of the big picture, will revisit CPerezz' PR to see how to integrate.
f968266 to
7566504
Compare
7bebfa3 to
b488fe8
Compare
There was a problem hiding this comment.
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 👍🏼
fselmo
left a comment
There was a problem hiding this comment.
Really cool feature! And really elegant implementation 👌🏼
lgtm 🚀!
CPerezz
left a comment
There was a problem hiding this comment.
Thanks for adding this!!
All comments addressed and other reviewers approved.
…hereum#1934) * feat(test-all): Implement `deterministic_deploy_contract` * feat(tests): `deterministic_deploy_contract` example * docs: update * fix(testing): Remove `minimum_balance`, `setup_calldata` * fix(execute): Use `fork.transaction_gas_limit_cap` * fix: Allow storage in deterministic deploy contract * feat(testing): Add `minimum_balance` to `pre.fund_address` * fix(testing): tox * fix: Review comments * feat(testing/forks): Determinisitc predeploy fork method * feat(testing/cli): add `execute deploy-required-contracts` * fix: tox * fix: tox 2 * better docstrings * Add max code size checks to execute * fix(docs): Add more details * nit * words * Add comment. * Add comment.
🗒️ 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