Skip to content

Conversation

@Bakobiibizo
Copy link
Contributor

🚀 Bridge Relayer Integration Summary

📋 Overview

Adds a node-integrated bridge relayer that listens for BridgeOut::BridgeToL1Locked events and calls the L1 BridgeMinter on Ethereum (Sepolia) to mint and deposit to Base L2 via the canonical bridge.


🔑 Key Changes

  • subspace/node/src/relayer.rs:65
    Enables relayer when BRIDGE_ENABLE is true; merges env config.
  • subspace/node/src/relayer.rs:80
    Reads System::Events from storage each imported block.
  • subspace/node/src/relayer.rs:93
    Matches RuntimeEvent::BridgeOut(BridgeToL1Locked { … }).
  • subspace/node/src/relayer.rs:118
    Scales native amount → ERC20 using BRIDGE_SUBSTRATE_DECIMALS and BRIDGE_ERC20_DECIMALS.
  • subspace/node/src/relayer.rs:121
    Builds eventId and invokes BridgeMinter.mintAndBridge via Foundry cast.
  • subspace/node/Cargo.toml:93
    Adds pallet-bridge-out dependency for event type matching.

⚙️ Configuration

Environment Variables:

  • BRIDGE_ENABLE=true
  • BRIDGE_L1_RPC
  • BRIDGE_MINTER
  • BRIDGE_PK
  • BRIDGE_L1_TOKEN
  • BRIDGE_L2_GAS
  • BRIDGE_SUBSTRATE_DECIMALS
  • BRIDGE_ERC20_DECIMALS

Dependencies:

  • Requires Foundry cast in PATH on the node host.

🛠️ How It Works

  1. On BridgeOut.lock_for_base(amount, l2_recipient), the relayer:
    • Derives eventId = keccak256(block_hash || nonce_le || l2_recipient).
    • Converts amount to ERC20 units.
    • Calls mintAndBridge(eventId, to, amountWei, l2Gas).
  2. Idempotent by design using BridgeMinter.consumed(eventId).

🧪 Testing

  1. Start node with:
    --chain <main.json|test.json> --bridge-enable
    (with env vars set).
  2. Submit BridgeOut.lock_for_base from Polkadot.js Apps.
  3. Observe logs:
    • “mintAndBridge …”
    • “L1 tx sent …”
  4. Verify:
    • Sepolia logs (Consumed / Bridged).
    • Base Sepolia balance updated.

🔮 Follow-ups

  • Optionally switch from cast to ethers-rs.
  • Add retry/backoff + a persisted cursor (finalized only).
  • Governance-controlled runtime upgrade path for live networks.

📚 Quick Reviewer References

  • subspace/node/src/relayer.rs
  • cargo.toml

Mod-Net CI and others added 3 commits August 29, 2025 19:52
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