Expand description
Yellowstone jet-tpu-client
This crate is port of the custom TPU-QUIC client used by Yellowstone Jet a subsystem of Cascade-Marketplace,
This crates expose a generic TPU sender implementation TpuSender that can be used with different TPU info services, stake info services, eviction strategies, and leader schedule predictors.
The cores async event-loop engine uses quinn and tokio crates to provide a high-performance QUIC-based transport protocol implementation. It is designed to handle the latest Agave network changes and covers all the edge-cases observed in production usage:
- Automatic leader schedule tracking and slot updates
- Automatic TPU contact-info handling:
- Contact info discovery using latest gossip information from the network.
- Handles TPU endpoint changes due to leader contact info flapping (e.g. Jito validators)
- Automic connection manamgent: reconnect, connection-prediction, failures handling.
- Rescue transaction on connection dropped (e.g. due to remote peer connection eviction)
- Stake-aware TPU selection and eviction strategies.
§YellowstoneTpuSender : Smart TPU sender implementation
This crate come with a smart TPU sender implementation: YellowstoneTpuSender
§TpuSenderTxnInfo metadata model
The sender no longer carries a dedicated tx_sig field in response types.
Instead, callers can attach typed metadata using
TpuSenderTxnInfo and recover it from
TpuSenderResponse values.
Typical usage:
- Build metadata:
let info = TpuSenderTxnInfo::new(signature); - Send:
sender.send_txn(wire_txn, Some(info)).await?; - Decode in callback:
resp.info.as_ref().and_then(|i| i.downcast_ref::<Signature>())
Metadata constraints:
- Must be
Copy + Sized + 'static. - Must fit in TXN_INFO_CAP bytes.
Compile-time capacity tuning:
- Set
TXN_INFO_CAPbefore build to change metadata storage capacity. - Default capacity is
64bytes.
TXN_INFO_CAP=128 cargo build -p yellowstone-jet-tpu-clientYou can inspect the value at runtime:
use yellowstone_jet_tpu_client::TXN_INFO_CAP;
println!("TXN_INFO_CAP={}", TXN_INFO_CAP);See YellowstoneTpuSender rustdoc
for a complete end-to-end example covering TxSent, TxFailed, and TxDrop.
§HardenedKeypair: memory-hardened keypair loading
HardenedKeypair is a drop-in alternative to
solana_keypair::read_keypair/solana_keypair::read_keypair_file whose private key
bytes are mlocked and zeroized on drop from the moment they first exist, instead of passing
through an ordinary, unlocked String/solana_keypair::Keypair on the way in.
Construct one via:
HardenedKeypair::read_from_file(path)/read_from_reader(&mut reader)– same JSON[u8; 64]keypair file format assolana_keypair.HardenedKeypair::new()– generate a fresh random one.HardenedKeypair::from_keypair(&keypair)– wrap an existingKeypair.HardenedKeypair::try_from(&bytes[..])– parse raw 64-byte keypair bytes, rejecting a mismatched public/secret pair.
It implements TpuEd25519SigningKey, so it can be
handed directly to
TpuIdentity::from_ed25519_signing_key
to build the sender’s identity without a plain Keypair ever existing:
use yellowstone_jet_tpu_client::identity::{HardenedKeypair, TpuIdentity};
let hardened = HardenedKeypair::read_from_file("identity.json").expect("read keypair");
let identity = TpuIdentity::from_ed25519_signing_key(&hardened);This sender implementation supports three different sending strategies:
- Send transaction to one or more remote peers
- Send to the current leader
- Send to the the curent leader AND the next
N-1leaders in the schedule.
The sender automatically tracks the current slot and leader schedule.
§Example
See repository for more examples.
§feature-flag supports
- prometheus: Enable prometheus metrics exposition module [
crate::prom] - yellowstone-grpc: Enable Yellowstone gRPC based TPU sender implementation
crate::yellowstone_grpc - bytes : Enable
bytescrate based transaction representation support in TPU sender
Re-exports§
pub use core::TXN_INFO_CAP;
Modules§
- config
- module for top-level cnfiguration objects
- core
- module for the core tpu sending driver logic
- identity
- module for the TPU sender’s identity: a public key paired with its derived, memory-hardened QUIC client TLS credentials
- rpc
- module for RPC utilities
- sender
- module for common tpu sender implementation
- slot
- module for slot tracking
- yellowstone_
grpc - module to host utility that utilize Yellowstone gRPC services