Skip to content

Commit

Permalink
Merge pull request input-output-hk#1349 from input-output-hk/ensemble…
Browse files Browse the repository at this point in the history
…/1311-mithril-client-common-crates-publish

Mithril client and common crates preparation for publication
  • Loading branch information
jpraynaud authored Nov 15, 2023
2 parents 030a315 + f8ceea7 commit 0070d04
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,9 @@ jobs:
publish-crate-test:
strategy:
fail-fast: false
max-parallel: 1
matrix:
package: [ mithril-stm ]
package: [ mithril-stm, mithril-common, mithril-client ]

runs-on: ubuntu-22.04
needs:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ jobs:
publish-crate-test:
strategy:
fail-fast: false
max-parallel: 1
matrix:
package: [ mithril-stm ]
package: [ mithril-stm, mithril-common, mithril-client ]

runs-on: ubuntu-22.04
steps:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ jobs:

publish-crate:
strategy:
fail-fast: false
fail-fast: true
max-parallel: 1
matrix:
package: [ mithril-stm ]
package: [ mithril-stm, mithril-common, mithril-client ]
include:
- package: mithril-stm
api_token_secret_name: CRATES_IO_API_TOKEN
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Thanks for considering contributing and help us on creating the Mithril protocol!

The best way to contribute right now is to try things out and provide feedback,
but we also accept contributions to the documentation and the obviously to the
but we also accept contributions to the documentation and obviously to the
code itself.

This document contains guidelines to help you get started and how to make sure
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ This repository consists of the following parts:

* [**Mithril aggregator**](./mithril-aggregator): the node of the **Mithril network** responsible for collecting individual signatures from the **Mithril signers** and aggregating them into a multi-signature. The **Mithril aggregator** uses this ability to provide certified snapshots of the **Cardano** blockchain.

* [**Mithril client**](./mithril-client): the node of the **Mithril network** responsible for retrieving the certified artifacts produced by the **Mithril network**, eg the **Cardano** chain certified snapshots used to securely restore a **Cardano node**.
* [**Mithril client**](./mithril-client): this is the **client** library that can be used by developers to interact with Mithril certified data in their applications.

* [**Mithril client CLI**](./mithril-client-cli): the CLI used for retrieving the certified artifacts produced by the **Mithril network**, eg the **Cardano** chain certified snapshots used to securely restore a **Cardano node**.

* [**Mithril common**](./mithril-common): this is the **common** library that is used by the **Mithril network** nodes.

Expand Down
3 changes: 2 additions & 1 deletion docs/website/root/manual/developer-docs/references.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ To learn more about the **Mithril protocol**, please refer to the [about Mithril
| **Mithril common** | The **common** library used by **Mithril network** nodes. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-common) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_common/index.html) | -
| **Mithril STM** | The **core** library that implements the cryptographic engine for the **Mithril** protocol. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-stm) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_stm/index.html) | -
| **Mithril aggregator** | The node within the **Mithril network** responsible for collecting individual signatures from the **Mithril signers** and aggregating them into a multi-signature. This capability enables the **Mithril aggregator** to provide certified snapshots of the **Cardano** blockchain. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-aggregator) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_aggregator/index.html) | [:arrow_upper_right:](/aggregator-api)
| **Mithril client** | The node within the **Mithril network** responsible for restoring the **Cardano** blockchain on an empty node from a certified snapshot. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-client-cli) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_client/index.html) | -
| **Mithril client CLI** | The node within the **Mithril network** responsible for restoring the **Cardano** blockchain on an empty node from a certified snapshot. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-client-cli) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_client_cli/index.html) | -
| **Mithril client** | The library that can be used by developers to interact with Mithril certified data in their applications. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-client) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_client/index.html) | -
| **Mithril signer** | The node responsible for producing individual signatures that are collected and aggregated by the **Mithril aggregator**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-signer) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_signer/index.html) | -
| **Mithril devnet** | The private **Mithril/Cardano network** used to create a **Mithril network** on top of a private **Cardano network**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/blob/main/mithril-test-lab/mithril-devnet) | - | -
| **Mithril end to end** | The tool used to run test scenarios against a **Mithril devnet**. | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/blob/main/mithril-explorer) | - | -
Expand Down
13 changes: 8 additions & 5 deletions mithril-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[package]
name = "mithril-client"
version = "0.5.4"
description = "Mithril Client library"
version = "0.5.5"
description = "Mithril client library"
authors = { workspace = true }
edition = { workspace = true }
documentation = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
categories = ["cryptography"]
include = ["**/*.rs", "Cargo.toml", "README.md", ".gitignore"]

