Skip to content

Commit

Permalink
fix: add serde default to missing katana options
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Nov 14, 2024
1 parent 504b1a9 commit bcc8001
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/katana/cli/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::utils::{parse_block_hash_or_number, parse_genesis, LogFormat};
const DEFAULT_DEV_SEED: &str = "0";
const DEFAULT_DEV_ACCOUNTS: u16 = 10;

#[cfg(feature = "server")]
#[derive(Debug, Args, Clone, Serialize, Deserialize, PartialEq)]
#[command(next_help_heading = "Metrics options")]
pub struct MetricsOptions {
Expand All @@ -33,18 +34,21 @@ pub struct MetricsOptions {
/// For now, metrics will still be collected even if this flag is not set. This only
/// controls whether the metrics server is started or not.
#[arg(long)]
#[serde(default)]
pub metrics: bool,

/// The metrics will be served at the given address.
#[arg(requires = "metrics")]
#[arg(long = "metrics.addr", value_name = "ADDRESS")]
#[arg(default_value_t = DEFAULT_METRICS_ADDR)]
#[serde(default = "default_metrics_addr")]
pub metrics_addr: IpAddr,

/// The metrics will be served at the given port.
#[arg(requires = "metrics")]
#[arg(long = "metrics.port", value_name = "PORT")]
#[arg(default_value_t = DEFAULT_METRICS_PORT)]
#[serde(default = "default_metrics_port")]
pub metrics_port: u16,
}

Expand Down Expand Up @@ -77,6 +81,7 @@ pub struct ServerOptions {
/// Comma separated list of domains from which to accept cross origin requests.
#[arg(long = "http.cors_origins")]
#[arg(value_delimiter = ',')]
#[serde(default)]
pub http_cors_origins: Option<Vec<String>>,

/// Maximum number of concurrent connections allowed.
Expand Down Expand Up @@ -133,6 +138,7 @@ pub struct EnvironmentOptions {
/// ASCII values. It must be a valid Cairo short string.
#[arg(long)]
#[arg(value_parser = ChainId::parse)]
#[serde(default)]
pub chain_id: Option<ChainId>,

/// The maximum number of steps available for the account validation logic.
Expand Down Expand Up @@ -349,3 +355,13 @@ fn default_http_port() -> u16 {
fn default_max_connections() -> u32 {
DEFAULT_RPC_MAX_CONNECTIONS
}

#[cfg(feature = "server")]
fn default_metrics_addr() -> IpAddr {
DEFAULT_METRICS_ADDR
}

#[cfg(feature = "server")]
fn default_metrics_port() -> u16 {
DEFAULT_METRICS_PORT
}

0 comments on commit bcc8001

Please sign in to comment.