Skip to content

Commit

Permalink
chore(starknet_sequencer_node): set http server as active component
Browse files Browse the repository at this point in the history
commit-id:5bc74104
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 9, 2024
1 parent 0abe49f commit 154e738
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
5 changes: 3 additions & 2 deletions crates/starknet_integration_tests/src/config_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use starknet_sequencer_infra::component_definitions::{
use starknet_sequencer_infra::test_utils::get_available_socket;
use starknet_sequencer_node::config::component_config::ComponentConfig;
use starknet_sequencer_node::config::component_execution_config::{
ActiveComponentExecutionConfig,
ReactiveComponentExecutionConfig,
ReactiveComponentExecutionMode,
};
Expand Down Expand Up @@ -126,7 +127,7 @@ pub fn get_local_with_remote_enabled_component_config(

pub async fn get_http_only_component_config(gateway_socket: SocketAddr) -> ComponentConfig {
ComponentConfig {
http_server: ReactiveComponentExecutionConfig::http_server_default_config(),
http_server: ActiveComponentExecutionConfig::default(),
gateway: get_remote_component_config(gateway_socket),
monitoring_endpoint: Default::default(),
batcher: get_disabled_component_config(),
Expand All @@ -139,7 +140,7 @@ pub async fn get_http_only_component_config(gateway_socket: SocketAddr) -> Compo

pub async fn get_non_http_component_config(gateway_socket: SocketAddr) -> ComponentConfig {
ComponentConfig {
http_server: get_disabled_component_config(),
http_server: ActiveComponentExecutionConfig::disabled(),
monitoring_endpoint: Default::default(),
gateway: get_local_with_remote_enabled_component_config(gateway_socket),
..ComponentConfig::default()
Expand Down
5 changes: 2 additions & 3 deletions crates/starknet_sequencer_node/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,13 @@ pub fn create_node_components(
ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None,
};
let http_server = match config.components.http_server.execution_mode {
ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
ActiveComponentExecutionMode::Enabled => {
let gateway_client =
clients.get_gateway_shared_client().expect("Gateway Client should be available");

Some(create_http_server(config.http_server_config.clone(), gateway_client))
}
ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None,
ActiveComponentExecutionMode::Disabled => None,
};

let (mempool_p2p_propagator, mempool_p2p_runner) = match config
Expand Down
10 changes: 5 additions & 5 deletions crates/starknet_sequencer_node/src/config/component_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ pub struct ComponentConfig {
#[validate]
pub gateway: ReactiveComponentExecutionConfig,
#[validate]
pub http_server: ReactiveComponentExecutionConfig,
#[validate]
pub mempool: ReactiveComponentExecutionConfig,
#[validate]
pub mempool_p2p: ReactiveComponentExecutionConfig,
#[validate]
pub state_sync: ReactiveComponentExecutionConfig,

// Reactive component configs.
// Active component configs.
pub http_server: ActiveComponentExecutionConfig,
pub monitoring_endpoint: ActiveComponentExecutionConfig,
}

impl Default for ComponentConfig {
fn default() -> Self {
Self {
// Reactive component configs.
batcher: ReactiveComponentExecutionConfig::batcher_default_config(),
consensus_manager: ReactiveComponentExecutionConfig::consensus_manager_default_config(),
gateway: ReactiveComponentExecutionConfig::gateway_default_config(),
http_server: ReactiveComponentExecutionConfig::http_server_default_config(),
mempool: ReactiveComponentExecutionConfig::mempool_default_config(),
mempool_p2p: ReactiveComponentExecutionConfig::mempool_p2p_default_config(),
state_sync: ReactiveComponentExecutionConfig::state_sync_default_config(),
// Reactive component configs.
// Active component configs.
http_server: Default::default(),
monitoring_endpoint: Default::default(),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl SerializeConfig for ActiveComponentExecutionConfig {

impl Default for ActiveComponentExecutionConfig {
fn default() -> Self {
Self { execution_mode: ActiveComponentExecutionMode::Enabled, remote_client_config: None }
ActiveComponentExecutionConfig::enabled()
}
}

Expand Down Expand Up @@ -166,6 +166,16 @@ impl ReactiveComponentExecutionConfig {
}
}

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

pub fn enabled() -> Self {
Self { execution_mode: ActiveComponentExecutionMode::Enabled, remote_client_config: None }
}
}

fn validate_reactive_component_execution_config(
component_config: &ReactiveComponentExecutionConfig,
) -> Result<(), ValidationError> {
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_sequencer_node/src/servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ fn create_wrapper_servers(
&config.components.consensus_manager.execution_mode,
components.consensus_manager
);
let http_server = create_wrapper_server!(
let http_server = create_wrapper_server_for_active_component!(
&config.components.http_server.execution_mode,
components.http_server
);
Expand Down

0 comments on commit 154e738

Please sign in to comment.