[lib]
crate-type = ["lib", "cdylib", "staticlib"]
Expand All @@ -20,7 +21,7 @@ chrono = { version = "0.4.31", features = ["serde"] }
flate2 = "1.0.27"
flume = "0.11.0"
futures = "0.3.28"
mithril-common = { path = "../mithril-common" }
mithril-common = { path = "../mithril-common", version = "0.2.133" }
reqwest = { version = "0.11.22", features = ["json", "stream"] }
semver = "1.0.19"
serde = { version = "1.0.188", features = ["derive"] }
Expand All @@ -35,7 +36,9 @@ zstd = "0.13.0"
[dev-dependencies]
httpmock = "0.6.8"
indicatif = { version = "0.17.7", features = ["tokio"] }
mithril-common = { path = "../mithril-common", features = ["test_http_server"] }
mithril-common = { path = "../mithril-common", version = "0.2.133", features = [
"test_http_server",
] }
mockall = "0.11.4"
slog-async = "2.8.0"
slog-scope = "4.4.0"
Expand Down
65 changes: 61 additions & 4 deletions mithril-client/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,63 @@
# Mithril Client
# Mithril-client ![crates.io](https://img.shields.io/crates/v/mithril-client.svg) [![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](LICENSE-APACHE) [![Discord](https://img.shields.io/discord/500028886025895936.svg?logo=discord&style=flat-square)](https://discord.gg/5kaErDKDRq)

