Skip to content

pure transaction execution#236

Merged
smcio merged 11 commits intodevfrom
rupansh/simul-txn
May 7, 2026
Merged

pure transaction execution#236
smcio merged 11 commits intodevfrom
rupansh/simul-txn

Conversation

@rupansh
Copy link
Copy Markdown
Collaborator

@rupansh rupansh commented May 4, 2026

simulateTransaction rpc should have feature parity with agave (https://solana.com/docs/rpc/http/simulatetransaction)
quick js script to test: https://github.com/rupansh/solana-sim-txn/tree/master

@rupansh rupansh changed the title Rupansh/simul txn pure transaction execution May 4, 2026
NeerajGodiyal and others added 6 commits May 4, 2026 16:10
Make simulateTransaction safe for any user-submitted transaction.

* Missing accounts: the SIMD-186 loader panicked on absent pubkeys.
  Now returns an empty System-owned default (matches Agave), so
  transactions that create new accounts can simulate.
* Malformed transactions: added Agave-style sanitize that rejects
  zero/insufficient signatures, signatures > keys, out-of-range
  program/account indices, too many instructions (feature-gated),
  and the no-writable-signer case. All return SanitizeFailure.
* Address lookup tables resolved on the simulate path so versioned
  transactions work end-to-end.
* JSON wire format: TransactionError marshals to Agave's exact
  shape — bare string for unit variants, single-key object for
  tuple variants like InstructionError.
* Rent sysvar load failure and fees.go no-fee-payer panics are
  now clean error returns.
* Stake program: fix variable shadowing that silently dropped a
  rent sysvar read error.
* Pass-1 accountsdb fallback in loadAndValidateTxAcctsSimd186:
  per-block MemAccounts only holds accounts the block's txs reference,
  so System Program and other native programs are often missing on the
  simulate path. Fall back to slotCtx.AccountsDb before fabricating a
  default; matches the existing Pass-2 program fallback pattern.

* IsTransactionAgeValid accountsdb fallback for durable-nonce txs:
  when a user simulates a nonce-based tx without replaceRecentBlockhash,
  the nonce account isn't in MemAccounts. Same fallback pattern as
  Pass-1 so the on-chain nonce state is consulted instead of returning
  BlockhashNotFound.

* CalculateAndDeductTxFees: thread isSimulation through. Simulate
  returns the error cleanly to the RPC client; block-replay keeps the
  panic on a sanitize-bypass invariant break, preserving the loud
  operator-visible signal.

* Sanitize-block comment trim in transaction_processing_pure.go.
* fees: assert simulate returns err while block-replay panics with
  diagnostic context on a missing fee payer.
* sealevel: assert IsTransactionAgeValid returns true when the nonce
  account is in MemAccounts and false safely when both MemAccounts
  and AccountsDb are unavailable.
* replay: Go fuzz test that drives random tx shapes through
  LoadAndExecuteTransaction and asserts no panics. Covers sanitize,
  loader, and fees branches.
- Strict response shape: all 14 RpcSimulateTransactionResult fields
  with correct nil/empty/null distinctions
- Custom JSON-RPC errors: -32602 InvalidParams, -32016
  MinContextSlotNotReached with structured contextSlot data
- Inner instruction recording with stackHeight (Option<u32>),
  preserved across InstructionError paths via AssembleInnerInstructions
- SPL Token + Token-2022 balance decoding with precise uiAmountString
  for high-decimals tokens (no float saturation)
- Pre/post account snapshots for token balance pre-state
- accounts.encoding base58/binary rejection
- too-many-accounts cap uses post-ALT-resolved key count
- ALT resolve before sigVerify so sigVerify-fail responses carry
  resolved loadedAddresses
- PACKET_DATA_SIZE encoded-length cap matching Agave constants
- Log + return-data clamping to spec limits (10KB / 1KB)

Live-verified A-to-Z (48/48) against real mainnet CPI swaps,
Token-2022 txs, ALT-using txs, vote txs, sigVerify-fail paths,
and 50-parallel concurrent simulates. Block-replay running
cleanly across 400+ slots with these changes.
feat(rpcserver): Agave-parity simulateTransaction wire format
@rupansh rupansh requested a review from smcio May 7, 2026 09:49
@smcio smcio merged commit 2821808 into dev May 7, 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.

3 participants