2018-03-27 15:16:27 -07:00
[![Solana crate ](https://img.shields.io/crates/v/solana.svg )](https://crates.io/crates/solana)
[![Solana documentation ](https://docs.rs/solana/badge.svg )](https://docs.rs/solana)
[![Build Status ](https://travis-ci.org/solana-labs/solana.svg?branch=master )](https://travis-ci.org/solana-labs/solana)
[![codecov ](https://codecov.io/gh/solana-labs/solana/branch/master/graph/badge.svg )](https://codecov.io/gh/solana-labs/solana)
2018-02-14 14:25:49 -08:00
2018-03-01 08:16:39 -08:00
Disclaimer
===
2018-02-15 12:59:33 -08:00
2018-03-01 08:16:39 -08:00
All claims, content, designs, algorithms, estimates, roadmaps, specifications, and performance measurements described in this project are done with the author's best effort. It is up to the reader to check and validate their accuracy and truthfulness. Furthermore nothing in this project constitutes a solicitation for investment.
2018-03-27 16:20:23 -07:00
Solana: High Performance Blockchain
2018-03-01 08:16:39 -08:00
===
2018-03-27 15:16:27 -07:00
Solana™ is a new architecture for a high performance blockchain. It aims to support
2018-03-27 15:31:19 -07:00
over 700 thousand transactions per second on a gigabit network.
2018-02-15 15:09:11 -08:00
2018-03-05 15:05:16 -08:00
Running the demo
2018-03-01 08:16:39 -08:00
===
2018-02-19 08:19:26 -08:00
2018-03-08 10:40:42 -08:00
First, install Rust's package manager Cargo.
2018-03-05 15:05:16 -08:00
```bash
2018-03-08 10:40:42 -08:00
$ curl https://sh.rustup.rs -sSf | sh
$ source $HOME/.cargo/env
```
2018-03-19 09:23:43 -07:00
The testnode server is initialized with a ledger from stdin and
generates new ledger entries on stdout. To create the input ledger, we'll need
to create *the mint* and use it to generate a *genesis ledger* . It's done in
2018-03-07 15:58:01 -08:00
two steps because the mint.json file contains a private key that will be
used later in this demo.
2018-02-19 11:00:56 -08:00
2018-03-05 15:05:16 -08:00
```bash
2018-03-28 21:18:33 -07:00
$ echo 1000000000 | cargo run --release --bin solana-mint | tee mint.json
2018-03-28 21:20:31 -07:00
$ cat mint.json | cargo run --release --bin solana-genesis | tee genesis.log
2018-02-19 11:00:56 -08:00
```
2018-03-05 15:05:16 -08:00
Now you can start the server:
```bash
2018-03-28 21:18:33 -07:00
$ cat genesis.log | cargo run --release --bin solana-testnode | tee transactions0.log
2018-03-05 15:05:16 -08:00
```
2018-03-06 16:21:45 -08:00
Then, in a separate shell, let's execute some transactions. Note we pass in
2018-03-19 09:23:43 -07:00
the JSON configuration file here, not the genesis ledger.
2018-02-20 12:07:54 -08:00
2018-03-05 15:05:16 -08:00
```bash
2018-03-28 21:18:33 -07:00
$ cat mint.json | cargo run --release --bin solana-client-demo
2018-03-05 15:05:16 -08:00
```
2018-02-20 12:07:54 -08:00
2018-03-19 09:23:43 -07:00
Now kill the server with Ctrl-C, and take a look at the ledger. You should
2018-03-05 15:05:16 -08:00
see something similar to:
```json
2018-03-05 15:18:46 -08:00
{"num_hashes":27,"id":[0, "..."],"event":"Tick"}
2018-03-19 09:23:43 -07:00
{"num_hashes":3,"id":[67, "..."],"event":{"Transaction":{"tokens":42}}}
2018-03-05 15:18:46 -08:00
{"num_hashes":27,"id":[0, "..."],"event":"Tick"}
2018-03-05 15:05:16 -08:00
```
2018-03-19 09:23:43 -07:00
Now restart the server from where we left off. Pass it both the genesis ledger, and
the transaction ledger.
2018-03-05 15:05:16 -08:00
```bash
2018-03-28 21:20:31 -07:00
$ cat genesis.log transactions0.log | cargo run --release --bin solana-testnode | tee transactions1.log
2018-03-05 15:05:16 -08:00
```
2018-03-06 16:21:45 -08:00
Lastly, run the client demo again, and verify that all funds were spent in the
previous round, and so no additional transactions are added.
2018-03-05 15:05:16 -08:00
```bash
2018-03-28 21:18:33 -07:00
$ cat mint.json | cargo run --release --bin solana-client-demo
2018-02-20 12:07:54 -08:00
```
2018-03-06 16:21:45 -08:00
Stop the server again, and verify there are only Tick entries, and no Transaction entries.
2018-02-19 11:00:56 -08:00
2018-03-01 08:16:39 -08:00
Developing
===
2018-02-15 15:09:11 -08:00
2018-02-16 09:38:12 -08:00
Building
---
Install rustc, cargo and rustfmt:
2018-02-15 15:09:11 -08:00
```bash
$ curl https://sh.rustup.rs -sSf | sh
2018-02-16 09:38:12 -08:00
$ source $HOME/.cargo/env
$ rustup component add rustfmt-preview
2018-02-15 15:09:11 -08:00
```
Download the source code:
```bash
2018-03-27 15:16:27 -07:00
$ git clone https://github.com/solana-labs/solana.git
$ cd solana
2018-02-15 15:09:11 -08:00
```
2018-02-16 09:38:12 -08:00
Testing
---
2018-02-15 15:09:11 -08:00
Run the test suite:
```bash
cargo test
```
2018-02-16 09:38:12 -08:00
Benchmarking
---
First install the nightly build of rustc. `cargo bench` requires unstable features:
```bash
$ rustup install nightly
```
Run the benchmarks:
```bash
2018-03-19 15:42:28 -07:00
$ cargo +nightly bench --features="unstable"
2018-02-16 09:38:12 -08:00
```
2018-04-04 08:26:32 -07:00
Code coverage
---
To generate code coverage statistics, run kcov via Docker:
```bash
$ docker run -it --rm --security-opt seccomp=unconfined --volume "$PWD:/volume" elmtai/docker-rust-kcov
```
Why coverage? While most see coverage as a code quality metric, we see it primarily as a developer
productivity metric. When a developer makes a change to the codebase, presumably it's a *solution* to
some problem. Our unit-test suite is how we encode the set of *problems* the codebase solves. Running
the test suite should indicate that your change didn't *infringe* on anyone else's solutions. Adding a
test *protects* your solution from future changes. Say you don't understand why a line of code exists,
try deleting it and running the unit-tests. The nearest test failure should tell you what problem
was solved by that code. If no test fails, go ahead and submit a Pull Request that asks, "what
problem is solved by this code?" On the other hand, if a test does fail and you can think of a
better way to solve the same problem, a Pull Request with your solution would most certainly be
welcome! Likewise, if rewriting a test can better communicate what code it's protecting, please
send us that patch!