Skip to content

feat(rpc): implement simulateTransaction#1333

Merged
yewman merged 85 commits intomainfrom
harnew/send-simulate
Apr 6, 2026
Merged

feat(rpc): implement simulateTransaction#1333
yewman merged 85 commits intomainfrom
harnew/send-simulate

Conversation

@ajw221
Copy link
Copy Markdown
Contributor

@ajw221 ajw221 commented Mar 20, 2026

Intent

  • Implement simulateTransaction RPC method
  • Implement simulateTranasction functionality in sendTransaction's skipPreflight=false codepath

Implementation

  • Implemented simulateTransaction in SendTransactionHookContext

Ramifications

  • Currently skipPreflight=false is unimplemented and will panic, this PR adds the missing functionality for this codepath

Tests

  • Tested making an RPC sendTransaction request with skipPreflight=false successfully
  • Tested making multiple different RPC simulateTransaction requests touching different codepaths successfully
  • Added test coverage for the simulateTransaction RPC method

yewman and others added 29 commits March 17, 2026 04:50
- destroy conns on deinit
- basic connection eviction
- pass ptr to empty slice instead of null in lsquic_engine_connect
- update peer address on packet ingestion
- destroy conns on deinit
- basic connection eviction
- pass ptr to empty slice instead of null in lsquic_engine_connect
- update peer address on packet ingestion
- Add SendTransaction hook context with decode, deserialize, and sanitize logic
- Expose TransactionSender type alias and initWithWire constructor
- Add getBlockhashLastValidBlockHeight to SlotTracker
- Make getDurableNonce public for use in preflight checks
- Move MAX_INSTRUCTION_TRACE_LENGTH to transaction_context module
- Add decodeAndDeserialize tests for base64/base58 encoding and error cases
- Add sendTransactionImpl tests for channel dispatch and durable nonce
- Add SlotTracker getBlockhashLastValidBlockHeight tests
- Add TransactionInfo.initWithWire unit tests
- Add SendTransaction serialization and resolveEncoding tests
- Make transaction_legacy_example fields public for test access
…connection pool and metrics

- Replace the comptime-parameterized generic Client with a heap-allocated QuicClient that owns all resources (socket, SSL context, lsquic engine, connection pool, receiver channel).
- Use fixed-size connection pool with slot reuse via idle timeout
- Improve error handling in packetsOut and stream writes (partial write support)
- Improve documentation
- Add prometheus metric
- Move timing metrics into receiveTransactions and processTransactions via defer blocks
- Make metrics logging interval configurable via log_metrics_interval config option
- Add doc comments to receiveTransactions and processTransactions.
- Fix test cleanup ordering with proper defer statements and increase test timeout.
…tAccountReader

- Change loadAndExecuteTransaction to take SlotAccountReader instead of SlotAccountStore,
  enabling simulation use without side effects on the account store.
- Introduce PreparedAccount type to thread fee payer (with loaded_size and rent_collected)
  from checkFeePayer through loadTransactionAccounts, avoiding store round-trip.
- Move account persistence to callers: svm_gateway persists writes for intra-slot visibility,
  conformance and simulation callers can remain read-only.
- Update checkFeePayer to take SlotAccountReader and return PreparedAccount instead of
  writing the fee-deducted payer back to the store.
- Add simulateTransaction to SendTransactionHookContext, using SvmGateway to execute transactions in a read-only simulation context for preflight checks
- Return preflight failures as JSON-RPC error code -32002 with transaction error, logs, units consumed, and loaded accounts data size, matching agave's format
- Change SendTransaction.Response from a plain Signature to a tagged union distinguishing signature success from preflight_fail
- Replace account_reader with account_store and add epoch_tracker and status_cache fields to SendTransactionHookContext to support simulation setup
- Add integration test verifying -32002 error response on preflight failure.
…bmit modes

- Remove Mode union (RpcMode/SigMode) in favor of a single RpcClient for state queries
- Add SubmitMode union with direct (channel) and rpc (client) variants for transaction submission
- Inline RPC query methods (getAccountBalance, getLatestBlockhash, getSignatureStatus) on Service
- Update call sites in cmd.zig and test_send_transactions.zig
- Implement rpc submit path that base64-encodes the wire transaction and calls sendTransaction on a dedicated RPC client, handling preflight failures
- Add --mock-submit-url CLI arg to specify the RPC endpoint for transaction submission; when omitted, transactions are submitted directly to the channel
- Validate that --mock-submit-url requires --mock-transfer-transactions
- Return error.SlotNotAvailable when preflight slot is pruned between commitment lookup and slot_tracker.get()
- Replace preflight_failure unreachable with explicit @Panic for clearer diagnostics if server layer invariant is violated
- Set emit_null_optional_fields=false to avoid sending null values that Solana rejects (e.g. "skipPreflight": null → "invalid type: null, expected a boolean")
- Add preflight config to MockTransferService with preflightCommitment matching the blockhash commitment level
- Log RPC error code, message, and data on sendTransaction failure
- Add standalone test_mock_transfers script for testing RPC submission mode independently from the validator
- Remove --mock-submit-url from validator CLI; validator always uses direct submission mode
Previously wire_transaction.len was used (always PACKET_DATA_SIZE),
instead of the actual decoded length. Thread wire_len from
decodeAndDeserialize through to sendTransactionImpl so
TransactionInfo receives the correct size.
Execute compute_budget program on the transaction message to populate
compute_budget_instruction_details instead of leaving it as default
empty, ensuring correct fee/priority calculations downstream.
@ajw221 ajw221 self-assigned this Mar 20, 2026
dnut and others added 14 commits April 1, 2026 21:12
…ack to the supermajority root instead of our tower's root
…llision and it really has no reason to be hardcoded when the OS will assign a free port.
…n removing the root slot if our root is older than the supermajority root
Guard against committing transactions with total_stake=0 on ticks
with no newly frozen slots, which would wipe out valid commitment
data from the previous cycle.
Base automatically changed from adamw/implement-sendTransaction-in-rpc to main April 3, 2026 17:24
ajw221 added 2 commits April 3, 2026 16:59
…types

- Move fromLedger converters into UiInnerInstructions, UiTransactionTokenBalances, and UiTransactionReturnData
- Remove duplicate conversion functions from Ledger.zig and SendTransaction.zig
- Reuse Committer.FallbackAccountReader instead of duplicating SimulationFallbackAccountReader
@ajw221 ajw221 marked this pull request as ready for review April 3, 2026 21:11
Cover unsupported encoding, min context slot, slot not found,
and replaceRecentBlockhash + sigVerify conflict cases.
@ajw221 ajw221 requested a review from dnut April 3, 2026 21:48
ajw221 added 2 commits April 3, 2026 19:01
…on helpers

- Add missing epoch_info.release() in simulateRuntimeTransaction
- Add tests for resolveAndConvertTokenBalances edge cases
- Add tests for getSimulatedAccount lookup behavior
- Add test for simulateRuntimeTransaction blockhash-not-found path
@github-project-automation github-project-automation Bot moved this from 🏗 In progress to 👀 In review in Sig Apr 6, 2026
@yewman yewman added this pull request to the merge queue Apr 6, 2026
Merged via the queue into main with commit 4f61682 Apr 6, 2026
12 of 13 checks passed
@yewman yewman deleted the harnew/send-simulate branch April 6, 2026 22:31
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Sig Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants