Skip to main content

SurfnetSvm

Struct SurfnetSvm 

Source
pub struct SurfnetSvm {
Show 55 fields pub inner: SurfnetLiteSvm, pub remote_rpc_url: Option<String>, pub chain_tip: BlockIdentifier, pub blocks: Box<dyn Storage<u64, BlockHeader>>, pub transactions: Box<dyn Storage<String, SurfnetTransactionStatus>>, pub jito_bundles: Box<dyn Storage<String, Vec<String>>>, pub transactions_queued_for_confirmation: VecDeque<(VersionedTransaction, Sender<TransactionStatusEvent>, Option<TransactionError>)>, pub transactions_queued_for_finalization: VecDeque<(Slot, VersionedTransaction, Sender<TransactionStatusEvent>, Option<TransactionError>)>, pub perf_samples: VecDeque<RpcPerfSample>, pub transactions_processed: u64, pub latest_epoch_info: EpochInfo, pub simnet_events_tx: Sender<SimnetEvent>, pub geyser_events_tx: Sender<GeyserEvent>, pub signature_subscriptions: HashMap<Signature, Vec<SignatureSubscriptionData>>, pub account_subscriptions: AccountSubscriptionData, pub program_subscriptions: ProgramSubscriptionData, pub slot_subscriptions: Vec<Sender<SlotInfo>>, pub slots_updates_subscriptions: Vec<SlotsUpdatesSubscriptionData>, pub profile_tag_map: Box<dyn Storage<String, Vec<UuidOrSignature>>>, pub simulated_transaction_profiles: Box<dyn Storage<String, KeyedProfileResult>>, pub executed_transaction_profiles: Box<dyn Storage<String, KeyedProfileResult>>, pub logs_subscriptions: Vec<LogsSubscriptionData>, pub snapshot_subscriptions: Vec<SnapshotSubscriptionData>, pub updated_at: u64, pub slot_time: u64, pub start_time: SystemTime, pub accounts_by_owner: Box<dyn Storage<String, Vec<String>>>, pub account_associated_data: Box<dyn Storage<String, SerializableAccountAdditionalData>>, pub token_accounts: Box<dyn Storage<String, TokenAccount>>, pub token_mints: Box<dyn Storage<String, MintAccount>>, pub token_accounts_by_owner: Box<dyn Storage<String, Vec<String>>>, pub token_accounts_by_delegate: Box<dyn Storage<String, Vec<String>>>, pub token_accounts_by_mint: Box<dyn Storage<String, Vec<String>>>, pub total_supply: u64, pub circulating_supply: u64, pub non_circulating_supply: u64, pub non_circulating_accounts: Vec<String>, pub genesis_config: GenesisConfig, pub inflation: Inflation, pub write_version: u64, pub registered_idls: Box<dyn Storage<String, Vec<VersionedIdl>>>, pub feature_set: FeatureSet, pub instruction_profiling_enabled: bool, pub max_profiles: usize, pub skip_blockhash_check: bool, pub runbook_executions: Vec<RunbookExecutionStatusReport>, pub account_update_slots: HashMap<Pubkey, Slot>, pub streamed_accounts: Box<dyn Storage<String, bool>>, pub recent_blockhashes: VecDeque<(SyntheticBlockhash, i64)>, pub scheduled_overrides: Box<dyn Storage<u64, Vec<OverrideInstance>>>, pub offline_accounts: Box<dyn Storage<String, OfflineAccountConfig>>, pub genesis_slot: Slot, pub genesis_updated_at: u64, pub slot_checkpoint: Box<dyn Storage<String, u64>>, pub last_checkpoint_slot: u64,
}
Expand description

SurfnetSvm provides a lightweight Solana Virtual Machine (SVM) for testing and simulation.

It supports a local in-memory blockchain state, remote RPC connections, transaction processing, and account management.

It also exposes channels to listen for simulation events (SimnetEvent) and Geyser plugin events (GeyserEvent).

Fields§

