Skip to content

feat(ev-deployer): add live chain deployment via CREATE2#200

Open
randygrok wants to merge 13 commits intoev-deployer-part3-permit2from
ev-deployer-part3a
Open

feat(ev-deployer): add live chain deployment via CREATE2#200
randygrok wants to merge 13 commits intoev-deployer-part3-permit2from
ev-deployer-part3a

Conversation

@randygrok
Copy link
Copy Markdown
Contributor

@randygrok randygrok commented Mar 30, 2026

Summary

Adds a deploy subcommand to ev-deployer for deploying AdminProxy and Permit2 contracts to a live chain via CREATE2 using the deterministic deployer factory.

Previously, ev-deployer could only generate genesis alloc JSON for pre-genesis deployment. This PR adds the ability to deploy the same contracts to an already-running chain, with deterministic addresses, state persistence, and idempotent resume.

Key changes

  • Optional addresses in configaddress is now Option<Address> in contract configs. Required for genesis mode (validated at runtime), ignored in deploy mode where CREATE2 determines the address.
  • CREATE2 module — Computes deterministic addresses using Nick's factory (0x4e59b44847b379578588920ca78fbf26c0b4956c).
  • Deploy state file — JSON state file tracks a random salt, the original config intent, and per-contract status (pendingdeployedverified). Immutability checks prevent config drift between runs.
  • ChainDeployer trait — Abstracts on-chain operations (get_code, deploy_create2). LiveDeployer implements it with alloy provider + signer.
  • Deploy pipeline — Orchestrates: connect → verify factory exists → deploy each contract → verify bytecodes on-chain. Fully idempotent (skips already-deployed contracts).

Usage

# Deploy to a live chain
ev-deployer deploy \
  --config deploy.toml \
  --rpc-url http://localhost:8545 \
  --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
  --state deploy-state.json \
  --addresses-out addresses.json

# RPC URL and private key can also be set via env vars
export EV_DEPLOYER_RPC_URL=http://localhost:8545
export EV_DEPLOYER_PRIVATE_KEY=0xac0974...
ev-deployer deploy --config deploy.toml --state deploy-state.json

The state file is created on first run and reused on subsequent runs for resumability. If a deploy is interrupted, re-running the same command picks up where it left off.

@randygrok randygrok requested a review from a team as a code owner March 30, 2026 15:39
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c6c6d9a8-1fb5-4572-b62b-63bae7132df4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ev-deployer-part3a

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.

@claude
Copy link
Copy Markdown

claude bot commented Mar 30, 2026

Claude finished @randygrok's task —— View job


Code Review for ev-deployer Live Chain Deployment

Reviewing the PR for live chain deployment functionality via CREATE2. I'll analyze code quality, security, performance, and potential issues.

Todo List

  • Read repository guidelines
  • Review configuration changes
  • Analyze CREATE2 implementation
  • Review deployment pipeline
  • Check state management
  • Assess security considerations
  • Evaluate error handling
  • Check test coverage
  • Provide comprehensive feedback

Review Summary

This PR adds excellent live chain deployment functionality to ev-deployer. The implementation is well-structured, secure, and follows Rust best practices. Here's my detailed analysis:

Strengths

Architecture & Design

  • Clean separation of concerns: Well-organized modules (create2.rs, deployer.rs, pipeline.rs, state.rs)
  • Trait abstraction: ChainDeployer trait properly abstracts on-chain operations for testability
  • Idempotent design: Excellent resumability with state persistence and immutability checks

Security

  • Private key handling: Secure parsing with 0x prefix handling in LiveDeployer::new (bin/ev-deployer/src/deploy/deployer.rs:42-45)
  • Address validation: Proper zero-address validation in config (bin/ev-deployer/src/config.rs:79-82, 87-92)
  • Chain ID verification: Validates config chain ID matches actual chain (bin/ev-deployer/src/deploy/pipeline.rs:32-37)
  • CREATE2 security: Uses established Nick's factory with proper address computation

