-
Notifications
You must be signed in to change notification settings - Fork 11
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
fix: add create3 predeploys #320
base: develop
Are you sure you want to change the base?
fix: add create3 predeploys #320
Conversation
There are 2 versions of ZeframLou's CREATE3 predeploys: - the first is deployed using a private key controlled by the deployer and a nonce of 0 - the second is deployed using CREATE2 and a salt of bytes32(0) While the second can be deployed by us manually, the first can cannot. Hence, add it manually. For ease of use, add both.
WalkthroughThe change extends the predeploy system by adding two new predeploy contracts, Changes
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Awesome. LGTM.
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
x/evm/types/predeploys.go
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: test-unit-e2e
- GitHub Check: test-unit-cover
- GitHub Check: Analyze (go)
- GitHub Check: goreleaser
🔇 Additional comments (4)
x/evm/types/predeploys.go (4)
33-33
: Addition of CREATE3 predeploys looks good.The addition of
create3
andcreate3Deterministic
to theDefaultPredeploys
list is consistent with the existing pattern and will make these contracts available at genesis.
106-113
: Well-documented CREATE3 implementation.The comments clearly explain the source and purpose of the contract, noting that it comes from ZeframLou's create3-factory and explaining the difference between the two deployment methods. This clarity is valuable for maintainers.
111-112
: Answers to previous review questions.To address the previous questions about predeploy address determination:
- These addresses are deterministic based on the deployment method
- For the first version (
create3
), the address was determined by the author's deployer address and nonce=0- For the second version (
create3Deterministic
), the address is determined using CREATE2 with salt=bytes32(0)The bytecode is sourced from ZeframLou's CREATE3 factory implementation as indicated in the comment link.
114-117
: CREATE3Deterministic implementation is correctly defined.The contract address and bytecode are properly specified, enabling deterministic deployments through CREATE2 with a zero salt. This implementation complements the standard CREATE3 predeploy.
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
x/evm/types/predeploys.go (2)
118-119
: Enhance documentation about CREATE3 bytecode origin.While there's a link to the repository, it would be helpful to include more details about the source of this bytecode and how it was obtained (e.g., from which network it was fetched).
- Code: "6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220a194c2eaa665b9a3b7df63a08195224328c42d9f7f651494deafa8b9a230d5ee64736f6c63430008160033", + // Code obtained from the ZeframLou's implementation deployed on Ethereum mainnet + // Compiled with Solidity 0.8.16 and contains the deployCreate3 (50f1c464) and + // deployCreate3AndInit (cdcb760a) functions + Code: "6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220a194c2eaa665b9a3b7df63a08195224328c42d9f7f651494deafa8b9a230d5ee64736f6c63430008160033",
122-124
: Enhance documentation about CREATE3Deterministic bytecode origin.Similar to the create3 predeploy, add more details about the source and versioning of this bytecode.
- Code: "6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220fd377c185926b3110b7e8a544f897646caf36a0e82b2629de851045e2a5f937764736f6c63430008100033", + // Version deployed using CREATE2 with a salt of bytes32(0) + // Compiled with Solidity 0.8.10 and contains the same interface as create3 + // (deployCreate3 and deployCreate3AndInit functions) + Code: "6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610489565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e6100853660046104fd565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346102b2565b604080518082018252601081527f67363d3d37363d34f03d5260086018f30000000000000000000000000000000060209182015290517fff00000000000000000000000000000000000000000000000000000000000000918101919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003060601b166021820152603581018290527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f60558201526000908190610228906075015b6040516020818303038152906040528051906020012090565b6040517fd69400000000000000000000000000000000000000000000000000000000000060208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660228201527f010000000000000000000000000000000000000000000000000000000000000060368201529091506100e79060370161020f565b6000806040518060400160405280601081526020017f67363d3d37363d34f03d5260086018f30000000000000000000000000000000081525090506000858251602084016000f5905073ffffffffffffffffffffffffffffffffffffffff811661037d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4445504c4f594d454e545f4641494c454400000000000000000000000000000060448201526064015b60405180910390fd5b6103868661014c565b925060008173ffffffffffffffffffffffffffffffffffffffff1685876040516103b091906105d6565b60006040518083038185875af1925050503d80600081146103ed576040519150601f19603f3d011682016040523d82523d6000602084013e6103f2565b606091505b50509050808015610419575073ffffffffffffffffffffffffffffffffffffffff84163b15155b61047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e495449414c495a4154494f4e5f4641494c454400000000000000000000006044820152606401610374565b5050509392505050565b6000806040838503121561049c57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146104c057600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806040838503121561051057600080fd5b82359150602083013567ffffffffffffffff8082111561052f57600080fd5b818501915085601f83011261054357600080fd5b813581811115610555576105556104ce565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561059b5761059b6104ce565b816040528281528860208487010111156105b457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b818110156105f757602081860181015185830152016105dd565b50600092019182525091905056fea2646970667358221220fd377c185926b3110b7e8a544f897646caf36a0e82b2629de851045e2a5f937764736f6c63430008100033",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
x/evm/predeploys_test.go
(5 hunks)x/evm/types/predeploys.go
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: test-unit-e2e
- GitHub Check: test-unit-cover
- GitHub Check: Analyze (go)
- GitHub Check: goreleaser
🔇 Additional comments (16)
x/evm/types/predeploys.go (5)
32-35
: LGTM! Predeploys list logically organized.The DefaultPredeploys list now includes the new CREATE3 predeploys along with the renamed arachnidCreate2 and new zoltuCreate2 entries, maintaining a clear structure.
78-81
: Appropriate renaming of create2 to arachnidCreate2.Renaming to include the source/author name provides better clarity about which implementation this is, especially now that multiple CREATE2 implementations are available.
82-86
: Good addition of Zoltu's CREATE2 implementation.Adding an alternative CREATE2 implementation gives developers more options and flexibility.
105-105
: Updated reference to use the renamed arachnidCreate2.Code.This ensures consistency with the renaming of create2 to arachnidCreate2.
113-125
:❓ Verification inconclusive
Address the bytecode discrepancy between create3 and create3Deterministic.
While the PR summary mentions that the two CREATE3 implementations should differ only by metadata, a previous verification showed that the bytecode strings have no common characters. This seems unexpected.
🏁 Script executed:
#!/bin/bash # Description: Compare the bytecode of create3 and create3Deterministic # Extract function selectors from create3 and create3Deterministic to verify implementation create3_selectors=$(echo "0x${create3[Code]:0:500}" | grep -o '50f1c464\|cdcb760a') create3_deterministic_selectors=$(echo "0x${create3Deterministic[Code]:0:500}" | grep -o '50f1c464\|cdcb760a') echo "create3 selectors: $create3_selectors" echo "create3Deterministic selectors: $create3_deterministic_selectors" # Check if both bytecodes contain the same size echo "create3 bytecode length: ${#create3[Code]}" echo "create3Deterministic bytecode length: ${#create3Deterministic[Code]}" # Compare bytecode equality if [ "${create3[Code]}" == "${create3Deterministic[Code]}" ]; then echo "Bytecodes are identical" else # Do a deeper analysis of differences # First check the end (metadata section) which is expected to differ last_100_create3="${create3[Code]: -100}" last_100_det="${create3Deterministic[Code]: -100}" echo "Last 100 chars of create3: $last_100_create3" echo "Last 100 chars of create3Deterministic: $last_100_det" # Check the middle part which should be the same middle_start=500 middle_length=100 middle_create3="${create3[Code]:$middle_start:$middle_length}" middle_det="${create3Deterministic[Code]:$middle_start:$middle_length}" echo "Middle section of create3: $middle_create3" echo "Middle section of create3Deterministic: $middle_det" # Determine if only metadata is different if [ "$middle_create3" == "$middle_det" ]; then echo "Middle sections match - likely only metadata differences" else echo "Middle sections differ - implementations appear to be different" fi fiLength of output: 493
BYTECODE VERIFICATION RE-EXAMINATION REQUIRED
The current verification script is not extracting any bytecode: both
create3
andcreate3Deterministic
report a length of 0 and yield empty function selectors. This indicates that the shell extraction logic (e.g. usingcreate3[Code]
) isn’t working as intended in Bash. Since the PR summary claims that the two CREATE3 implementations should differ only by metadata, please review and update the verification approach to correctly extract the bytecode (ensuring the extraction of the hex string from the struct literal) and then manually confirm that any differences are limited to the metadata section.
- File:
x/evm/types/predeploys.go
, Lines: 113-125- Action: Update the extraction logic in the verification script to properly capture the bytecode strings and verify that only the metadata sections differ.
x/evm/predeploys_test.go (11)
81-81
: Good addition of supply tracking.Capturing the initial supply allows for proper validation of token balances throughout the test.
83-83
: Clarified comment for balance initialization.The updated comment more accurately describes that balances are set at genesis time.
94-94
: Supply calculation correctly uses initial balance.The expected supply calculation now properly accounts for the initial supply.
123-124
: Added supply validation to complete the test.The addition of supply validation completes the balance retention test, ensuring that tokens are not created or destroyed unexpectedly.
127-128
: Test renamed for better clarity.The function name now correctly reflects that it's testing the deployment of a contract using CREATE2 rather than CREATE3.
136-136
: Updated contract bytecode for test.The updated runCode bytecode implements the ERC165 interface based on the function selectors.
139-139
: Simplified initCode construction.The initCode now concatenates the constructor code with the runCode in a more readable way.
141-142
: Renamed variable for clarity.Changing
create3
todestination
better reflects the purpose of the variable as the target address for deployment.
145-146
: Updated assertions to use the new variable name.The assertions now correctly compare string representations and check the balance of the destination address.
163-163
: Updated comment to reflect variable name change.The comment now correctly references the destination variable.
176-176
: Updated balance assertion to use the new variable name.The balance check now correctly refers to the destination address.
// the predeploys are blocked from receiving funds in app/app.go. | ||
// however, this block should not deter them from forwarding funds | ||
// to the contracts they deploy. | ||
func (suite *KeeperTestSuite) TestBalanceForwarding() { |
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.
so adding a predeploy address like create3factory contract address to blocklist would only forbid the predeploy to receive funds in bank module(or similar native module), now the test shows the predeploy could forward the balance to deploted contract, but would the blocklist prevent it from receiving funds through EVM call?
There are 2 versions of ZeframLou's CREATE3 predeploys:
While the second can be deployed by us manually, the first can cannot. Hence, add it manually. For ease of use, add both.
Summary by CodeRabbit
New Features
create3
andcreate3Deterministic
, provide enhanced flexibility, including deterministic deployment for predictable contract addresses. This update expands native deployment capabilities, ensuring seamless integration while preserving existing functionalities and compatibility. Users will benefit from more robust contract management and improved support for advanced integration scenarios.Deployed.json
, has been introduced to encapsulate essential information for contract interaction and execution.Deployed
, is now available for testing balance forwarding and deployment functionality.ICreate3Factory
, has been added to facilitate contract deployments to deterministic addresses.Bug Fixes
create2
, ensuring reliability in testing outcomes.