§inner: SurfnetLiteSvm§remote_rpc_url: Option<String>§chain_tip: BlockIdentifier§blocks: Box<dyn Storage<u64, BlockHeader>>§transactions: Box<dyn Storage<String, SurfnetTransactionStatus>>§jito_bundles: Box<dyn Storage<String, Vec<String>>>§transactions_queued_for_confirmation: VecDeque<(VersionedTransaction, Sender<TransactionStatusEvent>, Option<TransactionError>)>§transactions_queued_for_finalization: VecDeque<(Slot, VersionedTransaction, Sender<TransactionStatusEvent>, Option<TransactionError>)>§perf_samples: VecDeque<RpcPerfSample>§transactions_processed: u64§latest_epoch_info: EpochInfo§simnet_events_tx: Sender<SimnetEvent>§geyser_events_tx: Sender<GeyserEvent>§signature_subscriptions: HashMap<Signature, Vec<SignatureSubscriptionData>>§account_subscriptions: AccountSubscriptionData§program_subscriptions: ProgramSubscriptionData§slot_subscriptions: Vec<Sender<SlotInfo>>§slots_updates_subscriptions: Vec<SlotsUpdatesSubscriptionData>

Senders fed by Self::subscribe_for_slots_updates. Each sender delivers tagged SlotUpdate events (the wire format consumed by slotsUpdatesSubscribe clients).

§profile_tag_map: Box<dyn Storage<String, Vec<UuidOrSignature>>>§simulated_transaction_profiles: Box<dyn Storage<String, KeyedProfileResult>>§executed_transaction_profiles: Box<dyn Storage<String, KeyedProfileResult>>§logs_subscriptions: Vec<LogsSubscriptionData>§snapshot_subscriptions: Vec<SnapshotSubscriptionData>§updated_at: u64§slot_time: u64§start_time: SystemTime§accounts_by_owner: Box<dyn Storage<String, Vec<String>>>§account_associated_data: Box<dyn Storage<String, SerializableAccountAdditionalData>>§token_accounts: Box<dyn Storage<String, TokenAccount>>§token_mints: Box<dyn Storage<String, MintAccount>>§token_accounts_by_owner: Box<dyn Storage<String, Vec<String>>>§token_accounts_by_delegate: Box<dyn Storage<String, Vec<String>>>§token_accounts_by_mint: Box<dyn Storage<String, Vec<String>>>§total_supply: u64§circulating_supply: u64§non_circulating_supply: u64§non_circulating_accounts: Vec<String>§genesis_config: GenesisConfig§inflation: Inflation§write_version: u64

A global monotonically increasing atomic number, which can be used to tell the order of the account update. For example, when an account is updated in the same slot multiple times, the update with higher write_version should supersede the one with lower write_version.

§registered_idls: Box<dyn Storage<String, Vec<VersionedIdl>>>§feature_set: FeatureSet§instruction_profiling_enabled: bool§max_profiles: usize§skip_blockhash_check: bool§runbook_executions: Vec<RunbookExecutionStatusReport>§account_update_slots: HashMap<Pubkey, Slot>§streamed_accounts: Box<dyn Storage<String, bool>>§recent_blockhashes: VecDeque<(SyntheticBlockhash, i64)>§scheduled_overrides: Box<dyn Storage<u64, Vec<OverrideInstance>>>§offline_accounts: Box<dyn Storage<String, OfflineAccountConfig>>

Tracks accounts that should not be downloaded from the remote RPC. This includes accounts explicitly closed locally and accounts marked offline via cheatcodes. The key is the account pubkey as a string. If include_owned_accounts is true, accounts owned by this pubkey are also marked offline and excluded from remote download.

§genesis_slot: Slot

The slot at which this surfnet instance started (may be non-zero when connected to remote). Used as the lower bound for block reconstruction.

§genesis_updated_at: u64

The updated_at timestamp when this surfnet started at genesis_slot. Used to reconstruct block_time: genesis_updated_at + ((slot - genesis_slot) * slot_time)

§slot_checkpoint: Box<dyn Storage<String, u64>>

Storage for persisting the latest slot checkpoint. Used for recovery on restart with sparse block storage.

§last_checkpoint_slot: u64

Tracks the slot at which we last persisted the checkpoint.

Implementations§

Source§

impl SurfnetSvm

Source

pub fn default() -> (Self, Receiver<SimnetEvent>, Receiver<GeyserEvent>)

Source

pub fn new( config: SurfnetSvmConfig, ) -> SurfpoolResult<(Self, Receiver<SimnetEvent>, Receiver<GeyserEvent>)>

Source

