RustAG
Advanced

Architecture

RustAG is a dual-layer system. The Ingest layer resolves every account a proposed transaction will touch. The Sealed Rehearsal layer executes it in isolation, diffs the state, fires invariant alarms, and signs the result as a cryptographic EvidenceBundle.

Architecture overview

The core design principle: the rehearser must be independently verifiable. That means the input (pre-state closure) must be content-addressable from public mainnet data, and the output (EvidenceBundle) must be byte-for-byte reproducible by anyone who runs the same closure through the same payload.

RustAG achieves this by splitting responsibility into two layers that share no mutable state with each other.

Ingest layer

The ingest layer's job is to resolve the exact set of accounts the proposed payload will read or write — called the touch set. It never executes anything; it only reads mainnet.

  • SquadsDecoder — Borsh-decodes a multisig VaultTransaction from its on-chain proposal address.
  • TouchSetResolver — static analysis walk of instruction account metas to produce the minimal pubkey set.
  • MultiRpcFetcher — batches getMultipleAccounts calls (≤100 keys per call) over raw reqwest without solana-rpc-client — this keeps EVM sandbox 0.12 dep compatibility.
  • ForwardRecorder — optional corpus recorder that serializes the resolved closure to disk for CI replay.

Sealed rehearsal layer

The rehearsal layer receives the sealed closure (pubkey → AccountData snapshot at a known slot). It runs a deterministic two-pass process and produces a signed artifact:

  1. Pass 1 — Pre-state root: load the closure into an isolated EVM sandbox instance, SHA-256 hash every account in pubkey order → pre_state_root.
  2. Pass 2 — Execute + diff: execute the payload, capture post-state, run SemanticDiff (11 change types) and InvariantPolicy (6 alarm rules), derive post_state_root, assign FidelityGrade.
  3. Signing: Ed25519-sign the concatenation of pre_state_root + post_state_root + semantic_diff + alarms + grade → write EvidenceBundle.json and portable closure.json.
Grade A vs Grade B
Grade A means the closure is complete — every account was resolved and the rehearsal is deterministically re-executable offline. Grade B means one or more accounts could not be fetched (rate-limited, new account, etc.); the bundle is still signed but the post_state_root cannot be reproduced without re-fetching. Treat Grade B as advisory only and verify with a fresh RPC key.

End-to-end data flow

GroundTruth two-layer data flow
  Wallet / multisig UI / Multisig signer / CI pipeline           │  POST /api/rehearse { proposal | payload }┌─────────────────────────────────────────────────────────┐│ INGEST LAYER                                             ││   SquadsDecoder  — Borsh-decode VaultTransaction        ││   TouchSetResolver — walk instruction accounts          ││   MultiRpcFetcher  — getMultipleAccounts (≤100/call)    ││   ForwardRecorder  — record traffic corpus              │└─────────────────────────────────────────────────────────┘           │ sealed pre-state closure (pubkey → AccountData)┌─────────────────────────────────────────────────────────┐│ SEALED REHEARSAL (rustag-rehearse)                       ││   Pass 1 (Pre-state)                                     ││     • load closure into isolated EVM sandbox instance        ││     • content-hash every account → pre_state_root        ││   Pass 2 (Execution)                                     ││     • execute payload → capture post-state               ││     • SemanticDiff  — 11 change types                    ││     • InvariantPolicy — 6 alarm rules                    ││     • FidelityGrade — Grade A / Grade B                  ││   Signing                                                ││     • Ed25519 sign over pre+post root + diff + alarms    ││     → EvidenceBundle.json + closure.json                 │└─────────────────────────────────────────────────────────┘           │  signed EvidenceBundle  Signer review / offline verify / CI gate / registry

Crate map

RustAG is a Cargo workspace under crates/. The core dependency direction is rustag-cli → rustag-rpc → rustag-rehearse → rustag-sim + rustag-attest → rustag-mirror → rustag-core. Every Phase 2/3 crate is pure Rust with no external service dependency.

CrateResponsibilityPhase
rustag-rehearseSealed two-pass rehearsal engine: PortableBundle, EvidenceBundle, FidelityGrade (A/B). The core GroundTruth primitive.1
rustag-mirrorIngest layer: TouchSetResolver, SquadsDecoder, MultiRpcFetcher (≤100 keys/call, no solana-rpc-client), ForwardRecorder corpus builder.1 · realtime 2
rustag-simSemanticDiff (11 change types), InvariantPolicy (6 alarm rules), fuzzing, exploit scanning, differential execution.1 / 2
rustag-attestEd25519 signing, Merkle state_root, offline verify, EvidenceBundle wrapper, hash-chained AuditLog.1 / 3
rustag-corePersistent EVM stagenet runtime: EVM sandbox + AccountSync state machine (Unknown→Clean→Dirty→Pinned) + SQLite via sqlx.1
rustag-rpcaxum server: POST /api/rehearse, POST /api/verify, Robinhood Chain-compatible JSON-RPC, WebSocket, REST API.1
rustag-cliThe rustag binary: rehearse, verify, forensics, record, serve, and full stagenet management surface.1 + 2/3
rustag-schedulerActivity Scheduler: @every / cron actions (airdrop / transfer / raw-tx) for the stagenet dev-tool surface.2
rustag-cloudMulti-tenant control plane: isolated child processes behind a reverse proxy with Bearer rk_… API-key auth.2
rustag-replayTime-travel: content-addressed Checkpoint, deterministic Journal replay, Timeline diffs, fork-of-fork Lineage.3
rustag-compressionOff-chain spl-account-compression-compatible ConcurrentMerkleTree (keccak-256, changelog, root-history, canopy).3
packages/sdk@rustag/sdk — TypeScript client for POST /api/rehearse, POST /api/verify, and the full REST surface.1

Phase 2 & 3

The invariant across all phases: the pre-state closure is always sealed before execution and never mutated after. Every Phase 2/3 extension is additive — it does not change how Phase 1 bundles are produced or verified.

Phase 2 features Phase 2 · Preview

  • Yellowstone gRPC recording — real-time traffic corpus from a Geyser stream; replaces ForwardRecorder's poll-based approach with a push source for sub-second latency corpus building.
  • Evidence Registry — hosted, append-only store for signed bundles with N-of-M signer provenance. A multisig vault can require M-of-N reviewers to submit a valid Grade A bundle before a proposal can be approved.
  • multisig web UI embed — a signer-review panel that fetches and renders the EvidenceBundle inline in the multisig proposal UI, without requiring any CLI.
  • Activity Scheduler — recurring on-chain actions for the stagenet dev surface (@every / cron).
  • Real-time mirror pushaccountSubscribe WebSocket / Yellowstone gRPC → oracle prices under 2s staleness.
  • Cloud control plane (rustag-cloud) — multi-tenant hosted rehearsal service with Bearer rk_… API-key auth.
semantic diff — 11 change types (rustag-sim)
// A sample of the SemanticChange variants produced by SemanticDiffSemanticChange::LamportsDrained    { from, to, delta }SemanticChange::UpgradeAuthority   { from, to }       // CRITICAL alarmSemanticChange::ProgramUpgraded    { pubkey, old_hash, new_hash }SemanticChange::TokenAuthorityChanged { mint, from, to }SemanticChange::AccountClosed      { pubkey, recovered_lamports }SemanticChange::DataWritten        { pubkey, len }// + 5 more: Created, Frozen, Thawed, NonceDerived, SysvarMutated

Phase 3 features Phase 3 · Experimental

  • Per-flow pricing & quota — usage-metered rehearsal API with tiered plans (free / pro / enterprise).
  • Time-travel & replay (rustag-replay) — content-addressed Checkpoints, deterministic Journal replay, Timeline diffs, and fork-of-fork Lineage.
  • Adversarial simulation (rustag-sim) — atomic MEV-style bundles with tip accounting, deterministic invariant fuzzing, and a reproducible exploit-signature scanner.
  • State / ZK compression testing (rustag-compression) — a keccak-256 ConcurrentMerkleTree matching spl-account-compression so compressed-state programs verify deterministically off-chain.
Honest boundary
Phase 1 delivers: rehearse, verify, forensics, serve, and the signed EvidenceBundle end-to-end. The Evidence Registry, multisig UI embed, Yellowstone gRPC, and hosted multi-tenant service are Phase 2 and are not yet released. Everything documented on this page as Phase 1 works today — build from source and run locally.