From b2bc7fde7d59bb45198830835da6bca7ff2241af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20HUBERT=20/=20PALO-IT?= Date: Tue, 19 Sep 2023 16:23:20 +0200 Subject: [PATCH 1/5] add snapshot statistics route --- mithril-aggregator/.vscode/settings.json | 3 + .../src/http_server/routes/mod.rs | 1 + .../src/http_server/routes/router.rs | 3 + .../src/http_server/routes/statistics.rs | 115 ++++++++++++++++++ openapi.yaml | 28 +++++ 5 files changed, 150 insertions(+) create mode 100644 mithril-aggregator/.vscode/settings.json create mode 100644 mithril-aggregator/src/http_server/routes/statistics.rs diff --git a/mithril-aggregator/.vscode/settings.json b/mithril-aggregator/.vscode/settings.json new file mode 100644 index 00000000000..3b664107303 --- /dev/null +++ b/mithril-aggregator/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "git.ignoreLimitWarning": true +} \ No newline at end of file diff --git a/mithril-aggregator/src/http_server/routes/mod.rs b/mithril-aggregator/src/http_server/routes/mod.rs index d00afafad8e..c9ae0f21b5d 100644 --- a/mithril-aggregator/src/http_server/routes/mod.rs +++ b/mithril-aggregator/src/http_server/routes/mod.rs @@ -6,3 +6,4 @@ mod reply; pub mod router; mod signatures_routes; mod signer_routes; +mod statistics; diff --git a/mithril-aggregator/src/http_server/routes/router.rs b/mithril-aggregator/src/http_server/routes/router.rs index 73b0b5c4685..38087fb8399 100644 --- a/mithril-aggregator/src/http_server/routes/router.rs +++ b/mithril-aggregator/src/http_server/routes/router.rs @@ -14,6 +14,8 @@ use warp::http::Method; use warp::reject::Reject; use warp::{Filter, Rejection, Reply}; +use super::statistics; + #[derive(Debug)] pub struct VersionMismatchError; @@ -49,6 +51,7 @@ pub fn routes( .or(signer_routes::routes(dependency_manager.clone())) .or(signatures_routes::routes(dependency_manager.clone())) .or(epoch_routes::routes(dependency_manager.clone())) + .or(statistics::routes(dependency_manager.clone())) .with(cors), ) .recover(handle_custom) diff --git a/mithril-aggregator/src/http_server/routes/statistics.rs b/mithril-aggregator/src/http_server/routes/statistics.rs new file mode 100644 index 00000000000..7506e6624ba --- /dev/null +++ b/mithril-aggregator/src/http_server/routes/statistics.rs @@ -0,0 +1,115 @@ +use mithril_common::MITHRIL_SIGNER_VERSION_HEADER; +use std::sync::Arc; +use warp::Filter; + +use crate::http_server::routes::middlewares; +use crate::DependencyContainer; + +pub fn routes( + dependency_manager: Arc, +) -> impl Filter + Clone { + post_statistics(dependency_manager) +} + +/// POST /statistics/snapshot +fn post_statistics( + dependency_manager: Arc, +) -> impl Filter + Clone { + warp::path!("statistics" / "snapshot") + .and(warp::post()) + .and(warp::header::optional::( + MITHRIL_SIGNER_VERSION_HEADER, + )) + .and(warp::body::json()) + .and(middlewares::with_event_transmitter( + dependency_manager.clone(), + )) + .and_then(handlers::post_snapshot_statistics) +} + +mod handlers { + use std::{convert::Infallible, sync::Arc}; + + use mithril_common::messages::SnapshotMessage; + use reqwest::StatusCode; + + use crate::event_store::{EventMessage, TransmitterService}; + use crate::http_server::routes::reply; + + pub async fn post_snapshot_statistics( + signer_node_version: Option, + snapshot_message: SnapshotMessage, + event_transmitter: Arc>, + ) -> Result { + let headers: Vec<(&str, &str)> = signer_node_version + .as_ref() + .map(|v| ("signer-node-version", v.as_str())) + .into_iter() + .collect(); + let _ = event_transmitter.send_event_message( + "HTTP::statistics", + "snapshot_downloaded", + &snapshot_message, + headers, + ); + + Ok(reply::empty(StatusCode::CREATED)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + use mithril_common::messages::SnapshotMessage; + use mithril_common::test_utils::apispec::APISpec; + + use warp::{http::Method, test::request}; + + use crate::{ + dependency_injection::DependenciesBuilder, http_server::SERVER_BASE_PATH, Configuration, + }; + + fn setup_router( + dependency_manager: Arc, + ) -> impl Filter + Clone { + let cors = warp::cors() + .allow_any_origin() + .allow_headers(vec!["content-type"]) + .allow_methods(vec![Method::GET, Method::POST, Method::OPTIONS]); + + warp::any() + .and(warp::path(SERVER_BASE_PATH)) + .and(routes(dependency_manager).with(cors)) + } + + #[tokio::test] + async fn post_statistics_ok() { + let config = Configuration::new_sample(); + let mut builder = DependenciesBuilder::new(config); + let mut rx = builder.get_event_transmitter_receiver().await.unwrap(); + let dependency_manager = builder.build_dependency_container().await.unwrap(); + let snapshot_message = SnapshotMessage::dummy(); + + let method = Method::POST.as_str(); + let path = "/statistics/snapshot"; + + let response = request() + .method(method) + .json(&snapshot_message) + .path(&format!("/{SERVER_BASE_PATH}{path}")) + .reply(&setup_router(Arc::new(dependency_manager))) + .await; + + APISpec::verify_conformity( + APISpec::get_all_spec_files(), + method, + path, + "application/json", + &snapshot_message, + &response, + ); + + let _ = rx.try_recv().unwrap(); + } +} diff --git a/openapi.yaml b/openapi.yaml index fc197f85766..ea85ada4795 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -360,6 +360,34 @@ paths: application/json: schema: $ref: "#/components/schemas/Error" + /statistics/snapshot: + post: + summary: Increments download statistics + description: Increments snapshot download statistics + requestBody: + description: Downloaded snapshot + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/SnapshotMessage" + responses: + "201": + description: Statistic succesfully posted + "400": + description: Increments download statistics bad request + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "412": + description: API version mismatch + default: + description: Snapshot download statistics error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" components: schemas: From 29cc900167ea103fc0ddfe4d8c86de01e016ac5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20HUBERT=20/=20PALO-IT?= Date: Wed, 20 Sep 2023 09:51:31 +0200 Subject: [PATCH 2/5] client issue statistic HTTP call --- .../src/aggregator_client/http_client.rs | 48 +++++++++++++++++++ .../src/aggregator_client/snapshot_client.rs | 16 ++++++- mithril-client/src/services/snapshot.rs | 22 +++++++-- 3 files changed, 81 insertions(+), 5 deletions(-) diff --git a/mithril-client/src/aggregator_client/http_client.rs b/mithril-client/src/aggregator_client/http_client.rs index a23720e838b..dd7d782f5cf 100644 --- a/mithril-client/src/aggregator_client/http_client.rs +++ b/mithril-client/src/aggregator_client/http_client.rs @@ -54,6 +54,13 @@ pub trait AggregatorClient: Sync + Send { /// Get the content back from the Aggregator, the URL is a relative path for a resource async fn get_content(&self, url: &str) -> Result; + /// Post information to the Aggregator, the URL is a relative path for a resource + async fn post_content( + &self, + url: &str, + json: &str, + ) -> Result; + /// Download and unpack large archives on the disk async fn download_unpack( &self, @@ -149,6 +156,27 @@ impl AggregatorHTTPClient { } } + /// Issue a POST HTTP request. + async fn post(&self, url: &str, json: &str) -> Result { + let request_builder = Client::new().post(url.to_owned()).json(json); + let current_api_version = self + .compute_current_api_version() + .await + .unwrap() + .to_string(); + debug!("Prepare request with version: {current_api_version}"); + let request_builder = + request_builder.header(MITHRIL_API_VERSION_HEADER, current_api_version); + + request_builder + .send() + .await + .map_err(|e| AggregatorHTTPClientError::SubsystemError { + message: format!("Error while posting data '{json}' to URL '{url}'."), + error: e.into(), + }) + } + /// API version error handling async fn handle_api_error(&self, response: &Response) -> AggregatorHTTPClientError { if let Some(version) = response.headers().get(MITHRIL_API_VERSION_HEADER) { @@ -183,6 +211,26 @@ impl AggregatorClient for AggregatorHTTPClient { }) } + async fn post_content( + &self, + url: &str, + json: &str, + ) -> Result { + let url = format!("{}/{}", self.aggregator_endpoint.trim_end_matches('/'), url); + let response = self.post(&url, json).await?; + + let body = + response + .text() + .await + .map_err(|e| AggregatorHTTPClientError::SubsystemError { + message: "Could not find a text body in the response.".to_string(), + error: e.into(), + })?; + + Ok(body) + } + async fn download_unpack( &self, url: &str, diff --git a/mithril-client/src/aggregator_client/snapshot_client.rs b/mithril-client/src/aggregator_client/snapshot_client.rs index b2e5377d099..16c05a2b5ab 100644 --- a/mithril-client/src/aggregator_client/snapshot_client.rs +++ b/mithril-client/src/aggregator_client/snapshot_client.rs @@ -75,7 +75,12 @@ impl SnapshotClient { ) .await { - Ok(()) => Ok(()), + Ok(()) => { + // the snapshot download does not fail if the statistic call fails. + let _ = self.add_statistics(snapshot).await; + + Ok(()) + } Err(e) => { warn!("Failed downloading snapshot from '{url}' Error: {e}."); Err(e.into()) @@ -92,4 +97,13 @@ impl SnapshotClient { } .into()) } + + /// Increments Aggregator's download statistics + pub async fn add_statistics(&self, snapshot: &Snapshot) -> StdResult<()> { + let url = "statistics/snapshot"; + let json = serde_json::to_string(snapshot)?; + let _response = self.http_client.post_content(url, &json).await?; + + Ok(()) + } } diff --git a/mithril-client/src/services/snapshot.rs b/mithril-client/src/services/snapshot.rs index d6aea34bf69..4f5358f770f 100644 --- a/mithril-client/src/services/snapshot.rs +++ b/mithril-client/src/services/snapshot.rs @@ -260,7 +260,12 @@ impl SnapshotService for MithrilClientSnapshotService { DownloadProgressReporter::new(pb, progress_output_type), ) .await - .with_context(|| format!("Could not download file in '{}'", download_dir.display()))?; + .with_context(|| { + format!( + "Could not download file in directory '{}'", + download_dir.display() + ) + })?; // Append 'clean' file to speedup node bootstrap if let Err(error) = File::create(db_dir.join("clean")) { @@ -541,8 +546,11 @@ mod tests { let test_path = std::env::temp_dir().join("test_download_snapshot_ok"); let _ = std::fs::remove_dir_all(&test_path); - let (http_client, certificate_verifier, digester) = + let (mut http_client, certificate_verifier, digester) = get_mocks_for_snapshot_service_configured_to_make_download_succeed(); + http_client + .expect_post_content() + .returning(|_, _| Ok(String::new())); let mut builder = get_dep_builder(Arc::new(http_client)); builder.certificate_verifier = Some(Arc::new(certificate_verifier)); @@ -581,8 +589,11 @@ mod tests { .join("test_download_snapshot_ok_add_clean_file_allowing_node_bootstrap_speedup"); let _ = std::fs::remove_dir_all(&test_path); - let (http_client, certificate_verifier, digester) = + let (mut http_client, certificate_verifier, digester) = get_mocks_for_snapshot_service_configured_to_make_download_succeed(); + http_client + .expect_post_content() + .returning(|_, _| Ok(String::new())); let mut builder = get_dep_builder(Arc::new(http_client)); builder.certificate_verifier = Some(Arc::new(certificate_verifier)); @@ -625,8 +636,11 @@ mod tests { let test_path = std::env::temp_dir().join("test_download_snapshot_invalid_digest"); let _ = std::fs::remove_dir_all(&test_path); - let (http_client, certificate_verifier, _) = + let (mut http_client, certificate_verifier, _) = get_mocks_for_snapshot_service_configured_to_make_download_succeed(); + http_client + .expect_post_content() + .returning(|_, _| Ok(String::new())); let immutable_digester = DumbImmutableDigester::new("snapshot-digest-KO", true); let mut dep_builder = get_dep_builder(Arc::new(http_client)); From 00536c4f5495db528dad9f71f49bccf6809747d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20HUBERT=20/=20PALO-IT?= Date: Wed, 20 Sep 2023 11:24:02 +0200 Subject: [PATCH 3/5] add statistics SQL query --- .gitignore | 1 + docs/runbook/statistics/snapshot_downloads.sql | 13 +++++++++++++ mithril-aggregator/.vscode/settings.json | 3 --- mithril-aggregator/src/http_server/routes/mod.rs | 2 +- mithril-aggregator/src/http_server/routes/router.rs | 5 ++--- .../routes/{statistics.rs => statistics_routes.rs} | 0 6 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 docs/runbook/statistics/snapshot_downloads.sql delete mode 100644 mithril-aggregator/.vscode/settings.json rename mithril-aggregator/src/http_server/routes/{statistics.rs => statistics_routes.rs} (100%) diff --git a/.gitignore b/.gitignore index e8fd7c49744..55419a848f1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .DS_Store .direnv/ .tmp/ +.vscode/ target target-* test-results.xml diff --git a/docs/runbook/statistics/snapshot_downloads.sql b/docs/runbook/statistics/snapshot_downloads.sql new file mode 100644 index 00000000000..425c00a2364 --- /dev/null +++ b/docs/runbook/statistics/snapshot_downloads.sql @@ -0,0 +1,13 @@ +select + content->>'digest' as snapshot_digest, + date(created_at) as downloaded_at, + count(*) as downloads +from event +where + source = 'HTTP::statistics' + and action = 'snapshot_downloaded' +group by 1, 2 +order by + downloaded_at desc, + downloads desc + diff --git a/mithril-aggregator/.vscode/settings.json b/mithril-aggregator/.vscode/settings.json deleted file mode 100644 index 3b664107303..00000000000 --- a/mithril-aggregator/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "git.ignoreLimitWarning": true -} \ No newline at end of file diff --git a/mithril-aggregator/src/http_server/routes/mod.rs b/mithril-aggregator/src/http_server/routes/mod.rs index c9ae0f21b5d..977509d5570 100644 --- a/mithril-aggregator/src/http_server/routes/mod.rs +++ b/mithril-aggregator/src/http_server/routes/mod.rs @@ -6,4 +6,4 @@ mod reply; pub mod router; mod signatures_routes; mod signer_routes; -mod statistics; +mod statistics_routes; diff --git a/mithril-aggregator/src/http_server/routes/router.rs b/mithril-aggregator/src/http_server/routes/router.rs index 38087fb8399..4fcd660851b 100644 --- a/mithril-aggregator/src/http_server/routes/router.rs +++ b/mithril-aggregator/src/http_server/routes/router.rs @@ -1,5 +1,6 @@ use crate::http_server::routes::{ artifact_routes, certificate_routes, epoch_routes, signatures_routes, signer_routes, + statistics_routes, }; use crate::http_server::SERVER_BASE_PATH; use crate::DependencyContainer; @@ -14,8 +15,6 @@ use warp::http::Method; use warp::reject::Reject; use warp::{Filter, Rejection, Reply}; -use super::statistics; - #[derive(Debug)] pub struct VersionMismatchError; @@ -51,7 +50,7 @@ pub fn routes( .or(signer_routes::routes(dependency_manager.clone())) .or(signatures_routes::routes(dependency_manager.clone())) .or(epoch_routes::routes(dependency_manager.clone())) - .or(statistics::routes(dependency_manager.clone())) + .or(statistics_routes::routes(dependency_manager.clone())) .with(cors), ) .recover(handle_custom) diff --git a/mithril-aggregator/src/http_server/routes/statistics.rs b/mithril-aggregator/src/http_server/routes/statistics_routes.rs similarity index 100% rename from mithril-aggregator/src/http_server/routes/statistics.rs rename to mithril-aggregator/src/http_server/routes/statistics_routes.rs From 0567c2f2798f90e91a0da829d3a79b5e21a8afc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20HUBERT=20/=20PALO-IT?= Date: Wed, 20 Sep 2023 17:35:26 +0200 Subject: [PATCH 4/5] handle precondition failed for POST --- docs/runbook/README.md | 1 + docs/runbook/statistics/README.md | 14 +++++++++ .../http_server/routes/statistics_routes.rs | 21 +++++-------- .../src/aggregator_client/http_client.rs | 31 +++++++++++++++---- mithril-client/src/lib.rs | 2 ++ openapi.yaml | 10 +++--- 6 files changed, 54 insertions(+), 25 deletions(-) create mode 100644 docs/runbook/statistics/README.md diff --git a/docs/runbook/README.md b/docs/runbook/README.md index c4da31be7c1..34dfe3f1159 100644 --- a/docs/runbook/README.md +++ b/docs/runbook/README.md @@ -10,6 +10,7 @@ This page gathers the available guides to operate a Mithril network. |------------|------------|------------ | **Genesis manually** | [manual-genesis](./genesis-manually/README.md) | Proceed to manual (re)genesis of the aggregator certificate chain. | **Era markers** | [era-markers](./era-markers/README.md) | Create and update era markers on the Cardano chain. +| **Downloads statistics** | [downloads statistics](./statistics/README.md) | Display the number of downloads per day and per snapshot. | **Signer registrations monitoring** | [registrations-monitoring](./registrations-monitoring/README.md) | Gather aggregated data about signer registrations (versions, stake, ...). | **Update protocol parameters** | [protocol-parameters](./protocol-parameters/README.md) | Update the protocol parameters of a Mithril network. | **Recompute certificates hash** | [recompute-certificates-hash](./recompute-certificates-hash/README.md) | Recompute the certificates has of an aggregator. diff --git a/docs/runbook/statistics/README.md b/docs/runbook/statistics/README.md new file mode 100644 index 00000000000..7e3e40af22a --- /dev/null +++ b/docs/runbook/statistics/README.md @@ -0,0 +1,14 @@ +# Statistics + +## Snapshot downloads per snapshot per day + +```sh +$> sqlite3 -table -batch \ + $DATA_STORES_DIRECTORY/monitoring.sqlite3 \ + < snapshot_downloads.sql +``` + +The variable `$DATA_STORES_DIRECTORY` should point to the directory where the +databases files are stored (see files in `mithril-aggregator/config` using the +key `data_stores_directory` to know where they are). + diff --git a/mithril-aggregator/src/http_server/routes/statistics_routes.rs b/mithril-aggregator/src/http_server/routes/statistics_routes.rs index 7506e6624ba..b6c78a3a6c5 100644 --- a/mithril-aggregator/src/http_server/routes/statistics_routes.rs +++ b/mithril-aggregator/src/http_server/routes/statistics_routes.rs @@ -1,4 +1,3 @@ -use mithril_common::MITHRIL_SIGNER_VERSION_HEADER; use std::sync::Arc; use warp::Filter; @@ -17,9 +16,6 @@ fn post_statistics( ) -> impl Filter + Clone { warp::path!("statistics" / "snapshot") .and(warp::post()) - .and(warp::header::optional::( - MITHRIL_SIGNER_VERSION_HEADER, - )) .and(warp::body::json()) .and(middlewares::with_event_transmitter( dependency_manager.clone(), @@ -37,23 +33,20 @@ mod handlers { use crate::http_server::routes::reply; pub async fn post_snapshot_statistics( - signer_node_version: Option, snapshot_message: SnapshotMessage, event_transmitter: Arc>, ) -> Result { - let headers: Vec<(&str, &str)> = signer_node_version - .as_ref() - .map(|v| ("signer-node-version", v.as_str())) - .into_iter() - .collect(); - let _ = event_transmitter.send_event_message( + let headers: Vec<(&str, &str)> = Vec::new(); + + match event_transmitter.send_event_message( "HTTP::statistics", "snapshot_downloaded", &snapshot_message, headers, - ); - - Ok(reply::empty(StatusCode::CREATED)) + ) { + Err(e) => Ok(reply::internal_server_error(e)), + Ok(_) => Ok(reply::empty(StatusCode::CREATED)), + } } } diff --git a/mithril-client/src/aggregator_client/http_client.rs b/mithril-client/src/aggregator_client/http_client.rs index dd7d782f5cf..0b3ec270562 100644 --- a/mithril-client/src/aggregator_client/http_client.rs +++ b/mithril-client/src/aggregator_client/http_client.rs @@ -157,6 +157,7 @@ impl AggregatorHTTPClient { } /// Issue a POST HTTP request. + #[async_recursion] async fn post(&self, url: &str, json: &str) -> Result { let request_builder = Client::new().post(url.to_owned()).json(json); let current_api_version = self @@ -168,13 +169,31 @@ impl AggregatorHTTPClient { let request_builder = request_builder.header(MITHRIL_API_VERSION_HEADER, current_api_version); - request_builder - .send() - .await - .map_err(|e| AggregatorHTTPClientError::SubsystemError { - message: format!("Error while posting data '{json}' to URL '{url}'."), + let response = request_builder.send().await.map_err(|e| { + AggregatorHTTPClientError::SubsystemError { + message: format!("Error while POSTing data '{json}' to URL='{url}'."), error: e.into(), - }) + } + })?; + + match response.status() { + StatusCode::OK => Ok(response), + StatusCode::PRECONDITION_FAILED => { + if self.discard_current_api_version().await.is_some() + && !self.api_versions.read().await.is_empty() + { + return self.post(url, json).await; + } + + Err(self.handle_api_error(&response).await) + } + StatusCode::NOT_FOUND => Err(AggregatorHTTPClientError::RemoteServerLogical(format!( + "Url='{url} not found" + ))), + status_code => Err(AggregatorHTTPClientError::RemoteServerTechnical(format!( + "Unhandled error {status_code}" + ))), + } } /// API version error handling diff --git a/mithril-client/src/lib.rs b/mithril-client/src/lib.rs index 2189767ed98..7b8576c09c2 100644 --- a/mithril-client/src/lib.rs +++ b/mithril-client/src/lib.rs @@ -16,3 +16,5 @@ pub mod utils; pub use entities::*; pub use message_adapters::{FromCertificateMessageAdapter, FromSnapshotMessageAdapter}; + +pub const MITHRIL_CLIENT_VERSION_HEADER: &str = "client-node-version"; diff --git a/openapi.yaml b/openapi.yaml index ea85ada4795..f41a5ddf989 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -362,8 +362,8 @@ paths: $ref: "#/components/schemas/Error" /statistics/snapshot: post: - summary: Increments download statistics - description: Increments snapshot download statistics + summary: Records snapshot download event + description: Records snapshot download event requestBody: description: Downloaded snapshot required: true @@ -373,9 +373,9 @@ paths: $ref: "#/components/schemas/SnapshotMessage" responses: "201": - description: Statistic succesfully posted + description: Event successfully recorded "400": - description: Increments download statistics bad request + description: Record event bad request content: application/json: schema: @@ -383,7 +383,7 @@ paths: "412": description: API version mismatch default: - description: Snapshot download statistics error + description: Record event error content: application/json: schema: From 2ed485b3f52fe26cf8e6b68b8c1b518decbe869a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20HUBERT=20/=20PALO-IT?= Date: Thu, 21 Sep 2023 10:09:28 +0200 Subject: [PATCH 5/5] update versions --- Cargo.lock | 4 ++-- docs/runbook/README.md | 2 +- docs/runbook/statistics/README.md | 2 +- docs/runbook/statistics/snapshot_downloads.sql | 3 +-- mithril-aggregator/Cargo.toml | 2 +- mithril-client/Cargo.toml | 2 +- .../src/aggregator_client/http_client.rs | 17 +++++++---------- mithril-client/src/lib.rs | 2 -- openapi.yaml | 2 +- 9 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1d85b2249fa..2bab6f555c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2154,7 +2154,7 @@ dependencies = [ [[package]] name = "mithril-aggregator" -version = "0.3.93" +version = "0.3.94" dependencies = [ "anyhow", "async-trait", @@ -2194,7 +2194,7 @@ dependencies = [ [[package]] name = "mithril-client" -version = "0.4.0" +version = "0.4.1" dependencies = [ "anyhow", "async-recursion", diff --git a/docs/runbook/README.md b/docs/runbook/README.md index 34dfe3f1159..64d0638c572 100644 --- a/docs/runbook/README.md +++ b/docs/runbook/README.md @@ -10,7 +10,7 @@ This page gathers the available guides to operate a Mithril network. |------------|------------|------------ | **Genesis manually** | [manual-genesis](./genesis-manually/README.md) | Proceed to manual (re)genesis of the aggregator certificate chain. | **Era markers** | [era-markers](./era-markers/README.md) | Create and update era markers on the Cardano chain. -| **Downloads statistics** | [downloads statistics](./statistics/README.md) | Display the number of downloads per day and per snapshot. +| **Downloads statistics** | [downloads statistics](./statistics/README.md) | Display the number of downloads per day. | **Signer registrations monitoring** | [registrations-monitoring](./registrations-monitoring/README.md) | Gather aggregated data about signer registrations (versions, stake, ...). | **Update protocol parameters** | [protocol-parameters](./protocol-parameters/README.md) | Update the protocol parameters of a Mithril network. | **Recompute certificates hash** | [recompute-certificates-hash](./recompute-certificates-hash/README.md) | Recompute the certificates has of an aggregator. diff --git a/docs/runbook/statistics/README.md b/docs/runbook/statistics/README.md index 7e3e40af22a..6d59d0e2454 100644 --- a/docs/runbook/statistics/README.md +++ b/docs/runbook/statistics/README.md @@ -1,6 +1,6 @@ # Statistics -## Snapshot downloads per snapshot per day +## Snapshot downloads per day ```sh $> sqlite3 -table -batch \ diff --git a/docs/runbook/statistics/snapshot_downloads.sql b/docs/runbook/statistics/snapshot_downloads.sql index 425c00a2364..67ab6592515 100644 --- a/docs/runbook/statistics/snapshot_downloads.sql +++ b/docs/runbook/statistics/snapshot_downloads.sql @@ -1,12 +1,11 @@ select - content->>'digest' as snapshot_digest, date(created_at) as downloaded_at, count(*) as downloads from event where source = 'HTTP::statistics' and action = 'snapshot_downloaded' -group by 1, 2 +group by 1 order by downloaded_at desc, downloads desc diff --git a/mithril-aggregator/Cargo.toml b/mithril-aggregator/Cargo.toml index f56fa884a53..3adb3519469 100644 --- a/mithril-aggregator/Cargo.toml +++ b/mithril-aggregator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-aggregator" -version = "0.3.93" +version = "0.3.94" description = "A Mithril Aggregator server" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-client/Cargo.toml b/mithril-client/Cargo.toml index a90e32a5232..faf4cfb4a98 100644 --- a/mithril-client/Cargo.toml +++ b/mithril-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-client" -version = "0.4.0" +version = "0.4.1" description = "A Mithril Client" authors = { workspace = true } edition = { workspace = true } diff --git a/mithril-client/src/aggregator_client/http_client.rs b/mithril-client/src/aggregator_client/http_client.rs index 0b3ec270562..0d79c496ccf 100644 --- a/mithril-client/src/aggregator_client/http_client.rs +++ b/mithril-client/src/aggregator_client/http_client.rs @@ -238,16 +238,13 @@ impl AggregatorClient for AggregatorHTTPClient { let url = format!("{}/{}", self.aggregator_endpoint.trim_end_matches('/'), url); let response = self.post(&url, json).await?; - let body = - response - .text() - .await - .map_err(|e| AggregatorHTTPClientError::SubsystemError { - message: "Could not find a text body in the response.".to_string(), - error: e.into(), - })?; - - Ok(body) + response + .text() + .await + .map_err(|e| AggregatorHTTPClientError::SubsystemError { + message: "Could not find a text body in the response.".to_string(), + error: e.into(), + }) } async fn download_unpack( diff --git a/mithril-client/src/lib.rs b/mithril-client/src/lib.rs index 7b8576c09c2..2189767ed98 100644 --- a/mithril-client/src/lib.rs +++ b/mithril-client/src/lib.rs @@ -16,5 +16,3 @@ pub mod utils; pub use entities::*; pub use message_adapters::{FromCertificateMessageAdapter, FromSnapshotMessageAdapter}; - -pub const MITHRIL_CLIENT_VERSION_HEADER: &str = "client-node-version"; diff --git a/openapi.yaml b/openapi.yaml index f41a5ddf989..cdf5b16aa6a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -4,7 +4,7 @@ info: # `mithril-common/src/lib.rs` file. If you plan to update it # here to reflect changes in the API, please also update the constant in the # Rust file. - version: 0.1.10 + version: 0.1.11 title: Mithril Aggregator Server description: | The REST API provided by a Mithril Aggregator Node in a Mithril network.