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

fix: add create3 predeploys #320

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

MaxMustermann2
Copy link
Contributor

@MaxMustermann2 MaxMustermann2 commented Feb 27, 2025

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.

Summary by CodeRabbit

  • New Features

    • Advanced contract deployment options are now available at genesis. Two distinct deployment modes, create3 and create3Deterministic, 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.
    • A new JSON file, Deployed.json, has been introduced to encapsulate essential information for contract interaction and execution.
    • A new Solidity contract, Deployed, is now available for testing balance forwarding and deployment functionality.
    • A new interface, ICreate3Factory, has been added to facilitate contract deployments to deterministic addresses.
  • Bug Fixes

    • Updated test logic to accurately reflect the deployment of contracts using create2, ensuring reliability in testing outcomes.

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.
Copy link
Contributor

coderabbitai bot commented Feb 27, 2025

Walkthrough

The change extends the predeploy system by adding two new predeploy contracts, create3 and create3Deterministic. Both are defined with specific addresses and bytecode in the x/evm/types/predeploys.go file. These entries are appended to the DefaultPredeploys list without altering existing predeploys, ensuring the genesis configuration now supports extra contract functionality. Additionally, the test for contract deployment has been renamed and modified to accurately reflect its purpose. New JSON files and Solidity contracts have been introduced to support the new features.

Changes

File Change Summary
x/evm/types/predeploys.go Added two new predeploy contracts: create3 and create3Deterministic to the DefaultPredeploys list; renamed create2 to arachnidCreate2 and added zoltuCreate2; updated safeSingletonFactory to reference arachnidCreate2.
x/evm/predeploys_test.go Renamed TestCreate3 to TestCreate2Deployment; updated variables and logic to reflect new contract deployment using create2; added TestBalanceForwarding for verifying fund forwarding.
x/evm/testdata/Deployed.json Introduced a new JSON file containing ABI, bytecode, and contract name for a smart contract.
x/evm/testdata/Deployed.sol Added a new Solidity contract Deployed for testing balance forwarding and create2 deployment.
x/evm/testdata/ICreate3Factory.json Added a new JSON file containing the ABI for the ICreate3Factory contract.
x/evm/testdata/ICreate3Factory.sol Introduced a new Solidity interface ICreate3Factory for deploying contracts deterministically.
x/evm/testdata/create3_factory.go Added a new Go file to embed and handle the JSON data for ICreate3Factory.
x/evm/testdata/deployed.go Introduced a new Go file defining a CompiledContract struct for managing ABI and binary data.

Poem

I'm a rabbit with a twitching nose,
Hopping through code where new predeploys grow.
create3 and its deterministic friend join the ride,
Adding fresh magic to the genesis inside.
With every line, my heart does hop—
Celebrating fresh features that never stop!
🥕🐰 Enjoy the code, it's time to pop!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af0da7c and 2e3d533.

📒 Files selected for processing (1)
  • x/evm/predeploys_test.go (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • x/evm/predeploys_test.go
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: goreleaser
  • GitHub Check: docker-build
  • GitHub Check: test-unit-cover
  • GitHub Check: test-unit-e2e
  • GitHub Check: Analyze (go)
  • GitHub Check: docker-localnet-build

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@bwhour bwhour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. LGTM.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 119f95b and 39ca22c.

📒 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 and create3Deterministic to the DefaultPredeploys 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:

  1. These addresses are deterministic based on the deployment method
  2. For the first version (create3), the address was determined by the author's deployer address and nonce=0
  3. 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 04df216 and b19fe9c.

📒 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
fi

Length of output: 493


BYTECODE VERIFICATION RE-EXAMINATION REQUIRED

The current verification script is not extracting any bytecode: both create3 and create3Deterministic report a length of 0 and yield empty function selectors. This indicates that the shell extraction logic (e.g. using create3[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 to destination 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() {
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants