Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
130 changes: 120 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bincode = "1.2.1"
blake2 = { version = "0.8.1", default-features = false }
bytes = "0.5.4"
derive_more = "0.99.7"
directories = "2.0.2"
ed25519-dalek = { version = "1.0.0-pre.3", default-features = false, features = ["rand", "serde", "u64_backend"] }
either = "1.5.3"
enum-iterator = "0.6.0"
Expand All @@ -27,6 +28,8 @@ getrandom = "0.1.14"
hex = "0.4.2"
hex_fmt = "0.3.0"
http = "0.2.1"
libc = "0.2.71"
lmdb = "0.8.0"
maplit = "1.0.2"
openssl = "0.10.29"
rand = "0.7.3"
Expand All @@ -38,6 +41,7 @@ serde-big-array = "0.3.0"
serde_json = "1.0.55"
smallvec = "1.4.0"
structopt = "0.3.14"
tempfile = "3.1.0"
thiserror = "1.0.18"
tokio = { version = "0.2.20", features = ["macros", "rt-threaded", "sync", "tcp", "time", "blocking"] }
tokio-openssl = "0.4.0"
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ cargo run --release -- generate-config > mynode.toml
cargo run --release -- validator --config=mynode.toml
```

**NOTE:** If you want to run multiple instances on the same machine, ensure you modify the `[storage.path]` field of
their configuration files to give each a unique path, or else instances will share database files.

## Logging

Logging can be enabled by setting the environment variable `RUST_LOG`. This can be set to one of the following levels,
Expand Down Expand Up @@ -64,6 +67,8 @@ There is a minimal client which can be executed to store and retrieve `Deploy`s
The client targets the HTTP service of a validator node. This can be configured via the config file for the node, and
the actual bound endpoint is displayed as an info-level log message just after node startup.

#### Put a `Deploy`

To create a new random `Deploy` and store it:

```
Expand All @@ -73,8 +78,18 @@ cargo run --release --bin=casperlabs-client -- put-deploy http://localhost:7777
On success, the hash identifying the `Deploy` is output as a 64 character hex-encoded string. The `Deploy` will be
broadcast immediately to all interconnected validator nodes.

#### Get a `Deploy`

To retrieve that deploy from any node:

```
cargo run --release --bin=casperlabs-client -- get-deploy http://localhost:8888 a555b68c8fed43078db6022a3de83fce97c1d80caf070c3654f9526d149e8182
```

#### List stored `Deploy`s

To get a list of all stored `Deploy`s' hashes:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just for PoC right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think so, I certainly put it in for that reason. If it were to remain, it'd need some work (e.g. to handle larger responses)


```
cargo run --release --bin=casperlabs-client -- list-deploys http://localhost:9999
```
19 changes: 18 additions & 1 deletion src/apps/client/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use structopt::StructOpt;

use casperlabs_node::types::Deploy;

const DEPLOY_API_PATH: &str = "deploy";
const DEPLOY_API_PATH: &str = "deploys";

#[derive(Debug, StructOpt)]
/// CasperLabs client.
Expand All @@ -25,6 +25,12 @@ pub enum Args {
/// Hex-encoded deploy hash.
deploy_hash: String,
},
/// Get the list of all stored deploys' hashes.
ListDeploys {
/// Address of the casperlabs-node HTTP service to contact. Example format:
/// http://localhost:7777
node_address: String,
},
}

#[tokio::main]
Expand All @@ -35,6 +41,7 @@ async fn main() -> anyhow::Result<()> {
node_address,
deploy_hash,
} => get_deploy(node_address, deploy_hash).await,
Args::ListDeploys { node_address } => list_deploys(node_address).await,
}
}

Expand Down Expand Up @@ -71,3 +78,13 @@ async fn get_deploy(node_address: String, deploy_hash: String) -> anyhow::Result

Ok(())
}

async fn list_deploys(node_address: String) -> anyhow::Result<()> {
let url = format!("{}/{}", node_address, DEPLOY_API_PATH);
let body = reqwest::get(&url).await?.bytes().await?;

let json_encoded = str::from_utf8(body.as_ref())?;
println!("{}", json_encoded);

Ok(())
}
4 changes: 2 additions & 2 deletions src/apps/node/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ impl Cli {
io::stdout().write_all(cfg_str.as_bytes())?;
}
Cli::Validator { config } => {
logging::init()?;
// We load the specified config, if any, otherwise use defaults.
let cfg = config
.map(config::load_from_file)
.transpose()?
.unwrap_or_default();
logging::init()?;

reactor::validator::run(cfg.validator_net, cfg.http_server).await?
reactor::validator::run(cfg.validator_net, cfg.http_server, cfg.storage).await?
}
}
Ok(())
Expand Down
Loading