Skip to content

⚡Optimize Create3 Lib#6564

Open
atarpara wants to merge 4 commits into
OpenZeppelin:masterfrom
atarpara:cret3
Open

⚡Optimize Create3 Lib#6564
atarpara wants to merge 4 commits into
OpenZeppelin:masterfrom
atarpara:cret3

Conversation

@atarpara

@atarpara atarpara commented May 29, 2026

Copy link
Copy Markdown

Reduce bytecode size by 1 byte by removing the RETURN opcode from the successful deployment path.

If CREATE succeeds, the initcode has already returned the runtime bytecode, which the EVM copies into the newly created contract's code storage. Nothing is returned to the caller's returndata buffer, so an additional RETURN is unnecessary.

Cheaper 16 gas for successful deployment and 3 gas for revert path.

PR Checklist

  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

@atarpara atarpara requested a review from a team as a code owner May 29, 2026 12:40
@changeset-bot

changeset-bot Bot commented May 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d8d826f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR optimizes the CREATE3 proxy initialization bytecode by updating the PROXY_INITCODE and PROXY_INITCODE_HASH constants in contracts/utils/Create3.sol to new byte values. The corresponding test constant in test/utils/Create3.test.js is updated to match the new hash, ensuring address computations remain synchronized. A changeset entry declares the minor version bump for the release.

Possibly related PRs

  • OpenZeppelin/openzeppelin-contracts#6402: Both PRs directly modify the Create3 proxy initialization bytecode/hash (PROXY_INITCODE / PROXY_INITCODE_HASH) in contracts/utils/Create3.sol and update corresponding test constants.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Optimize Create3 Lib' directly and clearly reflects the main change in the PR: optimizing the Create3 library by removing an unnecessary RETURN opcode to reduce bytecode size.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description clearly explains the optimization: removing the RETURN opcode from the successful deployment path in Create3 to reduce bytecode by 1 byte and save gas.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@contracts/utils/Create3.sol`:
- Around line 45-46: Update the success-path annotations for the JUMPDEST at
0x12 in Create3.sol: change the stack/memory state to reflect that after a
successful JUMPI both operands were popped (stack empty at 0x12) and that a
successful CREATE does not leave returndata to reference; replace the current
revert-path stack/returndata notes with an empty-stack annotation and remove any
returndata reference for the success path so the comment accurately matches the
success flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 54a6f7a6-f0e4-4e27-84d8-b76d79b2b836

📥 Commits

Reviewing files that changed from the base of the PR and between 74edc4b and b966238.

📒 Files selected for processing (3)
  • .changeset/whole-trains-sin.md
  • contracts/utils/Create3.sol
  • test/utils/Create3.test.js

Comment thread contracts/utils/Create3.sol Outdated
@atarpara

Copy link
Copy Markdown
Author

@Amxx Request for review.

@Amxx

Amxx commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Because this PR changes the helper code (which is deployed using create2), it changes the create3 target address and is therefore not backward compatible. This is fine (as of today) because the Create3 library was never released. We should not do this change after 5.7

Comment thread contracts/utils/Create3.sol Outdated
@Amxx

Amxx commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator
image

@Amxx Amxx requested review from a team and ernestognw June 8, 2026 13:58
@atarpara

atarpara commented Jun 8, 2026

Copy link
Copy Markdown
Author

@Amxx Thanks for considering my CREATE3 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants