Solana

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.

Building

1. Install rustc, cargo, and rustfmt.

$ 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.

System Dependencies

On Linux systems, you may need to install additional dependencies:

On Ubuntu:

$ sudo apt-get update
$ sudo apt-get install libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev protobuf-compiler

On Fedora:

$ sudo dnf install openssl-devel systemd-devel pkg-config zlib-devel llvm clang cmake make protobuf-devel protobuf-compiler perl-core

2. Download the source code.

$ git clone https://github.com/solana-labs/solana.git
$ cd solana

3. Build.

$ ./cargo build

Testing

Run the test suite:

$ ./cargo test

Starting a local testnet

Start your own testnet locally; instructions are in the online docs.

Accessing the remote development cluster

  • devnet: A stable public cluster for development accessible via devnet.solana.com. Runs 24/7. Learn more about the public clusters.

Benchmarking

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

Code Coverage

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!

Similar Projects