pub fn new_with_db( database_url: Option<&str>, config: SurfnetSvmConfig, ) -> SurfpoolResult<(Self, Receiver<SimnetEvent>, Receiver<GeyserEvent>)>

Source

pub fn shutdown(&self)

Explicitly shutdown the SVM, performing cleanup like WAL checkpoint for SQLite. This should be called before the application exits to ensure data is persisted.

Source

pub fn clone_for_profiling(&self) -> Self

Creates a clone of the SVM with overlay storage wrappers for all database-backed fields. This allows profiling transactions without affecting the underlying database. All storage writes are buffered in memory and discarded when the clone is dropped.

Subscription registries (signature_subscriptions, account_subscriptions, etc) are all replaced with empty containers on the sandbox so that any notification dispatched during sandbox execution cannot reach live WebSocket clients. Although HashMap::clone() of the original maps is a deep copy of the container, each contained crossbeam_channel::Sender is a handle to the same channel held by live subscriber receivers — re-firing them from the sandbox would leak notifications even on bundle abort. Emptying the containers closes that leak.

Event channels (simnet_events_tx, geyser_events_tx) are replaced with internal buffered channels whose receivers are kept on the sandbox under sandbox_simnet_events_rx and sandbox_geyser_events_rx. Bundle commit code can drain these to replay the events on the original VM’s channels.

Source

pub fn clone_for_bundle_sandbox(&self) -> BundleSandbox

Creates a sandbox tailored for atomic Jito-style bundle execution. Behavior matches Self::clone_for_profiling (all storage fields are overlay-wrapped; subscription containers are emptied so live WS subscribers cannot be notified from the sandbox), but the simnet_events_tx and geyser_events_tx channels are replaced with unbounded buffered channels whose receivers are returned alongside the sandbox. The atomic-commit phase (Self::commit_sandbox) drains those receivers to replay the captured events onto the original VM’s real event channels on bundle success.

On bundle failure, simply dropping the returned BundleSandbox discards every buffered event, every overlay write, and the cloned LiteSVM state — the original VM is left byte-identical to its pre-bundle state.

Source

pub fn commit_sandbox( &mut self, sandbox: BundleSandbox, bundle_status_tx: Sender<TransactionStatusEvent>, ) -> SurfpoolResult<Vec<Signature>>

Atomically commit the outcome of a fully-successful bundle sandbox onto self.

This is the second half of the atomic Jito bundle pipeline. It must be invoked only after every transaction in the bundle succeeded inside the sandbox. The caller must hold an exclusive writer guard on self’s SurfnetSvmLocker so that no other RPC path can observe a half-committed state.

Order of operations is state mutations first, side-effects second:

  1. Drain every overlay-wrapped storage field from the sandbox onto self’s corresponding underlying storage. This is the first moment any SQLite/Postgres handle is touched on behalf of the bundle.
  2. Move the sandbox’s LiteSVM (the in-memory accounts DB) onto self, replacing self.inner.svm with the post-bundle account state.
  3. Drain the sandbox’s account-DB overlay (inner.db) onto self.inner.db so any SQLite-backed account persistence reflects the bundle’s mutations.
  4. Pull forward counters (write_version, transactions_processed), per-account update slots, pending confirmation/finalization queues, perf samples, and the recent-blockhash deque from the sandbox.
  5. Drain the sandbox’s buffered geyser events; replay each onto self.geyser_events_tx. For each UpdateAccount event, also fire notify_account_subscribers / notify_program_subscribers on self (the sandbox’s registries were emptied, so those notifications could not have been delivered during sandbox execution).
  6. Drain the sandbox’s buffered simnet events; replay each onto self.simnet_events_tx.
  7. For each transaction committed by the bundle, fire signature and logs subscribers at Processed commitment on self’s subscription registries, and send a TransactionStatusEvent::Success(Processed) on the per-tx status channel that is now part of self.transactions_queued_for_confirmation (so the existing confirmation/finalization runloop will promote bundle txs through the commitment ladder identically to txs submitted via sendTransaction).

Returns the ordered list of signatures committed by the bundle.

Source

pub fn increment_write_version(&mut self) -> u64

Source

pub fn initialize( &mut self, epoch_info: EpochInfo, epoch_schedule: EpochSchedule, )

Initializes the SVM with the provided epoch info and epoch schedule.

This is reserved for remote-derived startup data that is not known until the runloop is ready to connect to a remote RPC.

