Skip to content

perf(solana): drop both RPC round-trips from the x402 payment critical path (0.19.1) - #6

Merged
VickyXAI merged 2 commits into
mainfrom
feat/solana-fast-path
Jul 28, 2026
Merged

perf(solana): drop both RPC round-trips from the x402 payment critical path (0.19.1)#6
VickyXAI merged 2 commits into
mainfrom
feat/solana-fast-path

Conversation

@VickyXAI

Copy link
Copy Markdown
Contributor

Why

Paid latency benchmark of the Go VIP SDK (gpt-4o-mini, n=6 per chain) showed Solana payments running a median 2.16s vs 1.37s on Base, with a 9.68s worst case. The entire gap traced to two serial JSON-RPC calls on the signing path — `getAccountInfo` (mint info) and `getLatestBlockhash` — each measured at 0.26–4.53s against the default RPC proxy. Base signs EIP-712 purely locally.

What

Mirrors the TS SDK fast path (blockrun-llm-ts `src/x402.ts`):

  • USDC mint info hardcoded. SPL Token fixes `decimals` in `InitializeMint` and ships no instruction to change it, and USDC's owner is the classic token program — both values are immutable. `getAccountInfo` is gone outright for USDC; any other mint still resolves over RPC (Token-2022 detection preserved).
  • Blockhash cached per RPC endpoint, 10s TTL. A blockhash lives ~60s and the default proxy caches it 30s server-side; 10s client TTL keeps the worst case ~40s with ~20s settlement margin. Cache is mutex-guarded and bounded to 8 endpoints (oldest evicted).
  • No duplicate-transaction guard needed — unlike the TS SDK, which dropped the memo instruction and needed `issuedByBlockhash` + fee-nonce stepping. Every Go transaction carries a random 16-byte memo nonce, so two payments can never compile to the same bytes or signature even on a shared blockhash.

Results (paid calls via sol.blockrun.ai)

median mean max
before 2.16s 3.57s 9.68s
after 1.72s 1.74s 2.31s

Steady-state signing now does zero RPC. The residual ~0.6s gap vs Base is gateway-side settlement, not SDK.

Tests

TDD: 5 new tests in `solana_fastpath_test.go` (USDC skips mint RPC, non-USDC still fetches, cache hit within TTL, refetch after TTL, cache bounded), all watched red first. Full suite + `-race` + `go vet` clean.

1bcMax added 2 commits July 27, 2026 16:01
Marketing numbers here were hand-maintained and had drifted from the catalog.
They now regenerate from blockrun.ai/brand/numbers.json via markers, and CI
fails offline against a committed snapshot when they disagree.

scripts/sync-brand-numbers.mjs is vendored byte-for-byte from
BlockRunAI/blockrun:brand/ — a package would mean a dependency bump in every
repo, and several consumers have no package manifest at all. blockrun CI
compares the copies, so this one cannot quietly fall behind.

Frontmatter takes literals rather than markers: an HTML comment there is part
of the YAML string, not invisible.
…l path (0.19.1)

USDC mint info (token program + decimals=6) is immutable, so getAccountInfo
is skipped for USDC; getLatestBlockhash is cached per RPC endpoint with a
10s TTL, bounded to 8 endpoints. No duplicate-transaction guard is needed
on blockhash reuse (unlike the TS SDK): every transaction carries a random
16-byte memo nonce, so payments are never byte-identical.

Paid benchmark (gpt-4o-mini via sol.blockrun.ai, n=6): median 2.16s -> 1.72s,
mean 3.57s -> 1.74s, max 9.68s -> 2.31s.
@VickyXAI
VickyXAI merged commit 8a4b137 into main Jul 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant