Skip to content

Commit 0070d04

Browse files
authored
Merge pull request #1349 from input-output-hk/ensemble/1311-mithril-client-common-crates-publish
Mithril client and common crates preparation for publication
2 parents 030a315 + f8ceea7 commit 0070d04

File tree

13 files changed

+107
-31
lines changed

13 files changed

+107
-31
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,9 @@ jobs:
353353
publish-crate-test:
354354
strategy:
355355
fail-fast: false
356+
max-parallel: 1
356357
matrix:
357-
package: [ mithril-stm ]
358+
package: [ mithril-stm, mithril-common, mithril-client ]
358359

359360
runs-on: ubuntu-22.04
360361
needs:

.github/workflows/pre-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ jobs:
227227
publish-crate-test:
228228
strategy:
229229
fail-fast: false
230+
max-parallel: 1
230231
matrix:
231-
package: [ mithril-stm ]
232+
package: [ mithril-stm, mithril-common, mithril-client ]
232233

233234
runs-on: ubuntu-22.04
234235
steps:

.github/workflows/release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ jobs:
166166

167167
publish-crate:
168168
strategy:
169-
fail-fast: false
169+
fail-fast: true
170+
max-parallel: 1
170171
matrix:
171-
package: [ mithril-stm ]
172+
package: [ mithril-stm, mithril-common, mithril-client ]
172173
include:
173174
- package: mithril-stm
174175
api_token_secret_name: CRATES_IO_API_TOKEN

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Thanks for considering contributing and help us on creating the Mithril protocol!
44

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

99
This document contains guidelines to help you get started and how to make sure

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ This repository consists of the following parts:
5656

5757
* [**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.
5858

59-
* [**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**.
59+
* [**Mithril client**](./mithril-client): this is the **client** library that can be used by developers to interact with Mithril certified data in their applications.
60+
61+
* [**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**.
6062

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

docs/website/root/manual/developer-docs/references.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ To learn more about the **Mithril protocol**, please refer to the [about Mithril
2929
| **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) | -
3030
| **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) | -
3131
| **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)
32-
| **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) | -
32+
| **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) | -
33+
| **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) | -
3334
| **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) | -
3435
| **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) | - | -
3536
| **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) | - | -

mithril-client/Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[package]
22
name = "mithril-client"
3-
version = "0.5.4"
4-
description = "Mithril Client library"
3+
version = "0.5.5"
4+
description = "Mithril client library"
55
authors = { workspace = true }
66
edition = { workspace = true }
7-
documentation = { workspace = true }
87
homepage = { workspace = true }
98
license = { workspace = true }
109
repository = { workspace = true }
10+
categories = ["cryptography"]
11+
include = ["**/*.rs", "Cargo.toml", "README.md", ".gitignore"]
1112

1213
[lib]
1314
crate-type = ["lib", "cdylib", "staticlib"]
@@ -20,7 +21,7 @@ chrono = { version = "0.4.31", features = ["serde"] }
2021
flate2 = "1.0.27"
2122
flume = "0.11.0"
2223
futures = "0.3.28"
23-
mithril-common = { path = "../mithril-common" }
24+
mithril-common = { path = "../mithril-common", version = "0.2.133" }
2425
reqwest = { version = "0.11.22", features = ["json", "stream"] }
2526
semver = "1.0.19"
2627
serde = { version = "1.0.188", features = ["derive"] }
@@ -35,7 +36,9 @@ zstd = "0.13.0"
3536
[dev-dependencies]
3637
httpmock = "0.6.8"
3738
indicatif = { version = "0.17.7", features = ["tokio"] }
38-
mithril-common = { path = "../mithril-common", features = ["test_http_server"] }
39+
mithril-common = { path = "../mithril-common", version = "0.2.133", features = [
40+
"test_http_server",
41+
] }
3942
mockall = "0.11.4"
4043
slog-async = "2.8.0"
4144
slog-scope = "4.4.0"

mithril-client/README.md

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,63 @@
1-
# Mithril Client
1+
# 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)
22

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

