CCNext Cross-Chain Bridge Worker
๐ญ Overview
A production-grade off-chain worker system that orchestrates cross-chain token transfers between Ethereum Sepolia and a custom Substrate-based L2 (CCNext). This is the infrastructure layer that makes the bridge actually work โ event monitoring, proof generation, confirmation handling, and cross-chain submission, all with proper resilience patterns.
โ The Problem
Cross-chain bridges require an off-chain coordinator: something that watches for events on the source chain, waits for sufficient confirmations, requests a cryptographic proof from an external prover service, then submits that proof to the destination chain. Every step can fail, and failures need to be handled gracefully without double-spending or losing transactions.
๐ ๏ธ Architecture
Ethereum Sepolia (ERC-20 Transfer Event)
โ wait N confirmations
Off-Chain Worker (NestJS)
โ call Proof API (exponential backoff, 20 retries, 15-min timeout)
External Proof API (generates cryptographic inclusion proof)
โ submit proof transaction
CCNext L2 (USC Contract โ verify proof + mint)
๐ ๏ธ What I Built
๐ก Event Monitoring Layer
- ๐ก Subscribes to Ethereum Sepolia ERC-20 Transfer events via ethers.js
- โณ Implements confirmation window logic: waits for N block confirmations before processing
- ๐พ Persistent event state tracking in PostgreSQL via TypeORM (prevents reprocessing on restart)
๐ Proof API Orchestration
- ๐ Calls external Proof API with exponential backoff retry (20 attempts, 15-minute total timeout)
- ๐ก๏ธ Handles API timeouts, rate limits, and transient failures gracefully
- ๐ Logs all retry attempts with structured metadata for observability
๐ค CCNext Transaction Submission (viem)
- โ๏ธ Uses viem for CCNext L2 interactions (EIP-1559 transaction construction)
- ๐ข Per-wallet nonce management: tracks nonce per wallet address to enable parallel transaction submission
- ๐ Supports 4 concurrent wallets with independent nonce tracking
๐งช Traffic Simulator
- ๐ง Companion tool that generates parallel ERC-20 transfers across 4 wallets for load testing
- ๐ข Per-wallet nonce management with EIP-1559 support
- โ Used for end-to-end bridge flow validation and stress testing
โ๏ธ Infrastructure
- ๐ณ Docker Compose with NestJS worker + PostgreSQL + Redis
- โ๏ธ Azure App Configuration for dynamic config management across environments
- ๐ Environment-specific deployments: testnet, devnet, production
โญ Key Highlights
- ๐ Exponential backoff proof API retry: 20 attempts, 15-min total timeout โ handles real network conditions
- ๐ข Per-wallet nonce management enabling parallel cross-chain submissions
- ๐พ Persistent state prevents duplicate processing on worker restart
- โ๏ธ Full multi-environment support via Azure App Configuration
- ๐งช Companion traffic simulator for end-to-end load testing