## Documentation
:rocket: The documentation is available at [`Mithril client library`](https://mithril.network/doc/next/manual/developer-docs/nodes/mithril-client-library) with Mithril
**This is a work in progress** 🛠

:bulb: A guide on how to [`Bootstrap a Cardano Node`](https://mithril.network/doc/manual/getting-started/bootstrap-cardano-node) with Mithril
* `mithril-client` defines all the tooling necessary to manipulate Mithril certified types available from a Mithril aggregator.

* The different types of available data certified by Mithril are:
* Snapshot: list, get and download tarball.
* Mithril stake distribution: list and get.
* Certificate: list, get, and chain validation.

## Example

Below is a basic example of how to use most of the functions exposed by the Mithril client library:

```rust
use mithril_client::{ClientBuilder, MessageBuilder};
use std::path::Path;

#[tokio::main]
async fn main() -> mithril_client::MithrilResult<()> {
let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;

let snapshots = client.snapshot().list().await?;

let last_digest = snapshots.first().unwrap().digest.as_ref();
let snapshot = client.snapshot().get(last_digest).await?.unwrap();

let certificate = client
.certificate()
.verify_chain(&snapshot.certificate_hash)
.await?;

// Note: the directory must already exist, and the user running this code must have read/write access to it.
let target_directory = Path::new("YOUR_TARGET_DIRECTORY");
client
.snapshot()
.download_unpack(&snapshot, target_directory)
.await?;

let message = MessageBuilder::new()
.compute_snapshot_message(&certificate, target_directory)
.await?;
assert!(certificate.match_message(&message));

Ok(())
}
```

## Getting Help
First, check our [Developer documentation](https://mithril.network/doc/manual/developer-docs/nodes/mithril-client-library).

If you need more information, feel free to join IOG's Technical Community [discord server](https://discord.gg/5kaErDKDRq).

## Contributing

Thanks for considering contributing and help us on creating the Mithril protocol!

The best way to contribute right now is to try things out and provide feedback,
but we also accept contributions to the documentation and obviously to the
code itself.

When contributing to this project and interacting with others, please follow our [Code of Conduct](https://github.com/input-output-hk/mithril/blob/main/CODE-OF-CONDUCT.md) and our [Contributing Guidelines](https://github.com/input-output-hk/mithril/blob/main/CONTRIBUTING.md).
21 changes: 13 additions & 8 deletions mithril-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
name = "mithril-common"
version = "0.2.133"
version = "0.2.134"
description = "Common types, interfaces, and utilities for Mithril nodes."
authors = { workspace = true }
edition = { workspace = true }
documentation = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
include = ["**/*.rs", "Cargo.toml", "README.md", ".gitignore"]

[lib]
crate-type = ["lib", "cdylib", "staticlib"]
Expand Down Expand Up @@ -48,18 +49,24 @@ slog = "2.7.0"
sqlite = { version = "0.31.1", features = ["bundled"] }
strum = { version = "0.25.0", features = ["derive"] }
thiserror = "1.0.49"
tokio = { version = "1.32.0", features = ["fs", "io-util", "process", "rt", "sync"] }
tokio = { version = "1.32.0", features = [
"fs",
"io-util",
"process",
"rt",
"sync",
] }
typetag = "0.2.13"
walkdir = "2.4.0"
warp = { version = "0.3.6", optional = true }

[target.'cfg(not(windows))'.dependencies]
# non-windows: use default rug backend
mithril-stm = { path = "../mithril-stm" }
mithril-stm = { path = "../mithril-stm", version = "0.3.8" }

[target.'cfg(windows)'.dependencies]
# Windows doesn't support rug backend, fallback to num-integer
mithril-stm = { path = "../mithril-stm", default-features = false, features = [
mithril-stm = { path = "../mithril-stm", version = "0.3.8", default-features = false, features = [
"num-integer-backend",
] }

Expand All @@ -83,9 +90,7 @@ default = []

allow_skip_signer_certification = []
# portable feature avoids SIGILL crashes on CPUs not supporting Intel ADX instruction set when built on CPUs that support it
portable = [
"mithril-stm/portable",
]
portable = ["mithril-stm/portable"]

# Enable all tests tools
test_tools = ["apispec", "test_http_server"]
Expand Down
6 changes: 6 additions & 0 deletions mithril-common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Mithril-common ![crates.io](https://img.shields.io/crates/v/mithril-common.svg) [![Discord](https://img.shields.io/discord/500028886025895936.svg?logo=discord&style=flat-square)](https://discord.gg/5kaErDKDRq)


**This is a work in progress** 🛠

This crate contains common utility types and testing infrastructure used in the implementation of the Mithril nodes.
3 changes: 1 addition & 2 deletions mithril-stm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[package]
name = "mithril-stm"
version = "0.3.8"
version = "0.3.9"
edition = { workspace = true }
authors = { workspace = true }
documentation = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions mithril-stm/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Mithril-stm ![CI workflow](https://github.com/input-output-hk/mithril/actions/workflows/ci.yml/badge.svg) ![crates.io](https://img.shields.io/crates/v/mithril_stm.svg)
# Mithril-stm ![CI workflow](https://github.com/input-output-hk/mithril/actions/workflows/ci.yml/badge.svg) ![crates.io](https://img.shields.io/crates/v/mithril_stm.svg) [![Discord](https://img.shields.io/discord/500028886025895936.svg?logo=discord&style=flat-square)](https://discord.gg/5kaErDKDRq)


**This is a work in progress** :hammer_and_wrench:s
**This is a work in progress** 🛠

* `mithril-stm` is a Rust implementation of the scheme described in the paper [Mithril: Stake-based Threshold Multisignatures](https://eprint.iacr.org/2021/916.pdf) by Pyrros Chaidos and Aggelos Kiayias.
* The BLS12-381 signature library [blst](https://github.com/supranational/blst) is used as the backend for the implementation of STM.
Expand Down

0 comments on commit 0070d04

Please sign in to comment.