§Arguments
  • epoch_info - The epoch information to initialize with.
Source

pub fn set_profile_instructions(&mut self, do_profile_instructions: bool)

Source

pub fn airdrop( &mut self, pubkey: &Pubkey, lamports: u64, ) -> Result<TransactionResult, AirdropError>

Airdrops a specified amount of lamports to a single public key.

Validates the amount before doing anything observable: an airdrop of 0 lamports, or an amount below the rent-exempt minimum for an empty account, is rejected up front so no synthetic transaction is written and no balances are captured. The underlying SVM would not persist a sub-rent-exempt recipient account, and a follow-up account lookup would then panic on the missing account.

§Arguments
  • pubkey - The recipient public key.
  • lamports - The amount of lamports to airdrop.
Source

pub fn airdrop_pubkeys(&mut self, lamports: u64, addresses: &[Pubkey])

Airdrops a specified amount of lamports to a list of public keys.

Defers the zero-amount and below-rent-exemption checks to Self::airdrop; on either of those variants the whole batch is abandoned after a single info/error event, since the rejection depends only on lamports and would otherwise repeat per recipient.

§Arguments
  • lamports - The amount of lamports to airdrop.
  • addresses - Slice of recipient public keys.
Source

pub const fn get_latest_absolute_slot(&self) -> Slot

Returns the latest known absolute slot from the local epoch info.

Source

pub fn latest_blockhash(&self) -> Hash

Returns the latest blockhash known by the SVM.

Source

pub fn latest_epoch_info(&self) -> EpochInfo

Returns the latest epoch info known by the SurfnetSvm.

Source

pub fn calculate_block_time_for_slot(&self, slot: Slot) -> u64

Calculates the block time for a given slot based on genesis timestamp. Returns the time in milliseconds since genesis.

Source

pub fn is_slot_in_valid_range(&self, slot: Slot) -> bool

Checks if a slot is within the valid range for sparse block storage. A slot is valid if it’s between genesis_slot (inclusive) and latest_slot (inclusive).

§Arguments
  • slot - The slot number to check.
§Returns

true if the slot is within the valid range, false otherwise.

Source

pub fn get_block_or_reconstruct( &self, slot: Slot, ) -> SurfpoolResult<Option<BlockHeader>>

Gets a block from storage, or reconstructs an empty block if the slot is within the valid range (sparse block storage).

§Arguments
  • slot - The slot number to retrieve.
§Returns
  • Ok(Some(BlockHeader)) - If the block exists or can be reconstructed
  • Ok(None) - If the slot is outside the valid range
  • Err(_) - If there was an error accessing storage
Source

pub fn reconstruct_empty_block(&self, slot: Slot) -> BlockHeader

Reconstructs an empty block header for a slot that wasn’t stored. This is used for sparse block storage where empty blocks are not persisted.

Source

pub fn reconstruct_sysvars(&mut self)

Reconstructs RecentBlockhashes, SlotHashes, and Clock sysvars deterministically from the current slot. Called on startup and after garbage collection to ensure consistent sysvar state without requiring database persistence.

Note: SyntheticBlockhash uses chain_tip.index (relative index), while SlotHashes and Clock use absolute slots (chain_tip.index + genesis_slot).

Source

pub fn check_blockhash_is_recent(&self, recent_blockhash: &Hash) -> bool

Checks if the provided blockhash is recent (present in the RecentBlockhashes sysvar).

§Arguments
  • recent_blockhash - The blockhash to check.
§Returns

true if the blockhash is recent, false otherwise.

Source

pub fn validate_transaction_blockhash(&self, tx: &VersionedTransaction) -> bool

Validates the blockhash of a transaction, considering nonce accounts if present. If the transaction uses a nonce account, the blockhash is validated against the nonce account’s stored blockhash. Otherwise, it is validated against the RecentBlockhashes sysvar.

§Arguments
  • tx - The transaction to validate.
§Returns

true if the transaction blockhash is valid, false otherwise.

Source

pub fn sigverify( &self, tx: &VersionedTransaction, ) -> Result<(), FailedTransactionMetadata>

Verifies the signature of a transaction and validates that it hasn’t already been processed.

§Note

