Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
70f845f
Add initial implementation of TLS module from PoC
marc-casperlabs May 17, 2020
6c93f90
Cleanup and refactor `tls` module to make it accessible and usable vi…
marc-casperlabs May 17, 2020
a85e0e3
Add signature scheme and disentangle `Fingerprint` from `Signature`
marc-casperlabs May 17, 2020
3c079dd
Make TLS certificate validation more strict and convenient
marc-casperlabs May 17, 2020
1e8be23
Implement more traits for `TlsCert` wrapper
marc-casperlabs May 17, 2020
8d72314
Alter `EventQueueHandle` to carry a wrapper function, add `Scheduler`…
marc-casperlabs May 17, 2020
acc6071
Simplify event queue handle down to two pointers
marc-casperlabs May 17, 2020
8e1b76e
Add effect wrapping convenience functions
marc-casperlabs May 17, 2020
3e1a0ad
Allow reactor and components to own configuration
marc-casperlabs May 18, 2020
e652a6d
Increase event size limit by factor of 4
marc-casperlabs May 18, 2020
8c8e673
Support cloning in TLS module
marc-casperlabs May 18, 2020
c12e7b4
Support self-signed values and improve fingerprint support in TLS module
marc-casperlabs May 18, 2020
c949fc5
Add `SmallNetwork` component with just message receiving supported
marc-casperlabs May 18, 2020
aa108b3
Support generating self-signed certificates
marc-casperlabs May 18, 2020
fb69183
Complete basic functionality of network sending capabilities
marc-casperlabs May 18, 2020
ce8c5a0
Make TLS module more foolproof by typing different kinds of fingerprints
marc-casperlabs May 18, 2020
58ee940
Synchronously create tcp listener
marc-casperlabs May 18, 2020
94af3bf
Use `u64` for nanosecond timestamps, as 200 years are plenty of time
marc-casperlabs May 18, 2020
8256f68
Make signature actually carry a signature
marc-casperlabs May 18, 2020
1bd2e57
Add a force-debug option to CLI
marc-casperlabs May 18, 2020
786209d
Add root-connection functionality
marc-casperlabs May 18, 2020
ac6363c
Introduce Display-based logging everywhere
marc-casperlabs May 18, 2020
4aaa7c7
Output snapshots using `DisplayIter`
marc-casperlabs May 18, 2020
1bdd639
Improve reporting and fix endpoint duplication detection bug
marc-casperlabs May 18, 2020
aa8b295
Fix remaining lints
marc-casperlabs May 18, 2020
0c726e6
EE-1020: bring code in line with current CL practices
Fraser999 May 19, 2020
3c9b0fb
EE-1020: add unit test for scheduler
Fraser999 May 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
314 changes: 299 additions & 15 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 13 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
[package]
name = "casper-node"
version = "0.1.0"
authors = ["Marc Brinkmann <marc@casperlabs.io>",
"Fraser Hutchison <fraser@casperlabs.io>"]
authors = ["Marc Brinkmann <marc@casperlabs.io>", "Fraser Hutchison <fraser@casperlabs.io>"]
edition = "2018"
description = "The CasperLabs blockchain node server"
description = "The CasperLabs blockchain node"
publish = false # Prevent accidental `cargo publish` for now.
license-file = "LICENSE"

[dependencies]
anyhow = "1.0.28"
async-trait = "0.1.31"
displaydoc = "0.1.6"
either = "1.5.3"
enum-iterator = "0.6.0"
futures = "0.3.5"
hex_fmt = "0.3.0"
maplit = "1.0.2"
openssl = "0.10.29"
rmp-serde = "0.14.3"
serde = { version = "1.0.110", features = ["derive"] }
serde-big-array = "0.3.0"
smallvec = "1.4.0"
structopt = "0.3.14"
tokio = { version = "0.2.20", features = ["macros", "rt-threaded", "sync"] }
thiserror = "1.0.18"
tokio = { version = "0.2.20", features = ["macros", "rt-threaded", "sync", "tcp"] }
tokio-openssl = "0.4.0"
tokio-serde = { version = "0.6.1", features = ["messagepack"] }
tokio-util = { version = "0.3.1", features = ["codec"] }
toml = "0.5.6"
tracing = "0.1.14"
tracing-subscriber = "0.2.5"
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
# CasperLabs node
# casper-node

The is the core application for the CasperLabs blockchain.

## Building

To compile this application, simply run `cargo build` on a recent stable Rust (`>= 1.43.1`) version.
This is the core application for the CasperLabs blockchain.

## Running a validator node

Launching a validator node with the default configuration is done by simply launching the application:
To run a validator node with the default configuration:

```
casper-node validator
cargo run --release -- validator
```

It is very likely that the configuration requires editing though, so typically one will want to generate a configuration file first, edit it and then launch:

```
casper-node generate-config > mynode.toml
cargo run --release -- generate-config > mynode.toml
# ... edit mynode.toml
casper-node validator -c mynode.toml
cargo run --release -- validator --config=mynode.toml
```

## Development
Expand All @@ -30,4 +26,4 @@ A good starting point is to build the documentation and read it in your browser:
cargo doc --no-deps --open
```

When generating a configuration file, it is usually helpful to set the log-level to `DEBUG` during development.
When generating a configuration file, it is usually helpful to set the log-level to `DEBUG` during development.
Binary file added images/CasperLabs_Logo_Favicon_RGB_50px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/CasperLabs_Logo_Symbol_RGB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 48 additions & 10 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,49 +1,87 @@
//! Command-line option parsing.
//!
//! Most configuration is done through the configuration, which is the only required command-line
//! argument. However some configuration values can be overwritten for convenience's sake.
use std::{io, io::Write, path};
//! Most configuration is done via config files (see [`config`](../config/index.html) for details).

use std::{io, io::Write, path::PathBuf};

use anyhow::bail;
use structopt::StructOpt;
use tracing::Level;

use crate::{config, reactor};
use crate::{
config,
reactor::{self, validator::Reactor},
tls,
};

// Note: The docstring on `Cli` is the help shown when calling the binary with `--help`.
#[derive(Debug, StructOpt)]
/// CasperLabs blockchain node.
pub enum Cli {
/// Generate a self-signed node certificate.
GenerateCert {
/// Output path base of the certificate. The certificate will be stored as
/// `output.crt.pem`, while the key will be stored as `output.key.pem`.
output: PathBuf,
},
/// Generate a configuration file from defaults and dump it to stdout.
GenerateConfig {},

/// Run the validator node.
///
/// Loads the configuration values from the given configuration file or uses defaults if not
/// given, then launches the reactor.
Validator {
#[structopt(short, long, env)]
/// Path to configuration file.
config: Option<path::PathBuf>,
config: Option<PathBuf>,

/// Override log-level, forcing debug output.
#[structopt(short, long)]
debug: bool,
},
}

impl Cli {
/// Execute selected CLI command.
/// Executes selected CLI command.
pub async fn run(self) -> anyhow::Result<()> {
match self {
Cli::GenerateCert { output } => {
if output.file_name().is_none() {
bail!("not a valid output path");
}

let mut cert_path = output.clone();
cert_path.set_extension("crt.pem");

let mut key_path = output;
key_path.set_extension("key.pem");

let (cert, key) = tls::generate_node_cert()?;

tls::save_cert(&cert, cert_path)?;
tls::save_private_key(&key, key_path)?;

Ok(())
}
Cli::GenerateConfig {} => {
let cfg_str = config::to_string(&Default::default())?;
io::stdout().write_all(cfg_str.as_bytes())?;

Ok(())
}
Cli::Validator { config } => {
Cli::Validator { config, debug } => {
// We load the specified config, if any, otherwise use defaults.
let cfg = config
let mut cfg = config
.map(config::load_from_file)
.transpose()?
.unwrap_or_default();

if debug {
cfg.log.level = Level::DEBUG;
}
cfg.log.setup_logging()?;

reactor::launch::<reactor::validator::Reactor>(cfg).await
reactor::launch::<Reactor>(cfg).await
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/components.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! Components
//!
//! Docs to be written, sorry.

pub mod small_network;
Loading