Skip to content

Latest commit

Β 

History

455 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Open-Audit

The Google Translate for Soroban β€” an open-source transparency tool for the Stellar/Soroban ecosystem.

License: MIT Contributions Welcome Built on Stellar


What is Open-Audit?

Smart contracts on Stellar/Soroban emit events as cryptic, hex-encoded binary data. To the average user β€” or even most developers β€” these events are completely unreadable. Open-Audit solves this by:

  1. Fetching raw contract events from the Stellar network via Horizon/RPC.
  2. Translating them into plain English sentences using a community-maintained Translation Registry.
  3. Displaying the results in a clean, searchable dashboard anyone can use.

Example:

Before (Raw) After (Translated)
0x000000000000000000000000... Public Key [GABC...1234] transferred 100 USDC to [GXYZ...5678]

Tech Stack

  • Framework: Next.js 16.2.10 (App Router) + TypeScript
  • Design System: Tailwind CSS + shadcn/ui
  • Stellar Integration: stellar-sdk
  • State Management: React Context + Server Components

Getting Started

Prerequisites

  • Node.js >= 20.9
  • npm >= 9

Installation

git clone https://github.com/Open-audit-foundation/Open-Audit.git
cd open-audit
npm install
npm run dev

Open http://localhost:3000 in your browser.

If you want the custom server with WebSocket support and /metrics, run:

npm run dev:ws

Environment Variables

Copy .env.example to .env.local and fill in the values:

cp .env.example .env.local

See .env.example for the full, commented list of required and optional variables β€” it's organized into [REQUIRED] and [OPTIONAL] sections with defaults and explanations for each.

Available Scripts

Development:

npm run dev              # Standard Next.js dev server
npm run dev:ws           # Legacy monolithic server with WebSocket support
npm run test             # Run the repository test suite
npm run build:cli        # Build the standalone CLI
npm run cli:example      # Exercise the CLI against the sample blueprint

Testing & Quality:

npm run test             # Run all tests
npm run test:parity      # Native/TS XDR decoder parity + fallback tests
npm run lint             # Run ESLint
npm run lint:registry    # Validate translation registry
npm run format           # Format code with Prettier

Native XDR decoder (optional):

npm run build:native         # Build the Rust N-API decoder (release)
npm run build:native:debug   # Debug build
npm run build:native:docker  # Build in a clean container
npm run bench:xdr            # TS vs native throughput comparison

Telemetry

The custom server exposes Prometheus metrics on http://localhost:3000/metrics when running npm run dev:ws.

You can configure OpenTelemetry to export spans to Jaeger by setting:

export JAEGER_ENDPOINT="http://localhost:14268/api/traces"
export OTEL_SERVICE_NAME="open-audit"

The default Jaeger endpoint is http://localhost:14268/api/traces.


Architecture

Open-Audit currently runs as a single-process monolithic architecture:

πŸ“š Documentation:

πŸ“Š Status Monitoring System (Production-Ready)

Real-time health monitoring for all system components with sub-500ms response:

Worker Heartbeat β†’ Redis β†’ Health API β†’ Status Dashboard

Features:

  • βœ… Real-time component health checks (Stellar RPC, Database, Redis, Worker)
  • βœ… Circuit breaker state monitoring
  • βœ… System metrics (events, translations, connections)
  • βœ… Beautiful auto-refreshing dashboard
  • βœ… Sub-500ms API response time
  • βœ… Graceful degradation

Components Monitored:

  • Stellar RPC (with circuit breaker state)
  • Database (Prisma connection)
  • Redis cache
  • Indexer worker (heartbeat-based)

πŸ“š Documentation:

Quick Start:

# Access status dashboard
open http://localhost:3000/status

# Check health via API
curl http://localhost:3000/api/status | jq

Worker Heartbeat:

  • Writes to Redis every 30 seconds
  • Validates worker is alive (< 90s threshold)
  • Includes metrics: processed count, error count, uptime

πŸ”’ Security Hardening (Production-Ready)

Bulletproof XDR parser protection against malicious contract payloads:

