โ†
Previous Module
GraphQL Indexer Simulator

๐Ÿ—๏ธ Bridge Architecture: Validators & Relayers

Learn the components that power cross-chain communication

Transfer assets between different blockchains

๐Ÿ—๏ธ Production Bridge Architecture

Understanding bridge architecture at the implementation level is critical for developers building or integrating cross-chain apps. A production bridge involves 7 distinct steps spanning multiple actors (user, smart contracts, relayers, validators) and both chains. Ethereum โ†’ Polygon transfer takes ~10-30 minutes from user initiation to final receipt. Each step has specific gas costs, time estimates, and failure modes. Relayers provide liveness (message passing) while validators provide security (signature verification). Gas optimization is crucialโ€”Polygon Bridge batches proofs to reduce L1 costs. This section breaks down the complete flow with real code examples from production bridges.

๐ŸŽฎ Interactive: 7-Step Transaction Flow

Click through each step of a real bridge transaction. See the actors involved, time estimates, gas costs, technical details, and actual code snippets.

Step 1 of 7

User Initiates Bridge

โšก

User connects wallet, selects source/dest chains, amount, clicks "Bridge"

Chain
Frontend
Actor
User
Time
Instant
Gas Cost
-
๐Ÿ”ง Technical Details
  • โ€ขFrontend calls: bridgeContract.lock(amount, destChain, destAddress)
  • โ€ขUser approves token spend if ERC20 (not needed for native ETH)
  • โ€ขTransaction broadcast to source chain mempool
๐Ÿ’ป Code Example
// Frontend code
const tx = await bridgeContract.lock(
  ethers.utils.parseEther("10"), // amount
  137, // Polygon chain ID
  userAddress // destination address
)
1 / 7

๐Ÿ‘ฅ Key Actors in Bridge Architecture

๐Ÿ”„ Relayers

Off-chain services that watch both chains and relay messages. Provide liveness.

  • โ€ข Run full nodes on source + destination chains
  • โ€ข Monitor for LockEvents, submit proofs to destination
  • โ€ข Anyone can run a relayer (permissionless)
  • โ€ข Incentivized via fees (~0.1% of bridge volume)
  • โ€ข Cannot forge messages (no validator keys)
โœ“ Validators

Consensus participants who sign cross-chain messages. Provide security.

  • โ€ข Hold private keys, sign messages after independent verification
  • โ€ข Typically staked (Polygon: 1M MATIC minimum)
  • โ€ข Slashable if sign invalid messages
  • โ€ข N-of-M threshold (e.g., 2/3 must agree)
  • โ€ข Decentralization critical (Ronin had only 9 validators)

โšก Gas Optimization Strategies

1. Batch Processing

Instead of relaying each lock event individually (expensive L1 gas), batch multiple events into single Merkle tree. Submit root + proofs. Polygon processes 100+ checkpoints per Ethereum transaction.

2. ZK Proof Aggregation

zkSync, StarkNet compress 1000s of transactions into single proof (~200 bytes). Verification cost constant regardless of transaction count. Future of bridges.

3. State Compression

Store only Merkle roots on L1, full state on L2/off-chain. User provides inclusion proof when withdrawing. Reduces L1 storage costs 10-100x.

4. Optimistic Assumptions

Assume messages valid, only verify if challenged (Optimism model). Fast deposits (1 confirmation), slow withdrawals (7-day challenge). Most transfers honest = cheaper on average.

๐Ÿญ Production Examples

Polygon PoS Bridge: Uses Heimdall validators (2/3 consensus), checkpoints every 30 min, ~30 min transfers, 7-day withdrawals. $4B+ TVL.
Arbitrum Bridge: Optimistic model, instant deposits (trust sequencer), 7-day withdrawals (fraud proof window). Native to Arbitrum ecosystem.
Hop Protocol: Liquidity pools on each chain, AMM-based swaps, 5-10 min transfers. No wrapping (native tokens). $100M+ daily volume.
Wormhole: 19 guardians (13-of-19 threshold), supports 20+ chains, general message passing (not just tokens). Rebuilt after $325M hack.

โš ๏ธ Common Failure Modes

โ€ข
Chain Reorg: Source chain reorganizes after relayer saw event. Solution: Wait 12+ confirmations before relaying.
โ€ข
Relayer Offline: All relayers down = bridge halts. Solution: Permissionless relaying + economic incentives.
โ€ข
Validator Offline: If < threshold validators online, bridge stops. Solution: Large validator set (50+).
โ€ข
Gas Spike: L1 gas hits 1000+ gwei, relayers can't afford to submit proofs. Solution: Gas price oracles + dynamic fees.
โ€ข
Nonce Desync: Nonce on source/dest chains out of sync = proofs rejected. Solution: Global nonce counter + replay protection.