Solana is a high-performance blockchain platform designed to support decentralized applications and cryptocurrencies. Solana is known for its scalability, speed, and low transaction costs.
$ curl https://sh.rustup.rs -sSf | sh
$ source $HOME/.cargo/env
$ rustup component add rustfmt
When building the master branch, ensure you are using the latest stable rust version by running:
$ rustup update
When building a specific release branch, check the rust version in ci/rust-version.sh
and, if necessary, install that version:
$ rustup install VERSION
Note that if this is not the latest rust version on your machine, cargo commands may require an override to use the correct version.
On Linux systems, you may need to install additional dependencies:
$ sudo apt-get update
$ sudo apt-get install libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev protobuf-compiler
$ sudo dnf install openssl-devel systemd-devel pkg-config zlib-devel llvm clang cmake make protobuf-devel protobuf-compiler perl-core
$ git clone https://github.com/solana-labs/solana.git
$ cd solana
$ ./cargo build
$ ./cargo test
Start your own testnet locally; instructions are in the online docs.
First, install the nightly build of rustc. cargo bench
requires the use of the unstable features available only in the nightly build.
$ rustup install nightly
Run the benchmarks:
$ cargo +nightly bench
To generate code coverage statistics:
$ scripts/coverage.sh
$ open target/cov/lcov-local/index.html
Why coverage? While most see coverage as a code quality metric, Solana sees it primarily as a developer productivity metric. When a developer makes a change to the codebase, the test suite indicates if the change didn't infringe on any other solutions. Adding a test protects your solution from future changes. If a line of code seems unnecessary, try deleting it and running the unit tests. The nearest test failure should indicate why the code exists. If no test fails, consider submitting a Pull Request to ask, "what problem is solved by this code?" If a test fails and you have a better solution, a Pull Request with your solution is welcome! Similarly, if rewriting a test can better communicate what code it's protecting, please send that patch!