-
Notifications
You must be signed in to change notification settings - Fork 18
Implement CREATE2 factory for deterministic contract deployments #3798
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
base: dev
Are you sure you want to change the base?
Implement CREATE2 factory for deterministic contract deployments #3798
Conversation
- Set bytecode_hash = none - Set cbor_metadata = false - Pin evm_version = cancun These settings ensure identical bytecode across builds, which is essential for CREATE2 address determinism.
Implements a CREATE2 factory contract with: - Deterministic address computation - Deployment tracking and redeployment prevention - Sender-protected and simple salt generation - Address prediction helpers
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Claude finished @silva-fj's task —— View job CREATE2 Factory Code ReviewI've completed a comprehensive review of this CREATE2 factory implementation. Overall, this is a high-quality implementation with excellent testing and documentation. Here's my detailed feedback: ✅ StrengthsCode Quality & Architecture
Security
Testing
🟡 Minor Issues & SuggestionsCode Quality Improvementstee-worker/omni-executor/aa-contracts/src/core/Create2Factory.sol:42-44 // Check if address already has code (additional safety check)
if (deployed.code.length > 0) {
revert AddressAlreadyDeployed(deployed);
}This check is redundant since the tee-worker/omni-executor/aa-contracts/src/core/Create2Factory.sol:115-122 /**
* @notice Generates a simple salt for deployment (SECURITY WARNING: vulnerable to frontrunning)
* @dev WARNING: Anyone can frontrun deployments using simple salts. Only use if frontrunning
* protection is not required. Consider using generateSalt() instead.
*/tee-worker/omni-executor/aa-contracts/script/DeployCreate2Factory.s.sol:46-55 if (vm.getNonce(deployer) > 0) {
console.log("⚠️ WARNING: Deployer has non-zero nonce!");
console.log("⚠️ For consistent factory addresses across chains, use a fresh EOA");
console.log("⚠️ Current nonce:", vm.getNonce(deployer));
console.log("");
}Performance Considerationstee-worker/omni-executor/aa-contracts/src/core/Create2Factory.sol:70-75 // More efficient if you already have the hash
bytes32 hash = keccak256(bytecode);
address predicted = factory.computeAddressWithHash(salt, hash);Gas Optimization: The Minor Script Improvementstee-worker/omni-executor/aa-contracts/script/DeployWithCreate2.s.sol:108-147 function predictAndLogAddress(string memory name, bytes32 salt, bytes memory bytecode) internal view {
address predicted = factory.computeAddress(salt, bytecode);
console.log(string(abi.encodePacked(name, " (predicted):")), predicted);
}🔍 Security AnalysisCREATE2 Implementation
Assembly Safety
Access Control
🧪 Test Coverage AssessmentExcellent coverage including:
Consider adding:
🏗️ Architecture EvaluationDesign Decisions
Multi-Chain Strategy
📋 Minor Suggestions
🎯 Overall AssessmentThis is a production-ready implementation that follows best practices for CREATE2 factories. The code quality is excellent, security considerations are well-addressed, and the testing is comprehensive. The deployment scripts and documentation are particularly well-crafted, making this easy to use and maintain. Recommendation: Approve ✅ The implementation is ready for production use with only minor optimization opportunities identified above.
|
Kailai-Wang
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.
Thank you, I left some comments - mainly questions around the salt generation
| bytecode_hash = "none" | ||
| cbor_metadata = false |
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.
Have you tried to deploy contracts with create2 factory? I'm not sure if would cause any verification problem (or you'll need manually verify that) as etherscan probably expects some metadatas to verify the contract
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.
I tried deploying a contract locally on Anvil. I got these values from the docs here
tee-worker/omni-executor/aa-contracts/src/core/Create2Factory.sol
Outdated
Show resolved
Hide resolved
tee-worker/omni-executor/aa-contracts/src/core/Create2Factory.sol
Outdated
Show resolved
Hide resolved
…y-contract Resolved conflicts by keeping Create2Factory-related files from dev branch: - tee-worker/omni-executor/contracts/aa/deployments/create2-factories.json - tee-worker/omni-executor/contracts/aa/script/DeployContract.s.sol - tee-worker/omni-executor/contracts/aa/script/DeployCreate2Factory.s.sol - tee-worker/omni-executor/contracts/aa/script/DeployWithCreate2.s.sol - tee-worker/omni-executor/contracts/aa/src/core/Create2FactoryV1.sol - tee-worker/omni-executor/contracts/aa/test/Create2Factory.t.sol
Summary
Implements a CREATE2 factory system for deterministic contract deployments across multiple EVM chains.
Changes
bytecode_hash = none,cbor_metadata = false)Create2Factorycontract with deployment tracking and redeployment prevention