Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate current documentation #1446

Merged
merged 1 commit into from Jan 23, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -29,9 +29,9 @@ Mithril aggregator is responsible for collecting individual signatures from the

## Resources

| Node | Source repository | Rust documentation | Docker packages | REST API |
|:-:|:-----------------:|:------------------:|:---------------:|:---------------:|
**Mithril aggregator** | [: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:](https://github.com/input-output-hk/mithril/pkgs/container/mithril-aggregator) | [:arrow_upper_right:](/doc/aggregator-api) |
| Node | Source repository | Rust documentation | Docker packages | REST API
|:-:|:-----------------:|:------------------:|:---------------:|
**Mithril aggregator** | [: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:](https://github.com/input-output-hk/mithril/pkgs/container/mithril-aggregator) | [:arrow_upper_right:](/doc/aggregator-api)

## Pre-requisites

Expand Down Expand Up @@ -300,7 +300,7 @@ You can run 'era generate-tx-datum' to create the transaction datum file that wi
**Case 1**: If there is only one supported era in the code, create the datum file:

```bash
./mithril-aggregator era generate-tx-datum --current-era-epoch **EPOCH_AT_WHICH_CURRENT_ERA_STARTS** --era-markers-secret-key **YOUR_ERA_ACTIVATION_SECRET_KEY**
./mithril-aggregator era generate-tx-datum --current-era-epoch **EPOCH_AT_WHICH_CURRENT_ERA_STARTS** --era-markers-secret-key **YOUR_ERA_ACTIVATION_SECRET_KEY** --target-path **TARGET_PATH**
```

You should see something like:
Expand All @@ -312,13 +312,13 @@ You should see something like:
**Case 2**: If there are two supported eras in the code and the activation epoch of the upcoming era is not yet known, run the command:

```bash
./mithril-aggregator era generate-tx-datum --current-era-epoch **EPOCH_AT_WHICH_CURRENT_ERA_STARTS** --era-markers-secret-key **YOUR_ERA_ACTIVATION_SECRET_KEY**
./mithril-aggregator era generate-tx-datum --current-era-epoch **EPOCH_AT_WHICH_CURRENT_ERA_STARTS** --era-markers-secret-key **YOUR_ERA_ACTIVATION_SECRET_KEY** --target-path **TARGET_PATH**
```

**Case 3**: If there are two supported eras in the code and the activation epoch of the era switch is known to be at the following epoch, run the command:

```bash
./mithril-aggregator era generate-tx-datum --current-era-epoch **EPOCH_AT_WHICH_CURRENT_ERA_STARTS** --next-era-epoch **EPOCH_AT_WHICH_NEXT_ERA_STARTS** --era-markers-secret-key **YOUR_ERA_ACTIVATION_SECRET_KEY**
./mithril-aggregator era generate-tx-datum --current-era-epoch **EPOCH_AT_WHICH_CURRENT_ERA_STARTS** --next-era-epoch **EPOCH_AT_WHICH_NEXT_ERA_STARTS** --era-markers-secret-key **YOUR_ERA_ACTIVATION_SECRET_KEY** --target-path **TARGET_PATH**
```

## Release the build and run the binary 'tools' command
Expand Down Expand Up @@ -439,8 +439,10 @@ Here is a list of the available parameters:
| `snapshot_bucket_name` | - | - | `SNAPSHOT_BUCKET_NAME` | Name of the bucket where the snapshots are stored | - | `snapshot-bucket` | :heavy_check_mark: | Required if `snapshot_uploader_type` is `gcp`
| `snapshot_use_cdn_domain` | - | - | `SNAPSHOT_USE_CDN_DOMAIN` | Use CDN domain for constructing snapshot url | `false` | - | - | To be used if `snapshot_uploader_type` is `gcp`
| `run_interval` | - | - | `RUN_INTERVAL` | Interval between two runtime cycles in ms | - | `60000` | :heavy_check_mark: |
| `chain_observer_type` | `--chain-observer-type` | - | `CHAIN_OBSERVER_TYPE` | Chain observer type that can be `cardano-cli`, `pallas` or `fake`. | `pallas` | - | - |
| `era_reader_adapter_type` | `--era-reader-adapter-type` | - | `ERA_READER_ADAPTER_TYPE` | Era reader adapter type that can be `cardano-chain`, `file` or `bootstrap`. | `bootstrap` | - | - |
| `era_reader_adapter_params` | `--era-reader-adapter-params` | - | `ERA_READER_ADAPTER_PARAMS` | Era reader adapter params that is an optional JSON encoded parameters structure that is expected depending on the `era_reader_adapter_type` parameter | - | - | - |
| `signed_entity_types` | `--signed-entity-types` | - | `SIGNED_ENTITY_TYPES` | Signed entity types parameters (discriminants names in an ordered comma separated list) | - | `MithrilStakeDistribution,CardanoImmutableFilesFull,CardanoStakeDistribution` | - |
| `snapshot_compression_algorithm` | `--snapshot-compression-algorithm` | - | `SNAPSHOT_COMPRESSION_ALGORITHM` | Compression algorithm of the snapshot archive | `zstandard` | `gzip` or `zstandard` | - |
| `zstandard_parameters` | - | - | `ZSTANDARD_PARAMETERS__LEVEL` and `ZSTANDARD_PARAMETERS__NUMBER_OF_WORKERS` | Zstandard specific parameters | - | `{ level: 9, number_of_workers: 4 }` | - |

Expand Down Expand Up @@ -483,5 +485,6 @@ Here is a list of the available parameters:
| `current_era_epoch` | `--current-era-epoch` | - | `CURRENT_ERA_EPOCH` | Epoch at which current era starts. | - | - | - | :heavy_check_mark: |
| `next_era_epoch` | `--next-era-epoch` | - | `NEXT_ERA_EPOCH` | Epoch at which the next era starts. If not specified and an upcoming era is available, it will announce the next era. If specified, it must be strictly greater than `current-epoch-era` | - | - | - | - |
| `era_markers_secret_key` | `--era-markers-secret-key` | - | `ERA_MARKERS_SECRET_KEY` | Era markers secret key that is used to verify the authenticity of the era markers on the chain. | - | - | - | :heavy_check_mark: |
| `target_path` | `--target-path` | - | - | Path of the file to export the payload to. | - | - | - | - |

The `tools recompute-certificates-hash` command has no dedicated parameters.
@@ -0,0 +1,125 @@
---
sidebar_position: 5
---

import NetworksMatrix from '../../../networks-matrix.md';
import CompiledBinaries from '../../../compiled-binaries.md'

# Mithril client library WASM

:::info

Mithril client library WASM can be used by Javascript developers to use the Mithril network in their web applications.

It is responsible for handling the different types of data certified by Mithril, and available through a Mithril aggregator:
- [**Snapshot**](../../../glossary.md#snapshot): list and get.
- [**Mithril stake distribution**](../../../glossary.md#stake-distribution): list and get.
- [**Certificate**](../../../glossary.md#certificate): list, get, and chain validation.

:::

:::tip

* For more information about the **Mithril network**, please see the [architecture](../../../mithril/mithril-network/architecture.md) overview.

:::

:::note Mithril networks

<NetworksMatrix />

:::

## Resources

| Node | Source repository | Rust documentation |
|:-:|:-----------------:|:------------------:|
**Mithril client WASM** | [:arrow_upper_right:](https://github.com/input-output-hk/mithril/tree/main/mithril-client-wasm) | [:arrow_upper_right:](https://mithril.network/rust-doc/mithril_client_wasm/index.html) |


## Installation

The Mithril client library is compatible with the following browsers:

| Browser | Minimum version | Released | Tested in CI |
| --- |:---:|:---:|:---:|
| **Chrome** | `54` | 2016-10-12 | :heavy_check_mark: |
| **Edge** | `79` | 2020-01-15 | - |
| **Firefox** | `38` | 2015-05-12 | :heavy_check_mark: |
| **Opera** | `41` | 2016-10-25 | - |
| **Safari** | `15.4` | 2022-03-14 | - |
| **Chrome Android** | `54` | 2016-10-19 | - |
| **Firefox for Android** | `38` | 2015-05-12 | - |
| **Opera Android** | `41` | 2016-10-25 | - |
| **Safari on iOS** | `15.4` | 2022-03-14 | - |


:::warning

The package is not yet released (it will be published soon on [npm](https://www.npmjs.com/)). In the meantime, you can test the librayr by compiling it from [Mithril repository](https://github.com/input-output-hk/mithril/tree/main/mithril-client-wasm).

:::

In your Javascript project, use `npm` to add [mithril-client]https://www.npmjs.com/package/@mithril-dev/mithril-client-wasm) library as a dependency:

```bash
npm i @mithril-dev/mithril-client-wasm
```

## Using Mithril client library

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

```js
import { MithrilClient } from "@mithril-dev/mithril-client-wasm"

let aggregator_endpoint =
"https://aggregator.testing-preview.api.mithril.network/aggregator"
let genesis_verification_key =
"5b3132372c37332c3132342c3136312c362c3133372c3133312c3231332c3230372c3131372c3139382c38352c3137362c3139392c3136322c3234312c36382c3132332c3131392c3134352c31332c3233322c3234332c34392c3232392c322c3234392c3230352c3230352c33392c3233352c34345d"

const broadcast_channel = new BroadcastChannel("mithril-client");
broadcast_channel.onmessage = (e) => {
let event = e.data;
if (event.type == "CertificateChainValidationStarted") {
console.log("The certificate chain validation has started");
} else if (event.type == "CertificateValidated") {
console.log("A certificate has been validated, certificate_hash: " + event.payload.certificate_hash);
} else if (event.type == "CertificateChainValidated") {
console.log("The certificate chain is valid");
} else {
console.log(event);
}
};

let client = await new MithrilClient(
aggregator_endpoint,
genesis_verification_key
)
let mithril_stake_distributions_list = await client.list_mithril_stake_distributions();
console.log("stake distributions:", mithril_stake_distributions_list);

let last_mithril_stake_distribution = mithril_stake_distributions_list[0];
console.log("last_mithril_stake_distribution:", last_mithril_stake_distribution);

let last_stake_distribution = await client.get_mithril_stake_distribution(last_mithril_stake_distribution.hash);
console.log("last_stake_distribution:", last_stake_distribution);

let certificate = await client.get_mithril_certificate(last_stake_distribution.certificate_hash);
console.log("certificate:", certificate);

let last_certificate_from_chain = await client.verify_certificate_chain(certificate.hash);
console.log("verify certificate chain OK, last_certificate_from_chain:", last_certificate_from_chain);

let mithril_stake_distributions_message = await client.compute_mithril_stake_distribution_message(last_stake_distribution);
console.log("mithril_stake_distributions_message:", mithril_stake_distributions_message);

let valid_stake_distribution_message = await client.verify_message_match_certificate(mithril_stake_distributions_message, last_certificate_from_chain);
console.log("valid_stake_distribution_message:", valid_stake_distribution_message);
```

:::tip

You can read the complete [Rust developer documentation](https://mithril.network/rust-doc/mithril_client_wasm/index.html).

:::
Expand Up @@ -12,7 +12,7 @@ import CompiledBinaries from '../../../compiled-binaries.md'
Mithril client library can be used by Rust developers to use the Mithril network in their applications.

It is responsible for handling the different types of data certified by Mithril, and available through a Mithril aggregator:
- [**Snapshot**](../../../glossary.md#snapshot): list, get and download tarball.
- [**Snapshot**](../../../glossary.md#snapshot): list, get, download tarball and record statistics.
- [**Mithril stake distribution**](../../../glossary.md#stake-distribution): list and get.
- [**Certificate**](../../../glossary.md#certificate): list, get, and chain validation.

Expand Down Expand Up @@ -88,6 +88,10 @@ async fn main() -> mithril_client::MithrilResult<()> {
.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)
Expand All @@ -102,10 +106,16 @@ async fn main() -> mithril_client::MithrilResult<()> {

Snapshot download and certificate chain validation can take quite some time even with a fast computer and network. We have implemented a feedback mechanism for them, more details on it are available in the [feedback sub-module](https://mithril.network/rust-doc/mithril_client/feedback/index.html).

An example of implementation with the crate [indicatif](https://crates.io/crates/indicatif) is available in the [Mithril repository](https://github.com/input-output-hk/mithril/tree/main/examples/client-snapshot). To run it, execute the following command:
An example of implementation with the crate [indicatif](https://crates.io/crates/indicatif) is available in the [Mithril repository](https://github.com/input-output-hk/mithril/tree/main/examples/client-snapshot/src/main.rs). To run it, execute the following command:

```bash
cargo run -p client-snapshot
```

or directly from the example crate directory:

```bash
cargo run --example snapshot_list_get_show_download_verify --features fs
cargo run
```

:::
Expand Down Expand Up @@ -136,6 +146,10 @@ async fn main() -> mithril_client::MithrilResult<()> {
.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)
Expand Down
Expand Up @@ -137,6 +137,10 @@ Options:
Directory where configuration file is located [default: ./config]
--aggregator-endpoint <AGGREGATOR_ENDPOINT>
Override configuration Aggregator endpoint URL
--log-format-json
Enable JSON output for logs displayed according to verbosity level
--log-output <LOG_OUTPUT>
Redirect the logs to a file
-h, --help
Print help
-V, --version
Expand Down Expand Up @@ -296,20 +300,35 @@ Here is a list of the available parameters:
| `network` | - | - | `NETWORK` | Cardano network | - | `testnet` or `mainnet` or `devnet` | :heavy_check_mark: |
| `aggregator_endpoint` | `--aggregator-endpoint` | - | `AGGREGATOR_ENDPOINT` | Aggregator node endpoint | - | `https://aggregator.pre-release-preview.api.mithril.network/aggregator` | :heavy_check_mark: |
| `genesis_verification_key` | - | - | `GENESIS_VERIFICATION_KEY` | Genesis verification key | - | - | :heavy_check_mark: |
| `json_output` | `--json` | `-j` | - | Enable JSON output | no | - | - |
| `log_format_json` | `--log-format-json` | - | - | Enable JSON output for logs | - | - | - |
| `log_output` | `--log-output` | `-o` | - | Redirect the logs to a file | - | `./mithril-client.log` | - |

`snapshot show` command:

| Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory |
|-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:|
| `digest` | `--digest` | - | `DIGEST` | Snapshot digest or `latest` for the latest digest | - | - | :heavy_check_mark: |
| `json` | `--json` | - | - | Enable JSON output for command results | - | - | - |

`snapshot list` command:

| Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory |
|-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:|
| `json` | `--json` | - | - | Enable JSON output for command results | - | - | - |

`snapshot download` command:

| Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory |
|-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:|
| `digest` | `--digest` | - | `DIGEST` | Snapshot digest or `latest` for the latest digest | - | - | :heavy_check_mark: |
| `download_dir` | `--download-dir` | - | - | Directory where the snapshot will be downloaded | . | - | - |
| `json` | `--json` | - | - | Enable JSON output for progress logs | - | - | - |

`mithril-stake-distribution list` command:

| Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory |
|-----------|---------------------|:---------------------:|----------------------|-------------|---------------|---------|:---------:|
| `json` | `--json` | - | - | Enable JSON output for command results | - | - | - |

`mithril-stake-distribution download` command:

Expand Down
Expand Up @@ -281,7 +281,7 @@ You will see more information about the snapshot:
+-----------------------+-------------------------------------------------------------------------------------------------------------------------------+
| Location 1 | https://storage.googleapis.com/mithril-release-preprod-…aa11b0e2ccf737d4f5def8b0a9f2245eded2b4ec4be876f7bd64deddcbbf.tar.gz |
+-----------------------+-------------------------------------------------------------------------------------------------------------------------------+
| Cardano node version | 8.1.2 |
| Cardano node version | 8.7.3 |
+-----------------------+-------------------------------------------------------------------------------------------------------------------------------+
| Created | 2023-05-31T14:02:40.150189810Z |
+-----------------------+-------------------------------------------------------------------------------------------------------------------------------+
Expand Down
Expand Up @@ -77,7 +77,7 @@ Note that this guide works on a Linux machine only.
* Read rights on the `Database` folder (specified by the `--database-path` setting of the **Cardano node**)
* Read and write rights on the `Inter Process Communication` file (typically defined by the `CARDANO_NODE_SOCKET_PATH` environment variable used to launch the **Cardano node**)

* Install a recent version of [`cardano-cli`](https://github.com/input-output-hk/cardano-node/releases/tag/8.1.2) (version 8.1.2+).
* Install a recent version of [`cardano-cli`](https://github.com/input-output-hk/cardano-node/releases/tag/8.7.3) (version 8.7.3+).

* Install a correctly configured Rust toolchain (latest stable version). You can follow the instructions provided [here](https://www.rust-lang.org/learn/get-started).

Expand Down