6-
:bulb: A guide on how to [`Bootstrap a Cardano Node`](https://mithril.network/doc/manual/getting-started/bootstrap-cardano-node) with Mithril
5+
* `mithril-client` defines all the tooling necessary to manipulate Mithril certified types available from a Mithril aggregator.
6+
7+
* The different types of available data certified by Mithril are:
8+
* Snapshot: list, get and download tarball.
9+
* Mithril stake distribution: list and get.
10+
* Certificate: list, get, and chain validation.
11+
12+
## Example
13+
14+
Below is a basic example of how to use most of the functions exposed by the Mithril client library:
15+
16+
```rust
17+
use mithril_client::{ClientBuilder, MessageBuilder};
18+
use std::path::Path;
19+
20+
#[tokio::main]
21+
async fn main() -> mithril_client::MithrilResult<()> {
22+
let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
23+
24+
let snapshots = client.snapshot().list().await?;
25+
26+
let last_digest = snapshots.first().unwrap().digest.as_ref();
27+
let snapshot = client.snapshot().get(last_digest).await?.unwrap();
28+
29+
let certificate = client
30+
.certificate()
31+
.verify_chain(&snapshot.certificate_hash)
32+
.await?;
33+
34+
// Note: the directory must already exist, and the user running this code must have read/write access to it.
35+
let target_directory = Path::new("YOUR_TARGET_DIRECTORY");
36+
client
37+
.snapshot()
38+
.download_unpack(&snapshot, target_directory)
39+
.await?;
40+
41+
let message = MessageBuilder::new()
42+
.compute_snapshot_message(&certificate, target_directory)
43+
.await?;
44+
assert!(certificate.match_message(&message));
45+
46+
Ok(())
47+
}
48+
```
49+
50+
## Getting Help
51+
First, check our [Developer documentation](https://mithril.network/doc/manual/developer-docs/nodes/mithril-client-library).
52+
53+
If you need more information, feel free to join IOG's Technical Community [discord server](https://discord.gg/5kaErDKDRq).
54+
55+
## Contributing
56+
57+
Thanks for considering contributing and help us on creating the Mithril protocol!
58+
59+
The best way to contribute right now is to try things out and provide feedback,
60+
but we also accept contributions to the documentation and obviously to the
61+
code itself.
62+
63+
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).

mithril-common/Cargo.toml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[package]
22
name = "mithril-common"
3-
version = "0.2.133"
3+
version = "0.2.134"
4+
description = "Common types, interfaces, and utilities for Mithril nodes."
45
authors = { workspace = true }
56
edition = { workspace = true }
6-
documentation = { workspace = true }
77
homepage = { workspace = true }
88
license = { workspace = true }
99
repository = { workspace = true }
10+
include = ["**/*.rs", "Cargo.toml", "README.md", ".gitignore"]
1011

1112
[lib]
1213
crate-type = ["lib", "cdylib", "staticlib"]
@@ -48,18 +49,24 @@ slog = "2.7.0"
4849
sqlite = { version = "0.31.1", features = ["bundled"] }
4950
strum = { version = "0.25.0", features = ["derive"] }
5051
thiserror = "1.0.49"
51-
tokio = { version = "1.32.0", features = ["fs", "io-util", "process", "rt", "sync"] }
52+
tokio = { version = "1.32.0", features = [
53+
"fs",
54+
"io-util",
55+
"process",
56+
"rt",
57+
"sync",
58+
] }
5259
typetag = "0.2.13"
5360
walkdir = "2.4.0"
5461
warp = { version = "0.3.6", optional = true }
5562

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

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

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

8491
allow_skip_signer_certification = []
8592
# portable feature avoids SIGILL crashes on CPUs not supporting Intel ADX instruction set when built on CPUs that support it
86-
portable = [
87-
"mithril-stm/portable",
88-
]
93+
portable = ["mithril-stm/portable"]
8994

9095
# Enable all tests tools
9196
test_tools = ["apispec", "test_http_server"]

0 commit comments

Comments
 (0)