A minimal implementation of a shared sequencing — a single ordering service that provides global transaction ordering to multiple independent rollups, cleanly separating ordering from execution.
- One sequencer receives transactions from multiple rollups
- Global ordering produces a single canonical transaction order
- Independent execution — each rollup executes its own transactions
- On-chain anchoring — ordering metadata is posted to L1
The sequencer:
- ✅ Orders transactions globally
- ✅ Tags transactions by
rollup_id - ✅ Emits ordered batches per rollup
- ❌ Never executes transactions
- ❌ Never inspects rollup state
- ❌ Never validates transaction content
┌─────────────────────────────────────────────────┐
│ Shared Sequencer (Rust) │
│ - Accepts transactions from multiple rollups │
│ - Maintains global FIFO queue │
│ - Produces ordered batches per rollup │
└─────────────────────────────────────────────────┘
│
┌───────────────┴───────────────┐
│ │
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ Rollup 1 Inbox │ │ Rollup 2 Inbox │
│ (Solidity) │ │ (Solidity) │
│ - Anchors batch │ │ - Anchors batch │
│ - Emits events │ │ - Emits events │
└──────────────────┘ └──────────────────┘
│ │
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ Rollup 1 Executor│ │ Rollup 2 Executor│
│ (Rust) │ │ (Rust) │
│ - Executes txs │ │ - Executes txs │
│ - Updates state │ │ - Updates state │
└──────────────────┘ └──────────────────┘
shared-sequencer/
├── README.md # This file
├── Cargo.toml # Rust dependencies
├── src/
│ ├── main.rs # Integration demo
│ ├── sequencer.rs # Shared sequencer implementation
│ ├── executor.rs # Rollup executor (mock)
└── contracts/
├── src/
│ └── Inbox.sol # L1 inbox contract
├── script/
│ └── Deploy.s.sol # Deployment script
└── test/
└── Inbox.t.sol # Contract tests
File: src/sequencer.rs
- Maintains global transaction queue
- Assigns
global_indexto each transaction - Groups transactions into batches by
rollup_id - Returns ordered batches with ordering metadata
Key invariant: Transactions receive global_index in FIFO order, regardless of rollup_id
File: contracts/src/Inbox.sol
- One contract per rollup
- Accepts ordered batches from sequencer
- Emits
BatchSubmittedevents with:batch_idrollup_idordered_tx_hashes[]global_start_indextimestamp
No validation — purely anchors ordering metadata
File: src/executor.rs
- Consumes ordered batches sequentially
- Executes transactions (mock: increments counter)
- Maintains independent state
- No cross-rollup communication
# Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryupTerminal 1: Start Anvil
anvilTerminal 2: Deploy Contracts
cd contracts
forge build
forge script script/Deploy.s.sol \
--rpc-url http://127.0.0.1:8545 \
--broadcast \
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80Copy deployed contract addresses from output.
Terminal 3: Update and Run
# Update src/main.rs with deployed addresses
# Replace INBOX1_ADDRESS_HERE and INBOX2_ADDRESS_HERE
cargo runRollup 1 executed and anchored batch 0
Rollup 2 executed and anchored batch 0
Rollup 1 tx count: Some(2)
Rollup 2 tx count: Some(2)