LiteSVM also can do this for our transactions, but we disable it. If sigverify is enabled at the LiteSVM level, the transaction simulations are always verified as well. So, if the user is trying to skip signature verification for a simulation, we’d need to unset and set this value, requiring a mutable reference to the SVM, which we don’t have/want in the simulation path. Additionally, having this function internally lets us do this check before we start fetching accounts from mainnet.

Source

pub fn set_account( &mut self, pubkey: &Pubkey, account: Account, ) -> SurfpoolResult<()>

Sets an account in the local SVM state and notifies listeners.

§Arguments
  • pubkey - The public key of the account.
  • account - The Account to insert.
§Returns

Ok(()) on success, or an error if the operation fails.

Source

pub fn update_account_registries( &mut self, pubkey: &Pubkey, account: &Account, ) -> SurfpoolResult<()>

Source

pub fn reset_network( &mut self, epoch_info: EpochInfo, epoch_schedule: EpochSchedule, ) -> SurfpoolResult<()>

Source

pub fn reset_account( &mut self, pubkey: &Pubkey, include_owned_accounts: bool, ) -> SurfpoolResult<()>

Source

pub fn restore_from_snapshot( &mut self, snapshot_path: &str, ) -> SurfpoolResult<usize>

Restores account state from a snapshot file.

The snapshot should be a JSON file containing a map of pubkey strings to AccountSnapshot objects, as generated by the surfnet_exportSnapshot RPC method.

§Arguments
  • snapshot_path - Path to the snapshot JSON file
§Returns

The number of accounts restored, or an error if the operation fails.

Source

pub fn send_transaction( &mut self, tx: VersionedTransaction, cu_analysis_enabled: bool, sigverify: bool, ) -> TransactionResult

Sends a transaction to the system for execution.

This function attempts to send a transaction to the blockchain. It first increments the transactions_processed counter. Then it sends the transaction to the system and updates its status. If the transaction is successfully processed, it is cached locally, and a “transaction processed” event is sent. If the transaction fails, the error is recorded and an event is sent indicating the failure.

§Arguments
  • tx - The transaction to send.
  • cu_analysis_enabled - Whether compute unit analysis is enabled.
§Returns

Ok(res) if processed successfully, or Err(tx_failure) if failed.

Source

pub fn estimate_compute_units( &self, transaction: &VersionedTransaction, ) -> ComputeUnitsEstimationResult

Estimates the compute units that a transaction will consume by simulating it.

Does not commit any state changes to the SVM.

§Arguments
  • transaction - The transaction to simulate.
§Returns

A ComputeUnitsEstimationResult with simulation details.

Source

pub fn simulate_transaction( &self, tx: VersionedTransaction, sigverify: bool, ) -> Result<SimulatedTransactionInfo, FailedTransactionMetadata>

Simulates a transaction and returns detailed simulation info or failure metadata.

§Arguments
  • tx - The transaction to simulate.
§Returns

Ok(SimulatedTransactionInfo) if successful, or Err(FailedTransactionMetadata) if failed.

Source

pub fn write_account_update(&mut self, account_update: GetAccountResult)

Writes account updates to the SVM state based on the provided account update result.

§Arguments
  • account_update - The account update result to process.
Source

pub fn confirm_current_block(&mut self) -> SurfpoolResult<()>

Source

pub async fn materialize_overrides( &mut self, remote_ctx: &Option<(SurfnetRemoteClient, CommitmentConfig)>, ) -> SurfpoolResult<()>

Materializes scheduled overrides for the current slot

This function:

  1. Dequeues overrides scheduled for the current slot
  2. Resolves account addresses (Pubkey or PDA)
  3. Optionally fetches fresh account data from remote if fetch_before_use is enabled
  4. Applies the overrides to the account data
  5. Updates the SVM state
Source

pub async fn materialize_overrides_for_slot( &mut self, remote_ctx: &Option<(SurfnetRemoteClient, CommitmentConfig)>, target_slot: Slot, ) -> SurfpoolResult<()>

Materializes scheduled overrides for a specific slot

Source

pub fn get_forged_account_data( &self, account_pubkey: &Pubkey, account_data: &[u8], idl: &Idl, overrides: &HashMap<String, Value>, ) -> SurfpoolResult<Vec<u8>>

Forges account data by applying overrides to existing account data

This function:

  1. Validates account data size (must be at least 8 bytes for discriminator)
  2. Splits discriminator and serialized data
  3. Finds the account type in the IDL using the discriminator
  4. Deserializes the account data
  5. Applies field overrides using dot notation
  6. Re-serializes the modified data
  7. Reconstructs the account data with the original discriminator
