Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.3.81"
version = "0.3.82"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl ToMessageAdapter<Vec<SignedEntity<Snapshot>>, SnapshotListMessage>
size: entity.artifact.size,
created_at: entity.created_at,
locations: entity.artifact.locations,
compression_algorithm: Some(entity.artifact.compression_algorithm),
cardano_node_version: Some(entity.artifact.cardano_node_version),
})
.collect()
Expand Down
2 changes: 2 additions & 0 deletions mithril-client/src/services/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ mod tests {
size: 1024,
created_at: DateTime::<Utc>::default(),
locations: vec!["location-1.1".to_string(), "location-1.2".to_string()],
compression_algorithm: Some(CompressionAlgorithm::Zstandard),
cardano_node_version: None,
};
let item2 = SnapshotListItemMessage {
Expand All @@ -378,6 +379,7 @@ mod tests {
size: 1024,
created_at: DateTime::<Utc>::default(),
locations: vec!["location-2.1".to_string(), "location-2.2".to_string()],
compression_algorithm: None,
cardano_node_version: Some("1.0.0".to_string()),
};

Expand Down
55 changes: 54 additions & 1 deletion mithril-common/src/messages/snapshot_list.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

use crate::entities::{Beacon, Epoch};
use crate::entities::{Beacon, CompressionAlgorithm, Epoch};

/// Message structure of a snapshot list
pub type SnapshotListMessage = Vec<SnapshotListItemMessage>;
Expand All @@ -27,6 +27,10 @@ pub struct SnapshotListItemMessage {
/// Locations where the binary content of the snapshot can be retrieved
pub locations: Vec<String>,

/// Compression algorithm of the snapshot archive
#[serde(skip_serializing_if = "Option::is_none")]
pub compression_algorithm: Option<CompressionAlgorithm>,

/// Cardano node version
#[serde(skip_serializing_if = "Option::is_none")]
pub cardano_node_version: Option<String>,
Expand All @@ -49,6 +53,7 @@ impl SnapshotListItemMessage {
.unwrap()
.with_timezone(&Utc),
locations: vec!["https://host/certificate.tar.gz".to_string()],
compression_algorithm: Some(CompressionAlgorithm::default()),
cardano_node_version: None,
}
}
Expand All @@ -73,6 +78,7 @@ mod tests {
.unwrap()
.with_timezone(&Utc),
locations: vec!["https://host/certificate.tar.gz".to_string()],
compression_algorithm: None,
cardano_node_version: None,
}]
}
Expand All @@ -92,6 +98,27 @@ mod tests {
.unwrap()
.with_timezone(&Utc),
locations: vec!["https://host/certificate.tar.gz".to_string()],
compression_algorithm: None,
cardano_node_version: Some("1.0.0".to_string()),
}]
}

fn golden_message_v3() -> SnapshotListMessage {
vec![SnapshotListItemMessage {
digest: "0b9f5ad7f33cc523775c82249294eb8a1541d54f08eb3107cafc5638403ec7c6".to_string(),
beacon: Beacon {
network: "preview".to_string(),
epoch: Epoch(86),
immutable_file_number: 1728,
},
certificate_hash: "d5daf6c03ace4a9c074e951844075b9b373bafc4e039160e3e2af01823e9abfb"
.to_string(),
size: 807803196,
created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
.unwrap()
.with_timezone(&Utc),
locations: vec!["https://host/certificate.tar.gz".to_string()],
compression_algorithm: Some(CompressionAlgorithm::Zstandard),
cardano_node_version: Some("1.0.0".to_string()),
}]
}
Expand Down Expand Up @@ -144,4 +171,30 @@ mod tests {

assert_eq!(golden_message_v2(), message);
}

// Test the retro compatibility with possible future upgrades.
#[test]
fn test_v3() {
let json = r#"[{
"digest": "0b9f5ad7f33cc523775c82249294eb8a1541d54f08eb3107cafc5638403ec7c6",
"beacon": {
"network": "preview",
"epoch": 86,
"immutable_file_number": 1728
},
"certificate_hash": "d5daf6c03ace4a9c074e951844075b9b373bafc4e039160e3e2af01823e9abfb",
"size": 807803196,
"created_at": "2023-01-19T13:43:05.618857482Z",
"locations": [
"https://host/certificate.tar.gz"
],
"compression_algorithm": "zstandard",
"cardano_node_version": "1.0.0"
}]"#;
let message: SnapshotListMessage = serde_json::from_str(json).expect(
"This JSON is expected to be succesfully parsed into a SnapshotListMessage instance.",
);

assert_eq!(golden_message_v3(), message);
}
}
4 changes: 2 additions & 2 deletions mithril-explorer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mithril-explorer",
"version": "0.3.3",
"version": "0.3.4",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down Expand Up @@ -32,4 +32,4 @@
"jest-environment-jsdom": "^29.6.4",
"next-router-mock": "^0.9.9"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ export default function SnapshotsList(props) {
<Card.Title>{snapshot.digest}</Card.Title>
<ListGroup variant="flush" className="data-list-group">
<ListGroup.Item>Epoch: {snapshot.beacon.epoch}</ListGroup.Item>
<ListGroup.Item>Immutable File Number: {snapshot.beacon.immutable_file_number}</ListGroup.Item>
<ListGroup.Item>Immutable file number: {snapshot.beacon.immutable_file_number}</ListGroup.Item>
{snapshot.cardano_node_version &&
<ListGroup.Item>Cardano Node Version: {snapshot.cardano_node_version}</ListGroup.Item>
<ListGroup.Item>Cardano node: {snapshot.cardano_node_version}</ListGroup.Item>
}
{snapshot.compression_algorithm &&
<ListGroup.Item>Compression: {snapshot.compression_algorithm}</ListGroup.Item>
}
<ListGroup.Item>Certificate hash: <br />
{snapshot.certificate_hash}{' '}
Expand All @@ -90,7 +93,7 @@ export default function SnapshotsList(props) {
<ListGroup.Item>
Created: <LocalDateTime datetime={snapshot.created_at} />
</ListGroup.Item>
<ListGroup.Item>Size: {formatBytes(snapshot.size)}</ListGroup.Item>
<ListGroup.Item>Archive size: {formatBytes(snapshot.size)}</ListGroup.Item>
</ListGroup>
</Card.Body>
<Card.Footer>
Expand Down