Skip to content

Commit

Permalink
chore(starknet_sequencer_node): cleanup explicit default config fns
Browse files Browse the repository at this point in the history
commit-id:c320383b
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 10, 2024
1 parent 8795cf9 commit 291ed01
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 87 deletions.
19 changes: 1 addition & 18 deletions crates/starknet_sequencer_node/src/config/component_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::config::component_execution_config::{
};

/// The components configuration.
#[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)]
#[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)]
pub struct ComponentConfig {
// Reactive component configs.
#[validate]
Expand All @@ -34,23 +34,6 @@ pub struct ComponentConfig {
pub monitoring_endpoint: ActiveComponentExecutionConfig,
}

impl Default for ComponentConfig {
fn default() -> Self {
Self {
// Reactive component configs.
batcher: ReactiveComponentExecutionConfig::batcher_default_config(),
gateway: ReactiveComponentExecutionConfig::gateway_default_config(),
mempool: ReactiveComponentExecutionConfig::mempool_default_config(),
mempool_p2p: ReactiveComponentExecutionConfig::mempool_p2p_default_config(),
state_sync: ReactiveComponentExecutionConfig::state_sync_default_config(),
// Active component configs.
consensus_manager: Default::default(),
http_server: Default::default(),
monitoring_endpoint: Default::default(),
}
}
}

impl SerializeConfig for ComponentConfig {
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
let sub_configs = vec![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,75 +98,6 @@ impl Default for ActiveComponentExecutionConfig {
}
}

/// Specific components default configurations.
impl ReactiveComponentExecutionConfig {
pub fn gateway_default_config() -> Self {
Self {
execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled,
local_server_config: Some(LocalServerConfig::default()),
remote_client_config: None,
remote_server_config: None,
}
}

// TODO(Tsabary/Lev): There's a bug here: the http server component does not need a local nor a
// remote config. However, the validation function requires that at least one of them is set. As
// a workaround I've set the local one, but this should be addressed.
pub fn http_server_default_config() -> Self {
Self {
execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled,
local_server_config: Some(LocalServerConfig::default()),
remote_client_config: None,
remote_server_config: Some(RemoteServerConfig::default()),
}
}

pub fn mempool_default_config() -> Self {
Self {
execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled,
local_server_config: Some(LocalServerConfig::default()),
remote_client_config: None,
remote_server_config: None,
}
}

pub fn batcher_default_config() -> Self {
Self {
execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled,
local_server_config: Some(LocalServerConfig::default()),
remote_client_config: None,
remote_server_config: None,
}
}

pub fn consensus_manager_default_config() -> Self {
Self {
execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled,
local_server_config: Some(LocalServerConfig::default()),
remote_client_config: None,
remote_server_config: None,
}
}

pub fn mempool_p2p_default_config() -> Self {
Self {
execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled,
local_server_config: Some(LocalServerConfig::default()),
remote_client_config: None,
remote_server_config: None,
}
}

pub fn state_sync_default_config() -> Self {
Self {
execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled,
local_server_config: Some(LocalServerConfig::default()),
remote_client_config: None,
remote_server_config: None,
}
}
}

impl ActiveComponentExecutionConfig {
pub fn disabled() -> Self {
Self { execution_mode: ActiveComponentExecutionMode::Disabled, remote_client_config: None }
Expand Down

0 comments on commit 291ed01

Please sign in to comment.