Untrusted XDR β†’ Security Guards β†’ Safe Parsing β†’ Graceful Error Handling

Protection Against:

  • βœ… Stack overflow (deeply nested structures)
  • βœ… Out-of-memory attacks (large payloads)
  • βœ… Denial of service (infinite loops)
  • βœ… Malformed XDR exploitation

Security Mechanisms:

  • Recursion depth limits (MAX=100 levels)
  • Memory allocation guards (MAX=10 MB)
  • Parsing timeout protection (MAX=5 seconds)
  • Collection size limits (MAX=10,000 elements)
  • Real-time attack detection

πŸ“š Documentation:

Quick Start:

import { secureParseScVal } from '@/lib/translator/secure-xdr-parser';

const result = secureParseScVal(hex);
if (result.success) {
  // Use result.value safely
}

⚑ Native XDR Decoder (Optional, Rust)

A native N-API module (native/soroban-xdr-decode) accelerates secureParseScVal for high-throughput scenarios. It is a drop-in performance path, not a second parser contract: it enforces the exact same security guards as the TypeScript implementation (recursion depth, allocation, timeout, collection size β€” same limits, same error classes, same messages) and the TypeScript parser remains the automatic fallback.

Zero configuration: if the addon has been built for the current platform it is used automatically (for payloads large enough to benefit); if it is missing, fails to load, or misbehaves at runtime, secureParseScVal transparently uses the pure-TypeScript implementation. Set OPEN_AUDIT_DISABLE_NATIVE_XDR=1 to force the TypeScript path (debugging/benchmarking only).

Building (requires a Rust toolchain, or Docker):

npm run build:native          # release build for the current platform
npm run build:native:debug    # debug build
npm run build:native:docker   # build inside a clean container (no local Rust needed)

Supported platforms: Linux x64/arm64 (glibc & musl), macOS x64/arm64, Windows x64. On anything else the build script exits with a message and the TypeScript parser is used β€” that is a fully supported configuration, not an error.

Verification: npm run test:parity runs every fuzz/security corpus input (including all payloads from fuzz-xdr-parser.test.ts and secure-xdr-parser.test.ts, deterministic mutation/random sweeps, UTF-8 edge cases and guard-boundary payloads) against both implementations and asserts identical results, and covers the automatic fallback with simulated missing/crashing/lying addons.

Measured throughput (npm run bench:xdr, Node v20.20.2, linux-x64, release build, interleaved best-of-3 rounds):

workload TS ops/s native ops/s speedup
typical transfer event (4 payloads) 104,654 104,173 1.00x
medium nested struct (depth 5, 50 fields) 8,204 19,634 2.39x
large vec (1,000 u32) 1,081 3,568 3.30x
large map (5,000 entries) 104 324 3.12x
attack: nested vec depth 150 1,928 24,781 12.86x
attack: vec with 20,000 elements 292 1,401 4.80x
malformed: tiny truncated garbage 10,877 11,128 1.02x
malformed: 4KB of garbage 23,406 29,623 1.27x

Small payloads (< ~50 bytes) intentionally stay on the TypeScript path β€” the N-API call overhead exceeds the work saved there, so the hybrid is never slower than pure TS. The largest wins are on hostile payloads, where rejection happens in Rust before the JavaScript XDR parser ever runs.

Legacy Monolithic Architecture

Single-process system (for simple deployments):

Stellar Network β†’ Event Indexer β†’ Translation Engine β†’ WebSocket Server β†’ Frontend Dashboard

⚠️ Known limitations: Under heavy load, indexing can starve the HTTP/WebSocket server of CPU cycles. See deprecation notice in server.ts.

npm run dev:ws

For new contributors wanting to understand the system's data flow and internal architecture, see the comprehensive ARCHITECTURE.md guide which includes:

  • πŸ“Š Interactive Mermaid diagrams showing data flow
  • πŸ” Component deep dives for each service
  • πŸ“ Step-by-step event journey from blockchain to UI
  • πŸ› οΈ Development guides for adding new features

