Skip to content

Commit 46802f0

Browse files
authored
Merge pull request #2633 from input-output-hk/dlachaume/2619/client-era-support
feat: add support for Mithril era transition in clients
2 parents b6fb6c2 + 1ffc3da commit 46802f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3024
-2900
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ As a minor extension, we have adopted a slightly different versioning convention
2727

2828
- Add pre-built Linux ARM binaries in the distribution for the signer, client CLI, and aggregator.
2929

30+
- Support for Mithril era transition in the client library, CLI and WASM.
31+
3032
- **UNSTABLE** :
3133
- Support for DMQ signature publisher in the signer and signature consumer in the aggregator.
3234

Cargo.lock

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

docs/website/adr/004-mithril-network-update-strategy.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,7 @@ sequenceDiagram
9292
Chain->>Old Node: Era change at Epoch XX
9393
Old Node->>User: 💀 unsupported Era, quit.
9494
```
95+
96+
### Client-side era awareness
97+
98+
The Mithril clients do not have access to a Cardano node and therefore can not read the Era Activation Markers stored on chain. As a consequence, they rely on the current era run by the aggregator, by using the era advertised by its `/status` route.

docs/website/root/manual/develop/nodes/mithril-client.md

Lines changed: 15 additions & 0 deletions
Large diffs are not rendered by default.

examples/client-wasm-nodejs/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/client-wasm-web/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/mithril-build-script/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-build-script"
3-
version = "0.2.24"
3+
version = "0.2.25"
44
description = "A toolbox for Mithril crates build scripts"
55
authors = { workspace = true }
66
edition = { workspace = true }

internal/mithril-build-script/src/fake_aggregator.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub type FileContent = String;
1414
/// of the fake aggregator.
1515
#[derive(Debug, Default)]
1616
pub struct FakeAggregatorData {
17+
status: FileContent,
18+
1719
epoch_settings: FileContent,
1820

1921
certificates_list: FileContent,
@@ -50,6 +52,9 @@ impl FakeAggregatorData {
5052
});
5153

5254
match filename.as_str() {
55+
"status.json" => {
56+
data.status = file_content;
57+
}
5358
"epoch-settings.json" => {
5459
data.epoch_settings = file_content;
5560
}
@@ -155,6 +160,7 @@ impl FakeAggregatorData {
155160
pub fn generate_code_for_all_data(self) -> String {
156161
Self::assemble_code(
157162
&[
163+
generate_list_getter("status", self.status),
158164
generate_list_getter("epoch_settings", self.epoch_settings),
159165
generate_ids_array(
160166
"snapshot_digests",

mithril-client-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-client-cli"
3-
version = "0.12.20"
3+
version = "0.12.21"
44
description = "A Mithril Client"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-client-cli/src/commands/mod.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ pub mod tools;
1212

1313
pub use deprecation::{DeprecatedCommand, Deprecation};
1414

15+
use std::sync::Arc;
16+
1517
use mithril_client::{ClientBuilder, MithrilResult};
1618

17-
use crate::configuration::ConfigParameters;
19+
use crate::{configuration::ConfigParameters, utils::ForcedEraFetcher};
1820

1921
const CLIENT_TYPE_CLI: &str = "CLI";
2022

2123
pub(crate) fn client_builder(params: &ConfigParameters) -> MithrilResult<ClientBuilder> {
2224
let builder = ClientBuilder::aggregator(
2325
&params.require("aggregator_endpoint")?,
2426
&params.require("genesis_verification_key")?,
25-
)
26-
.with_origin_tag(params.get("origin_tag"))
27-
.with_client_type(Some(CLIENT_TYPE_CLI.to_string()));
27+
);
2828

29-
Ok(builder)
29+
Ok(finalize_builder_config(builder, params))
3030
}
3131

3232
pub(crate) fn client_builder_with_fallback_genesis_key(
@@ -44,9 +44,19 @@ pub(crate) fn client_builder_with_fallback_genesis_key(
4444
"genesis_verification_key",
4545
fallback_genesis_verification_key,
4646
),
47-
)
48-
.with_origin_tag(params.get("origin_tag"))
49-
.with_client_type(Some(CLIENT_TYPE_CLI.to_string()));
47+
);
48+
49+
Ok(finalize_builder_config(builder, params))
50+
}
51+
52+
fn finalize_builder_config(mut builder: ClientBuilder, params: &ConfigParameters) -> ClientBuilder {
53+
builder = builder
54+
.with_origin_tag(params.get("origin_tag"))
55+
.with_client_type(Some(CLIENT_TYPE_CLI.to_string()));
56+
57+
if let Some(era) = params.get("era") {
58+
builder = builder.with_era_fetcher(Arc::new(ForcedEraFetcher::new(era.to_string())));
59+
}
5060

51-
Ok(builder)
61+
builder
5262
}

0 commit comments

Comments
 (0)