§Arguments
  • account_pubkey - The account address (for error messages)
  • account_data - The original account data bytes
  • idl - The IDL for the account’s program
  • overrides - Map of field paths to new values
§Returns

The forged account data as bytes, or an error

Source

pub fn subscribe_for_signature_updates( &mut self, signature: &Signature, subscription_type: SignatureSubscriptionType, ) -> Receiver<(Slot, Option<TransactionError>)>

Subscribes for updates on a transaction signature for a given subscription type.

§Arguments
  • signature - The transaction signature to subscribe to.
  • subscription_type - The type of subscription (confirmed/finalized).
§Returns

A receiver for slot and transaction error updates.

Source

pub fn subscribe_for_account_updates( &mut self, account_pubkey: &Pubkey, encoding: Option<UiAccountEncoding>, ) -> Receiver<UiAccount>

Source

pub fn subscribe_for_program_updates( &mut self, program_id: &Pubkey, encoding: Option<UiAccountEncoding>, filters: Option<Vec<RpcFilterType>>, ) -> Receiver<RpcKeyedAccount>

Source

pub fn notify_signature_subscribers( &mut self, status: SignatureSubscriptionType, signature: &Signature, slot: Slot, err: Option<TransactionError>, )

Notifies signature subscribers of a status update, sending slot and error info.

§Arguments
  • status - The subscription type (confirmed/finalized).
  • signature - The transaction signature.
  • slot - The slot number.
  • err - Optional transaction error.
Source

pub fn notify_account_subscribers( &mut self, account_updated_pubkey: &Pubkey, account: &Account, )

Source

pub fn notify_program_subscribers( &mut self, account_pubkey: &Pubkey, account: &Account, )

Source

pub fn get_block_at_slot( &self, slot: Slot, config: &RpcBlockConfig, ) -> SurfpoolResult<Option<UiConfirmedBlock>>

Retrieves a confirmed block at the given slot, including transactions and metadata.

§Arguments
  • slot - The slot number to retrieve the block for.
  • config - The configuration for the block retrieval.
§Returns

Some(UiConfirmedBlock) if found, or None if not present.

Source

pub fn blockhash_for_slot(&self, slot: Slot) -> Option<Hash>

Returns the blockhash for a given slot, if available.

Source

pub fn get_account_owned_by( &self, program_id: &Pubkey, ) -> SurfpoolResult<Vec<(Pubkey, Account)>>

Gets all accounts owned by a specific program ID from the account registry.

§Arguments
  • program_id - The program ID to search for owned accounts.
§Returns
  • A vector of (account_pubkey, account) tuples for all accounts owned by the program.
Source

pub fn account_to_rpc_keyed_account<T: ReadableAccount>( &self, pubkey: &Pubkey, account: &T, config: &RpcAccountInfoConfig, token_mint: Option<Pubkey>, ) -> RpcKeyedAccount

Source

pub fn get_token_accounts_by_delegate( &self, delegate: &Pubkey, ) -> Vec<(Pubkey, TokenAccount)>

Gets all token accounts that have delegated authority to a specific delegate.

§Arguments
  • delegate - The delegate pubkey to search for token accounts that have granted authority.
§Returns
  • A vector of (account_pubkey, token_account) tuples for all token accounts delegated to the specified delegate.
Source

pub fn get_parsed_token_accounts_by_owner( &self, owner: &Pubkey, ) -> Vec<(Pubkey, TokenAccount)>

Gets all token accounts owned by a specific owner.

§Arguments
  • owner - The owner pubkey to search for token accounts.
§Returns
  • A vector of (account_pubkey, token_account) tuples for all token accounts owned by the specified owner.
Source

pub fn get_token_accounts_by_owner( &self, owner: &Pubkey, ) -> SurfpoolResult<Vec<(Pubkey, Account)>>

Source

pub fn get_token_accounts_by_mint( &self, mint: &Pubkey, ) -> Vec<(Pubkey, TokenAccount)>

Gets all token accounts for a specific mint (token type).

§Arguments
  • mint - The mint pubkey to search for token accounts.
§Returns
  • A vector of (account_pubkey, token_account) tuples for all token accounts of the specified mint.
Source

