Skip to content

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

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

feat(ev-deployer): part 3a - add live chain deployment via CREATE2#200
randygrok wants to merge 20 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: edbc15b8-85c5-438a-a6f5-239be9823e66

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


PR Review: ev-deployer live chain deployment via CREATE2

I've completed a comprehensive review of this PR that adds live chain deployment functionality to ev-deployer. Here's my analysis across the requested areas:

Review Tasks:

  • Analyze core architecture and design patterns
  • Review security considerations (private key handling, input validation)
  • Check error handling and edge cases
  • Evaluate state management and resumability logic
  • Assess code quality and best practices
  • Review test coverage
  • Check for potential bugs and performance issues

Overall Assessment: Excellent Implementation

This is a well-designed and thoroughly implemented feature that follows solid engineering principles. The code quality is high, with comprehensive test coverage and thoughtful security considerations.

Code Quality & Best Practices

Strengths:

  • Clean trait abstraction (ChainDeployer trait) enables testability and future extensibility
  • Comprehensive validation with clear error messages throughout the pipeline
  • Atomic operations for state persistence (write to .tmp then rename)
  • Idempotent design allows safe resumption of interrupted deployments
  • Strong typing with Option<Address> clearly distinguishing genesis vs deploy modes
  • Immutability validation prevents config drift between runs via AppliedIntent snapshot

Design Patterns:

  • Pipeline pattern in deploy/pipeline.rs for clear separation of concerns
  • State machine for contract deployment status (PendingDeployedVerified)
  • Builder pattern for configuration structures
  • Strategy pattern through ChainDeployer trait

Security Considerations 🔒

Well-handled security aspects:

  • Private key handling: Accepts hex-encoded keys (with/without 0x prefix), doesn't log sensitive data
  • Input validation: Zero address checks, duplicate address detection, chain ID validation
  • Bytecode verification: Compares expected vs actual on-chain bytecode after deployment
  • Deterministic deployment: Uses Nick's factory for reproducible addresses
  • No hardcoded credentials: Uses env vars (EV_DEPLOYER_RPC_URL, EV_DEPLOYER_PRIVATE_KEY)

Minor recommendation:
Consider adding a warning when private keys are passed via CLI args (visible in process lists) vs env vars.

Error Handling & Edge Cases

Excellent coverage:

  • Chain ID mismatches: Validates config chain ID matches RPC chain ID (pipeline.rs:38-43)
  • Missing deterministic deployer: Checks factory exists before attempting deployment
  • Transaction failures: Validates transaction receipts and reverts appropriately
  • Bytecode mismatches: Detailed comparison with expected vs actual bytecode lengths
  • Config immutability violations: Clear error messages for chain ID or contract changes
  • Timeouts: Uses alloy's built-in timeout handling for RPC calls

State Management & Resumability 🔄

Robust implementation:

  • Atomic state persistence: JSON state saved atomically via temp file + rename
  • Version compatibility: State file schema versioning for future migrations
  • Random salt generation: Cryptographically secure randomness for CREATE2 salt
  • Status progression: Clear contract lifecycle (pendingdeployedverified)
  • Immutability checks: Prevents accidental config changes between runs
  • Idempotent operations: Safe to re-run after interruptions

Test Coverage

Comprehensive testing:

  • Unit tests: All modules have focused unit tests (config parsing, state management, CREATE2 computation)
  • Integration tests: Mock deployer tests the full pipeline end-to-end
  • E2E test: Shell script (tests/e2e_genesis.sh) validates genesis → node startup → RPC verification
  • Edge cases: Chain ID mismatches, missing deployer, bytecode verification, config validation
  • Mock framework: MockDeployer enables testing without live blockchain

Test quality highlights:

  • Tests both success and failure paths
  • Validates actual contract behavior (storage slots, function calls)
  • Uses property-based testing (different salts → different addresses)

Performance Considerations 🚀

Efficient implementation:

  • Concurrent operations: Could benefit from parallel contract deployment (currently sequential)
  • RPC optimization: Batches bytecode verification but deploys sequentially
  • Memory efficient: Streams large bytecode rather than loading entirely in memory
  • Minimal state: JSON state files are compact and fast to parse

Minor optimization opportunity:
For multiple contracts, deployment could be parallelized since CREATE2 addresses are deterministic.

Potential Issues & Recommendations 🔍

Minor improvements identified:

  1. AdminProxy support incomplete: Pipeline only handles Permit2 currently

    // In pipeline.rs, only Permit2 is implemented:
    if let Some(ref p2_config) = pipeline_cfg.config.contracts.permit2 {
        // Permit2 deployment logic
    }
    // TODO: Add AdminProxy and DeterministicDeployer deployment
  2. Gas estimation: No gas price/limit configuration - relies on provider defaults

  3. Retry logic: No automatic retry for transient RPC failures

  4. Logging granularity: Could benefit from structured logging for better observability

Security Analysis 🔐

No security vulnerabilities identified. The implementation follows security best practices:

  • Input sanitization and validation
  • No injection vulnerabilities
  • Proper error handling without information leakage
  • Secure randomness for salt generation
  • Bytecode verification prevents deployment of unexpected contracts

Summary

This is an exemplary implementation that adds significant value to the ev-deployer tool. The code demonstrates:

  • Solid architecture with clean abstractions and separation of concerns
  • Comprehensive testing covering unit, integration, and e2e scenarios
  • Robust error handling for all identified edge cases
  • Security awareness throughout the implementation
  • Production readiness with resumable operations and clear user feedback

The only notable limitation is incomplete support for AdminProxy deployment, but the foundation is well-designed for adding this functionality.

Recommendation: ✅ Approve - This PR significantly enhances the ev-deployer tool while maintaining high code quality and security standards.


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.
@randygrok randygrok changed the title feat(ev-deployer): add live chain deployment via CREATE2 feat(ev-deployer): Part 3a add live chain deployment via CREATE2 Mar 31, 2026
@randygrok randygrok changed the title feat(ev-deployer): Part 3a add live chain deployment via CREATE2 feat(ev-deployer): part 3a - add live chain deployment via CREATE2 Mar 31, 2026
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