Skip to content

0xdmtry/shared-sequencer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Shared Sequencer

Overview

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.

What This Project Demonstrates

Core Concept

  • 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

Key Separation: Ordering ≠ Execution

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

Architecture

┌─────────────────────────────────────────────────┐
│              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 │
└──────────────────┘          └──────────────────┘

Project Structure

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

Implementation Details

Sequencer (Rust)

File: src/sequencer.rs

  • Maintains global transaction queue
  • Assigns global_index to 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

Inbox Contracts (Solidity)

File: contracts/src/Inbox.sol

  • One contract per rollup
  • Accepts ordered batches from sequencer
  • Emits BatchSubmitted events with:
    • batch_id
    • rollup_id
    • ordered_tx_hashes[]
    • global_start_index
    • timestamp

No validation — purely anchors ordering metadata

Rollup Executors (Rust)

File: src/executor.rs

  • Consumes ordered batches sequentially
  • Executes transactions (mock: increments counter)
  • Maintains independent state
  • No cross-rollup communication

Running the Demo

Prerequisites

# Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryup

Steps

Terminal 1: Start Anvil

anvil

Terminal 2: Deploy Contracts

cd contracts
forge build
forge script script/Deploy.s.sol \
  --rpc-url http://127.0.0.1:8545 \
  --broadcast \
  --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

Copy 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 run

Expected Output

Rollup 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)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors