diff --git a/Cargo.lock b/Cargo.lock index 5565f5e7b..d93bd666c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1541,12 +1541,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" -[[package]] -name = "cld" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021080b0a3dbefcf1c1f0b3ad6a923b81f16801d874ec338c168ac0b0762baf5" - [[package]] name = "color-eyre" version = "0.6.2" @@ -3308,7 +3302,7 @@ dependencies = [ [[package]] name = "hotshot-query-service" -version = "0.1.18" +version = "0.1.19" dependencies = [ "anyhow", "ark-serialize", @@ -3321,7 +3315,6 @@ dependencies = [ "bit-vec", "chrono", "clap", - "cld", "committable", "custom_debug 0.6.1", "derivative", diff --git a/Cargo.toml b/Cargo.toml index 016839f10..440333010 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ [package] name = "hotshot-query-service" -version = "0.1.18" +version = "0.1.19" authors = ["Espresso Systems "] edition = "2021" license = "GPL-3.0-or-later" @@ -68,8 +68,6 @@ async-trait = "0.1" bincode = "1.3" bit-vec = { version = "0.6.3", features = ["serde_std"] } chrono = "0.4" -clap = { version = "4.5", features = ["derive", "env"] } -cld = "0.5" committable = "0.2" custom_debug = "0.6" derivative = "2.2" @@ -130,6 +128,7 @@ tempfile = { version = "3.10", optional = true } backtrace-on-stack-overflow = { version = "0.3", optional = true } [dev-dependencies] +clap = { version = "4.5", features = ["derive", "env"] } espresso-macros = { git = "https://github.com/EspressoSystems/espresso-macros.git", tag = "0.1.0" } generic-array = "0.14" hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.50" } diff --git a/src/availability.rs b/src/availability.rs index 95376c335..9f75a9611 100644 --- a/src/availability.rs +++ b/src/availability.rs @@ -27,14 +27,12 @@ //! the [node](crate::node) API. use crate::{api::load_api, Payload}; -use clap::Args; -use cld::ClDuration; use derive_more::From; use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt}; use hotshot_types::traits::node_implementation::NodeType; use serde::{Deserialize, Serialize}; use snafu::{OptionExt, Snafu}; -use std::{fmt::Display, path::PathBuf, str::FromStr, time::Duration}; +use std::{fmt::Display, path::PathBuf, time::Duration}; use tide_disco::{api::ApiError, method::ReadState, Api, RequestError, StatusCode}; use vbs::version::StaticVersionType; @@ -45,9 +43,7 @@ pub use data_source::*; pub use fetch::Fetch; pub use query_data::*; -#[derive(Args, Default)] pub struct Options { - #[arg(long = "availability-api-path", env = "HOTSHOT_AVAILABILITY_API_PATH")] pub api_path: Option, /// Timeout for failing requests due to missing data. @@ -55,39 +51,30 @@ pub struct Options { /// If data needed to respond to a request is missing, it can (in some cases) be fetched from an /// external provider. This parameter controls how long the request handler will wait for /// missing data to be fetched before giving up and failing the request. - #[arg( - long = "availability-fetch-timeout", - env = "HOTSHOT_AVAILABILITY_FETCH_TIMEOUT", - default_value = "500ms", - value_parser = parse_duration, - )] pub fetch_timeout: Duration, /// Additional API specification files to merge with `availability-api-path`. /// /// These optional files may contain route definitions for application-specific routes that have /// been added as extensions to the basic availability API. - #[arg( - long = "availability-extension", - env = "HOTSHOT_AVAILABILITY_EXTENSIONS", - value_delimiter = ',' - )] pub extensions: Vec, } +impl Default for Options { + fn default() -> Self { + Self { + api_path: None, + fetch_timeout: Duration::from_millis(500), + extensions: vec![], + } + } +} + #[derive(Clone, Debug, Snafu)] struct ParseDurationError { reason: String, } -fn parse_duration(s: &str) -> Result { - ClDuration::from_str(s) - .map(Duration::from) - .map_err(|err| ParseDurationError { - reason: err.to_string(), - }) -} - #[derive(Clone, Debug, From, Snafu, Deserialize, Serialize)] #[snafu(visibility(pub))] pub enum Error { diff --git a/src/lib.rs b/src/lib.rs index fbb97ea8c..75caeb284 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -474,15 +474,11 @@ impl QueryError { pub type QueryResult = Result; -#[derive(clap::Args, Default)] +#[derive(Default)] pub struct Options { - #[clap(flatten)] pub availability: availability::Options, - #[clap(flatten)] pub node: node::Options, - #[clap(flatten)] pub status: status::Options, - #[clap(short, long, default_value = "8080")] pub port: u16, } diff --git a/src/merklized_state.rs b/src/merklized_state.rs index 5e0df4961..f1442a215 100644 --- a/src/merklized_state.rs +++ b/src/merklized_state.rs @@ -17,7 +17,6 @@ //! If any parent state is missing then the partial snapshot can not be queried. use std::{fmt::Display, path::PathBuf}; -use clap::Args; use derive_more::From; use futures::FutureExt; use hotshot_types::traits::node_implementation::NodeType; @@ -33,23 +32,14 @@ use crate::{api::load_api, QueryError}; pub(crate) mod data_source; pub use data_source::*; -#[derive(Args, Default)] +#[derive(Default)] pub struct Options { - #[arg( - long = "merklized-state-api-path", - env = "HOTSHOT_MERKLIZED_STATE_API_PATH" - )] pub api_path: Option, /// Additional API specification files to merge with `merklized-state-api-path`. /// /// These optional files may contain route definitions for application-specific routes that have /// been added as extensions to the basic status API. - #[arg( - long = "merklized-state-extension", - env = "HOTSHOT_MERKLIZED_STATE_EXTENSIONS", - value_delimiter = ',' - )] pub extensions: Vec, } diff --git a/src/node.rs b/src/node.rs index 22dc33b20..5b7015594 100644 --- a/src/node.rs +++ b/src/node.rs @@ -21,7 +21,6 @@ //! return the expected counts. use crate::{api::load_api, QueryError}; -use clap::Args; use derive_more::From; use futures::FutureExt; use hotshot_types::traits::node_implementation::NodeType; @@ -37,20 +36,14 @@ pub(crate) mod query_data; pub use data_source::*; pub use query_data::*; -#[derive(Args, Default)] +#[derive(Default)] pub struct Options { - #[arg(long = "node-api-path", env = "HOTSHOT_NODE_API_PATH")] pub api_path: Option, /// Additional API specification files to merge with `node-api-path`. /// /// These optional files may contain route definitions for application-specific routes that have /// been added as extensions to the basic node API. - #[arg( - long = "node-extension", - env = "HOTSHOT_NODE_EXTENSIONS", - value_delimiter = ',' - )] pub extensions: Vec, } diff --git a/src/status.rs b/src/status.rs index b08d47784..986f13332 100644 --- a/src/status.rs +++ b/src/status.rs @@ -24,7 +24,6 @@ //! * summary statistics use crate::api::load_api; -use clap::Args; use derive_more::From; use futures::FutureExt; use serde::{Deserialize, Serialize}; @@ -39,20 +38,14 @@ pub(crate) mod data_source; pub use data_source::*; -#[derive(Args, Default)] +#[derive(Default)] pub struct Options { - #[arg(long = "status-api-path", env = "HOTSHOT_STATUS_API_PATH")] pub api_path: Option, /// Additional API specification files to merge with `status-api-path`. /// /// These optional files may contain route definitions for application-specific routes that have /// been added as extensions to the basic status API. - #[arg( - long = "status-extension", - env = "HOTSHOT_STATUS_EXTENSIONS", - value_delimiter = ',' - )] pub extensions: Vec, }