torna-sdk
The Rust client SDK for Torna: the PathPlanner. You call
insert / update / delete / find with a 32-byte key; the planner reads the tree off-chain through an
AccountReader and produces a ready solana_sdk::instruction::Instruction with the exact account set.
node_idx, PDA bumps, the descent path, and split spares never leak out.
Torna is a parallel, ordered, on-chain index primitive for Solana: a sorted key to value B+ tree with
one node per account, so writes at different keys carry disjoint write sets and the Sealevel scheduler
commits them in the same slot. The on-chain engine is written in C for SBF; this crate is the off-chain
client. A byte-equivalent TypeScript port is published as torna-sdk
on npm.
Add it
[]
= "0.1"
= "3.0"
Use
Implement AccountReader over your transport (an RPC client, a cache, or LiteSVM in tests):
use Pubkey;
use ;
; // wrap your RPC client / cache
let reader = Reader;
let tree = new;
// build a key (the order book uses a price-time key; any sorted key works)
let key = order_key;
// the planner resolves the exact accounts off-chain
let ix = tree.insert_fast_ix.unwrap;
// reads need no transaction
let top = tree.best; // top of book
let page = tree.scan; // a page
let val = tree.get; // a single value
What is in the box
Treewith the hot-path builders (insert_fast_ix,update_fast_ix,delete_fast_ix,find_ix), the cold split / merge path (insert_ix,delete_ix,cold_plan),init_tree_ix, and off-chain reads (best,scan,get,scan_accounts,header,path).keys:order_key,price_of,slot_offor the order-book key encoding.retry/Attemptfor the staleness model: re-resolve and retry when a concurrent split or merge invalidates a cached path.
The pure surface (key encoding, PDA derivations, init_tree_ix) is asserted byte-for-byte against the
on-chain ABI, and the full planner is verified end-to-end against the real engine over a multi-level
tree. In-house adversarial-reviewed; external audit pending.
License
MIT.