Crate mithril_client

Source
Expand description

Define all the tooling necessary to manipulate Mithril certified types from a Mithril Aggregator.

It handles the different types that can be queried to a Mithril aggregator:

The Client aggregates the queries of all of those types.

NOTE: Snapshot download and Certificate chain validation can take quite some time even with a fast computer and network. For those a feedback mechanism is available, more details on it in the feedback submodule.

§Example

Below is an example describing the usage of most of the library’s functions together:

Note: Snapshot download and the compute snapshot message functions are available using crate feature fs.

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

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 the binary must have read/write access to it.
let target_directory = Path::new("/home/user/download/");
client
    .snapshot()
    .download_unpack(&snapshot, &target_directory)
    .await?;

if let Err(e) = client.snapshot().add_statistics(&snapshot).await {
    println!("Could not increment snapshot download statistics: {:?}", e);
}

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

assert!(certificate.match_message(&message));

§Optional Features

The following are a list of Cargo features that can be enabled or disabled:

  • fs: Enables file system related functionalities.
  • unstable: Enables experimental or in-development mithril-client features that may change.
  • rug-backend (enabled by default): Enables usage of rug numerical backend in mithril-stm (dependency of mithril-common).
  • num-integer-backend: Enables usage of num-integer numerical backend in mithril-stm (dependency of mithril-common).

To allow fine tuning of the http queries, the following Reqwest features are re-exported:

  • native-tls (enabled by default): Enables TLS functionality provided by native-tls.
  • native-tls-vendored: Enables the vendored feature of native-tls.
  • native-tls-alpn: Enables the alpn feature of native-tls.
  • rustls-tls: Enables TLS functionality provided by rustls. Equivalent to rustls-tls-webpki-roots.
  • rustls-tls-manual-roots: Enables TLS functionality provided by rustls, without setting any root certificates. Roots have to be specified manually.
  • rustls-tls-webpki-roots: Enables TLS functionality provided by rustls, while using root certificates from the webpki-roots crate.
  • rustls-tls-native-roots: Enables TLS functionality provided by rustls, while using root certificates from the rustls-native-certs crate.
  • enable-http-compression (enabled by default): Enables compressed traffic with reqwest.

Modules§

aggregator_client
Mechanisms to exchange data with an Aggregator.
cardano_database_client
A client to retrieve Cardano databases data from an Aggregator.
cardano_stake_distribution_client
A client to retrieve Cardano stake distributions data from an Aggregator.
cardano_transaction_client
A client to retrieve from an aggregator cryptographic proofs of membership for a subset of Cardano transactions.
certificate_client
A client which retrieves and validates certificates from an Aggregator.
common
mithril-common re-exports
feedback
Long task feedbacks
file_downloader
File downloader module.
mithril_stake_distribution_client
A client to retrieve Mithril stake distributions data from an Aggregator.
snapshot_client
A client to retrieve snapshots data from an Aggregator.

Structs§

CardanoDatabaseSnapshot
A Cardano node database snapshot
CardanoDatabaseSnapshotListItem
List items of Cardano node database snapshot
CardanoStakeDistribution
A Cardano stake distribution. Message structure of a Cardano Stake Distribution
CardanoStakeDistributionListItem
List item of Cardano stake distributions. Message structure of a Cardano Stake Distribution list item
CardanoTransactionSnapshot
A snapshot that allow to know up to which point of time Mithril have certified Cardano transactions. Message structure of a Cardano Transactions snapshot
CardanoTransactionSnapshotListItem
List item of a Cardano transaction snapshot. Message structure of a Cardano Transactions Snapshot list item
CardanoTransactionsProofs
A cryptographic proof for a set of Cardano transactions
CardanoTransactionsSetProof
A cryptographic proof of a set of Cardano transactions is included in the global Cardano transactions set
Client
Structure that aggregates the available clients for each of the Mithril types of certified data.
ClientBuilder
Builder than can be used to create a Client easily or with custom dependencies.
ClientOptions
Options that can be used to configure the client.
MessageBuilder
A MessageBuilder can be used to compute the message of Mithril artifacts.
MithrilCertificate
A Mithril certificate.
MithrilCertificateListItem
List item of Mithril certificates
MithrilCertificateListItemMetadata
CertificateListItemMessage represents the metadata associated to a CertificateListItemMessage
MithrilCertificateMetadata
CertificateMetadata represents the metadata associated to a Certificate
MithrilSigner
An individual signer of a Mithril certificate
MithrilStakeDistribution
A Mithril stake distribution.
MithrilStakeDistributionListItem
List item of Mithril stake distributions.
Snapshot
A Mithril snapshot of a Cardano Node database.
SnapshotListItem
List item of Mithril snapshots
VerifiedCardanoTransactions
Set of transactions verified by CardanoTransactionsProofsMessage::verify.

Enums§

VerifyCardanoTransactionsProofsError
Error encountered or produced by the cardano transaction proof verification.

Type Aliases§

MithrilError
Mithril error type, an alias of anyhow::Error
MithrilResult
Mithril result type, an alias of anyhow::Result