Skip to content

Commit 44004bf

Browse files
authored
Merge pull request #2149 from input-output-hk/djo/2144/cardano-network-on-aggregator-status-and-explorer
Cardano network on aggregator status and explorer
2 parents 379fbd1 + 9e9716c commit 44004bf

File tree

11 files changed

+59
-31
lines changed

11 files changed

+59
-31
lines changed

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.

internal/mithril-persistence/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-persistence"
3-
version = "0.2.38"
3+
version = "0.2.39"
44
description = "Common types, interfaces, and utilities to persist data for Mithril nodes."
55
authors = { workspace = true }
66
edition = { workspace = true }

internal/mithril-persistence/src/sqlite/connection_builder.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl ConnectionBuilder {
8181
pub fn build(self) -> StdResult<ConnectionThreadSafe> {
8282
let logger = self.base_logger.new_with_component_name::<Self>();
8383

84-
debug!(logger, "Opening SQLite connection"; "path" => self.connection_path.display());
84+
debug!(logger, "Opening SQLite connection"; "path" => self.connection_path.display(), "options" => ?self.options);
8585
let connection =
8686
Connection::open_thread_safe(&self.connection_path).with_context(|| {
8787
format!(
@@ -94,14 +94,12 @@ impl ConnectionBuilder {
9494
.options
9595
.contains(&ConnectionOptions::EnableWriteAheadLog)
9696
{
97-
debug!(logger, "Enabling SQLite Write Ahead Log journal mode");
9897
connection
9998
.execute("pragma journal_mode = wal; pragma synchronous = normal;")
10099
.with_context(|| "SQLite initialization: could not enable WAL.")?;
101100
}
102101

103102
if self.options.contains(&ConnectionOptions::EnableForeignKeys) {
104-
debug!(logger, "Enabling SQLite foreign key support");
105103
connection
106104
.execute("pragma foreign_keys=true")
107105
.with_context(|| "SQLite initialization: could not enable FOREIGN KEY support.")?;
@@ -113,7 +111,6 @@ impl ConnectionBuilder {
113111
.options
114112
.contains(&ConnectionOptions::ForceDisableForeignKeys)
115113
{
116-
debug!(logger, "Force disabling SQLite foreign key support");
117114
connection
118115
.execute("pragma foreign_keys=false")
119116
.with_context(|| "SQLite initialization: could not disable FOREIGN KEY support.")?;

mithril-aggregator/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-aggregator"
3-
version = "0.5.116"
3+
version = "0.5.117"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/src/http_server/routes/status.rs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ fn status(
2424
.and(middlewares::extract_config(router_state, |config| {
2525
config.cardano_node_version.clone()
2626
}))
27+
.and(middlewares::extract_config(router_state, |config| {
28+
config.network.to_string()
29+
}))
2730
.and_then(handlers::status)
2831
}
2932

3033
async fn get_aggregator_status_message(
3134
epoch_service: EpochServiceWrapper,
3235
cardano_node_version: String,
36+
cardano_network: String,
3337
) -> StdResult<AggregatorStatusMessage> {
3438
let epoch_service = epoch_service.read().await;
3539

@@ -49,6 +53,7 @@ async fn get_aggregator_status_message(
4953
let message = AggregatorStatusMessage {
5054
epoch,
5155
cardano_era,
56+
cardano_network,
5257
mithril_era,
5358
cardano_node_version,
5459
aggregator_node_version,
@@ -81,9 +86,11 @@ mod handlers {
8186
logger: Logger,
8287
epoch_service: EpochServiceWrapper,
8388
cardano_node_version: String,
89+
cardano_network: String,
8490
) -> Result<impl warp::Reply, Infallible> {
8591
let aggregator_status_message =
86-
get_aggregator_status_message(epoch_service, cardano_node_version).await;
92+
get_aggregator_status_message(epoch_service, cardano_node_version, cardano_network)
93+
.await;
8794

8895
match aggregator_status_message {
8996
Ok(message) => Ok(reply::json(&message, StatusCode::OK)),
@@ -211,11 +218,11 @@ mod tests {
211218
..FakeEpochServiceBuilder::dummy(Epoch(3))
212219
}
213220
.build();
221+
let epoch_service = Arc::new(RwLock::new(epoch_service));
214222

215-
let message =
216-
get_aggregator_status_message(Arc::new(RwLock::new(epoch_service)), String::new())
217-
.await
218-
.unwrap();
223+
let message = get_aggregator_status_message(epoch_service, String::new(), String::new())
224+
.await
225+
.unwrap();
219226

220227
assert_eq!(
221228
message.protocol_parameters,
@@ -240,7 +247,7 @@ mod tests {
240247
.build();
241248
let epoch_service = Arc::new(RwLock::new(epoch_service));
242249

243-
let message = get_aggregator_status_message(epoch_service.clone(), String::new())
250+
let message = get_aggregator_status_message(epoch_service, String::new(), String::new())
244251
.await
245252
.unwrap();
246253

@@ -266,11 +273,28 @@ mod tests {
266273
.build();
267274
let epoch_service = Arc::new(RwLock::new(epoch_service));
268275

269-
let message = get_aggregator_status_message(epoch_service.clone(), String::new())
276+
let message = get_aggregator_status_message(epoch_service, String::new(), String::new())
270277
.await
271278
.unwrap();
272279

273280
assert_eq!(message.total_stakes_signers, total_stakes_signers);
274281
assert_eq!(message.total_next_stakes_signers, total_next_stakes_signers);
275282
}
283+
284+
#[tokio::test]
285+
async fn retrieves_node_version_and_network_from_parameters() {
286+
let epoch_service = FakeEpochServiceBuilder::dummy(Epoch(3)).build();
287+
let epoch_service = Arc::new(RwLock::new(epoch_service));
288+
289+
let message = get_aggregator_status_message(
290+
epoch_service,
291+
"1.0.4".to_string(),
292+
"network".to_string(),
293+
)
294+
.await
295+
.unwrap();
296+
297+
assert_eq!(message.cardano_node_version, "1.0.4");
298+
assert_eq!(message.cardano_network, "network");
299+
}
276300
}

mithril-common/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-common"
3-
version = "0.4.90"
3+
version = "0.4.91"
44
description = "Common types, interfaces, and utilities for Mithril nodes."
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-common/src/messages/aggregator_status.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ pub struct AggregatorStatusMessage {
1414
/// Current Cardano era
1515
pub cardano_era: CardanoEra,
1616

17+
/// Cardano network
18+
pub cardano_network: String,
19+
1720
/// Current Mithril era
1821
pub mithril_era: SupportedEra,
1922

@@ -57,6 +60,7 @@ mod tests {
5760
const ACTUAL_JSON: &str = r#"{
5861
"epoch": 48,
5962
"cardano_era": "conway",
63+
"cardano_network": "mainnet",
6064
"mithril_era": "pythagoras",
6165
"cardano_node_version": "1.2.3",
6266
"aggregator_node_version": "4.5.6",
@@ -74,6 +78,7 @@ mod tests {
7478
AggregatorStatusMessage {
7579
epoch: Epoch(48),
7680
cardano_era: "conway".to_string(),
81+
cardano_network: "mainnet".to_string(),
7782
mithril_era: SupportedEra::Pythagoras,
7883
cardano_node_version: "1.2.3".to_string(),
7984
aggregator_node_version: "4.5.6".to_string(),

mithril-explorer/package-lock.json

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

mithril-explorer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mithril-explorer",
3-
"version": "0.7.19",
3+
"version": "0.7.20",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",

mithril-explorer/src/components/ControlPanel/AggregatorStatus/index.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ function InfoGroupCard({ children, title, ...props }) {
3131
);
3232
}
3333

34-
function InfoRow({ label, children, ...props }) {
34+
function InfoRow({ label, children, className, ...props }) {
3535
return (
3636
<>
37-
<div className="d-flex justify-content-between" {...props}>
37+
<div className={`d-flex justify-content-between ${className}`} {...props}>
3838
<div className="me-2 flex-fill">
3939
<em>{label}:</em>
4040
</div>
@@ -120,10 +120,6 @@ export default function AggregatorStatus({ showContent = true }) {
120120
return ((value / total) * 100).toFixed(0);
121121
}
122122

123-
function capitalizeFirstLetter(string) {
124-
return string.charAt(0).toUpperCase() + string.slice(1);
125-
}
126-
127123
return fallbackToEpochSetting ? (
128124
<Stack direction="horizontal">
129125
<Collapse in={showContent}>
@@ -138,11 +134,12 @@ export default function AggregatorStatus({ showContent = true }) {
138134
<div id="contentRow">
139135
<Row className="d-flex flex-wrap justify-content-md-center">
140136
<InfoGroupCard title={`Epoch ${aggregatorStatus.epoch}`}>
137+
<InfoRow label="Cardano Network" className="text-capitalize">
138+
{aggregatorStatus.cardano_network}
139+
</InfoRow>
141140
<InfoRow label="Cardano Era">{aggregatorStatus.cardano_era}</InfoRow>
142-
<InfoRow label="Mithril Era">
143-
{aggregatorStatus.mithril_era
144-
? capitalizeFirstLetter(aggregatorStatus.mithril_era)
145-
: ""}
141+
<InfoRow label="Mithril Era" className="text-capitalize">
142+
{aggregatorStatus.mithril_era}
146143
</InfoRow>
147144
</InfoGroupCard>
148145

0 commit comments

Comments
 (0)