From bd1ce6ce72be7ede09fe583e142033533007b0d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Thu, 14 Mar 2024 18:00:50 +0100 Subject: [PATCH 01/13] Requests counter type --- Cargo.lock | 2 +- Cargo.toml | 3 ++- src/counter.rs | 17 +++++++++++++++++ src/main.rs | 14 +++++++++++++- 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 src/counter.rs diff --git a/Cargo.lock b/Cargo.lock index c302ee1..f7007ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3658,7 +3658,7 @@ dependencies = [ [[package]] name = "ya-gsb-http-proxy" version = "0.1.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=fb9a89b11c815b5b6b664ca6c8b1151524420aa3#fb9a89b11c815b5b6b664ca6c8b1151524420aa3" +source = "git+https://github.com/golemfactory/yagna.git?branch=pwalski/gsb_http_proxy_monitor#72143a807878cb0caadc5a1694112817a88071db" dependencies = [ "actix-http", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index fa91f3d..1453759 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,8 @@ flexi_logger = { version = "0.27", features = ["colors"] } regex = "1" reqwest = { version = "0.11", features = ["blocking", "json"] } async-stream = "0.3.5" -ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", rev = "fb9a89b11c815b5b6b664ca6c8b1151524420aa3" } +ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", branch = "pwalski/gsb_http_proxy_monitor" } +# ya-gsb-http-proxy = { path ="../yagna/exe-unit/components/gsb-http-proxy" } http = "0.2.11" bytes = "1.5.0" humantime = "2.1" diff --git a/src/counter.rs b/src/counter.rs new file mode 100644 index 0000000..64aedba --- /dev/null +++ b/src/counter.rs @@ -0,0 +1,17 @@ +use ya_gsb_http_proxy::monitor::{RequestMonitor, RequestsMonitor}; + + +#[derive(Clone, Copy, Debug)] +pub struct RequestsCounter {} + +impl RequestsMonitor for RequestsCounter { + fn on_request(&mut self) -> impl RequestMonitor { + RequestsCounter {} + } +} + +pub struct RequestCounter {} + +impl RequestMonitor for RequestsCounter { + fn on_response(self) {} +} diff --git a/src/main.rs b/src/main.rs index c6e467f..8a3b233 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ use actix::prelude::*; use anyhow::Context; use chrono::Utc; use clap::Parser; +use counter::RequestCounter; use futures::prelude::*; use ya_gsb_http_proxy::gsb_to_http::GsbToHttpProxy; use ya_gsb_http_proxy::message::GsbHttpCallMessage; @@ -22,17 +23,20 @@ use ya_client_model::activity::ExeScriptCommand; use ya_client_model::activity::{ActivityUsage, CommandResult, ExeScriptCommandResult}; use ya_core_model::activity; use ya_core_model::activity::RpcMessageError; +use ya_gsb_http_proxy::monitor::DisabledRequestsMonitor; use ya_service_bus::typed as gsb; use ya_transfer::transfer::{DeployImage, Shutdown, TransferService, TransferServiceContext}; use crate::agreement::AgreementDesc; use crate::cli::*; +use crate::counter::RequestsCounter; use crate::logger::*; use crate::process::ProcessController; use crate::signal::SignalMonitor; mod agreement; mod cli; +mod counter; mod logger; mod offer_template; mod process; @@ -58,6 +62,7 @@ async fn activity_loop( activity_id: &str, process: ProcessController, agreement: AgreementDesc, + counter: RequestsCounter, ) -> anyhow::Result<()> { let report_service = gsb::service(report_url); let start = Utc::now(); @@ -70,7 +75,9 @@ async fn activity_loop( if let Some(idx) = duration_idx { current_usage[idx] = duration.to_std()?.as_secs_f64(); + // fetch request counter data from aggregator } + match report_service .call(activity::local::SetUsage { activity_id: activity_id.to_string(), @@ -223,11 +230,14 @@ async fn run( model_path: None, }; + let counter = RequestsCounter {}; + let activity_pinger = activity_loop( report_url, activity_id, ctx.process_controller.clone(), ctx.agreement.clone(), + counter, ); #[cfg(target_os = "windows")] @@ -407,9 +417,11 @@ async fn run( }); gsb::bind_stream(&exe_unit_url, move |message: GsbHttpCallMessage| { + // inject request counter aggregator + let requests_monitor = counter.clone(); let mut proxy = GsbToHttpProxy { - // base_url: "http://10.30.13.8:7861/".to_string(), base_url: "http://localhost:7861/".to_string(), + requests_monitor, }; let stream = proxy.pass(message); Box::pin(stream.map(Ok)) From 246dde35bed938fb1a60df84b6ce858d0b8eff5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Fri, 15 Mar 2024 10:34:30 +0100 Subject: [PATCH 02/13] Counter module --- Cargo.lock | 9 +-- Cargo.toml | 6 +- src/counter.rs | 122 +++++++++++++++++++++++++++++-- src/counter/combined.rs | 0 src/counter/requests_duration.rs | 0 src/counter/requests_number.rs | 0 src/main.rs | 25 +++++-- 7 files changed, 141 insertions(+), 21 deletions(-) create mode 100644 src/counter/combined.rs create mode 100644 src/counter/requests_duration.rs create mode 100644 src/counter/requests_number.rs diff --git a/Cargo.lock b/Cargo.lock index f7007ed..af9e720 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1403,9 +1403,9 @@ dependencies = [ [[package]] name = "http" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes 1.5.0", "fnv", @@ -3658,7 +3658,6 @@ dependencies = [ [[package]] name = "ya-gsb-http-proxy" version = "0.1.0" -source = "git+https://github.com/golemfactory/yagna.git?branch=pwalski/gsb_http_proxy_monitor#72143a807878cb0caadc5a1694112817a88071db" dependencies = [ "actix-http", "actix-web", @@ -3666,7 +3665,7 @@ dependencies = [ "chrono", "futures 0.3.30", "futures-core", - "http 1.0.0", + "http 1.1.0", "log", "mockito", "reqwest", @@ -3706,7 +3705,7 @@ dependencies = [ "env_logger", "flexi_logger", "futures 0.3.30", - "http 0.2.11", + "http 1.1.0", "humantime", "humantime-serde", "log", diff --git a/Cargo.toml b/Cargo.toml index 1453759..615eeed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,9 +37,9 @@ flexi_logger = { version = "0.27", features = ["colors"] } regex = "1" reqwest = { version = "0.11", features = ["blocking", "json"] } async-stream = "0.3.5" -ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", branch = "pwalski/gsb_http_proxy_monitor" } -# ya-gsb-http-proxy = { path ="../yagna/exe-unit/components/gsb-http-proxy" } -http = "0.2.11" +# ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", branch = "pwalski/gsb_http_proxy_monitor" } +ya-gsb-http-proxy = { path ="../yagna/exe-unit/components/gsb-http-proxy" } +http = "1.1.0" bytes = "1.5.0" humantime = "2.1" humantime-serde = "1.1" diff --git a/src/counter.rs b/src/counter.rs index 64aedba..88abf5d 100644 --- a/src/counter.rs +++ b/src/counter.rs @@ -1,17 +1,125 @@ -use ya_gsb_http_proxy::monitor::{RequestMonitor, RequestsMonitor}; +use std::sync::Arc; +use chrono::{DateTime, Duration, Utc}; +use tokio::sync::RwLock; +use ya_gsb_http_proxy::monitor::{RequestsMonitor, ResponseMonitor}; -#[derive(Clone, Copy, Debug)] -pub struct RequestsCounter {} + +#[derive(Clone, Debug, Default)] +pub struct RequestsCounter { + counter: Arc>, +} impl RequestsMonitor for RequestsCounter { - fn on_request(&mut self) -> impl RequestMonitor { - RequestsCounter {} + async fn on_request(&mut self) -> impl ResponseMonitor { + let mut counter = self.counter.write().await; + counter.on_request(); + ResponseMonitorCombined { counted: false, counter: self.counter.clone() } + } +} + +#[derive(Clone, Debug, Default)] +struct ResponseMonitorCombined { + // failsafe flag to count response on Drop if not counted already. + counted: bool, + counter: Arc>, +} + +impl ResponseMonitor for ResponseMonitorCombined { + async fn on_response(mut self) { + let mut counter = self.counter.write().await; + if !self.counted { + self.counted = true; + counter.on_response().await; + } + } +} + +impl Drop for ResponseMonitorCombined { + fn drop(&mut self) { + let dropped = std::mem::replace(self, ResponseMonitorCombined::default()); + if !dropped.counted { + tokio::spawn(dropped.on_response()); + } + } +} + +#[derive(Clone, Copy, Debug, Default)] +struct RequestsCounterCombined { + duration_counter: RequestsDurationCounter, +} + +impl RequestsCounterCombined { + pub(crate) fn requests_duration(&self) -> f64 { + self.duration_counter.count() + } + + pub(crate) fn requests_count(&self) -> f64 { + 0.0 + } +} + +impl RequestsCounterCombined { + fn on_request(&mut self) { + self.duration_counter.on_request(); + //TODO call request number counter + } + + async fn on_response(&mut self) { + self.duration_counter.on_response(); + //TODO call request number counter } + } pub struct RequestCounter {} -impl RequestMonitor for RequestsCounter { - fn on_response(self) {} + +#[derive(Clone, Copy, Debug)] +pub struct RequestsDurationCounter { + duration: Duration, + active_requests_count: u16, + first_active_request_start_time: Option>, +} + +impl RequestsDurationCounter { + fn count(&self) -> f64 { + let duration_so_far = self.duration + self.active_request_duration(); + Self::duration_to_secs(duration_so_far) + } + + fn on_request(&mut self) { + self.active_requests_count += 1; + if self.first_active_request_start_time.is_none() { + self.first_active_request_start_time = Some(Utc::now()); + } + } + + fn on_response(&mut self) { + self.active_requests_count -= 1; + if self.active_requests_count == 0 { + self.duration = self.duration + self.active_request_duration(); + self.first_active_request_start_time = None; + } + + } + + fn active_request_duration(&self) -> Duration { + if let Some(active_request_start_time) = self.first_active_request_start_time { + let now = Utc::now(); + return now - active_request_start_time; + } + Duration::zero() + } + + fn duration_to_secs(duration: Duration) -> f64 { + duration.to_std().expect("Duration is bigger than 0").as_secs_f64() + } +} + +impl Default for RequestsDurationCounter { + fn default() -> Self { + let duration = Duration::zero(); + Self { duration, ..Default::default() } + } } diff --git a/src/counter/combined.rs b/src/counter/combined.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/counter/requests_duration.rs b/src/counter/requests_duration.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/counter/requests_number.rs b/src/counter/requests_number.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs index 8a3b233..a3c7a22 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,17 +67,30 @@ async fn activity_loop( let report_service = gsb::service(report_url); let start = Utc::now(); let mut current_usage = agreement.clean_usage_vector(); - let duration_idx = agreement.resolve_counter("golem.usage.duration_sec"); + let counter_duration_idx = agreement.resolve_counter("golem.usage.duration_sec"); + let counter_requests_duration_idx = agreement.resolve_counter("golem.usage.gpu-sec"); + let counter_requests_count_idx = agreement.resolve_counter("ai-runtime.requests"); while let Some(()) = process.report() { + + // Create duration counter type let now = Utc::now(); let duration = now - start; - - if let Some(idx) = duration_idx { + if let Some(idx) = counter_duration_idx { current_usage[idx] = duration.to_std()?.as_secs_f64(); - // fetch request counter data from aggregator } + if let Some(idx) = counter_requests_duration_idx { + // TODO make counter to return usage_vector, remove agreement from this function + // current_usage[idx] = counter.requests_duration(); + } + + if let Some(idx) = counter_requests_count_idx { + // TODO make counter to return usage_vector, remove agreement from this function + // current_usage[idx] = counter.requests_count(); + } + + match report_service .call(activity::local::SetUsage { activity_id: activity_id.to_string(), @@ -230,14 +243,14 @@ async fn run( model_path: None, }; - let counter = RequestsCounter {}; + let counter = RequestsCounter::default(); let activity_pinger = activity_loop( report_url, activity_id, ctx.process_controller.clone(), ctx.agreement.clone(), - counter, + counter.clone(), ); #[cfg(target_os = "windows")] From c00948cf043c7c1ee94745468b0eaf50a0431501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Fri, 15 Mar 2024 11:09:15 +0100 Subject: [PATCH 03/13] Rust toolchain 1.76.0 --- .github/workflows/release.yml | 3 ++- .github/workflows/tests.yml | 3 ++- rust-toolchain.toml | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 520404f..7ca4d8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,7 @@ on: - pre-rel-* env: CARGO_TERM_COLOR: always + rust_stable: 1.76.0 jobs: release: @@ -24,7 +25,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: - toolchain: 1.71.0 + toolchain: ${{ env.rust_stable }} components: clippy, rustfmt - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 11a2d42..17382c9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,6 +10,7 @@ on: branches: [ "main" ] env: CARGO_TERM_COLOR: always + rust_stable: 1.76.0 jobs: test: @@ -27,7 +28,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: - toolchain: 1.71.0 + toolchain: ${{ env.rust_stable }} components: clippy, rustfmt - uses: Swatinem/rust-cache@v2 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..338b945 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "1.76.0" +components = ["rustfmt", "clippy"] +targets = ["x86_64-unknown-linux-musl"] From 38db56400134118af5a96572ebe93e08f8f3db0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Fri, 15 Mar 2024 14:00:14 +0100 Subject: [PATCH 04/13] Counters type --- src/agreement.rs | 11 --- src/counter.rs | 199 +++++++++++++++++++++++++++++++++-------------- src/main.rs | 76 +++++++++--------- 3 files changed, 178 insertions(+), 108 deletions(-) diff --git a/src/agreement.rs b/src/agreement.rs index 6439945..31ccb37 100644 --- a/src/agreement.rs +++ b/src/agreement.rs @@ -27,17 +27,6 @@ impl AgreementDesc { Ok(AgreementDesc { counters, model }) } - - pub fn resolve_counter(&self, counter_id: &str) -> Option { - self.counters - .iter() - .enumerate() - .find_map(|(idx, name)| if name == counter_id { Some(idx) } else { None }) - } - - pub fn clean_usage_vector(&self) -> Vec { - self.counters.iter().map(|_| 0f64).collect() - } } #[cfg(test)] diff --git a/src/counter.rs b/src/counter.rs index 88abf5d..da6dc46 100644 --- a/src/counter.rs +++ b/src/counter.rs @@ -1,79 +1,158 @@ -use std::sync::Arc; +use std::{str::FromStr, sync::Arc}; +use anyhow::bail; use chrono::{DateTime, Duration, Utc}; use tokio::sync::RwLock; use ya_gsb_http_proxy::monitor::{RequestsMonitor, ResponseMonitor}; +type SharedCounters = Arc>>; #[derive(Clone, Debug, Default)] -pub struct RequestsCounter { - counter: Arc>, +pub struct Counters { + counters: SharedCounters, } -impl RequestsMonitor for RequestsCounter { - async fn on_request(&mut self) -> impl ResponseMonitor { - let mut counter = self.counter.write().await; - counter.on_request(); - ResponseMonitorCombined { counted: false, counter: self.counter.clone() } +impl Counters { + /// From list of Agreement counter names + /// Fails on unsupported counter + pub fn from_counters(counter_names: &Vec) -> anyhow::Result { + if counter_names.is_empty() { + bail!("Agreement has no counters"); + } + let mut counters = Vec::with_capacity(counter_names.len()); + for counter in counter_names { + let counter = SupportedCounter::from_str(counter)?; + counters.push(counter); + } + let counters = Arc::new(RwLock::new(counters)); + Ok(Self { counters }) + } + + /// Returns usage reported by counters in Agreement specified order. + /// None if Agreement had no counter names. + pub async fn current_usage(&self) -> Option> { + let counters = self.counters.read().await; + let current_usage = counters + .iter() + .map(Counter::count) + .collect(); + Some(current_usage) + } + + pub fn requests_monitor(&mut self) -> impl RequestsMonitor { + let counters = self.counters.clone(); + RequestsCounters { counters } } } -#[derive(Clone, Debug, Default)] -struct ResponseMonitorCombined { - // failsafe flag to count response on Drop if not counted already. - counted: bool, - counter: Arc>, +#[derive(Clone, Debug)] +enum SupportedCounter { + Duration(DisabledCounter), + RequestsDuration(RequestsDurationCounter), + RequestsCount(DisabledCounter), } -impl ResponseMonitor for ResponseMonitorCombined { - async fn on_response(mut self) { - let mut counter = self.counter.write().await; - if !self.counted { - self.counted = true; - counter.on_response().await; +impl FromStr for SupportedCounter { + + type Err = anyhow::Error; + + fn from_str(counter: &str) -> anyhow::Result { + match counter { + "golem.usage.duration_sec" => Ok(SupportedCounter::Duration(DisabledCounter::default())), + "golem.usage.gpu-sec" => Ok(SupportedCounter::RequestsDuration(Default::default())), + "ai-runtime.requests" => Ok(SupportedCounter::RequestsCount(DisabledCounter::default())), + _ => bail!("Unsupported counter: {}", counter), } } } -impl Drop for ResponseMonitorCombined { - fn drop(&mut self) { - let dropped = std::mem::replace(self, ResponseMonitorCombined::default()); - if !dropped.counted { - tokio::spawn(dropped.on_response()); +impl SupportedCounter { + fn request_monitoring_counter(&mut self) -> Option<&mut impl RequestMonitoringCounter> { + match self { + SupportedCounter::Duration(_) => None, + SupportedCounter::RequestsDuration(counter) => Some(counter), + SupportedCounter::RequestsCount(_) => None, } } } -#[derive(Clone, Copy, Debug, Default)] -struct RequestsCounterCombined { - duration_counter: RequestsDurationCounter, +impl Counter for SupportedCounter { + fn count(&self) -> f64 { + match self { + SupportedCounter::Duration(counter) => counter.count(), + SupportedCounter::RequestsDuration(counter) => counter.count(), + SupportedCounter::RequestsCount(counter) => counter.count(), + } + } } -impl RequestsCounterCombined { - pub(crate) fn requests_duration(&self) -> f64 { - self.duration_counter.count() - } - - pub(crate) fn requests_count(&self) -> f64 { +pub trait Counter { + fn count(&self) -> f64; +} + +#[derive(Clone, Debug, Default)] +struct DisabledCounter {} + +impl Counter for DisabledCounter { + fn count(&self) -> f64 { 0.0 } } -impl RequestsCounterCombined { - fn on_request(&mut self) { - self.duration_counter.on_request(); - //TODO call request number counter - } - - async fn on_response(&mut self) { - self.duration_counter.on_response(); - //TODO call request number counter +pub trait RequestMonitoringCounter: Counter { + fn on_request(&mut self); + fn on_response(&mut self); +} + +#[derive(Clone, Debug, Default)] +pub struct RequestsCounters { + counters: SharedCounters, +} + +impl RequestsMonitor for RequestsCounters { + async fn on_request(&mut self) -> impl ResponseMonitor { + let mut counters = self.counters.write().await; + for counter in &mut *counters { + if let Some(counter) = counter.request_monitoring_counter() { + counter.on_request(); + } + } + let counters = self.counters.clone(); + ResponseMonitors { counters, ..Default::default() } } - } -pub struct RequestCounter {} +#[derive(Clone, Debug, Default)] +struct ResponseMonitors { + counters: SharedCounters, + // failsafe flag to count response on Drop if not counted already. + counted: bool, +} + +impl ResponseMonitor for ResponseMonitors { + async fn on_response(mut self) { + let mut counters = self.counters.write().await; + if self.counted { + return; + }; + self.counted = true; + for counter in &mut *counters { + if let Some(counter) = counter.request_monitoring_counter() { + counter.on_response(); + } + } + } +} +// Failsafe for not calling `on_response`. +impl Drop for ResponseMonitors { + fn drop(&mut self) { + let dropped = std::mem::take(self); + if !dropped.counted { + tokio::spawn(dropped.on_response()); + } + } +} #[derive(Clone, Copy, Debug)] pub struct RequestsDurationCounter { @@ -83,10 +162,27 @@ pub struct RequestsDurationCounter { } impl RequestsDurationCounter { + fn duration_to_secs(duration: Duration) -> f64 { + duration.to_std().expect("Duration is bigger than 0").as_secs_f64() + } + + fn active_request_duration(&self) -> Duration { + if let Some(active_request_start_time) = self.first_active_request_start_time { + let now = Utc::now(); + return now - active_request_start_time; + } + Duration::zero() + } +} + +impl Counter for RequestsDurationCounter { fn count(&self) -> f64 { let duration_so_far = self.duration + self.active_request_duration(); Self::duration_to_secs(duration_so_far) } +} + +impl RequestMonitoringCounter for RequestsDurationCounter { fn on_request(&mut self) { self.active_requests_count += 1; @@ -101,25 +197,12 @@ impl RequestsDurationCounter { self.duration = self.duration + self.active_request_duration(); self.first_active_request_start_time = None; } - - } - - fn active_request_duration(&self) -> Duration { - if let Some(active_request_start_time) = self.first_active_request_start_time { - let now = Utc::now(); - return now - active_request_start_time; - } - Duration::zero() - } - - fn duration_to_secs(duration: Duration) -> f64 { - duration.to_std().expect("Duration is bigger than 0").as_secs_f64() } } impl Default for RequestsDurationCounter { fn default() -> Self { let duration = Duration::zero(); - Self { duration, ..Default::default() } + Self { duration, active_requests_count: 0, first_active_request_start_time: None } } } diff --git a/src/main.rs b/src/main.rs index a3c7a22..51dc1b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,11 +10,8 @@ use actix::prelude::*; use anyhow::Context; use chrono::Utc; use clap::Parser; -use counter::RequestCounter; +use counter::Counters; use futures::prelude::*; -use ya_gsb_http_proxy::gsb_to_http::GsbToHttpProxy; -use ya_gsb_http_proxy::message::GsbHttpCallMessage; - use process::Runtime; use tokio::select; use tokio::sync::{mpsc, mpsc::Receiver, mpsc::Sender}; @@ -23,13 +20,13 @@ use ya_client_model::activity::ExeScriptCommand; use ya_client_model::activity::{ActivityUsage, CommandResult, ExeScriptCommandResult}; use ya_core_model::activity; use ya_core_model::activity::RpcMessageError; -use ya_gsb_http_proxy::monitor::DisabledRequestsMonitor; +use ya_gsb_http_proxy::gsb_to_http::GsbToHttpProxy; +use ya_gsb_http_proxy::message::GsbHttpCallMessage; use ya_service_bus::typed as gsb; use ya_transfer::transfer::{DeployImage, Shutdown, TransferService, TransferServiceContext}; use crate::agreement::AgreementDesc; use crate::cli::*; -use crate::counter::RequestsCounter; use crate::logger::*; use crate::process::ProcessController; use crate::signal::SignalMonitor; @@ -61,42 +58,42 @@ async fn activity_loop( report_url: &str, activity_id: &str, process: ProcessController, - agreement: AgreementDesc, - counter: RequestsCounter, + // agreement: AgreementDesc, + counters: Counters, ) -> anyhow::Result<()> { let report_service = gsb::service(report_url); - let start = Utc::now(); - let mut current_usage = agreement.clean_usage_vector(); - let counter_duration_idx = agreement.resolve_counter("golem.usage.duration_sec"); - let counter_requests_duration_idx = agreement.resolve_counter("golem.usage.gpu-sec"); - let counter_requests_count_idx = agreement.resolve_counter("ai-runtime.requests"); + // let start = Utc::now(); + // let mut current_usage = agreement.clean_usage_vector(); + // let counter_duration_idx = agreement.resolve_counter("golem.usage.duration_sec"); + // let counter_requests_duration_idx = agreement.resolve_counter("golem.usage.gpu-sec"); + // let counter_requests_count_idx = agreement.resolve_counter("ai-runtime.requests"); while let Some(()) = process.report() { - - // Create duration counter type - let now = Utc::now(); - let duration = now - start; - if let Some(idx) = counter_duration_idx { - current_usage[idx] = duration.to_std()?.as_secs_f64(); - } - - if let Some(idx) = counter_requests_duration_idx { - // TODO make counter to return usage_vector, remove agreement from this function - // current_usage[idx] = counter.requests_duration(); - } - - if let Some(idx) = counter_requests_count_idx { - // TODO make counter to return usage_vector, remove agreement from this function - // current_usage[idx] = counter.requests_count(); - } - - + // // Create duration counter type + // let now = Utc::now(); + // let duration = now - start; + // if let Some(idx) = counter_duration_idx { + // current_usage[idx] = duration.to_std()?.as_secs_f64(); + // } + + // if let Some(idx) = counter_requests_duration_idx { + // // TODO make counter to return usage_vector, remove agreement from this function + // // current_usage[idx] = counter.requests_duration(); + // } + + // if let Some(idx) = counter_requests_count_idx { + // // TODO make counter to return usage_vector, remove agreement from this function + // // current_usage[idx] = counter.requests_count(); + // } + + let current_usage = counters.current_usage().await; + let timestamp = Utc::now().timestamp(); match report_service .call(activity::local::SetUsage { activity_id: activity_id.to_string(), usage: ActivityUsage { - current_usage: Some(current_usage.clone()), - timestamp: now.timestamp(), + current_usage, + timestamp, }, timeout: None, }) @@ -228,6 +225,8 @@ async fn run( let agreement = AgreementDesc::load(agreement_path)?; + let counters = Counters::from_counters(&agreement.counters)?; + let ctx = ExeUnitContext { activity_id: activity_id.clone(), report_url: report_url.clone(), @@ -243,14 +242,12 @@ async fn run( model_path: None, }; - let counter = RequestsCounter::default(); - let activity_pinger = activity_loop( report_url, activity_id, ctx.process_controller.clone(), - ctx.agreement.clone(), - counter.clone(), + // ctx.agreement.clone(), + counters.clone(), ); #[cfg(target_os = "windows")] @@ -429,9 +426,10 @@ async fn run( } }); + let mut counters = counters.clone(); gsb::bind_stream(&exe_unit_url, move |message: GsbHttpCallMessage| { // inject request counter aggregator - let requests_monitor = counter.clone(); + let requests_monitor = counters.requests_monitor(); let mut proxy = GsbToHttpProxy { base_url: "http://localhost:7861/".to_string(), requests_monitor, From 92b209ba9d931d289d8c89b698e8f3e05ec5a239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Fri, 15 Mar 2024 19:14:53 +0100 Subject: [PATCH 05/13] Duration counter --- src/counter.rs | 154 ++++++------------------------- src/counter/combined.rs | 62 +++++++++++++ src/counter/duration.rs | 21 +++++ src/counter/requests_duration.rs | 52 +++++++++++ 4 files changed, 165 insertions(+), 124 deletions(-) create mode 100644 src/counter/duration.rs diff --git a/src/counter.rs b/src/counter.rs index da6dc46..8e384a9 100644 --- a/src/counter.rs +++ b/src/counter.rs @@ -1,11 +1,18 @@ +mod combined; +mod duration; +mod requests_duration; +mod requests_number; + use std::{str::FromStr, sync::Arc}; use anyhow::bail; -use chrono::{DateTime, Duration, Utc}; +use chrono::Duration; use tokio::sync::RwLock; -use ya_gsb_http_proxy::monitor::{RequestsMonitor, ResponseMonitor}; +use ya_gsb_http_proxy::monitor::RequestsMonitor; + +use self::{combined::RequestsCounters, duration::DurationCounter, requests_duration::RequestsDurationCounter}; -type SharedCounters = Arc>>; +pub(self) type SharedCounters = Arc>>; #[derive(Clone, Debug, Default)] pub struct Counters { @@ -32,37 +39,34 @@ impl Counters { /// None if Agreement had no counter names. pub async fn current_usage(&self) -> Option> { let counters = self.counters.read().await; - let current_usage = counters - .iter() - .map(Counter::count) - .collect(); + let current_usage = counters.iter().map(Counter::count).collect(); Some(current_usage) } pub fn requests_monitor(&mut self) -> impl RequestsMonitor { let counters = self.counters.clone(); - RequestsCounters { counters } + RequestsCounters::new(counters) } } #[derive(Clone, Debug)] enum SupportedCounter { - Duration(DisabledCounter), + Duration(DurationCounter), RequestsDuration(RequestsDurationCounter), RequestsCount(DisabledCounter), } impl FromStr for SupportedCounter { - type Err = anyhow::Error; fn from_str(counter: &str) -> anyhow::Result { - match counter { - "golem.usage.duration_sec" => Ok(SupportedCounter::Duration(DisabledCounter::default())), - "golem.usage.gpu-sec" => Ok(SupportedCounter::RequestsDuration(Default::default())), - "ai-runtime.requests" => Ok(SupportedCounter::RequestsCount(DisabledCounter::default())), - _ => bail!("Unsupported counter: {}", counter), - } + let counter = match counter { + "golem.usage.duration_sec" => SupportedCounter::Duration(DurationCounter::default()), + "golem.usage.gpu-sec" => SupportedCounter::RequestsDuration(Default::default()), + "ai-runtime.requests" => SupportedCounter::RequestsCount(DisabledCounter::default()), + _ => bail!("Unsupported counter: {}", counter), + }; + return Ok(counter); } } @@ -78,15 +82,16 @@ impl SupportedCounter { impl Counter for SupportedCounter { fn count(&self) -> f64 { - match self { - SupportedCounter::Duration(counter) => counter.count(), - SupportedCounter::RequestsDuration(counter) => counter.count(), - SupportedCounter::RequestsCount(counter) => counter.count(), - } + let counter: &dyn Counter = match self { + SupportedCounter::Duration(counter) => counter, + SupportedCounter::RequestsDuration(counter) => counter, + SupportedCounter::RequestsCount(counter) => counter, + }; + counter.count() } } -pub trait Counter { +pub(self) trait Counter { fn count(&self) -> f64; } @@ -99,110 +104,11 @@ impl Counter for DisabledCounter { } } -pub trait RequestMonitoringCounter: Counter { +pub(self) trait RequestMonitoringCounter: Counter { fn on_request(&mut self); fn on_response(&mut self); } -#[derive(Clone, Debug, Default)] -pub struct RequestsCounters { - counters: SharedCounters, -} - -impl RequestsMonitor for RequestsCounters { - async fn on_request(&mut self) -> impl ResponseMonitor { - let mut counters = self.counters.write().await; - for counter in &mut *counters { - if let Some(counter) = counter.request_monitoring_counter() { - counter.on_request(); - } - } - let counters = self.counters.clone(); - ResponseMonitors { counters, ..Default::default() } - } -} - -#[derive(Clone, Debug, Default)] -struct ResponseMonitors { - counters: SharedCounters, - // failsafe flag to count response on Drop if not counted already. - counted: bool, -} - -impl ResponseMonitor for ResponseMonitors { - async fn on_response(mut self) { - let mut counters = self.counters.write().await; - if self.counted { - return; - }; - self.counted = true; - for counter in &mut *counters { - if let Some(counter) = counter.request_monitoring_counter() { - counter.on_response(); - } - } - } -} - -// Failsafe for not calling `on_response`. -impl Drop for ResponseMonitors { - fn drop(&mut self) { - let dropped = std::mem::take(self); - if !dropped.counted { - tokio::spawn(dropped.on_response()); - } - } -} - -#[derive(Clone, Copy, Debug)] -pub struct RequestsDurationCounter { - duration: Duration, - active_requests_count: u16, - first_active_request_start_time: Option>, -} - -impl RequestsDurationCounter { - fn duration_to_secs(duration: Duration) -> f64 { - duration.to_std().expect("Duration is bigger than 0").as_secs_f64() - } - - fn active_request_duration(&self) -> Duration { - if let Some(active_request_start_time) = self.first_active_request_start_time { - let now = Utc::now(); - return now - active_request_start_time; - } - Duration::zero() - } -} - -impl Counter for RequestsDurationCounter { - fn count(&self) -> f64 { - let duration_so_far = self.duration + self.active_request_duration(); - Self::duration_to_secs(duration_so_far) - } -} - -impl RequestMonitoringCounter for RequestsDurationCounter { - - fn on_request(&mut self) { - self.active_requests_count += 1; - if self.first_active_request_start_time.is_none() { - self.first_active_request_start_time = Some(Utc::now()); - } - } - - fn on_response(&mut self) { - self.active_requests_count -= 1; - if self.active_requests_count == 0 { - self.duration = self.duration + self.active_request_duration(); - self.first_active_request_start_time = None; - } - } -} - -impl Default for RequestsDurationCounter { - fn default() -> Self { - let duration = Duration::zero(); - Self { duration, active_requests_count: 0, first_active_request_start_time: None } - } +pub(self) fn duration_to_secs(duration: Duration) -> f64 { + duration.to_std().expect("Duration is bigger than 0").as_secs_f64() } diff --git a/src/counter/combined.rs b/src/counter/combined.rs index e69de29..9eeefba 100644 --- a/src/counter/combined.rs +++ b/src/counter/combined.rs @@ -0,0 +1,62 @@ +use ya_gsb_http_proxy::monitor::{RequestsMonitor, ResponseMonitor}; + +use super::{SharedCounters, RequestMonitoringCounter}; + +#[derive(Clone, Debug, Default)] +pub(super) struct RequestsCounters { + counters: SharedCounters, +} + +impl RequestsCounters { + pub(super) fn new(counters: SharedCounters) -> Self { + Self { counters } + } +} + +impl RequestsMonitor for RequestsCounters { + async fn on_request(&mut self) -> impl ResponseMonitor { + let mut counters = self.counters.write().await; + for counter in &mut *counters { + if let Some(counter) = counter.request_monitoring_counter() { + counter.on_request(); + } + } + let counters = self.counters.clone(); + ResponseMonitors { + counters, + ..Default::default() + } + } +} + +#[derive(Clone, Debug, Default)] +struct ResponseMonitors { + counters: SharedCounters, + // failsafe flag to count response on Drop if not counted already. + counted: bool, +} + +impl ResponseMonitor for ResponseMonitors { + async fn on_response(mut self) { + let mut counters = self.counters.write().await; + if self.counted { + return; + }; + self.counted = true; + for counter in &mut *counters { + if let Some(counter) = counter.request_monitoring_counter() { + counter.on_response(); + } + } + } +} + +// Failsafe for not calling `on_response`. +impl Drop for ResponseMonitors { + fn drop(&mut self) { + let dropped = std::mem::take(self); + if !dropped.counted { + tokio::spawn(dropped.on_response()); + } + } +} diff --git a/src/counter/duration.rs b/src/counter/duration.rs new file mode 100644 index 0000000..0d69102 --- /dev/null +++ b/src/counter/duration.rs @@ -0,0 +1,21 @@ +use chrono::{DateTime, Utc}; + +use super::{duration_to_secs, Counter}; + +#[derive(Clone, Debug)] +pub(super) struct DurationCounter { + start: DateTime +} + +impl Default for DurationCounter { + fn default() -> Self { + Self { start: Utc::now() } + } +} + +impl Counter for DurationCounter { + fn count(&self) -> f64 { + let duration = self.start - Utc::now(); + duration_to_secs(duration) + } +} diff --git a/src/counter/requests_duration.rs b/src/counter/requests_duration.rs index e69de29..067cb71 100644 --- a/src/counter/requests_duration.rs +++ b/src/counter/requests_duration.rs @@ -0,0 +1,52 @@ +use chrono::{DateTime, Duration, Utc}; + +use super::{Counter, RequestMonitoringCounter}; + +#[derive(Clone, Copy, Debug)] +pub(super) struct RequestsDurationCounter { + duration: Duration, + active_requests_count: u16, + first_active_request_start_time: Option>, +} + +impl RequestsDurationCounter { + fn active_request_duration(&self) -> Duration { + if let Some(active_request_start_time) = self.first_active_request_start_time { + let now = Utc::now(); + return now - active_request_start_time; + } + Duration::zero() + } +} + +impl Counter for RequestsDurationCounter { + fn count(&self) -> f64 { + let duration_so_far = self.duration + self.active_request_duration(); + super::duration_to_secs(duration_so_far) + } +} + +impl RequestMonitoringCounter for RequestsDurationCounter { + + fn on_request(&mut self) { + self.active_requests_count += 1; + if self.first_active_request_start_time.is_none() { + self.first_active_request_start_time = Some(Utc::now()); + } + } + + fn on_response(&mut self) { + self.active_requests_count -= 1; + if self.active_requests_count == 0 { + self.duration = self.duration + self.active_request_duration(); + self.first_active_request_start_time = None; + } + } +} + +impl Default for RequestsDurationCounter { + fn default() -> Self { + let duration = Duration::zero(); + Self { duration, active_requests_count: 0, first_active_request_start_time: None } + } +} From 684dc081d66584c899ee78e2180603e29ce51a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Fri, 15 Mar 2024 19:48:22 +0100 Subject: [PATCH 06/13] Yagna rev update. Old counters code cleanup. --- Cargo.lock | 2225 ++++++++++++++++++++++++++++++-- Cargo.toml | 19 +- src/counter.rs | 39 +- src/counter/combined.rs | 8 +- src/counter/duration.rs | 2 +- src/counter/requests.rs | 21 + src/counter/requests_number.rs | 0 src/main.rs | 25 - 8 files changed, 2193 insertions(+), 146 deletions(-) create mode 100644 src/counter/requests.rs delete mode 100644 src/counter/requests_number.rs diff --git a/Cargo.lock b/Cargo.lock index af9e720..45f969e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,14 +13,14 @@ dependencies = [ "actix_derive", "bitflags 2.4.1", "bytes 1.5.0", - "crossbeam-channel", + "crossbeam-channel 0.5.11", "futures-core", "futures-sink", "futures-task", "futures-util", "log", "once_cell", - "parking_lot", + "parking_lot 0.12.1", "pin-project-lite", "smallvec", "tokio", @@ -44,6 +44,29 @@ dependencies = [ "tracing", ] +[[package]] +name = "actix-files" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf0bdd6ff79de7c9a021f5d9ea79ce23e108d8bfc9b49b5b4a2cf6fad5a35212" +dependencies = [ + "actix-http", + "actix-service", + "actix-utils", + "actix-web", + "bitflags 2.4.1", + "bytes 1.5.0", + "derive_more", + "futures-core", + "http-range", + "log", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "v_htmlescape", +] + [[package]] name = "actix-http" version = "3.5.1" @@ -54,8 +77,8 @@ dependencies = [ "actix-rt", "actix-service", "actix-utils", - "ahash", - "base64", + "ahash 0.8.7", + "base64 0.21.7", "bitflags 2.4.1", "brotli", "bytes 1.5.0", @@ -159,14 +182,16 @@ dependencies = [ "impl-more", "openssl", "pin-project-lite", - "rustls", + "rustls 0.21.10", "rustls-webpki", "tokio", "tokio-openssl", - "tokio-rustls", + "tokio-rustls 0.23.4", + "tokio-rustls 0.24.1", "tokio-util", "tracing", - "webpki-roots", + "webpki-roots 0.22.6", + "webpki-roots 0.25.3", ] [[package]] @@ -194,7 +219,7 @@ dependencies = [ "actix-service", "actix-utils", "actix-web-codegen", - "ahash", + "ahash 0.8.7", "bytes 1.5.0", "bytestring", "cfg-if 1.0.0", @@ -219,6 +244,24 @@ dependencies = [ "url", ] +[[package]] +name = "actix-web-actors" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "420b001bb709d8510c3e2659dae046e54509ff9528018d09c78381e765a1f9fa" +dependencies = [ + "actix", + "actix-codec", + "actix-http", + "actix-web", + "bytes 1.5.0", + "bytestring", + "futures-core", + "pin-project-lite", + "tokio", + "tokio-util", +] + [[package]] name = "actix-web-codegen" version = "4.2.2" @@ -257,6 +300,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.8.7" @@ -294,6 +348,12 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "android-tzdata" version = "0.1.1" @@ -320,9 +380,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.7" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" dependencies = [ "anstyle", "anstyle-parse", @@ -334,9 +394,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -372,6 +432,18 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +[[package]] +name = "arc-swap" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dabe5a181f83789739c194cbe5a897dde195078fac08568d09221fd6137a7ba8" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "assert-json-diff" version = "2.0.2" @@ -447,6 +519,24 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-shim" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d20fdac7156779a1a30d970e838195558b4810dd06aa69e7c7461bdc518edf9b" +dependencies = [ + "crossbeam", +] + [[package]] name = "atty" version = "0.2.14" @@ -476,7 +566,7 @@ dependencies = [ "actix-service", "actix-tls", "actix-utils", - "base64", + "base64 0.21.7", "bytes 1.5.0", "cfg-if 1.0.0", "cookie", @@ -492,7 +582,8 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rand 0.8.5", - "rustls", + "rustls 0.20.9", + "rustls 0.21.10", "serde", "serde_json", "serde_urlencoded", @@ -514,12 +605,24 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "base64" version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bigdecimal" version = "0.2.2" @@ -543,6 +646,30 @@ name = "bitflags" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +dependencies = [ + "serde", +] + +[[package]] +name = "bitmaps" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" +dependencies = [ + "typenum", +] + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] [[package]] name = "block-buffer" @@ -574,6 +701,69 @@ dependencies = [ "byte-tools", ] +[[package]] +name = "bollard" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af254ed2da4936ef73309e9597180558821cb16ae9bba4cb24ce6b612d8d80ed" +dependencies = [ + "base64 0.21.7", + "bollard-stubs", + "bytes 1.5.0", + "futures-core", + "futures-util", + "hex", + "http 0.2.11", + "hyper", + "hyperlocal", + "log", + "pin-project-lite", + "serde", + "serde_derive", + "serde_json", + "serde_repr", + "serde_urlencoded", + "thiserror", + "tokio", + "tokio-util", + "url", + "winapi", +] + +[[package]] +name = "bollard-stubs" +version = "1.42.0-rc.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "602bda35f33aeb571cef387dcd4042c643a8bf689d8aaac2cc47ea24cb7bc7e0" +dependencies = [ + "serde", + "serde_with", +] + +[[package]] +name = "borsh" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd" +dependencies = [ + "once_cell", + "proc-macro-crate 3.1.0", + "proc-macro2", + "quote", + "syn 2.0.48", + "syn_derive", +] + [[package]] name = "brotli" version = "3.4.0" @@ -612,12 +802,40 @@ version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + [[package]] name = "byte-tools" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +[[package]] +name = "bytecheck" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "byteorder" version = "1.5.0" @@ -698,6 +916,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "chrono" version = "0.4.31" @@ -768,6 +992,15 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "cmake" version = "0.1.50" @@ -793,6 +1026,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "convert_case" version = "0.4.0" @@ -835,6 +1074,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.3.2" @@ -844,13 +1098,94 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "crossbeam" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e" +dependencies = [ + "cfg-if 0.1.10", + "crossbeam-channel 0.4.4", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue 0.2.3", + "crossbeam-utils 0.7.2", +] + +[[package]] +name = "crossbeam-channel" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" +dependencies = [ + "crossbeam-utils 0.7.2", + "maybe-uninit", +] + [[package]] name = "crossbeam-channel" version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" dependencies = [ - "crossbeam-utils", + "crossbeam-utils 0.8.19", +] + +[[package]] +name = "crossbeam-deque" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils 0.7.2", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +dependencies = [ + "autocfg", + "cfg-if 0.1.10", + "crossbeam-utils 0.7.2", + "lazy_static", + "maybe-uninit", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-queue" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" +dependencies = [ + "cfg-if 0.1.10", + "crossbeam-utils 0.7.2", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +dependencies = [ + "crossbeam-utils 0.8.19", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg", + "cfg-if 0.1.10", + "lazy_static", ] [[package]] @@ -859,6 +1194,12 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -869,6 +1210,33 @@ dependencies = [ "typenum", ] +[[package]] +name = "ctor" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "data-encoding" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" + +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "deranged" version = "0.3.11" @@ -876,6 +1244,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -913,7 +1282,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", + "subtle", ] [[package]] @@ -949,6 +1320,12 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + [[package]] name = "dummy" version = "0.1.0" @@ -958,6 +1335,9 @@ name = "either" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +dependencies = [ + "serde", +] [[package]] name = "encoding_rs" @@ -969,8 +1349,30 @@ dependencies = [ ] [[package]] -name = "env_logger" -version = "0.10.1" +name = "enum-as-inner" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ @@ -981,12 +1383,152 @@ dependencies = [ "termcolor", ] +[[package]] +name = "env_logger" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "erc20_payment_lib" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bbea905b6390c599da94e4222895e4c904671abe8785e7d7a1c696d6f6a845f" +dependencies = [ + "actix", + "actix-files", + "actix-web", + "actix-web-actors", + "awc", + "chrono", + "dotenv", + "erc20_payment_lib_common", + "erc20_rpc_pool", + "fastrand", + "futures 0.3.30", + "futures-util", + "hex", + "humantime", + "lazy_static", + "log", + "metrics", + "rand 0.8.5", + "regex", + "rust_decimal", + "rustc-hex", + "secp256k1", + "serde", + "serde_json", + "sha3 0.10.8", + "sqlx", + "structopt", + "thunderdome", + "tokio", + "tokio-stream", + "toml", + "trust-dns-resolver", + "url", + "uuid 1.7.0", + "web3", +] + +[[package]] +name = "erc20_payment_lib_common" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8349085a0b6916f934112a80ad78534b05bcb74d382987e32664e85b61c3be" +dependencies = [ + "actix-files", + "actix-web", + "anyhow", + "awc", + "chrono", + "dotenv", + "env_logger 0.10.1", + "fastrand", + "futures 0.3.30", + "futures-util", + "hex", + "humantime", + "lazy_static", + "log", + "metrics", + "metrics-core", + "metrics-runtime", + "rand 0.8.5", + "regex", + "rust_decimal", + "rustc-hex", + "secp256k1", + "serde", + "serde_json", + "sha3 0.10.8", + "sqlx", + "structopt", + "thunderdome", + "tokio", + "toml", + "trust-dns-resolver", + "url", + "uuid 1.7.0", + "web3", +] + +[[package]] +name = "erc20_rpc_pool" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aa63b091ec67dded9c02181b7dfc6787b955680f9124740b99b44d90f77f331" +dependencies = [ + "actix-files", + "actix-web", + "anyhow", + "awc", + "bollard", + "chrono", + "dotenv", + "env_logger 0.10.1", + "erc20_payment_lib_common", + "fastrand", + "futures 0.3.30", + "futures-util", + "hex", + "humantime", + "lazy_static", + "log", + "metrics", + "parking_lot 0.12.1", + "rand 0.8.5", + "reqwest", + "rust_decimal", + "rustc-hex", + "secp256k1", + "serde", + "serde_json", + "sha3 0.10.8", + "sqlx", + "structopt", + "thunderdome", + "tokio", + "toml", + "trust-dns-resolver", + "uuid 1.7.0", + "web3", +] + [[package]] name = "errno" version = "0.3.8" @@ -997,6 +1539,67 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if 1.0.0", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "ethabi" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" +dependencies = [ + "ethereum-types", + "hex", + "once_cell", + "regex", + "serde", + "serde_json", + "sha3 0.10.8", + "thiserror", + "uint", +] + +[[package]] +name = "ethbloom" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" +dependencies = [ + "crunchy", + "fixed-hash", + "impl-rlp", + "impl-serde", + "tiny-keccak", +] + +[[package]] +name = "ethereum-types" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" +dependencies = [ + "ethbloom", + "fixed-hash", + "impl-rlp", + "impl-serde", + "primitive-types", + "uint", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + [[package]] name = "fastrand" version = "2.0.1" @@ -1015,6 +1618,24 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "finl_unicode" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand 0.8.5", + "rustc-hex", + "static_assertions", +] + [[package]] name = "fixedbitset" version = "0.2.0" @@ -1052,14 +1673,13 @@ dependencies = [ [[package]] name = "flexi_logger" -version = "0.27.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac35b454b60e1836602173e2eb7ef531173388c0212e02ec7f9fac086159ee5" +checksum = "f248c29a6d4bc5d065c9e9068d858761a0dcd796759f7801cc14db35db23abd8" dependencies = [ "chrono", "glob", "is-terminal", - "lazy_static", "log", "nu-ansi-term", "regex", @@ -1075,6 +1695,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "futures-core", + "futures-sink", + "spin 0.9.8", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1111,6 +1742,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures" version = "0.1.31" @@ -1159,6 +1796,17 @@ dependencies = [ "futures-util", ] +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api 0.4.11", + "parking_lot 0.12.1", +] + [[package]] name = "futures-io" version = "0.3.30" @@ -1188,6 +1836,12 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +[[package]] +name = "futures-timer" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" + [[package]] name = "futures-util" version = "0.3.30" @@ -1249,7 +1903,7 @@ dependencies = [ [[package]] name = "gftp" version = "0.4.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=fb9a89b11c815b5b6b664ca6c8b1151524420aa3#fb9a89b11c815b5b6b664ca6c8b1151524420aa3" +source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" dependencies = [ "actix-rt", "anyhow", @@ -1259,7 +1913,7 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", - "sha3", + "sha3 0.8.2", "structopt", "thiserror", "tokio", @@ -1338,12 +1992,62 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.8", +] [[package]] name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash 0.8.7", + "allocator-api2", +] + +[[package]] +name = "hashlink" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" +dependencies = [ + "hashbrown 0.14.3", +] + +[[package]] +name = "hdrhistogram" +version = "6.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d331ebcdbca4acbefe5da8c3299b2e246f198a8294cc5163354e743398b89d" +dependencies = [ + "byteorder", + "num-traits", +] + +[[package]] +name = "headers" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" +dependencies = [ + "base64 0.21.7", + "bytes 1.5.0", + "headers-core", + "http 0.2.11", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http 0.2.11", +] [[package]] name = "heck" @@ -1359,6 +2063,9 @@ name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] [[package]] name = "hermit-abi" @@ -1381,6 +2088,24 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "home" version = "0.5.9" @@ -1390,6 +2115,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + [[package]] name = "http" version = "0.2.11" @@ -1423,6 +2159,12 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "http-range" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" + [[package]] name = "httparse" version = "1.8.0" @@ -1475,6 +2217,20 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.11", + "hyper", + "rustls 0.21.10", + "tokio", + "tokio-rustls 0.24.1", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -1489,14 +2245,27 @@ dependencies = [ ] [[package]] -name = "iana-time-zone" -version = "0.1.59" +name = "hyperlocal" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "0fafdf7b2b2de7c9784f76e02c0935e65a8117ec3b768644379983ab333ac98c" dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", + "futures-util", + "hex", + "hyper", + "pin-project 1.1.5", + "tokio", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", "js-sys", "wasm-bindgen", "windows-core", @@ -1511,6 +2280,16 @@ dependencies = [ "cc", ] +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "idna" version = "0.5.0" @@ -1521,12 +2300,64 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "im" +version = "15.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" +dependencies = [ + "bitmaps", + "rand_core 0.6.4", + "rand_xoshiro", + "sized-chunks", + "typenum", + "version_check", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + [[package]] name = "impl-more" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206ca75c9c03ba3d4ace2460e57b189f39f43de612c2f85836e65c929701bb2d" +[[package]] +name = "impl-rlp" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" +dependencies = [ + "rlp", +] + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -1535,6 +2366,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", + "serde", ] [[package]] @@ -1547,6 +2379,18 @@ dependencies = [ "hashbrown 0.14.3", ] +[[package]] +name = "ipconfig" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" +dependencies = [ + "socket2", + "widestring", + "windows-sys 0.48.0", + "winreg", +] + [[package]] name = "ipnet" version = "2.9.0" @@ -1582,6 +2426,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.10" @@ -1606,6 +2459,21 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonrpc-core" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" +dependencies = [ + "futures 0.3.30", + "futures-executor", + "futures-util", + "log", + "serde", + "serde_derive", + "serde_json", +] + [[package]] name = "keccak" version = "0.1.5" @@ -1626,6 +2494,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] [[package]] name = "libc" @@ -1633,6 +2504,12 @@ version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + [[package]] name = "libredox" version = "0.0.1" @@ -1644,6 +2521,17 @@ dependencies = [ "redox_syscall 0.4.1", ] +[[package]] +name = "libsqlite3-sys" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -1673,6 +2561,15 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" +[[package]] +name = "lock_api" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +dependencies = [ + "scopeguard", +] + [[package]] name = "lock_api" version = "0.4.11" @@ -1689,6 +2586,15 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "lzma-sys" version = "0.1.20" @@ -1700,12 +2606,43 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if 1.0.0", + "digest 0.10.7", +] + [[package]] name = "memchr" version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +[[package]] +name = "memoffset" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +dependencies = [ + "autocfg", +] + [[package]] name = "metrics" version = "0.12.1" @@ -1721,12 +2658,93 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c064b3a1ff41f4bf6c91185c8a0caeccf8a8a27e9d0f92cc54cf3dbec812f48" +[[package]] +name = "metrics-observer-json" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe930460a6c336b8f873dcfb28da3f805fd0dbadbea7beaf3042c7fb1d9fcd3" +dependencies = [ + "hdrhistogram", + "metrics-core", + "metrics-util", + "serde_json", +] + +[[package]] +name = "metrics-observer-prometheus" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bfe24ad8285ef8b239232135a65f89cc5fa4690bbfaf8907f4bef38f8b08eba" +dependencies = [ + "hdrhistogram", + "metrics-core", + "metrics-util", +] + +[[package]] +name = "metrics-observer-yaml" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83f66811013592560efc75d75a92d6e2f415a11b52f085e51d9fb4d1edec6335" +dependencies = [ + "hdrhistogram", + "metrics-core", + "metrics-util", + "serde_yaml", +] + +[[package]] +name = "metrics-runtime" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce0e4f69639ccc0c6b2f0612164f9817349eb25545ed1ffb5ef3e1e1c1d220b4" +dependencies = [ + "arc-swap", + "atomic-shim", + "crossbeam-utils 0.7.2", + "im", + "metrics", + "metrics-core", + "metrics-observer-json", + "metrics-observer-prometheus", + "metrics-observer-yaml", + "metrics-util", + "parking_lot 0.10.2", + "quanta", +] + +[[package]] +name = "metrics-util" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "277619f040719a5a23d75724586d5601286e8fa53451cfaaca3b8c627c2c2378" +dependencies = [ + "crossbeam-epoch", + "serde", +] + [[package]] name = "mime" version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.5.4" @@ -1800,6 +2818,16 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "normalize-line-endings" version = "0.3.0" @@ -1826,6 +2854,23 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -1836,6 +2881,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.17" @@ -1843,6 +2899,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -1870,7 +2927,7 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -1941,14 +2998,64 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "parity-scale-codec" +version = "3.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +dependencies = [ + "proc-macro-crate 2.0.0", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "parking_lot" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +dependencies = [ + "lock_api 0.3.4", + "parking_lot_core 0.7.3", +] + [[package]] name = "parking_lot" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "lock_api", - "parking_lot_core", + "lock_api 0.4.11", + "parking_lot_core 0.9.9", +] + +[[package]] +name = "parking_lot_core" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b93f386bb233083c799e6e642a9d73db98c24a5deeb95ffc85bf281255dffc98" +dependencies = [ + "cfg-if 0.1.10", + "cloudabi", + "libc", + "redox_syscall 0.1.57", + "smallvec", + "winapi", ] [[package]] @@ -1970,6 +3077,15 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -2013,20 +3129,40 @@ version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ef0f924a5ee7ea9cbcea77529dba45f8a9ba9f622419fe3386ca581a3ae9d5a" dependencies = [ - "pin-project-internal", + "pin-project-internal 0.4.30", ] [[package]] -name = "pin-project-internal" -version = "0.4.30" +name = "pin-project" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "851c8d0ce9bebe43790dedfc86614c23494ac9f423dd618d3a61fc693eafe61e" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal 1.1.5", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "851c8d0ce9bebe43790dedfc86614c23494ac9f423dd618d3a61fc693eafe61e" dependencies = [ "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -2039,6 +3175,27 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.28" @@ -2087,6 +3244,19 @@ dependencies = [ "termtree", ] +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "uint", +] + [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -2094,7 +3264,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +dependencies = [ + "toml_edit 0.20.7", +] + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.1", ] [[package]] @@ -2236,6 +3424,44 @@ dependencies = [ "prost 0.10.4", ] +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quanta" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21484fda3d8ad7affee37755c77a5d0da527543f0af0c7f731c14e2215645d39" +dependencies = [ + "atomic-shim", + "ctor", + "libc", + "winapi", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" version = "1.0.35" @@ -2245,6 +3471,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.4.6" @@ -2303,6 +3535,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_xoshiro" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" +dependencies = [ + "rand_core 0.6.4", +] + [[package]] name = "rdrand" version = "0.4.0" @@ -2312,6 +3553,12 @@ dependencies = [ "rand_core 0.3.1", ] +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + [[package]] name = "redox_syscall" version = "0.3.5" @@ -2379,13 +3626,22 @@ dependencies = [ "winapi", ] +[[package]] +name = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + [[package]] name = "reqwest" version = "0.11.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ - "base64", + "base64 0.21.7", "bytes 1.5.0", "encoding_rs", "futures-core", @@ -2394,6 +3650,7 @@ dependencies = [ "http 0.2.11", "http-body", "hyper", + "hyper-rustls", "hyper-tls", "ipnet", "js-sys", @@ -2403,20 +3660,49 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls 0.21.10", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "system-configuration", "tokio", "tokio-native-tls", + "tokio-rustls 0.24.1", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots 0.25.3", "winreg", ] +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin 0.5.2", + "untrusted 0.7.1", + "web-sys", + "winapi", +] + [[package]] name = "ring" version = "0.17.7" @@ -2426,17 +3712,98 @@ dependencies = [ "cc", "getrandom", "libc", - "spin", - "untrusted", + "spin 0.9.8", + "untrusted 0.9.0", "windows-sys 0.48.0", ] +[[package]] +name = "rkyv" +version = "0.7.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" +dependencies = [ + "bitvec", + "bytecheck", + "bytes 1.5.0", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid 1.7.0", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes 1.5.0", + "rustc-hex", +] + +[[package]] +name = "rsa" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +dependencies = [ + "const-oid", + "digest 0.10.7", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", +] + +[[package]] +name = "rust_decimal" +version = "1.34.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39449a79f45e8da28c57c341891b69a183044b29518bb8f86dbac9df60bb7df" +dependencies = [ + "arrayvec", + "borsh", + "bytes 1.5.0", + "num-traits", + "rand 0.8.5", + "rkyv", + "serde", + "serde_json", +] + [[package]] name = "rustc-demangle" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + [[package]] name = "rustc_version" version = "0.4.0" @@ -2459,6 +3826,18 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" +dependencies = [ + "log", + "ring 0.16.20", + "sct", + "webpki", +] + [[package]] name = "rustls" version = "0.21.10" @@ -2466,19 +3845,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", - "ring", + "ring 0.17.7", "rustls-webpki", "sct", ] +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + [[package]] name = "rustls-webpki" version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring", - "untrusted", + "ring 0.17.7", + "untrusted 0.9.0", ] [[package]] @@ -2529,8 +3917,32 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring", - "untrusted", + "ring 0.17.7", + "untrusted 0.9.0", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "secp256k1" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +dependencies = [ + "cc", ] [[package]] @@ -2611,9 +4023,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -2631,6 +4043,26 @@ dependencies = [ "serde_json", ] +[[package]] +name = "serde_repr" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2643,6 +4075,21 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" +dependencies = [ + "base64 0.13.1", + "chrono", + "hex", + "indexmap 1.9.3", + "serde", + "serde_json", + "time 0.3.31", +] + [[package]] name = "serde_yaml" version = "0.8.26" @@ -2666,6 +4113,17 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "sha3" version = "0.8.2" @@ -2679,6 +4137,16 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -2689,42 +4157,313 @@ dependencies = [ ] [[package]] -name = "similar" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" - -[[package]] -name = "slab" -version = "0.4.9" +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + +[[package]] +name = "similar" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" + +[[package]] +name = "sized-chunks" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" +dependencies = [ + "bitmaps", + "typenum", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" + +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api 0.4.11", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlformat" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce81b7bd7c4493975347ef60d8c7e8b742d4694f4c49f93e0a12ea263938176c" +dependencies = [ + "itertools 0.12.1", + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9a2ccff1a000a5a59cd33da541d9f2fdcd9e6e8229cc200565942bff36d0aaa" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24ba59a9342a3d9bab6c56c118be528b27c9b60e490080e9711a04dccac83ef6" +dependencies = [ + "ahash 0.8.7", + "atoi", + "byteorder", + "bytes 1.5.0", + "chrono", + "crc", + "crossbeam-queue 0.3.11", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap 2.1.0", + "log", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "url", +] + +[[package]] +name = "sqlx-macros" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea40e2345eb2faa9e1e5e326db8c34711317d2b5e08d0d5741619048a803127" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5833ef53aaa16d860e92123292f1f6a3d53c34ba8b1969f152ef1a7bb803f3c8" +dependencies = [ + "dotenvy", + "either", + "heck 0.4.1", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 1.0.109", + "tempfile", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ed31390216d20e538e447a7a9b959e06ed9fc51c37b514b46eb758016ecd418" +dependencies = [ + "atoi", + "base64 0.21.7", + "bitflags 2.4.1", + "byteorder", + "bytes 1.5.0", + "chrono", + "crc", + "digest 0.10.7", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array 0.14.7", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand 0.8.5", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c824eb80b894f926f89a0b9da0c7f435d27cdd35b8c655b114e58223918577e" +dependencies = [ + "atoi", + "base64 0.21.7", + "bitflags 2.4.1", + "byteorder", + "chrono", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand 0.8.5", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +checksum = "b244ef0a8414da0bed4bb1910426e890b19e5e9bccc27ada6b797d05c55ae0aa" dependencies = [ - "autocfg", + "atoi", + "chrono", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "tracing", + "url", + "urlencoding", ] [[package]] -name = "smallvec" -version = "1.12.0" +name = "static_assertions" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] -name = "socket2" -version = "0.5.5" +name = "stringprep" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6" dependencies = [ - "libc", - "windows-sys 0.48.0", + "finl_unicode", + "unicode-bidi", + "unicode-normalization", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "strsim" version = "0.8.0" @@ -2772,6 +4511,9 @@ name = "strum" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros 0.24.3", +] [[package]] name = "strum_macros" @@ -2798,6 +4540,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + [[package]] name = "syn" version = "1.0.109" @@ -2820,6 +4568,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -2841,6 +4601,12 @@ dependencies = [ "libc", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tempdir" version = "0.3.7" @@ -2908,6 +4674,12 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "thunderdome" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e170f93360bf9ae6fe3c31116bbf27adb1d054cedd6bc3d7857e34f2d98d0b" + [[package]] name = "time" version = "0.1.45" @@ -2948,6 +4720,15 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -2974,7 +4755,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot", + "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", "socket2", @@ -3025,13 +4806,24 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +dependencies = [ + "rustls 0.20.9", + "tokio", + "webpki", +] + [[package]] name = "tokio-rustls" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.10", "tokio", ] @@ -3044,6 +4836,7 @@ dependencies = [ "futures-core", "pin-project-lite", "tokio", + "tokio-util", ] [[package]] @@ -3075,11 +4868,26 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af06656561d28735e9c1cd63dfd57132c8155426aa6af24f36a00a351f88c48e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.7", +] + [[package]] name = "toml_datetime" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -3089,7 +4897,42 @@ checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap 2.1.0", "toml_datetime", - "winnow", + "winnow 0.5.34", +] + +[[package]] +name = "toml_edit" +version = "0.20.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +dependencies = [ + "indexmap 2.1.0", + "toml_datetime", + "winnow 0.5.34", +] + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap 2.1.0", + "toml_datetime", + "winnow 0.5.34", +] + +[[package]] +name = "toml_edit" +version = "0.22.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18769cd1cec395d70860ceb4d932812a0b4d06b1a4bb336745a4d21b9496e992" +dependencies = [ + "indexmap 2.1.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.5", ] [[package]] @@ -3106,9 +4949,21 @@ checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "tracing-core" version = "0.1.32" @@ -3118,6 +4973,52 @@ dependencies = [ "once_cell", ] +[[package]] +name = "trust-dns-proto" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3119112651c157f4488931a01e586aa459736e9d6046d3bd9105ffb69352d374" +dependencies = [ + "async-trait", + "cfg-if 1.0.0", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna 0.4.0", + "ipnet", + "once_cell", + "rand 0.8.5", + "smallvec", + "thiserror", + "tinyvec", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a3e6c3aff1718b3c73e395d1f35202ba2ffa847c6a62eea0db8fb4cfe30be6" +dependencies = [ + "cfg-if 1.0.0", + "futures-util", + "ipconfig", + "lru-cache", + "once_cell", + "parking_lot 0.12.1", + "rand 0.8.5", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "tracing", + "trust-dns-proto", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -3136,6 +5037,27 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.14" @@ -3169,6 +5091,18 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "untrusted" version = "0.9.0" @@ -3182,11 +5116,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", - "idna", + "idna 0.5.0", "percent-encoding", "serde", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf8parse" version = "0.2.1" @@ -3202,6 +5142,22 @@ dependencies = [ "getrandom", ] +[[package]] +name = "uuid" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +dependencies = [ + "getrandom", + "serde", +] + +[[package]] +name = "v_htmlescape" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c" + [[package]] name = "vcpkg" version = "0.2.15" @@ -3271,6 +5227,12 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + [[package]] name = "wasm-bindgen" version = "0.2.90" @@ -3347,6 +5309,56 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web3" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5388522c899d1e1c96a4c307e3797e0f697ba7c77dd8e0e625ecba9dd0342937" +dependencies = [ + "arrayvec", + "base64 0.21.7", + "bytes 1.5.0", + "derive_more", + "ethabi", + "ethereum-types", + "futures 0.3.30", + "futures-timer", + "headers", + "hex", + "idna 0.4.0", + "jsonrpc-core", + "log", + "once_cell", + "parking_lot 0.12.1", + "pin-project 1.1.5", + "reqwest", + "rlp", + "secp256k1", + "serde", + "serde_json", + "tiny-keccak", + "url", +] + +[[package]] +name = "webpki" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" +dependencies = [ + "ring 0.17.7", + "untrusted 0.9.0", +] + +[[package]] +name = "webpki-roots" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +dependencies = [ + "webpki", +] + [[package]] name = "webpki-roots" version = "0.25.3" @@ -3365,6 +5377,22 @@ dependencies = [ "rustix", ] +[[package]] +name = "whoami" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" +dependencies = [ + "redox_syscall 0.4.1", + "wasite", +] + +[[package]] +name = "widestring" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" + [[package]] name = "winapi" version = "0.3.9" @@ -3546,6 +5574,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -3556,6 +5593,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "xattr" version = "1.3.1" @@ -3639,13 +5685,15 @@ dependencies = [ [[package]] name = "ya-core-model" version = "0.9.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=fb9a89b11c815b5b6b664ca6c8b1151524420aa3#fb9a89b11c815b5b6b664ca6c8b1151524420aa3" +source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" dependencies = [ "chrono", "derive_more", + "erc20_payment_lib", "log", "serde", "serde_bytes", + "serde_json", "serde_json_canonicalizer", "structopt", "strum 0.24.1", @@ -3658,6 +5706,7 @@ dependencies = [ [[package]] name = "ya-gsb-http-proxy" version = "0.1.0" +source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" dependencies = [ "actix-http", "actix-web", @@ -3702,7 +5751,7 @@ dependencies = [ "chrono", "clap 4.4.16", "dotenv", - "env_logger", + "env_logger 0.11.2", "flexi_logger", "futures 0.3.30", "http 1.1.0", @@ -3730,7 +5779,7 @@ dependencies = [ [[package]] name = "ya-runtime-api" version = "0.7.1" -source = "git+https://github.com/golemfactory/yagna.git?rev=fb9a89b11c815b5b6b664ca6c8b1151524420aa3#fb9a89b11c815b5b6b664ca6c8b1151524420aa3" +source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" dependencies = [ "anyhow", "bytes 1.5.0", @@ -3770,7 +5819,7 @@ dependencies = [ "actix", "bitflags 1.3.2", "futures 0.3.30", - "pin-project", + "pin-project 0.4.30", ] [[package]] @@ -3792,7 +5841,7 @@ dependencies = [ "tokio", "tokio-util", "url", - "uuid", + "uuid 0.8.2", "ya-packet-trace", "ya-sb-proto", "ya-sb-util", @@ -3801,7 +5850,7 @@ dependencies = [ [[package]] name = "ya-transfer" version = "0.3.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=fb9a89b11c815b5b6b664ca6c8b1151524420aa3#fb9a89b11c815b5b6b664ca6c8b1151524420aa3" +source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" dependencies = [ "actix", "actix-http", @@ -3823,7 +5872,7 @@ dependencies = [ "rand 0.8.5", "regex", "serde", - "sha3", + "sha3 0.8.2", "tempdir", "thiserror", "tokio", @@ -3843,7 +5892,7 @@ dependencies = [ [[package]] name = "ya-utils-futures" version = "0.3.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=fb9a89b11c815b5b6b664ca6c8b1151524420aa3#fb9a89b11c815b5b6b664ca6c8b1151524420aa3" +source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" dependencies = [ "futures 0.3.30", "tokio", @@ -3852,7 +5901,7 @@ dependencies = [ [[package]] name = "ya-utils-path" version = "0.1.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=fb9a89b11c815b5b6b664ca6c8b1151524420aa3#fb9a89b11c815b5b6b664ca6c8b1151524420aa3" +source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" dependencies = [ "anyhow", "directories", @@ -3870,9 +5919,9 @@ dependencies = [ [[package]] name = "yansi" -version = "0.5.1" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "zerocopy" @@ -3894,6 +5943,12 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + [[package]] name = "zip" version = "0.5.6" diff --git a/Cargo.toml b/Cargo.toml index 615eeed..ebd79b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,34 +11,33 @@ members = [ ] [dependencies] -ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "fb9a89b11c815b5b6b664ca6c8b1151524420aa3", features = ["activity", "appkey"] } -ya-runtime-api = { git = "https://github.com/golemfactory/yagna.git", rev = "fb9a89b11c815b5b6b664ca6c8b1151524420aa3" } +ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "e2325dacc99c53c37b05255c1159d14594edfbaf", features = ["activity", "appkey"] } +ya-runtime-api = { git = "https://github.com/golemfactory/yagna.git", rev = "e2325dacc99c53c37b05255c1159d14594edfbaf" } ya-service-bus = "0.7.1" ya-client-model = "0.6.0" ya-agreement-utils = "0.5" -ya-transfer = { git = "https://github.com/golemfactory/yagna.git", rev = "fb9a89b11c815b5b6b664ca6c8b1151524420aa3" } +ya-transfer = { git = "https://github.com/golemfactory/yagna.git", rev = "e2325dacc99c53c37b05255c1159d14594edfbaf" } actix = "0.13" actix-rt = "2" async-trait = "0.1.77" log = "0.4" -serde = { version = "^1.0", features = ["derive"] } +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" clap = { version = "4", features = ["derive", "env"] } dotenv = "0.15" anyhow = "1.0" -env_logger = "0.10" -yansi = "0.5" +env_logger = "0.11" +yansi = "1.0" chrono = "0.4" tokio = { version = "1.32", features = ["macros", "signal"] } tokio-stream = { version = "0.1.14", features = ["io-util"] } futures = "0.3" -flexi_logger = { version = "0.27", features = ["colors"] } +flexi_logger = { version = "0.28", features = ["colors"] } regex = "1" reqwest = { version = "0.11", features = ["blocking", "json"] } async-stream = "0.3.5" -# ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", branch = "pwalski/gsb_http_proxy_monitor" } -ya-gsb-http-proxy = { path ="../yagna/exe-unit/components/gsb-http-proxy" } +ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", rev = "e2325dacc99c53c37b05255c1159d14594edfbaf" } http = "1.1.0" bytes = "1.5.0" humantime = "2.1" @@ -53,4 +52,4 @@ assert_cmd = "2.0" predicates = "3.1" [patch.crates-io] -ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "fb9a89b11c815b5b6b664ca6c8b1151524420aa3" } +ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "e2325dacc99c53c37b05255c1159d14594edfbaf" } diff --git a/src/counter.rs b/src/counter.rs index 8e384a9..315ceeb 100644 --- a/src/counter.rs +++ b/src/counter.rs @@ -1,7 +1,7 @@ mod combined; mod duration; +mod requests; mod requests_duration; -mod requests_number; use std::{str::FromStr, sync::Arc}; @@ -10,9 +10,12 @@ use chrono::Duration; use tokio::sync::RwLock; use ya_gsb_http_proxy::monitor::RequestsMonitor; -use self::{combined::RequestsCounters, duration::DurationCounter, requests_duration::RequestsDurationCounter}; +use self::{ + combined::RequestsMonitoringCounters, duration::DurationCounter, requests::RequestsCounter, + requests_duration::RequestsDurationCounter, +}; -pub(self) type SharedCounters = Arc>>; +type SharedCounters = Arc>>; #[derive(Clone, Debug, Default)] pub struct Counters { @@ -45,7 +48,7 @@ impl Counters { pub fn requests_monitor(&mut self) -> impl RequestsMonitor { let counters = self.counters.clone(); - RequestsCounters::new(counters) + RequestsMonitoringCounters::new(counters) } } @@ -53,7 +56,7 @@ impl Counters { enum SupportedCounter { Duration(DurationCounter), RequestsDuration(RequestsDurationCounter), - RequestsCount(DisabledCounter), + RequestsCount(RequestsCounter), } impl FromStr for SupportedCounter { @@ -61,12 +64,12 @@ impl FromStr for SupportedCounter { fn from_str(counter: &str) -> anyhow::Result { let counter = match counter { - "golem.usage.duration_sec" => SupportedCounter::Duration(DurationCounter::default()), + "golem.usage.duration_sec" => SupportedCounter::Duration(Default::default()), "golem.usage.gpu-sec" => SupportedCounter::RequestsDuration(Default::default()), - "ai-runtime.requests" => SupportedCounter::RequestsCount(DisabledCounter::default()), + "ai-runtime.requests" => SupportedCounter::RequestsCount(Default::default()), _ => bail!("Unsupported counter: {}", counter), }; - return Ok(counter); + Ok(counter) } } @@ -91,24 +94,18 @@ impl Counter for SupportedCounter { } } -pub(self) trait Counter { +trait Counter { fn count(&self) -> f64; } -#[derive(Clone, Debug, Default)] -struct DisabledCounter {} - -impl Counter for DisabledCounter { - fn count(&self) -> f64 { - 0.0 - } -} - -pub(self) trait RequestMonitoringCounter: Counter { +trait RequestMonitoringCounter: Counter { fn on_request(&mut self); fn on_response(&mut self); } -pub(self) fn duration_to_secs(duration: Duration) -> f64 { - duration.to_std().expect("Duration is bigger than 0").as_secs_f64() +fn duration_to_secs(duration: Duration) -> f64 { + duration + .to_std() + .expect("Duration is bigger than 0") + .as_secs_f64() } diff --git a/src/counter/combined.rs b/src/counter/combined.rs index 9eeefba..9c6c6fa 100644 --- a/src/counter/combined.rs +++ b/src/counter/combined.rs @@ -1,19 +1,19 @@ use ya_gsb_http_proxy::monitor::{RequestsMonitor, ResponseMonitor}; -use super::{SharedCounters, RequestMonitoringCounter}; +use super::{RequestMonitoringCounter, SharedCounters}; #[derive(Clone, Debug, Default)] -pub(super) struct RequestsCounters { +pub(super) struct RequestsMonitoringCounters { counters: SharedCounters, } -impl RequestsCounters { +impl RequestsMonitoringCounters { pub(super) fn new(counters: SharedCounters) -> Self { Self { counters } } } -impl RequestsMonitor for RequestsCounters { +impl RequestsMonitor for RequestsMonitoringCounters { async fn on_request(&mut self) -> impl ResponseMonitor { let mut counters = self.counters.write().await; for counter in &mut *counters { diff --git a/src/counter/duration.rs b/src/counter/duration.rs index 0d69102..82b6e2c 100644 --- a/src/counter/duration.rs +++ b/src/counter/duration.rs @@ -15,7 +15,7 @@ impl Default for DurationCounter { impl Counter for DurationCounter { fn count(&self) -> f64 { - let duration = self.start - Utc::now(); + let duration = Utc::now() - self.start; duration_to_secs(duration) } } diff --git a/src/counter/requests.rs b/src/counter/requests.rs new file mode 100644 index 0000000..6b554a5 --- /dev/null +++ b/src/counter/requests.rs @@ -0,0 +1,21 @@ +use super::{Counter, RequestMonitoringCounter}; + +#[derive(Clone, Copy, Debug, Default)] +pub(super) struct RequestsCounter { + count: u64, +} + +impl Counter for RequestsCounter { + fn count(&self) -> f64 { + self.count as f64 + } +} + +impl RequestMonitoringCounter for RequestsCounter { + + fn on_request(&mut self) { + self.count += 1; + } + + fn on_response(&mut self) {} +} diff --git a/src/counter/requests_number.rs b/src/counter/requests_number.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/main.rs b/src/main.rs index 51dc1b3..c53c5ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,34 +58,11 @@ async fn activity_loop( report_url: &str, activity_id: &str, process: ProcessController, - // agreement: AgreementDesc, counters: Counters, ) -> anyhow::Result<()> { let report_service = gsb::service(report_url); - // let start = Utc::now(); - // let mut current_usage = agreement.clean_usage_vector(); - // let counter_duration_idx = agreement.resolve_counter("golem.usage.duration_sec"); - // let counter_requests_duration_idx = agreement.resolve_counter("golem.usage.gpu-sec"); - // let counter_requests_count_idx = agreement.resolve_counter("ai-runtime.requests"); while let Some(()) = process.report() { - // // Create duration counter type - // let now = Utc::now(); - // let duration = now - start; - // if let Some(idx) = counter_duration_idx { - // current_usage[idx] = duration.to_std()?.as_secs_f64(); - // } - - // if let Some(idx) = counter_requests_duration_idx { - // // TODO make counter to return usage_vector, remove agreement from this function - // // current_usage[idx] = counter.requests_duration(); - // } - - // if let Some(idx) = counter_requests_count_idx { - // // TODO make counter to return usage_vector, remove agreement from this function - // // current_usage[idx] = counter.requests_count(); - // } - let current_usage = counters.current_usage().await; let timestamp = Utc::now().timestamp(); match report_service @@ -246,7 +223,6 @@ async fn run( report_url, activity_id, ctx.process_controller.clone(), - // ctx.agreement.clone(), counters.clone(), ); @@ -428,7 +404,6 @@ async fn run( let mut counters = counters.clone(); gsb::bind_stream(&exe_unit_url, move |message: GsbHttpCallMessage| { - // inject request counter aggregator let requests_monitor = counters.requests_monitor(); let mut proxy = GsbToHttpProxy { base_url: "http://localhost:7861/".to_string(), From abbe1c121dca1c8041571faf6839143d4d7e7331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Mon, 18 Mar 2024 14:01:32 +0100 Subject: [PATCH 07/13] Yagna rev update. Response counder drop handling. --- Cargo.lock | 14 +++++++------- Cargo.toml | 10 +++++----- src/counter.rs | 5 +---- src/counter/combined.rs | 5 ++++- src/counter/duration.rs | 2 +- src/counter/requests.rs | 1 - src/counter/requests_duration.rs | 7 +++++-- src/main.rs | 2 +- 8 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 45f969e..ff3402f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1903,7 +1903,7 @@ dependencies = [ [[package]] name = "gftp" version = "0.4.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" +source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" dependencies = [ "actix-rt", "anyhow", @@ -5685,7 +5685,7 @@ dependencies = [ [[package]] name = "ya-core-model" version = "0.9.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" +source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" dependencies = [ "chrono", "derive_more", @@ -5706,7 +5706,7 @@ dependencies = [ [[package]] name = "ya-gsb-http-proxy" version = "0.1.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" +source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" dependencies = [ "actix-http", "actix-web", @@ -5779,7 +5779,7 @@ dependencies = [ [[package]] name = "ya-runtime-api" version = "0.7.1" -source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" +source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" dependencies = [ "anyhow", "bytes 1.5.0", @@ -5850,7 +5850,7 @@ dependencies = [ [[package]] name = "ya-transfer" version = "0.3.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" +source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" dependencies = [ "actix", "actix-http", @@ -5892,7 +5892,7 @@ dependencies = [ [[package]] name = "ya-utils-futures" version = "0.3.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" +source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" dependencies = [ "futures 0.3.30", "tokio", @@ -5901,7 +5901,7 @@ dependencies = [ [[package]] name = "ya-utils-path" version = "0.1.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=e2325dacc99c53c37b05255c1159d14594edfbaf#e2325dacc99c53c37b05255c1159d14594edfbaf" +source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" dependencies = [ "anyhow", "directories", diff --git a/Cargo.toml b/Cargo.toml index ebd79b3..3ac73bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,12 +11,12 @@ members = [ ] [dependencies] -ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "e2325dacc99c53c37b05255c1159d14594edfbaf", features = ["activity", "appkey"] } -ya-runtime-api = { git = "https://github.com/golemfactory/yagna.git", rev = "e2325dacc99c53c37b05255c1159d14594edfbaf" } +ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "c2c9279fa8be78db8fd291dca6200962b6cf0fdb", features = ["activity", "appkey"] } +ya-runtime-api = { git = "https://github.com/golemfactory/yagna.git", rev = "c2c9279fa8be78db8fd291dca6200962b6cf0fdb" } ya-service-bus = "0.7.1" ya-client-model = "0.6.0" ya-agreement-utils = "0.5" -ya-transfer = { git = "https://github.com/golemfactory/yagna.git", rev = "e2325dacc99c53c37b05255c1159d14594edfbaf" } +ya-transfer = { git = "https://github.com/golemfactory/yagna.git", rev = "c2c9279fa8be78db8fd291dca6200962b6cf0fdb" } actix = "0.13" actix-rt = "2" @@ -37,7 +37,7 @@ flexi_logger = { version = "0.28", features = ["colors"] } regex = "1" reqwest = { version = "0.11", features = ["blocking", "json"] } async-stream = "0.3.5" -ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", rev = "e2325dacc99c53c37b05255c1159d14594edfbaf" } +ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", rev = "c2c9279fa8be78db8fd291dca6200962b6cf0fdb" } http = "1.1.0" bytes = "1.5.0" humantime = "2.1" @@ -52,4 +52,4 @@ assert_cmd = "2.0" predicates = "3.1" [patch.crates-io] -ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "e2325dacc99c53c37b05255c1159d14594edfbaf" } +ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "c2c9279fa8be78db8fd291dca6200962b6cf0fdb" } diff --git a/src/counter.rs b/src/counter.rs index 315ceeb..fe95778 100644 --- a/src/counter.rs +++ b/src/counter.rs @@ -26,9 +26,6 @@ impl Counters { /// From list of Agreement counter names /// Fails on unsupported counter pub fn from_counters(counter_names: &Vec) -> anyhow::Result { - if counter_names.is_empty() { - bail!("Agreement has no counters"); - } let mut counters = Vec::with_capacity(counter_names.len()); for counter in counter_names { let counter = SupportedCounter::from_str(counter)?; @@ -46,7 +43,7 @@ impl Counters { Some(current_usage) } - pub fn requests_monitor(&mut self) -> impl RequestsMonitor { + pub fn requests_monitor(&self) -> impl RequestsMonitor { let counters = self.counters.clone(); RequestsMonitoringCounters::new(counters) } diff --git a/src/counter/combined.rs b/src/counter/combined.rs index 9c6c6fa..790dce8 100644 --- a/src/counter/combined.rs +++ b/src/counter/combined.rs @@ -54,7 +54,10 @@ impl ResponseMonitor for ResponseMonitors { // Failsafe for not calling `on_response`. impl Drop for ResponseMonitors { fn drop(&mut self) { - let dropped = std::mem::take(self); + if self.counted { + return; + } + let dropped = std::mem::replace(self, Default::default()); if !dropped.counted { tokio::spawn(dropped.on_response()); } diff --git a/src/counter/duration.rs b/src/counter/duration.rs index 82b6e2c..b7874cc 100644 --- a/src/counter/duration.rs +++ b/src/counter/duration.rs @@ -4,7 +4,7 @@ use super::{duration_to_secs, Counter}; #[derive(Clone, Debug)] pub(super) struct DurationCounter { - start: DateTime + start: DateTime, } impl Default for DurationCounter { diff --git a/src/counter/requests.rs b/src/counter/requests.rs index 6b554a5..c3cbc81 100644 --- a/src/counter/requests.rs +++ b/src/counter/requests.rs @@ -12,7 +12,6 @@ impl Counter for RequestsCounter { } impl RequestMonitoringCounter for RequestsCounter { - fn on_request(&mut self) { self.count += 1; } diff --git a/src/counter/requests_duration.rs b/src/counter/requests_duration.rs index 067cb71..b038d05 100644 --- a/src/counter/requests_duration.rs +++ b/src/counter/requests_duration.rs @@ -27,7 +27,6 @@ impl Counter for RequestsDurationCounter { } impl RequestMonitoringCounter for RequestsDurationCounter { - fn on_request(&mut self) { self.active_requests_count += 1; if self.first_active_request_start_time.is_none() { @@ -47,6 +46,10 @@ impl RequestMonitoringCounter for RequestsDurationCounter { impl Default for RequestsDurationCounter { fn default() -> Self { let duration = Duration::zero(); - Self { duration, active_requests_count: 0, first_active_request_start_time: None } + Self { + duration, + active_requests_count: 0, + first_active_request_start_time: None, + } } } diff --git a/src/main.rs b/src/main.rs index c53c5ae..f982042 100644 --- a/src/main.rs +++ b/src/main.rs @@ -402,7 +402,7 @@ async fn run( } }); - let mut counters = counters.clone(); + let counters = counters.clone(); gsb::bind_stream(&exe_unit_url, move |message: GsbHttpCallMessage| { let requests_monitor = counters.requests_monitor(); let mut proxy = GsbToHttpProxy { From a1800193d5a27d08afe1f8204a66e5ecd7d474b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Mon, 18 Mar 2024 16:08:37 +0100 Subject: [PATCH 08/13] Tests. Request counter bugfix --- src/counter.rs | 170 +++++++++++++++++++++++++++++++++++++++- src/counter/combined.rs | 2 +- src/counter/requests.rs | 2 +- 3 files changed, 169 insertions(+), 5 deletions(-) diff --git a/src/counter.rs b/src/counter.rs index fe95778..fbfcef3 100644 --- a/src/counter.rs +++ b/src/counter.rs @@ -49,7 +49,7 @@ impl Counters { } } -#[derive(Clone, Debug)] +#[derive(Debug)] enum SupportedCounter { Duration(DurationCounter), RequestsDuration(RequestsDurationCounter), @@ -71,11 +71,11 @@ impl FromStr for SupportedCounter { } impl SupportedCounter { - fn request_monitoring_counter(&mut self) -> Option<&mut impl RequestMonitoringCounter> { + fn request_monitoring_counter(&mut self) -> Option<&mut dyn RequestMonitoringCounter> { match self { SupportedCounter::Duration(_) => None, SupportedCounter::RequestsDuration(counter) => Some(counter), - SupportedCounter::RequestsCount(_) => None, + SupportedCounter::RequestsCount(counter) => Some(counter), } } } @@ -106,3 +106,167 @@ fn duration_to_secs(duration: Duration) -> f64 { .expect("Duration is bigger than 0") .as_secs_f64() } + +#[cfg(test)] +mod tests { + use tokio::task; + + use super::{Counters, SupportedCounter}; + use ya_gsb_http_proxy::monitor::{RequestsMonitor, ResponseMonitor}; + + #[tokio::test] + async fn counters_order_test() { + let c = Counters::from_counters(&vec![ + "ai-runtime.requests".into(), + "golem.usage.duration_sec".into(), + "golem.usage.gpu-sec".into(), + ]) + .expect("Creates counters"); + let counters = c.counters.read().await; + assert!(matches!( + counters.get(0), + Some(&SupportedCounter::RequestsCount(..)) + )); + assert!(matches!( + counters.get(1), + Some(&SupportedCounter::Duration(..)) + )); + assert!(matches!( + counters.get(2), + Some(&SupportedCounter::RequestsDuration(..)) + )); + assert_eq!(counters.len(), 3); + } + + #[tokio::test] + async fn one_counter_test() { + let counters = Counters::from_counters(&vec!["golem.usage.duration_sec".into()]) + .expect("Creates counters"); + let counters = counters.counters.read().await; + assert!(matches!( + counters.get(0), + Some(&SupportedCounter::Duration(..)) + )); + assert_eq!(counters.len(), 1); + } + + #[tokio::test] + async fn zero_counter_error_test() { + let counters = Counters::from_counters(&vec!["golem.usage.duration_sec".into()]) + .expect("Creates counters"); + let counters = counters.counters.read().await; + assert!(counters.is_empty()); + } + + #[tokio::test] + async fn counting_test() { + let counters = Counters::from_counters(&vec![ + "golem.usage.duration_sec".into(), + "ai-runtime.requests".into(), + "golem.usage.gpu-sec".into(), + ]) + .expect("Creates counters"); + + let test_tasks = task::LocalSet::new(); + + let delay = std::time::Duration::from_secs(1); + let mut requests_monitor = counters.requests_monitor(); + + // 3 requests at step 1, 3, and 5. + test_tasks.spawn_local(async move { + for i in 0..6 { + // println!("Step: {i}"); + if (i & 1) == 1 { + // odd step number + // println!("Short request on step: {i}"); + let response_monitor = requests_monitor.on_request().await; + // println!("Short request on step: {i}. Done."); + tokio::time::sleep(delay).await; + response_monitor.on_response().await; + // println!("Short request response on step: {i}"); + } else { + tokio::time::sleep(delay).await; + } + } + }); + + // 1 long request between steps 2 and 4. + let mut requests_monitor = counters.requests_monitor(); + test_tasks.spawn_local(async move { + tokio::time::sleep(2 * delay).await; + // println!("Long request"); + let response_monitor = requests_monitor.on_request().await; + tokio::time::sleep(delay * 2).await; + // println!("Long request response."); + response_monitor.on_response().await; + }); + + // checking counters + let c = counters.clone(); + test_tasks.spawn_local(async move { + assert_eq!( + vec![0.0, 0.0, 0.0], + round_vec(c.current_usage().await.unwrap()), + "0 sec. Initial assert" + ); + + tokio::time::sleep(delay / 2).await; + assert_eq!( + vec![0.5, 0.0, 0.0], + round_vec(c.current_usage().await.unwrap()), + "0.5 sec. Assert before first short request" + ); + + tokio::time::sleep(delay).await; + assert_eq!( + vec![1.5, 1.0, 0.5], + round_vec(c.current_usage().await.unwrap()), + "1.5 sec. Assert after first short request start" + ); + + tokio::time::sleep(delay).await; + assert_eq!( + vec![2.5, 2.0, 1.5], + round_vec(c.current_usage().await.unwrap()), + "2.5 sec. Assert after first short request end and after long request start." + ); + + tokio::time::sleep(delay).await; + assert_eq!( + vec![3.5, 3.0, 2.5], + round_vec(c.current_usage().await.unwrap()), + r###" + 3.5 sec. Assert after second short request end and before long request stop. + Overlapping requests did not increse Request (GPU) duration counter. + "### + ); + + tokio::time::sleep(delay).await; + assert_eq!( + vec![4.5, 3.0, 3.0], + round_vec(c.current_usage().await.unwrap()), + "4.5 sec. Assert before third short request start and after long request stop" + ); + }); + + test_tasks.await; + + assert_eq!( + vec![6.0, 4.0, 4.0], + round_vec(counters.current_usage().await.unwrap()), + "6.0 sec. Final assert after third short request end." + ); + } + + fn round_vec(vec: Vec) -> Vec { + vec.into_iter().map(|x| round_floor_f64(x, 1)).collect() + } + + fn round_floor_f64(x: f64, decimals: i32) -> f64 { + if x == 0.0 { + return 0.0; + } + let y: f64 = 10f64.powi(decimals) as f64; + (x * y).floor() / y + } +} diff --git a/src/counter/combined.rs b/src/counter/combined.rs index 790dce8..3d572a0 100644 --- a/src/counter/combined.rs +++ b/src/counter/combined.rs @@ -1,6 +1,6 @@ use ya_gsb_http_proxy::monitor::{RequestsMonitor, ResponseMonitor}; -use super::{RequestMonitoringCounter, SharedCounters}; +use super::SharedCounters; #[derive(Clone, Debug, Default)] pub(super) struct RequestsMonitoringCounters { diff --git a/src/counter/requests.rs b/src/counter/requests.rs index c3cbc81..7c81891 100644 --- a/src/counter/requests.rs +++ b/src/counter/requests.rs @@ -1,6 +1,6 @@ use super::{Counter, RequestMonitoringCounter}; -#[derive(Clone, Copy, Debug, Default)] +#[derive(Debug, Default)] pub(super) struct RequestsCounter { count: u64, } From 8aeba4395474e7a653c3590fc9018ef7250e0d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Mon, 18 Mar 2024 16:47:05 +0100 Subject: [PATCH 09/13] Test assert detailed messages --- src/counter.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/counter.rs b/src/counter.rs index fbfcef3..c5a51f9 100644 --- a/src/counter.rs +++ b/src/counter.rs @@ -214,21 +214,27 @@ mod tests { assert_eq!( vec![0.5, 0.0, 0.0], round_vec(c.current_usage().await.unwrap()), - "0.5 sec. Assert before first short request" + r###" + Duration 0.5 sec. Assert before first short request. + Request (GPU) duration counter had not increased. + "### ); tokio::time::sleep(delay).await; assert_eq!( vec![1.5, 1.0, 0.5], round_vec(c.current_usage().await.unwrap()), - "1.5 sec. Assert after first short request start" + r###" + Duration 1.5 sec. Assert after first short request start (before its end). + Request counter increased and Request duration (GPU) counter increased. + "### ); tokio::time::sleep(delay).await; assert_eq!( vec![2.5, 2.0, 1.5], round_vec(c.current_usage().await.unwrap()), - "2.5 sec. Assert after first short request end and after long request start." + "Duration 2.5 sec. Assert after first short request end and after long request start." ); tokio::time::sleep(delay).await; @@ -236,7 +242,7 @@ mod tests { vec![3.5, 3.0, 2.5], round_vec(c.current_usage().await.unwrap()), r###" - 3.5 sec. Assert after second short request end and before long request stop. + Duration 3.5 sec. Assert after second short request end and before long request stop. Overlapping requests did not increse Request (GPU) duration counter. "### ); @@ -245,7 +251,7 @@ mod tests { assert_eq!( vec![4.5, 3.0, 3.0], round_vec(c.current_usage().await.unwrap()), - "4.5 sec. Assert before third short request start and after long request stop" + "Duration 4.5 sec. Assert before third short request start and after long request stop" ); }); @@ -254,7 +260,7 @@ mod tests { assert_eq!( vec![6.0, 4.0, 4.0], round_vec(counters.current_usage().await.unwrap()), - "6.0 sec. Final assert after third short request end." + "Duration 6.0 sec. Final assert after third short request end." ); } From 244b539343844b40499edc7b5894a5b530054779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Mon, 18 Mar 2024 19:36:36 +0100 Subject: [PATCH 10/13] ResponseMonitors Drop handling (blocking and async env). ResponseMonitors drop test. Yagna ver update. --- Cargo.lock | 14 +++++----- Cargo.toml | 10 +++---- src/counter.rs | 60 ++++++++++++++++++++++++++++++++++++----- src/counter/combined.rs | 31 ++++++++++++++++----- 4 files changed, 90 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff3402f..5f68cf7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1903,7 +1903,7 @@ dependencies = [ [[package]] name = "gftp" version = "0.4.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" +source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" dependencies = [ "actix-rt", "anyhow", @@ -5685,7 +5685,7 @@ dependencies = [ [[package]] name = "ya-core-model" version = "0.9.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" +source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" dependencies = [ "chrono", "derive_more", @@ -5706,7 +5706,7 @@ dependencies = [ [[package]] name = "ya-gsb-http-proxy" version = "0.1.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" +source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" dependencies = [ "actix-http", "actix-web", @@ -5779,7 +5779,7 @@ dependencies = [ [[package]] name = "ya-runtime-api" version = "0.7.1" -source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" +source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" dependencies = [ "anyhow", "bytes 1.5.0", @@ -5850,7 +5850,7 @@ dependencies = [ [[package]] name = "ya-transfer" version = "0.3.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" +source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" dependencies = [ "actix", "actix-http", @@ -5892,7 +5892,7 @@ dependencies = [ [[package]] name = "ya-utils-futures" version = "0.3.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" +source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" dependencies = [ "futures 0.3.30", "tokio", @@ -5901,7 +5901,7 @@ dependencies = [ [[package]] name = "ya-utils-path" version = "0.1.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=c2c9279fa8be78db8fd291dca6200962b6cf0fdb#c2c9279fa8be78db8fd291dca6200962b6cf0fdb" +source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" dependencies = [ "anyhow", "directories", diff --git a/Cargo.toml b/Cargo.toml index 3ac73bd..a0ad736 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,12 +11,12 @@ members = [ ] [dependencies] -ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "c2c9279fa8be78db8fd291dca6200962b6cf0fdb", features = ["activity", "appkey"] } -ya-runtime-api = { git = "https://github.com/golemfactory/yagna.git", rev = "c2c9279fa8be78db8fd291dca6200962b6cf0fdb" } +ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e", features = ["activity", "appkey"] } +ya-runtime-api = { git = "https://github.com/golemfactory/yagna.git", rev = "1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" } ya-service-bus = "0.7.1" ya-client-model = "0.6.0" ya-agreement-utils = "0.5" -ya-transfer = { git = "https://github.com/golemfactory/yagna.git", rev = "c2c9279fa8be78db8fd291dca6200962b6cf0fdb" } +ya-transfer = { git = "https://github.com/golemfactory/yagna.git", rev = "1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" } actix = "0.13" actix-rt = "2" @@ -37,7 +37,7 @@ flexi_logger = { version = "0.28", features = ["colors"] } regex = "1" reqwest = { version = "0.11", features = ["blocking", "json"] } async-stream = "0.3.5" -ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", rev = "c2c9279fa8be78db8fd291dca6200962b6cf0fdb" } +ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", rev = "1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" } http = "1.1.0" bytes = "1.5.0" humantime = "2.1" @@ -52,4 +52,4 @@ assert_cmd = "2.0" predicates = "3.1" [patch.crates-io] -ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "c2c9279fa8be78db8fd291dca6200962b6cf0fdb" } +ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" } diff --git a/src/counter.rs b/src/counter.rs index c5a51f9..3be0ce9 100644 --- a/src/counter.rs +++ b/src/counter.rs @@ -124,7 +124,7 @@ mod tests { .expect("Creates counters"); let counters = c.counters.read().await; assert!(matches!( - counters.get(0), + counters.first(), Some(&SupportedCounter::RequestsCount(..)) )); assert!(matches!( @@ -144,7 +144,7 @@ mod tests { .expect("Creates counters"); let counters = counters.counters.read().await; assert!(matches!( - counters.get(0), + counters.first(), Some(&SupportedCounter::Duration(..)) )); assert_eq!(counters.len(), 1); @@ -152,14 +152,13 @@ mod tests { #[tokio::test] async fn zero_counter_error_test() { - let counters = Counters::from_counters(&vec!["golem.usage.duration_sec".into()]) - .expect("Creates counters"); + let counters = Counters::from_counters(&vec![]).expect("Creates empty counters collection"); let counters = counters.counters.read().await; assert!(counters.is_empty()); } #[tokio::test] - async fn counting_test() { + async fn overlapping_requests_counter_test() { let counters = Counters::from_counters(&vec![ "golem.usage.duration_sec".into(), "ai-runtime.requests".into(), @@ -207,7 +206,7 @@ mod tests { assert_eq!( vec![0.0, 0.0, 0.0], round_vec(c.current_usage().await.unwrap()), - "0 sec. Initial assert" + "Duration 0 sec. Initial assert" ); tokio::time::sleep(delay / 2).await; @@ -264,6 +263,53 @@ mod tests { ); } + #[tokio::test] + async fn unhandled_response_event_test() { + let counters = Counters::from_counters(&vec![ + "golem.usage.duration_sec".into(), + "ai-runtime.requests".into(), + "golem.usage.gpu-sec".into(), + ]) + .expect("Creates counters"); + + let test_tasks = task::LocalSet::new(); + + let delay = std::time::Duration::from_secs(1); + let mut requests_monitor = counters.requests_monitor(); + + // 3 requests at step 1, 3, and 5. + test_tasks.spawn_local(async move { + tokio::time::sleep(delay / 2).await; + let _response_monitor = requests_monitor.on_request().await; + tokio::time::sleep(delay).await; + }); + + // checking counters + let c = counters.clone(); + test_tasks.spawn_local(async move { + assert_eq!( + vec![0.0, 0.0, 0.0], + round_vec(c.current_usage().await.unwrap()), + "Duration 0 sec. Initial assert" + ); + + tokio::time::sleep(delay).await; + assert_eq!( + vec![1.0, 1.0, 0.5], + round_vec(c.current_usage().await.unwrap()), + "Duration 1.0 sec. Request started" + ); + }); + + test_tasks.await; + + assert_eq!( + vec![1.5, 1.0, 1.0], + round_vec(counters.current_usage().await.unwrap()), + "Duration 1.0 sec. Request closed on response monitor drop (Response (GPU) duration 1 sec)." + ); + } + fn round_vec(vec: Vec) -> Vec { vec.into_iter().map(|x| round_floor_f64(x, 1)).collect() } @@ -272,7 +318,7 @@ mod tests { if x == 0.0 { return 0.0; } - let y: f64 = 10f64.powi(decimals) as f64; + let y: f64 = 10f64.powi(decimals); (x * y).floor() / y } } diff --git a/src/counter/combined.rs b/src/counter/combined.rs index 3d572a0..8384bf6 100644 --- a/src/counter/combined.rs +++ b/src/counter/combined.rs @@ -1,3 +1,4 @@ +use tokio::runtime::Handle; use ya_gsb_http_proxy::monitor::{RequestsMonitor, ResponseMonitor}; use super::SharedCounters; @@ -29,7 +30,7 @@ impl RequestsMonitor for RequestsMonitoringCounters { } } -#[derive(Clone, Debug, Default)] +#[derive(Debug, Default)] struct ResponseMonitors { counters: SharedCounters, // failsafe flag to count response on Drop if not counted already. @@ -38,11 +39,19 @@ struct ResponseMonitors { impl ResponseMonitor for ResponseMonitors { async fn on_response(mut self) { - let mut counters = self.counters.write().await; + let counters = self.counters.write().await; if self.counted { return; }; self.counted = true; + ResponseMonitors::on_response(counters); + } +} + +impl ResponseMonitors { + fn on_response( + mut counters: tokio::sync::RwLockWriteGuard<'_, Vec>, + ) { for counter in &mut *counters { if let Some(counter) = counter.request_monitoring_counter() { counter.on_response(); @@ -57,9 +66,19 @@ impl Drop for ResponseMonitors { if self.counted { return; } - let dropped = std::mem::replace(self, Default::default()); - if !dropped.counted { - tokio::spawn(dropped.on_response()); - } + self.counted = true; + match Handle::try_current() { + Ok(runtime) => { + let counters = self.counters.clone(); + runtime.spawn(async move { + let counters = counters.write().await; + ResponseMonitors::on_response(counters); + }); + } + Err(_) => { + let counters = self.counters.blocking_write(); + ResponseMonitors::on_response(counters); + } + }; } } From 35fd3ea37490721ce7f92958998db8a0855b4a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Tue, 19 Mar 2024 10:55:37 +0100 Subject: [PATCH 11/13] Non blockigng ResponseMonitor. Response monitoring task. Yagna ver update. --- Cargo.lock | 14 ++--- Cargo.toml | 10 ++-- src/counter.rs | 42 ++++++++------ src/counter/combined.rs | 96 ++++++++++++++++++-------------- src/counter/requests.rs | 6 +- src/counter/requests_duration.rs | 16 +++--- src/main.rs | 2 +- 7 files changed, 102 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5f68cf7..ffcc7e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1903,7 +1903,7 @@ dependencies = [ [[package]] name = "gftp" version = "0.4.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" +source = "git+https://github.com/golemfactory/yagna.git?rev=b3f1e8238f26b224729c578eae6c29098d8800d7#b3f1e8238f26b224729c578eae6c29098d8800d7" dependencies = [ "actix-rt", "anyhow", @@ -5685,7 +5685,7 @@ dependencies = [ [[package]] name = "ya-core-model" version = "0.9.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" +source = "git+https://github.com/golemfactory/yagna.git?rev=b3f1e8238f26b224729c578eae6c29098d8800d7#b3f1e8238f26b224729c578eae6c29098d8800d7" dependencies = [ "chrono", "derive_more", @@ -5706,7 +5706,7 @@ dependencies = [ [[package]] name = "ya-gsb-http-proxy" version = "0.1.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" +source = "git+https://github.com/golemfactory/yagna.git?rev=b3f1e8238f26b224729c578eae6c29098d8800d7#b3f1e8238f26b224729c578eae6c29098d8800d7" dependencies = [ "actix-http", "actix-web", @@ -5779,7 +5779,7 @@ dependencies = [ [[package]] name = "ya-runtime-api" version = "0.7.1" -source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" +source = "git+https://github.com/golemfactory/yagna.git?rev=b3f1e8238f26b224729c578eae6c29098d8800d7#b3f1e8238f26b224729c578eae6c29098d8800d7" dependencies = [ "anyhow", "bytes 1.5.0", @@ -5850,7 +5850,7 @@ dependencies = [ [[package]] name = "ya-transfer" version = "0.3.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" +source = "git+https://github.com/golemfactory/yagna.git?rev=b3f1e8238f26b224729c578eae6c29098d8800d7#b3f1e8238f26b224729c578eae6c29098d8800d7" dependencies = [ "actix", "actix-http", @@ -5892,7 +5892,7 @@ dependencies = [ [[package]] name = "ya-utils-futures" version = "0.3.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" +source = "git+https://github.com/golemfactory/yagna.git?rev=b3f1e8238f26b224729c578eae6c29098d8800d7#b3f1e8238f26b224729c578eae6c29098d8800d7" dependencies = [ "futures 0.3.30", "tokio", @@ -5901,7 +5901,7 @@ dependencies = [ [[package]] name = "ya-utils-path" version = "0.1.0" -source = "git+https://github.com/golemfactory/yagna.git?rev=1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e#1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" +source = "git+https://github.com/golemfactory/yagna.git?rev=b3f1e8238f26b224729c578eae6c29098d8800d7#b3f1e8238f26b224729c578eae6c29098d8800d7" dependencies = [ "anyhow", "directories", diff --git a/Cargo.toml b/Cargo.toml index a0ad736..fcaacb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,12 +11,12 @@ members = [ ] [dependencies] -ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e", features = ["activity", "appkey"] } -ya-runtime-api = { git = "https://github.com/golemfactory/yagna.git", rev = "1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" } +ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "b3f1e8238f26b224729c578eae6c29098d8800d7", features = ["activity", "appkey"] } +ya-runtime-api = { git = "https://github.com/golemfactory/yagna.git", rev = "b3f1e8238f26b224729c578eae6c29098d8800d7" } ya-service-bus = "0.7.1" ya-client-model = "0.6.0" ya-agreement-utils = "0.5" -ya-transfer = { git = "https://github.com/golemfactory/yagna.git", rev = "1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" } +ya-transfer = { git = "https://github.com/golemfactory/yagna.git", rev = "b3f1e8238f26b224729c578eae6c29098d8800d7" } actix = "0.13" actix-rt = "2" @@ -37,7 +37,7 @@ flexi_logger = { version = "0.28", features = ["colors"] } regex = "1" reqwest = { version = "0.11", features = ["blocking", "json"] } async-stream = "0.3.5" -ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", rev = "1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" } +ya-gsb-http-proxy = { git = "https://github.com/golemfactory/yagna.git", rev = "b3f1e8238f26b224729c578eae6c29098d8800d7" } http = "1.1.0" bytes = "1.5.0" humantime = "2.1" @@ -52,4 +52,4 @@ assert_cmd = "2.0" predicates = "3.1" [patch.crates-io] -ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "1b84e87a3e5af163bfa5f6ef56144ed4f17cb57e" } +ya-core-model = { git = "https://github.com/golemfactory/yagna.git", rev = "b3f1e8238f26b224729c578eae6c29098d8800d7" } diff --git a/src/counter.rs b/src/counter.rs index 3be0ce9..e1b8376 100644 --- a/src/counter.rs +++ b/src/counter.rs @@ -6,7 +6,7 @@ mod requests_duration; use std::{str::FromStr, sync::Arc}; use anyhow::bail; -use chrono::Duration; +use chrono::{DateTime, Duration, Utc}; use tokio::sync::RwLock; use ya_gsb_http_proxy::monitor::RequestsMonitor; @@ -17,22 +17,29 @@ use self::{ type SharedCounters = Arc>>; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct Counters { counters: SharedCounters, + requests_monitor: RequestsMonitoringCounters, } impl Counters { - /// From list of Agreement counter names - /// Fails on unsupported counter - pub fn from_counters(counter_names: &Vec) -> anyhow::Result { + /// Creates counters from Agreement counter names and starts requests monitoring counters. + /// Fails on unsupported counter. + pub fn start(counter_names: &Vec) -> anyhow::Result { let mut counters = Vec::with_capacity(counter_names.len()); for counter in counter_names { let counter = SupportedCounter::from_str(counter)?; counters.push(counter); } let counters = Arc::new(RwLock::new(counters)); - Ok(Self { counters }) + + let requests_monitor = RequestsMonitoringCounters::start(counters.clone()); + + Ok(Self { + counters, + requests_monitor, + }) } /// Returns usage reported by counters in Agreement specified order. @@ -44,8 +51,7 @@ impl Counters { } pub fn requests_monitor(&self) -> impl RequestsMonitor { - let counters = self.counters.clone(); - RequestsMonitoringCounters::new(counters) + self.requests_monitor.clone() } } @@ -96,8 +102,8 @@ trait Counter { } trait RequestMonitoringCounter: Counter { - fn on_request(&mut self); - fn on_response(&mut self); + fn on_request(&mut self, request_time: DateTime); + fn on_response(&mut self, response_time: DateTime); } fn duration_to_secs(duration: Duration) -> f64 { @@ -116,7 +122,7 @@ mod tests { #[tokio::test] async fn counters_order_test() { - let c = Counters::from_counters(&vec![ + let c = Counters::start(&vec![ "ai-runtime.requests".into(), "golem.usage.duration_sec".into(), "golem.usage.gpu-sec".into(), @@ -140,8 +146,8 @@ mod tests { #[tokio::test] async fn one_counter_test() { - let counters = Counters::from_counters(&vec!["golem.usage.duration_sec".into()]) - .expect("Creates counters"); + let counters = + Counters::start(&vec!["golem.usage.duration_sec".into()]).expect("Creates counters"); let counters = counters.counters.read().await; assert!(matches!( counters.first(), @@ -152,14 +158,14 @@ mod tests { #[tokio::test] async fn zero_counter_error_test() { - let counters = Counters::from_counters(&vec![]).expect("Creates empty counters collection"); + let counters = Counters::start(&vec![]).expect("Creates empty counters collection"); let counters = counters.counters.read().await; assert!(counters.is_empty()); } #[tokio::test] async fn overlapping_requests_counter_test() { - let counters = Counters::from_counters(&vec![ + let counters = Counters::start(&vec![ "golem.usage.duration_sec".into(), "ai-runtime.requests".into(), "golem.usage.gpu-sec".into(), @@ -181,7 +187,7 @@ mod tests { let response_monitor = requests_monitor.on_request().await; // println!("Short request on step: {i}. Done."); tokio::time::sleep(delay).await; - response_monitor.on_response().await; + response_monitor.on_response(); // println!("Short request response on step: {i}"); } else { tokio::time::sleep(delay).await; @@ -197,7 +203,7 @@ mod tests { let response_monitor = requests_monitor.on_request().await; tokio::time::sleep(delay * 2).await; // println!("Long request response."); - response_monitor.on_response().await; + response_monitor.on_response(); }); // checking counters @@ -265,7 +271,7 @@ mod tests { #[tokio::test] async fn unhandled_response_event_test() { - let counters = Counters::from_counters(&vec![ + let counters = Counters::start(&vec![ "golem.usage.duration_sec".into(), "ai-runtime.requests".into(), "golem.usage.gpu-sec".into(), diff --git a/src/counter/combined.rs b/src/counter/combined.rs index 8384bf6..595b999 100644 --- a/src/counter/combined.rs +++ b/src/counter/combined.rs @@ -1,61 +1,87 @@ -use tokio::runtime::Handle; +use chrono::{DateTime, Utc}; +use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; use ya_gsb_http_proxy::monitor::{RequestsMonitor, ResponseMonitor}; use super::SharedCounters; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub(super) struct RequestsMonitoringCounters { counters: SharedCounters, + response_time_tx: UnboundedSender>, } impl RequestsMonitoringCounters { - pub(super) fn new(counters: SharedCounters) -> Self { - Self { counters } + pub(super) fn start(counters: SharedCounters) -> Self { + let (response_time_tx, response_time_rx) = tokio::sync::mpsc::unbounded_channel(); + Self::spawn_responses_receiver(response_time_rx, counters.clone()); + Self { + counters, + response_time_tx, + } + } + + fn spawn_responses_receiver( + mut response_time_rx: UnboundedReceiver>, + counters: SharedCounters, + ) { + tokio::spawn(async move { + while let Some(response_time) = response_time_rx.recv().await { + let mut counters = counters.write().await; + for counter in &mut *counters { + if let Some(counter) = counter.request_monitoring_counter() { + counter.on_response(response_time); + } + } + } + }); } } impl RequestsMonitor for RequestsMonitoringCounters { async fn on_request(&mut self) -> impl ResponseMonitor { let mut counters = self.counters.write().await; + let request_time = Utc::now(); for counter in &mut *counters { if let Some(counter) = counter.request_monitoring_counter() { - counter.on_request(); + counter.on_request(request_time); } } - let counters = self.counters.clone(); - ResponseMonitors { - counters, - ..Default::default() - } + let response_time_tx = self.response_time_tx.clone(); + ResponseMonitors::new(response_time_tx) } } -#[derive(Debug, Default)] +#[derive(Debug)] struct ResponseMonitors { - counters: SharedCounters, + response_time_tx: UnboundedSender>, // failsafe flag to count response on Drop if not counted already. counted: bool, } +impl ResponseMonitors { + fn new(response_time_tx: UnboundedSender>) -> Self { + let counted = false; + Self { + response_time_tx, + counted, + } + } +} + impl ResponseMonitor for ResponseMonitors { - async fn on_response(mut self) { - let counters = self.counters.write().await; - if self.counted { - return; - }; - self.counted = true; - ResponseMonitors::on_response(counters); + fn on_response(mut self) { + ResponseMonitors::on_response(&mut self); } } impl ResponseMonitors { - fn on_response( - mut counters: tokio::sync::RwLockWriteGuard<'_, Vec>, - ) { - for counter in &mut *counters { - if let Some(counter) = counter.request_monitoring_counter() { - counter.on_response(); - } + fn on_response(&mut self) { + if self.counted { + return; + }; + self.counted = true; + if let Err(error) = self.response_time_tx.send(Utc::now()) { + log::error!("Faied to send response monitoring event. Err: {error}"); } } } @@ -63,22 +89,6 @@ impl ResponseMonitors { // Failsafe for not calling `on_response`. impl Drop for ResponseMonitors { fn drop(&mut self) { - if self.counted { - return; - } - self.counted = true; - match Handle::try_current() { - Ok(runtime) => { - let counters = self.counters.clone(); - runtime.spawn(async move { - let counters = counters.write().await; - ResponseMonitors::on_response(counters); - }); - } - Err(_) => { - let counters = self.counters.blocking_write(); - ResponseMonitors::on_response(counters); - } - }; + self.on_response(); } } diff --git a/src/counter/requests.rs b/src/counter/requests.rs index 7c81891..f2a4611 100644 --- a/src/counter/requests.rs +++ b/src/counter/requests.rs @@ -1,3 +1,5 @@ +use chrono::{DateTime, Utc}; + use super::{Counter, RequestMonitoringCounter}; #[derive(Debug, Default)] @@ -12,9 +14,9 @@ impl Counter for RequestsCounter { } impl RequestMonitoringCounter for RequestsCounter { - fn on_request(&mut self) { + fn on_request(&mut self, _request_time: DateTime) { self.count += 1; } - fn on_response(&mut self) {} + fn on_response(&mut self, _response_time: DateTime) {} } diff --git a/src/counter/requests_duration.rs b/src/counter/requests_duration.rs index b038d05..a0ef1c5 100644 --- a/src/counter/requests_duration.rs +++ b/src/counter/requests_duration.rs @@ -10,34 +10,34 @@ pub(super) struct RequestsDurationCounter { } impl RequestsDurationCounter { - fn active_request_duration(&self) -> Duration { + fn active_request_duration(&self, response_time: DateTime) -> Duration { if let Some(active_request_start_time) = self.first_active_request_start_time { - let now = Utc::now(); - return now - active_request_start_time; + return response_time - active_request_start_time; } + //TODO log it Duration::zero() } } impl Counter for RequestsDurationCounter { fn count(&self) -> f64 { - let duration_so_far = self.duration + self.active_request_duration(); + let duration_so_far = self.duration + self.active_request_duration(Utc::now()); super::duration_to_secs(duration_so_far) } } impl RequestMonitoringCounter for RequestsDurationCounter { - fn on_request(&mut self) { + fn on_request(&mut self, request_time: DateTime) { self.active_requests_count += 1; if self.first_active_request_start_time.is_none() { - self.first_active_request_start_time = Some(Utc::now()); + self.first_active_request_start_time = Some(request_time); } } - fn on_response(&mut self) { + fn on_response(&mut self, response_time: DateTime) { self.active_requests_count -= 1; if self.active_requests_count == 0 { - self.duration = self.duration + self.active_request_duration(); + self.duration = self.duration + self.active_request_duration(response_time); self.first_active_request_start_time = None; } } diff --git a/src/main.rs b/src/main.rs index f982042..3d1eee4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -202,7 +202,7 @@ async fn run( let agreement = AgreementDesc::load(agreement_path)?; - let counters = Counters::from_counters(&agreement.counters)?; + let counters = Counters::start(&agreement.counters)?; let ctx = ExeUnitContext { activity_id: activity_id.clone(), From 4b67bba3814a5f5c399ad0bd75b72cde5a5fee71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Tue, 19 Mar 2024 11:14:04 +0100 Subject: [PATCH 12/13] Cleanup --- src/counter/requests_duration.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/counter/requests_duration.rs b/src/counter/requests_duration.rs index a0ef1c5..6031d0e 100644 --- a/src/counter/requests_duration.rs +++ b/src/counter/requests_duration.rs @@ -14,7 +14,6 @@ impl RequestsDurationCounter { if let Some(active_request_start_time) = self.first_active_request_start_time { return response_time - active_request_start_time; } - //TODO log it Duration::zero() } } From 2ad3bace0aa7f87593993a9ede471e4d9fb60ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Walski?= Date: Tue, 19 Mar 2024 11:49:54 +0100 Subject: [PATCH 13/13] Unsupported counter test --- src/counter.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/counter.rs b/src/counter.rs index e1b8376..16f5b3b 100644 --- a/src/counter.rs +++ b/src/counter.rs @@ -163,6 +163,17 @@ mod tests { assert!(counters.is_empty()); } + #[tokio::test] + async fn unsupported_counter_test() { + let res = Counters::start(&vec![ + "golem.usage.duration_sec".into(), + "unknown.timer.fail".into(), + ]); + assert!(matches!(res, Err(err) if err.to_string().contains("Unsupported counter"))); + let res = Counters::start(&vec!["unknown.timer.fail".into()]); + assert!(matches!(res, Err(err) if err.to_string().contains("Unsupported counter"))); + } + #[tokio::test] async fn overlapping_requests_counter_test() { let counters = Counters::start(&vec![