pub fn subscribe_for_slot_updates(&mut self) -> Receiver<SlotInfo>

Source

pub fn notify_slot_subscribers(&mut self, slot: Slot, parent: Slot, root: Slot)

Source

pub fn subscribe_for_slots_updates(&mut self) -> Receiver<Arc<SlotUpdate>>

Registers a new sender for slotsUpdatesSubscribe notifications and returns the matching receiver.

The returned channel will receive every tagged SlotUpdate produced by Self::notify_slots_updates_subscribers until the receiver is dropped (at which point the SVM will self-prune the sender on the next notification).

Source

pub fn notify_slots_updates_subscribers(&mut self, update: SlotUpdate)

Fan-out a tagged SlotUpdate to every active slotsUpdatesSubscribe subscriber. The update is allocated once and shared via Arc across all senders. Disconnected receivers cause their sender to be pruned, mirroring the cleanup pattern used by Self::notify_slot_subscribers.

Source

pub fn write_simulated_profile_result( &mut self, uuid: Uuid, tag: Option<String>, profile_result: KeyedProfileResult, ) -> SurfpoolResult<()>

Source

pub fn write_executed_profile_result( &mut self, signature: Signature, profile_result: KeyedProfileResult, ) -> SurfpoolResult<()>

Source

pub fn subscribe_for_logs_updates( &mut self, commitment_level: &CommitmentLevel, filter: &RpcTransactionLogsFilter, ) -> Receiver<(Slot, RpcLogsResponse)>

Source

pub fn notify_logs_subscribers( &mut self, signature: &Signature, err: Option<TransactionError>, logs: Vec<String>, commitment_level: CommitmentLevel, )

Source

pub fn register_snapshot_subscription( &mut self, ) -> (Sender<SnapshotImportNotification>, Receiver<SnapshotImportNotification>)

Registers a snapshot subscription and returns a sender and receiver for notifications. The actual import logic should be handled by the caller (SurfnetSvmLocker).

Source

pub async fn fetch_snapshot_from_url( snapshot_url: &str, ) -> Result<BTreeMap<String, Option<AccountSnapshot>>, Box<dyn Error + Send + Sync>>

Source

pub fn register_idl( &mut self, idl: Idl, slot: Option<Slot>, ) -> SurfpoolResult<()>

Source

pub fn encode_ui_keyed_profile_result( &self, keyed_profile_result: KeyedProfileResult, config: &RpcProfileResultConfig, ) -> UiKeyedProfileResult

Source

pub fn encode_ui_account<T: ReadableAccount>( &self, pubkey: &Pubkey, account: &T, encoding: UiAccountEncoding, additional_data: Option<AccountAdditionalDataV3>, data_slice_config: Option<UiDataSliceConfig>, ) -> UiAccount

Source

pub fn get_account(&self, pubkey: &Pubkey) -> SurfpoolResult<Option<Account>>

Source

pub fn get_all_accounts( &self, ) -> SurfpoolResult<Vec<(Pubkey, AccountSharedData)>>

Source

pub fn get_transaction( &self, signature: &Signature, ) -> SurfpoolResult<Option<SurfnetTransactionStatus>>

Source

pub fn start_runbook_execution(&mut self, runbook_id: String)

Source

pub fn complete_runbook_execution( &mut self, runbook_id: &str, error: Option<Vec<String>>, )

Source

pub fn export_snapshot( &self, config: ExportSnapshotConfig, ) -> SurfpoolResult<BTreeMap<String, AccountSnapshot>>

Export all accounts to a JSON file suitable for test fixtures

§Arguments
  • encoding - The encoding to use for account data (Base64, JsonParsed, etc.)
§Returns

A BTreeMap of pubkey -> AccountFixture that can be serialized to JSON.

Source

pub fn register_scenario( &mut self, scenario: Scenario, slot: Option<Slot>, ) -> SurfpoolResult<()>

Registers a scenario for execution by scheduling its overrides

The slot parameter is the base slot from which relative override slot heights are calculated. If not provided, uses the current slot.

Trait Implementations§

Source§

impl Clone for SurfnetSvm

Source§

fn clone(&self) -> SurfnetSvm

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AggregateExpressionMethods for T

Source§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
Source§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
Source§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
Source§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WindowExpressionMethods for T

Source§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
Source§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
Source§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
Source§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
Source§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more