Error Handling

  • Comprehensive validation: Multi-layer validation (config, immutability, on-chain state)
  • Atomic operations: State file uses atomic write-then-rename pattern (bin/ev-deployer/src/deploy/state.rs:89-96)
  • Clear error messages: Descriptive errors with context throughout

Test Coverage

  • Excellent unit test coverage: Found comprehensive tests across all modules (7 files with tests)
  • Edge cases covered: Tests for duplicate addresses, zero addresses, config validation, state immutability
  • Randomness testing: Proper verification of salt generation (bin/ev-deployer/src/deploy/state.rs:147-151)

🔍 Areas for Consideration

1. AdminProxy Support (Minor)

The state management only handles Permit2 currently. While AdminProxy config exists, the pipeline and state tracking don't include it:

// bin/ev-deployer/src/deploy/state.rs:37-40
pub(crate) struct ContractStates {
    pub permit2: Option<ContractState>,
    // Missing: pub admin_proxy: Option<ContractState>,
}

Impact: Low - AdminProxy deployment isn't implemented yet
Recommendation: This appears intentional for this PR scope

2. Gas Estimation (Enhancement)

The deployment doesn't include gas estimation or custom gas limits:

// bin/ev-deployer/src/deploy/deployer.rs:71-73
let tx = TransactionRequest::default()
    .to(DETERMINISTIC_DEPLOYER)
    .input(calldata.into());

Impact: Low - Default gas estimation usually works
Recommendation: Consider adding gas limit configuration for complex deployments

3. Transaction Confirmation (Minor)

The code waits for transaction receipt but doesn't specify confirmation count:

// bin/ev-deployer/src/deploy/deployer.rs:75-76
let pending = self.provider.send_transaction(tx).await?;
let receipt = pending.get_receipt().await?;

Impact: Low - Single confirmation is usually sufficient for deployment
Recommendation: Consider making confirmation count configurable for high-value deployments

🚀 Performance

  • Efficient state management: JSON serialization with pretty printing for debugging
  • Minimal on-chain calls: Smart idempotency checks reduce unnecessary transactions
  • Atomic operations: Proper file I/O with temporary files

🏗️ Code Quality

  • Consistent naming: Clear, descriptive function and variable names
  • Documentation: Good inline documentation and module-level docs
  • Type safety: Proper use of Rust's type system with Address, B256, etc.
  • Memory efficiency: Uses references and borrows appropriately

🧪 Testing Assessment

Excellent test coverage across all modules:

  • Configuration parsing and validation
  • CREATE2 address computation
  • State persistence and immutability
  • Error conditions and edge cases
  • Contract status progression

Notable testing patterns:

  • Property-based testing for salt randomness
  • Round-trip serialization tests
  • Comprehensive error case coverage

📋 Recommendations

  1. Consider AdminProxy integration: If AdminProxy deployment is planned, add it to the pipeline and state management
  2. Gas configuration: Add optional gas limit configuration for complex scenarios
  3. Confirmation settings: Consider making transaction confirmation count configurable
  4. Deployment verification: The bytecode verification is excellent - consider adding event log verification for additional confidence

🎯 Verdict

This is a high-quality implementation that demonstrates excellent Rust practices, security awareness, and thoughtful design. The code is production-ready with:

  • ✅ Robust error handling
  • ✅ Comprehensive testing
  • ✅ Security best practices
  • ✅ Clean architecture
  • ✅ Proper documentation

The CREATE2 deployment functionality will be a valuable addition to the ev-deployer toolkit.

AdminProxy has an empty constructor and sets owner via genesis storage
slot 0, making it incompatible with live CREATE2 deployment where the
owner would remain address(0). Restrict AdminProxy to genesis-only mode.
Write to a .tmp file first, then rename into place. Prevents
state file corruption if the process crashes mid-write.
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.

1 participant