A Verifiable Database AVS built on EigenLayer that provides PostgreSQL-compatible functionality with cryptographic verification capabilities.
Verifiable RDS AVS is a system that enables permissionless verification of database operations through Merkle tree-based state commitments, creating a migration path from traditional RDS to verifiable database services.
The system leverages existing PostgreSQL databases but adds a verification layer that:
- Captures database state changes
- Creates cryptographic proofs of state transitions
- Enables challenges for incorrect state transitions
- Provides integration with EigenLayer for decentralized verification
The Verifiable RDS AVS consists of several key components:
┌─────────────────┐ ┌──────────────────┐ ┌────────────────┐
│ PostgreSQL │ │ Verification │ │ EigenLayer │
│ Database │◄────┤ Proxy │◄────┤ Integration │
└─────────────────┘ └──────────────────┘ └────────────────┘
│
▼
┌──────────────────┐
│ Verification │
│ Engine │
└──────────────────┘
│
▼
┌──────────────────┐
│ State Capture │
│ & Merkle Trees │
└──────────────────┘
-
PostgreSQL Proxy
- Wire protocol compatible with standard PostgreSQL clients
- Intercepts and analyzes database queries
- Manages connections between clients and the database
-
Verification Engine
- Captures pre and post states for database operations
- Deterministically replays transactions for verification
- Builds Merkle trees of the database state
-
State Capture System
- Efficiently tracks database schema and data changes
- Builds incremental updates to state Merkle trees
- Provides proof generation for specific rows
-
EigenLayer Integration
- Commits state roots to EigenLayer contracts
- Handles verification challenges
- Manages operator registration and rewards
/proxy- PostgreSQL wire protocol proxy and query interception/verification- Cryptographic verification, Merkle trees, and state tracking/contracts- Smart contracts for EigenLayer integration/client- Client libraries and verification tools/core- Shared code and utilities
- Rust 1.70 or later
- PostgreSQL 14 or later
- Node.js 18 or later (for smart contracts)
- Docker and Docker Compose (for development)
-
Clone the repository:
git clone https://github.com/Gajesh2007/verifiable-rds-avs.git cd verifiable-rds-avs -
Start the development environment:
docker-compose up -d -
Build the proxy:
cd proxy cargo build --release -
Run the proxy:
./target/release/verifiable-db-proxy --config config/development.toml -
Connect to the proxy with any PostgreSQL client:
psql -h localhost -p 5433 -U postgres -d postgres
The Verifiable RDS AVS incorporates several security features:
- Secure Merkle tree implementation with domain separation
- Deterministic query handling for non-deterministic functions
- Transaction boundary protection
- DoS prevention through rate limiting and resource quotas
- Challenge economic security with optimal bonding curve
This project is currently in MVP development. Key components that are implemented:
- PostgreSQL wire protocol handler
- Query analysis and interception
- Merkle tree implementation
- State capture system
- Verification environment
- EigenLayer integration
Upcoming features:
- More comprehensive transaction validation
- Enhanced security features
- Performance optimizations
- Client libraries for multiple languages
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
The proxy module implements a complete PostgreSQL wire protocol handler, which intercepts and processes database queries. This enables the system to:
- Parse and analyze SQL queries
- Rewrite queries for deterministic execution
- Track transactions and their boundaries
- Capture state before and after transactions
The transaction module provides robust transaction boundary protection through WAL-level capture:
- Tracks transaction boundaries (BEGIN, COMMIT, ROLLBACK)
- Monitors savepoints within transactions
- Detects incomplete or improperly handled savepoints
- Validates transaction integrity
The verification module implements state capture and Merkleization:
- Captures database state before and after transactions
- Creates Merkle trees of table state
- Generates cryptographic proofs for verifying data
- Supports incremental state updates
The system provides comprehensive deterministic execution:
- Replaces non-deterministic functions like NOW(), RANDOM(), UUID_GENERATE_V4() with deterministic versions
- Enforces deterministic ordering for unordered queries
- Applies query hints to enforce deterministic query plans
- Detects and reports non-deterministic patterns in queries
The EigenLayer integration connects the verification system to the blockchain:
- Commits state roots to EigenLayer
- Supports submission and resolution of challenges
- Handles operator registration and management
- Provides cryptographic proofs for on-chain verification
Client libraries for interacting with the verification system:
- Verification client for checking transaction validity
- Query client for executing queries with verification
- Challenge client for submitting and monitoring challenges
- Command-line tools for common operations
cargo run --bin proxy -- --config config.jsonConnect to the proxy using any PostgreSQL client:
psql -h localhost -p 5432 -U postgres -d postgresUse the verification client to verify transactions:
let client = VerificationClient::new("http://localhost:8080");
let result = client.verify_transaction(transaction_id).await?;Use the query client to execute queries with verification:
let client = QueryClient::new("postgres://postgres:postgres@localhost:5432/postgres")
.with_verification_client(VerificationClient::new("http://localhost:8080"))
.with_verification(true);
let result = client.query("SELECT * FROM users").await?;Use the verification client to submit challenges:
let client = VerificationClient::new("http://localhost:8080");
let challenge = client.submit_challenge(state_root, block_number, evidence).await?;