This Rust program inspects the Solana validator's produced slots within the current epoch and computes the total and average Compute Units (CUs) consumed in those slots. It also tracks how many transactions are votes, how many fail, and how many succeed.
- Fetch Leader Schedule: The program retrieves the leader schedule from a specified Solana RPC endpoint and identifies which slots are assigned to a particular validator.
- Retrieve Block Data: It fetches blocks for those slots and extracts:
- Compute Units (CUs) consumed by each transaction.
- Transaction success/failure.
- Vote vs. non-vote transactions.
- Calculate Statistics:
- Average percentage of the total CU capacity used per slot.
- Average number of vote transactions, succeeded transactions, and failed transactions per slot.
- Rust (>= 1.60.0 recommended)
- A Solana RPC endpoint (default is
https://api.mainnet-beta.solana.comin this code).
- Clone this repository:
git clone https://github.com/<your-username>/compute-unit-inspector.git cd compute-unit-inspector
- Build:
cargo build --release
- Install (optional, to have a system-wide binary):
cargo install --path .
Alternatively you can run the following:
cargo run <validator_identity>The program requires exactly one argument: the validator's public key (validator_identity). For example:
./target/release/compute-unit-inspector <validator_identity><validator_identity>: The Solana validator identity key you want to inspect.
./target/release/compute-unit-inspector 11111111111111111111111111111111By default, the program uses:
RPC URL: https://api.mainnet-beta.solana.com
The per-block CU limit is not a fixed constant: it is read from the chain on
every run by checking the raise_block_limits_to_* feature-gate accounts
(anza-xyz/agave feature-set/src/lib.rs) against the current slot, and
falls back to 48_000_000 (the pre-SIMD-0207 default) if none of the known
gates have activated. SIMD-0286 raised it to 100_000_000 as of mainnet slot
435,888,000; add the next SIMD's gate to BLOCK_LIMIT_GATES in main.rs
when the limit moves again rather than editing a literal.
If you wish to change the RPC endpoint, you can edit the following line in main():
rust
let rpc_url = "https://api.mainnet-beta.solana.com"; // Replace with your RPC URL
Below is an example snippet of what the output might look like:
yaml
Validator 11111111111111111111111111111111 has 128 total slots in the leader schedule.
Validator 11111111111111111111111111111111 has 96 produced slots up to the current slot (123456789).
Slot: 123450001, CU Used: 300000, % of Total Capable CU: 0.63%, Vote Transactions: 1, Succeeded Transactions: 10, Failed Transactions: 2
Slot: 123450015, CU Used: 450000, % of Total Capable CU: 0.94%, Vote Transactions: 1, Succeeded Transactions: 13, Failed Transactions: 1
...
----------------------------------------
Epoch 350 Stats
Average CU per Slot: 0.75%
Average Vote Transactions per Slot: 1
Average Succeeded Transactions per Slot: 10
Average Failed Transactions per Slot: 1
Done calculating CU for validator's slots.
License
This project is open source and available under the MIT License. Feel free to use, modify, and distribute this software in accordance with the license terms.