Rust SDK for the Solana blockchain, used by on-chain programs and the Agave validator.
The following modules have been removed, please use their component crates directly:
address_lookup_table
->solana_address_lookup_table_interface
alt_bn128
->solana_bn254
bpf_loader_upgradeable
->solana_loader_v3_interface
client
->solana_client_traits
commitment_config
->solana_commitment_config
compute_budget
->solana_compute_budget_interface
decode_error
->solana_decode_error
derivation_path
->solana_derivation_path
ed25519_instruction
->solana_ed25519_program
exit
->solana_validator_exit
feature_set
->agave_feature_set
feature
->solana_feature_gate_interface
genesis_config
->solana_genesis_config
hard_forks
->solana_hard_forks
loader_instruction
->solana_loader_v2_interface
loader_upgradeable_instruction
->solana_loader_v3_interface::instruction
loader_v4
->solana_loader_v4_interface
loader_v4_instruction
->solana_loader_v4_interface::instruction
nonce
->solana_nonce
nonce_account
->solana_nonce_account
packet
->solana_packet
poh_config
->solana_poh_config
precompiles
->agave_precompiles
program_utils
->solana_bincode::limited_deserialize
quic
->solana_quic_definitions
rent_collector
->solana_rent_collector
rent_debits
->solana_rent_debits
reserved_account_keys
->agave_reserved_account_keys
reward_info
->solana_reward_info
reward_type
->solana_reward_info
sdk_ids
->solana_sdk_ids
secp256k1_instruction
->solana_secp256k1_program
secp256k1_recover
->solana_secp256k1_recover
stake
->solana_stake_interface
stake_history
->solana_stake_interface::stake_history
system_instruction
->solana_system_interface::instruction
system_program
->solana_system_interface::program
system_transaction
->solana_system_transaction
transaction_context
->solana_transaction_context
vote
->solana_vote_interface
The following modules have been removed, please use their component crates directly:
address_lookup_table
->solana_address_lookup_table_interface
bpf_loader_upgradeable
->solana_loader_v3_interface
decode_error
->solana_decode_error
feature
->solana_feature_gate_interface
loader_instruction
->solana_loader_v2_interface
loader_upgradeable_instruction
->solana_loader_v3_interface::instruction
loader_v4
->solana_loader_v4_interface
loader_v4_instruction
->solana_loader_v4_interface::instruction
message
->solana_message
nonce
->solana_nonce
program_utils
->solana_bincode::limited_deserialize
sanitize
->solana_sanitize
sdk_ids
->solana_sdk_ids
stake
->solana_stake_interface
stake_history
->solana_stake_interface::stake_history
system_instruction
->solana_system_interface::instruction
system_program
->solana_system_interface::program
vote
->solana_vote_interface
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
rustup component add rustfmt
git clone https://github.com/anza-xyz/solana-sdk.git
cd solana-sdk
When building the master branch, please make sure you are using the version
specified in the repo's rust-toolchain.toml
by running:
rustup show
This command will download the toolchain if it is missing in the system.
cargo test
If your change to Agave also entails changes to the SDK, you will need to patch your Agave repo to use a local checkout of solana-sdk crates.
To patch all of the crates in this repo for Agave, just run:
./scripts/patch-crates-no-header.sh <AGAVE_PATH> <SOLANA_SDK_PATH>
Unlike Agave, the solana-sdk crates are versioned independently, and published as needed.
If you need to publish a crate, you can use the "Publish Crate" GitHub Action.
Simply type in the path to the crate directory you want to release, ie.
program-entrypoint
, along with the kind of release, either patch
, minor
,
major
, or a specific version string.
The publish job will run checks, bump the crate version, commit and tag the bump, publish the crate to crates.io, and finally create GitHub Release with a simple changelog of all commits to the crate since the previous release.
Certain tests, such as rustfmt
and clippy
, require the nightly rustc
configured on the repository. To easily install it, use the ./cargo
helper
script in the root of the repository:
./cargo nightly tree
Run the test suite:
cargo test
Alternatively, there is a helper script:
./scripts/test-stable.sh
Format code for rustfmt check:
./cargo nightly fmt --all
The check can be run with a helper script:
./scripts/check-fmt.sh
To check the clippy lints:
./scripts/check-clippy.sh
Run the benchmarks:
./scripts/test-bench.sh
To generate code coverage statistics:
./scripts/test-coverage.sh
$ open target/cov/lcov-local/index.html
Code coverage requires llvm-tools-preview
for the configured nightly
toolchain. To install the component, run the command output by the script if it
fails to find the component:
rustup component add llvm-tools-preview --toolchain=<NIGHTLY_TOOLCHAIN>