feat: Phase 2 - Ethereum Escrow via IBC Eureka#18
Open
zmanian wants to merge 13 commits into
Open
Conversation
Phase 2 Ethereum escrow types: - EscrowStatus: Pending, Received, Finalized, Failed - EthereumEscrowedIntent: Intent wrapper with ETH sender and escrow status - Lifecycle methods: is_pending, is_ready_for_fronting, is_finalized - State transitions: mark_received, mark_finalized, mark_failed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Settlement risk types for solver fronting: - SettlementRiskPricing: failure probability, bond multiplier, risk premium - required_bond(): calculate bond for fronted amount - adjust_quote(): apply risk premium to output - FrontingRiskAssessment: expected value calculation for fronting decisions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Eureka packet monitoring types: - EurekaPacketStatus: NotFound, Pending, Finalized, Failed - EurekaPacketInfo: detailed packet information - MonitorError: errors for packet monitoring operations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Eureka packet monitoring: - EurekaPacketMonitor trait with async methods - MockEurekaMonitor for testing - watch_for_packet, get_packet_status, verify_finality, get_packet_info - Packet lifecycle simulation for tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New execute messages for Ethereum escrow: - RegisterEthereumEscrowIntent - NotifyEurekaPacketReceived - NotifyEurekaFinalized - FrontSettlement - ClaimEurekaEscrow - HandleEurekaEscrowFailure New query: EthereumEscrowStatus 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EurekaSolver fronting for Ethereum-escrowed intents: - can_front_settlement() check - calculate_fronting_bond() with risk multiplier - assess_fronting() with expected value calculation - get_fronting_quote() with risk premium - Builder methods: with_fronting(), with_risk_pricing() 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Integration tests for Phase 2 Ethereum escrow flow: - Intent creation and lifecycle - Solver fronting setup and configuration - Bond calculation and risk assessment - Custom risk pricing - Failure handling - Quote adjustment 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix formatting issues across multiple files - Ensure all lib.rs exports are correct - All 683 tests passing - Clippy clean with -D warnings 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove risk_premium_bps field from SettlementRiskPricing - Remove adjust_quote and get_fronting_quote methods - Risk premiums are now auction-discovered (solvers bid total spread) - Protocol only enforces bond requirements (1.5x default, 2x conservative) - Update finality times: Ethereum L1 20min, OP Stack 20min, ZK rollups 15min - Add source-specific presets: default_ethereum_l1, default_op_stack_l2, default_zk_rollup Key insight: Solvers compete on price in the auction. Their bid implicitly includes their risk assessment. The protocol only needs to enforce bond requirements for collateral, not compute risk premiums. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add complete implementation for Ethereum escrow handling through IBC Eureka with ZK proof finality: State storage: - EthereumEscrow struct with full lifecycle tracking - EthereumEscrowStatus enum (Pending/Received/Finalized/Fronted/Claimed/Failed) - FrontingInfo for solver fronting details Contract handlers: - RegisterEthereumEscrowIntent: Register intent awaiting Eureka transfer - NotifyEurekaPacketReceived: Update when packet arrives from Ethereum - NotifyEurekaFinalized: Update when ZK proof verifies - FrontSettlement: Solver fronts before finality with risk bond - ClaimEurekaEscrow: Solver claims after finality verification - HandleEurekaEscrowFailure: Handle timeout/failure with bond return Design aligned with Skip Go Fast principles: - Intent-based execution with solver fronting - Two-stage finality (Received → Finalized) for ZK proof architecture - Explicit risk bond mechanism - Timeout guarantees and failure handling 15 new tests for Ethereum escrow flow (68 total escrow tests passing). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 21 adversarial tests covering economic and security attack vectors: Economic attacks: - Griefing (register without sending ETH) - Front-running (double front attempt) - Claim theft (unauthorized claim) - Bond extraction (verify bond return on failure) - Timeout manipulation (edge cases) Security attacks: - Replay protection (duplicate intents) - Amount manipulation (less than expected) - Fake finalization/packet notification - Unauthorized registration/failure marking - Wrong packet ID, sender spoofing - Double claim, insufficient bond - Wrong state transitions Also adds comprehensive testing plan document covering: - 5 test levels (unit, adversarial, integration, testnet, performance) - Test scenarios with expected results - Test infrastructure requirements - Coverage goals and metrics Total escrow tests: 89 (29 unit + 24 adversarial escrow + 15 Ethereum + 21 adversarial Ethereum) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Design document for extending escrow system to support outbound transfers
where users escrow on Cosmos Hub and receive funds on Ethereum.
Key points:
- Symmetric design: same escrow + fronting + proof pattern
- Lower risk for outbound (Cosmos 6s finality vs ETH 20min)
- Proof options: Hyperlane (recommended), Eureka reverse, Optimistic
- Lower bond requirements (1.2x vs 1.5x) due to faster finality
State machine: Pending → Accepted → Filled → Released
New messages: RegisterOutboundEscrowIntent, SolverAcceptOutbound,
NotifyOutboundFilled, ReleaseOutboundEscrow
Integrates with Skip Go Fast solver infrastructure.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace Hyperlane/ZK proof options with IBC Eureka fulfillment contract approach: - Solver calls IntentFulfillment contract on Ethereum - Contract transfers tokens to user AND sends IBC packet back to Hub - Hub receives IBC packet as proof of fulfillment (no separate verification) - Added Solidity IntentFulfillment contract code - Added Rust ibc_packet_receive handler - Simplified state machine (Pending → Filled/Expired) - Lower bond requirement (1.2x vs 1.5x) due to reduced risk This leverages existing IBC Eureka bidirectional infrastructure instead of requiring additional trust assumptions (Hyperlane validators) or complex ZK proof verification. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EurekaPacketMonitortrait for tracking Eureka packet status and ZK proof finalityDesign Alignment with Skip Go Fast
This implementation follows Skip Go Fast design principles:
Key difference: Two-stage finality (Received → Finalized) for IBC Eureka's ZK proof architecture.
Changes
Types (
crates/types)EscrowStatusenum: Pending → Received → Finalized/Failed state machineEthereumEscrowedIntent: Intent with Ethereum-side escrow metadataSettlementRiskPricing: Bond multiplier, failure probability (risk premium auction-discovered)default_ethereum_l1(): 20 min finality, 1.5x bonddefault_op_stack_l2(): 20 min finality (Base, Optimism)default_zk_rollup(): 15 min finalityFrontingRiskAssessment: Should-front decision with expected value calculationEurekaPacketStatus: NotFound/Pending/Finalized/Failed packet statesEscrow Contract (
contracts/escrow)State Storage:
EthereumEscrowstruct with full lifecycle trackingEthereumEscrowStatusenum (Pending/Received/Finalized/Fronted/Claimed/Failed)FrontingInfofor solver fronting details (solver_id, bond_amount, output_amount)Handlers (all implemented):
RegisterEthereumEscrowIntent: Register intent with pending Eureka escrowNotifyEurekaPacketReceived: Relayer notifies packet arrival, validates senderNotifyEurekaFinalized: ZK proof verified, funds ready for claimFrontSettlement: Solver fronts funds with explicit risk bondClaimEurekaEscrow: Release escrowed funds + bond to solver after finalityHandleEurekaEscrowFailure: Handle timeout/failure, return bond to solverError Types:
InvalidEthereumEscrowStatus,EthereumSenderMismatch,EurekaTimeoutPacketIdMismatch,NotFronted,InsufficientBondRelayer (
crates/relayer)EurekaPacketMonitorasync trait for packet trackingMockEurekaMonitorfor testing with configurable delays/failuresSolver (
crates/solver)can_front_settlement(): Check if solver can front for escrowed intentcalculate_fronting_bond(): Compute required bond amountassess_fronting(): Full risk assessment with expected valuewith_fronting(),with_risk_pricing()Tests
Escrow Contract Tests: 89 total
Adversarial Coverage:
Documentation
docs/ETHEREUM_ESCROW_TESTING_PLAN.md: Comprehensive 5-level testing planTest Plan
Dependencies
This PR depends on Phase 1 (#17) - Eureka Integration for solver liquidity sourcing.
🤖 Generated with Claude Code