A proof-of-concept implementation of a sequencer for the PrimeV protocol, integrating Shutter Network's threshold cryptography for encrypted transaction ordering and MEV protection.
The PrimeV sequencer is a multi-module system that handles encrypted transactions, participates in MEV-commit bidding, and manages the complete lifecycle from transaction submission to blockchain finalization. The system combines privacy-preserving threshold cryptography with automated bidding to protect against MEV attacks.
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β RPC Server β β REST API β β P2P Messaging β
β (Port 8545) β β (Port 8080) β β (Libp2p/Shutter)β
βββββββββββ¬ββββββββ βββββββββββ¬ββββββββ βββββββββββ¬ββββββββ
β β β
ββββββββββββββββββββββββΌβββββββββββββββββββββββ
β
ββββββββββββββΌβββββββββββββ
β Transaction Handler β
β (Status Management) β
ββββββββββββββ¬βββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββ
β β β
βββββββββββΌβββββββ ββββββββββΌβββββββββ βββββββΌβββββββ
β Bid Manager β β Shutter Engine β β TX Verifierβ
β (MEV-Commit) β β (Encryption) β β (Blockchain)β
ββββββββββββββββββ βββββββββββββββββββ ββββββββββββββ
Purpose: Application entry point and orchestration layer
Key Responsibilities:
- Environment configuration and validation
- Module initialization and lifecycle management
- Graceful shutdown handling
- P2P network setup with Shutter Network integration
Key Components:
- CLI interface using Cobra
- Configuration management via environment variables
- Service orchestration with integrated health monitoring
- P2P bootstrap configuration for Shutter Network
Purpose: Core transaction state management and storage
Transaction Lifecycle:
init β bidsubmitted β committed β decrypted β finalised
β β
βββββββββββββββββ blocked ββββββββββββββββββββββ
Key Features:
- Thread-safe in-memory transaction storage
- Status-based transaction querying
- Identity-based transaction lookup for keyper integration
- Comprehensive transaction metadata tracking
Identity Management:
- Unique Identity Creation: Each transaction gets a unique identity created by hashing the transaction hash with the bidder node address
- Deterministic Generation:
Identity = Keccak256(txHash + bidderNodeAddress) - Keyper Verification: Keypers can verify identities by extracting the bidder node address from bid signatures in commitments
- No Re-registration: Unique identities prevent duplicate processing and ensure cryptographic integrity
Transaction States:
init: Newly submitted, awaiting bid inclusionbidsubmitted: Included in MEV-commit bidcommitted: Commitment received from providersdecrypted: Decryption keys received via P2Pfinalised: Verified on blockchainblocked: Failed verification after retries
Purpose: Threshold cryptography integration with Shutter Network
Core Functionality:
- Threshold Encryption: Encrypts transactions using Shutter's time-lock encryption
- Eon Management: Handles cryptographic epochs for time-based decryption
- Identity Generation: Creates unique identities for encrypted transactions
- Blockchain Integration: Fetches eon keys and manages keyper sets
Encryption Process:
- Calculate target block for transaction inclusion
- Determine cryptographic eon for target block
- Fetch eon public key from KeyBroadcast contract
- Generate unique identity for transaction
- Encrypt transaction data using threshold cryptography
Identity Generation & Verification:
- Cryptographic Identity:
Identity = Keccak256(TransactionHash || BidderNodeAddress) - Unique per Transaction: Each transaction gets a unique identity preventing replay attacks
- Bidder Binding: Identity is cryptographically bound to the bidder who submitted the transaction
- Keyper Verification: Keypers verify identities by:
- Extracting bidder address from bid signature in commitment message
- Recomputing identity using transaction hash and extracted bidder address
- Comparing computed identity with the one used for encryption
- No Re-registration Protection: Same identity cannot be used twice, preventing duplicate decryption requests
Purpose: MEV-commit integration and automated bidding
Bidding Strategy:
- Aggregates
initstatus transactions into bids - Creates time-decay bids with configurable parameters
- Submits bids to MEV-commit providers via gRPC
- Handles commitment processing and validation
Bid Parameters:
- Fixed bid amount (30 Gwei)
- Configurable slash conditions
- Time-decay mechanism for bid value
- Block-based inclusion windows
Purpose: Shutter Network communication and key distribution
Message Types:
- DecryptionKeys: Received from keypers when time-lock expires
- Commitments: Sent to keypers after successful bid commitments
Key Features:
- Libp2p-based networking with Shutter Network
- Message validation and filtering
- Automatic transaction status updates on key receipt
- Provider address verification
Purpose: Blockchain verification and finalization
Verification Process:
- Periodically scans for
decryptedtransactions - Queries blockchain for transaction inclusion
- Updates status to
finalisedif found - Implements retry logic with automatic fallback to
blocked
Key Features:
- Configurable verification intervals
- Ethereum client integration
- Comprehensive error handling
- Retry mechanism with maximum attempt limits
Purpose: Ethereum JSON-RPC compatibility with encryption
Supported Methods:
eth_sendRawTransaction: Intercepts and encrypts transactions- Standard Ethereum RPC proxy for other methods
Transaction Flow:
- Receive raw transaction via JSON-RPC
- Encrypt using Shutter threshold cryptography
- Store in transaction handler with
initstatus - Return transaction hash to client
- Proxy other RPC calls to upstream Ethereum node
Purpose: HTTP API for transaction introspection
Endpoints:
GET /get_decrypted_tx/{txHash}: Retrieve and decrypt transaction data
Features:
- Transaction status validation
- Real-time decryption of committed transactions
- Comprehensive error handling and logging
- Will be used by Builders to get the decrypted transaction
Purpose: Shared cryptographic and helper functions
Key Functions:
- Identity prefix generation for Shutter integration
- Cryptographic utilities for transaction hashing
- Common data structures and constants
Client β RPC Server β Shutter Engine β Transaction Handler
β β β β
β β βββ Encrypt β
β βββ JSON-RPC β β
β βββ Store ββββββ
βββ Return TxHash
Transaction Handler β Bid Manager β MEV-Commit β P2P Network
β β Provider β
β βββ Create Bid β β
βββ Status: init β β β
βββ gRPC β β
β β
Commitment βββββββ
Shutter Keypers β P2P Network β Message Handler β Transaction Handler
β β β β
β β βββ Update Status β
βββ Broadcast β β β
Keys βββ DecryptionKeys β β
βββ Status: decrypted
Transaction Verifier β Ethereum Node β Transaction Handler
β β β
β βββ Query β
βββ Check Status β β
βββ Update Status
(finalised/blocked)
The sequencer integrates with Shutter Network smart contracts:
- KeyperSetManager: Manages cryptographic epochs and keyper sets
- KeyBroadcast: Distributes eon public keys for encryption
- MEV-Commit: Provider network for bid submission and commitments
# Copy configuration template
cp sequencer/config.env.example sequencer/.env
# Update configuration with your values
nano sequencer/.envcd sequencer
chmod +x start.sh
./start.sh# Submit encrypted transaction
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_sendRawTransaction",
"params": ["0x..."],
"id": 1
}'# Check transaction status via REST API
curl http://localhost:8080/get_decrypted_tx/0x...A separate test client is provided in test_client/ for transaction sending:
cd test_client
./run_test.sh