Quick Overview:

  1. Event Indexer (lib/stellar/, src/worker/) β€” Polls Stellar RPC with resilient rate limiting
  2. Translation Engine (lib/translator/) β€” Converts XDR to human-readable text with security hardening
  3. Redis Pub/Sub β€” Message broker for event distribution
  4. WebSocket Server (server.ts) β€” Broadcasts events in real-time
  5. Frontend Dashboard (app/dashboard/, components/) β€” Interactive UI

Project Structure

open-audit/
β”œβ”€β”€ app/                    # Next.js App Router pages
β”‚   β”œβ”€β”€ dashboard/          # Main dashboard page
β”‚   β”œβ”€β”€ api/                # API routes (health checks, etc.)
β”‚   β”œβ”€β”€ layout.tsx          # Root layout with theme provider
β”‚   └── page.tsx            # Landing / redirect
β”œβ”€β”€ components/             # Reusable UI components
β”‚   β”œβ”€β”€ ui/                 # shadcn/ui primitives
β”‚   β”œβ”€β”€ dashboard/          # Dashboard-specific components
β”‚   └── theme/              # Dark mode toggle
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ translator/         # πŸ”‘ The Translation Registry core logic
β”‚   β”‚   β”œβ”€β”€ types.ts        # RawEvent / TranslatedEvent interfaces
β”‚   β”‚   β”œβ”€β”€ registry.ts     # Registry lookup function
β”‚   β”‚   └── blueprints/     # Per-contract translation blueprints
β”‚   β”œβ”€β”€ stellar/            # Stellar SDK helpers
β”‚   β”‚   β”œβ”€β”€ indexer.ts      # Event polling with rate limit handling
β”‚   β”‚   └── client.ts       # RPC client configuration
β”‚   β”œβ”€β”€ resilience/         # ⚑ Rate limiting & circuit breaker
β”‚   β”‚   β”œβ”€β”€ token-bucket.ts # Token bucket rate limiter
β”‚   β”‚   β”œβ”€β”€ circuit-breaker.ts # Circuit breaker pattern
β”‚   β”‚   └── resilient-client.ts # Resilient RPC client wrapper
β”‚   β”œβ”€β”€ hooks/              # React hooks for live data
β”‚   └── utils.ts            # Shared utilities
β”œβ”€β”€ src/
β”‚   └── worker/             # Standalone indexer worker
β”‚       └── indexer.ts
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ lint-registry.ts    # Translation registry validation
β”‚   └── test-websocket-client.js # WebSocket testing tool
β”œβ”€β”€ docs/
β”‚   └── good-first-issues.json
β”œβ”€β”€ server.ts               # Legacy monolithic server (deprecated)
β”œβ”€β”€ ARCHITECTURE.md         # πŸ“– Detailed architecture guide
β”œβ”€β”€ SECURITY_HARDENING_GUIDE.md # πŸ”’ Security documentation
└── public/

The Translation Registry

The heart of Open-Audit is the Translation Registry in /lib/translator/. Each contract gets a blueprint β€” a mapping from raw event topics/data to a human-readable template.

To add support for a new contract, create a file in /lib/translator/blueprints/ and register it in registry.ts. See CONTRIBUTING.md for a step-by-step guide.


πŸ› οΈ Developer Tools

open-audit-cli - Standalone Blueprint Testing

Instant offline testing for translation blueprints β€” no database, no network, no services required.

# Install and build
npm install
npm run build:cli

# Test a specification
node dist/cli/open-audit-cli.js test \
  --hex 0x74726e7312345678 \
  --spec ./blueprints/my-contract.json \
  --verbose

Benefits:

  • βœ… 17x faster iteration cycle vs. full system
  • βœ… Zero setup - Node.js only
  • βœ… Works offline
  • βœ… JSON & YAML support
  • βœ… CI/CD integration ready

πŸ“š Documentation:

Quick Example:

npm run cli:example

Output:

βœ… Translation Successful
Description: GABC...1234 transferred 100.00 USDC to GXYZ...5678

Contributing

We welcome contributions of all sizes! See CONTRIBUTING.md to get started.

Good first issues are listed in /docs/good-first-issues.json.


License

MIT Β© Open-Audit Contributors

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages