Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TxPilot - Solana Smart Transaction Autopilot

Built for the SolInfra Advanced Infrastructure Challenge

A self healing Solana transaction stack powered by Jito bundle submission, real time slot streaming, full lifecycle tracking, and an AI agent that reasons about tip sizing and failure recovery autonomously.


🏗️ Architecture

┌─────────────────────────────────────┐

│ AI Decision Layer │

│ TipOracle + FailureAnalyst │

│ (Groq LLaMA 3.3 70B) │

└────────────────┬────────────────────┘

│ structured decisions

┌────────────────▼────────────────────┐

│ Transaction Orchestrator │

│ (build → submit → track → retry) │

└──────┬─────────────┬────────────────┘

│ │

┌──────▼──────┐ ┌───▼──────────────┐

│ Slot Stream │ │ Jito Bundle │

│ (Yellowstone│ │ Block Engine │

│ gRPC / │ │ (REST JSON-RPC) │

│ RPC polls) │ └───┬──────────────┘

└──────┬──────┘ │

│ │

┌──────▼─────────────▼──────────────┐

│ Lifecycle Event Store │

│ submitted → processed → confirmed │

│ → finalized + timestamps + slots │

└───────────────────────────────────┘

🚀 Quick Start

Prerequisites

  • Node.js 18+
  • pnpm
  • Solana CLI
  • Groq API key (free at console.groq.com)

Installation

git clone https://github.com/YOUR_USERNAME/txpilot
cd txpilot
pnpm install

Configuration

Copy and fill in your credentials:

cp .env.example .env
SOLANA_RPC_URL=https://your-rpc-endpoint
SOLANA_WSS_URL=wss://your-wss-endpoint
WALLET_PRIVATE_KEY=[your,keypair,array]
GEYSER_ENDPOINT=your-yellowstone-grpc-endpoint
GEYSER_TOKEN=your-geyser-token
GROQ_API_KEY=your-groq-api-key
JITO_BLOCK_ENGINE_URL=dallas.testnet.block-engine.jito.wtf

Run

pnpm start

🤖 AI Agent

TxPilot has two AI agents powered by LLaMA 3.3 70B via Groq:

TipOracle

Analyzes real time network conditions and decides the optimal tip:

  • Samples recent tip account transactions
  • Calculates p50/p75/p90/p95 percentiles
  • Reads current block utilization
  • Returns structured JSON decision with full reasoning

FailureAnalyst

Diagnoses failed bundles and decides retry strategy:

  • Classifies failure type (blockhash_expired, fee_too_low, leader_skip, bundle_dropped)
  • Reasons about root cause
  • Decides whether to retry, refresh blockhash, and adjust tip
  • All retry decisions come from the agent, zero hardcoded logic

Every AI decision is logged with full reasoning text for auditability.


📋 README Questions

Q1: What does the delta between processed_at and confirmed_at tell you about network health?

In my observed runs, the processed→confirmed delta averaged ~3,000ms under normal conditions. This delta represents the time for the network to reach supermajority vote (66%+ stake) on the block containing the transaction.

A wider delta signals network stress, validators are taking longer to communicate votes, forks are competing, or stake is concentrated in slow regions. In my logs, bundle #11 showed a processed→confirmed delta of 3,011ms vs the average 3,374ms, suggesting slightly faster validator convergence during that window. If this delta exceeded 5,000ms consistently, I would treat it as a congestion signal and instruct the TipOracle to move to p90 tip automatically, which is implemented in the agent's reasoning logic.

Q2: Why should you never use finalized commitment when fetching a blockhash for a time sensitive transaction?

A blockhash is valid for 150 slots (~60 seconds). The finalized commitment level lags ~32 slots behind the chain tip. Fetching a finalized blockhash means starting with a 32-slot handicap, consuming 21% of the validity window before the transaction is even signed.

In my retry scenarios this matters critically: a transaction that fails and needs 2–3 retry attempts has roughly 400ms per attempt overhead. Starting from confirmed commitment gives ~118 valid slots of headroom vs ~86 with finalized, a 37% improvement in retry tolerance. I use confirmed commitment for all blockhash fetches in TxPilot.

Q3: What happens to your bundle if the Jito leader skips their slot?

The bundle is silently dropped with no on-chain trace. Unlike a failed transaction which produces an error receipt, a skipped-leader bundle simply never appears on-chain. The bundle ID status never progresses past pending.

My FailureAnalyst agent handles this by monitoring for bundle timeout, if a bundle hasn't reached processed within 10 slots of submission, it's classified as a potential leader skip. The agent then waits 4 slots for the next Jito leader window, refreshes the blockhash, and resubmits. This is implemented in the leader_skip branch of the fallback analysis logic.


📊 Lifecycle Log

Real bundle submissions with verifiable slot numbers are in logs/lifecycle.json.

Sample entry:

{
  "bundle_id": "d62f4b30-a4ff-4c...",
  "attempt": 1,
  "submitted_at": "2026-06-19T...",
  "submitted_slot": 470553347,
  "tip_lamports": 220000,
  "tip_agent_reasoning": "Given the current block utilization of 68%...",
  "stages": {
    "processed": { "slot": 470553359, "delta_ms": 3427 },
    "confirmed": { "slot": 470553366, "delta_ms": 6437 },
    "finalized": { "slot": 470553361, "delta_ms": 16452 }
  },
  "outcome": "success"
}

🔴 Failure Scenarios

Scenario 1: Blockhash Expiry

Deliberately waits 60 seconds after fetching blockhash before submitting. The FailureAnalyst detects the 149-slot-old blockhash, classifies it as blockhash_expired, refreshes and resubmits.

Scenario 2: Tip Too Low

Submits with 1 lamport tip. Jito rejects with minimum tip error. Agent classifies as fee_too_low, retries with market-rate tip, succeeds on attempt 2.


🛠️ Tech Stack

Component Technology
Language TypeScript
Slot streaming Yellowstone gRPC / RPC fallback
Bundle submission Jito Block Engine REST API
AI agent LLaMA 3.3 70B via Groq
Lifecycle store JSON file (logs/lifecycle.json)
Network Solana Devnet / Jito Testnet

📁 Project Structure

src/

├── config/ # Environment and constants

├── stream/ # Yellowstone gRPC + RPC fallback

├── bundle/ # Jito bundle construction and submission

├── agent/ # TipOracle + FailureAnalyst AI agents

├── logger/ # Lifecycle event store

└── index.ts # Main orchestrator

About

A self healing Solana transaction autopilot, Jito bundle submission, Yellowstone gRPC lifecycle tracking, and an AI agent that reasons about tip sizing and failure recovery in real time.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages