simulator-client
Rust client for the Termina simulator. A session replays a slot range of Solana mainnet on the server: step it forward, read and change its state through the session's RPC endpoint, and stream what it executes.
- Full guide and API reference: https://docs.rs/simulator-client/latest/simulator_client/
- Runnable programs: the examples repository. Start with
hello_session. - Concepts: the Termina docs
Install
[]
= "0.29.0" # x-release-please-version
= { = "1", = ["macros", "rt-multi-thread"] }
= { = "0.23", = false, = ["ring"] }
Needs Rust 1.97 or newer. Add Solana crates only at these versions:
| Crate | Version |
|---|---|
solana-address |
2.6 or newer, below 3 |
solana-pubkey |
4.x |
solana-account, solana-client, solana-rpc-client, solana-rpc-client-api, solana-transaction, solana-transaction-status |
4.3 or newer, below 5 |
solana-hash, solana-message |
4.x |
solana-commitment-config, solana-system-interface |
3.x |
solana-keypair, solana-signature |
3.1 or newer, below 4 |
solana-loader-v3-interface |
7.x |
solana-signer |
3.0.1 or newer, below 4 |
Addresses are simulator_client::Address. A Pubkey from solana-pubkey 4 is the same type.
Convert a Pubkey from an older Solana crate with Address::new_from_array(pubkey.to_bytes()).
TLS
Install a rustls crypto provider at the top of main, before you connect:
let _ = default_provider.install_default;
Without it, the first connection panics whenever your program also enables rustls's aws-lc-rs
provider (rustls's default features, reqwest 0.13, the AWS SDK).
Quickstart
Set SIMULATOR_API_KEY, then:
use ;
async
ManagedBacktestSession, or managed::ManagedParallelSession for a parallel run, reconnects and
reattaches on its own, so a dropped connection does not end your session. BacktestClient calls
the server's HTTP endpoints: ranges, usage, bundles, depth and dataset credentials.
Logging
The client logs through tracing. Install a subscriber (tracing-subscriber with its
env-filter feature) and set RUST_LOG=simulator_client=info:
fmt
.with_env_filter
.init;
Troubleshooting
| Symptom | Fix |
|---|---|
API key rejected: HTTP 401 (or 403), or 401 Unauthorized from available_ranges |
Check SIMULATOR_API_KEY; sim usage confirms a key works |
session create failed: ... block bundle not found, invalid request or no produced blocks in requested range |
Pick a range from available_ranges; start at its bundle_start_slot |
session create failed: ... insufficient capacity |
Set capacity_wait_timeout_secs, or retry later |
session not found when reattaching |
The session ended. Start a new one; raise disconnect_timeout_secs |
Panic: Could not automatically determine the process-level CryptoProvider |
Install a provider: see TLS |
Expected Address, found Pubkey, or two versions of solana_address |
Use the versions in Install; cargo tree -i solana-address@2 -e normal shows which crates use the 2.x copy. Other major versions, pulled in by spl-* crates, are harmless |
Datasets
BacktestClient also calls the dataset endpoints:
dataset_credentials: temporary, read-only S3 credentials for the prebuilt datasets and your custom ones.generate_depth: request a custom depth dataset. Poll it withget_depth_statusand its job ID.get_depth_coverage: the markets, venues and size rungs a request samples, and the slot ranges you have already published.build_bundle,get_bundle_status,list_bundle_builds,delete_bundle: custom bundles.
The crate docs cover session lifecycle, subscriptions, errors and timeouts.