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_interfacealt_bn128->solana_bn254bpf_loader_upgradeable->solana_loader_v3_interfaceclient->solana_client_traitscommitment_config->solana_commitment_configcompute_budget->solana_compute_budget_interfacedecode_error->solana_decode_errorderivation_path->solana_derivation_pathed25519_instruction->solana_ed25519_programexit->solana_validator_exitfeature_set->agave_feature_setfeature->solana_feature_gate_interfacegenesis_config->solana_genesis_confighard_forks->solana_hard_forksloader_instruction->solana_loader_v2_interfaceloader_upgradeable_instruction->solana_loader_v3_interface::instructionloader_v4->solana_loader_v4_interfaceloader_v4_instruction->solana_loader_v4_interface::instructionnonce->solana_noncenonce_account->solana_nonce_accountpacket->solana_packetpoh_config->solana_poh_configprecompiles->agave_precompilesprogram_utils->solana_bincode::limited_deserializequic->solana_quic_definitionsreserved_account_keys->agave_reserved_account_keysreward_info->solana_reward_inforeward_type->solana_reward_infosdk_ids->solana_sdk_idssecp256k1_instruction->solana_secp256k1_programsecp256k1_recover->solana_secp256k1_recoverstake->solana_stake_interfacestake_history->solana_stake_interface::stake_historysystem_instruction->solana_system_interface::instructionsystem_program->solana_system_interface::programsystem_transaction->solana_system_transactiontransaction_context->solana_transaction_contextvote->solana_vote_interface
The following modules have been removed, please use their component crates directly:
address_lookup_table->solana_address_lookup_table_interfacebpf_loader_upgradeable->solana_loader_v3_interfacedecode_error->solana_decode_errorfeature->solana_feature_gate_interfaceloader_instruction->solana_loader_v2_interfaceloader_upgradeable_instruction->solana_loader_v3_interface::instructionloader_v4->solana_loader_v4_interfaceloader_v4_instruction->solana_loader_v4_interface::instructionmessage->solana_messagenonce->solana_nonceprogram_utils->solana_bincode::limited_deserializesanitize->solana_sanitizesdk_ids->solana_sdk_idsstake->solana_stake_interfacestake_history->solana_stake_interface::stake_historysystem_instruction->solana_system_interface::instructionsystem_program->solana_system_interface::programvote->solana_vote_interface
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
rustup component add rustfmtgit clone https://github.com/anza-xyz/solana-sdk.git
cd solana-sdkWhen building the master branch, please make sure you are using the version
specified in the repo's rust-toolchain.toml by running:
rustup showThis command will download the toolchain if it is missing in the system.
cargo testIf 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>NOTE: The repo currently contains unpublished breaking changes, so please double-check before publishing any crates!
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.
If you would like to backport a pull request, simply add the appropriate label,
named backport <BRANCH_NAME>.
For example, to create a backport to the maintenance/v2.x branch, just add the
backport maintenance/v2.x label.
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 treeRun the test suite:
cargo testAlternatively, there is a helper script:
./scripts/test-stable.shFormat code for rustfmt check:
./cargo nightly fmt --allThe check can be run with a helper script:
./scripts/check-fmt.shTo check the clippy lints:
./scripts/check-clippy.shRun the benchmarks:
./scripts/test-bench.shTo generate code coverage statistics:
./scripts/test-coverage.sh
$ open target/cov/lcov-local/index.htmlCode 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>