From 4459c0e881d6553d4a082cd44125cb48144dffd5 Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Mon, 9 Dec 2024 10:48:40 +0200 Subject: [PATCH] chore(starknet_sequencer_node): set http server as active component commit-id:5bc74104 --- config/sequencer/default_config.json | 22 +------------------ .../src/config_utils.rs | 5 +++-- .../starknet_sequencer_node/src/components.rs | 5 ++--- .../src/config/component_config.rs | 10 ++++----- .../src/config/component_execution_config.rs | 12 +++++++++- crates/starknet_sequencer_node/src/servers.rs | 2 +- 6 files changed, 23 insertions(+), 33 deletions(-) diff --git a/config/sequencer/default_config.json b/config/sequencer/default_config.json index a942df1c40..504a066836 100644 --- a/config/sequencer/default_config.json +++ b/config/sequencer/default_config.json @@ -357,17 +357,7 @@ "components.http_server.execution_mode": { "description": "The component execution mode.", "privacy": "Public", - "value": "LocalExecutionWithRemoteEnabled" - }, - "components.http_server.local_server_config.#is_none": { - "description": "Flag for an optional field.", - "privacy": "TemporaryValue", - "value": false - }, - "components.http_server.local_server_config.channel_buffer_size": { - "description": "The communication channel buffer size.", - "privacy": "Public", - "value": 32 + "value": "Enabled" }, "components.http_server.remote_client_config.#is_none": { "description": "Flag for an optional field.", @@ -394,16 +384,6 @@ "privacy": "Public", "value": "0.0.0.0:8080" }, - "components.http_server.remote_server_config.#is_none": { - "description": "Flag for an optional field.", - "privacy": "TemporaryValue", - "value": false - }, - "components.http_server.remote_server_config.socket": { - "description": "The remote component server socket.", - "privacy": "Public", - "value": "0.0.0.0:8080" - }, "components.mempool.execution_mode": { "description": "The component execution mode.", "privacy": "Public", diff --git a/crates/starknet_integration_tests/src/config_utils.rs b/crates/starknet_integration_tests/src/config_utils.rs index 27ebe9e3b7..a95b5c1cd5 100644 --- a/crates/starknet_integration_tests/src/config_utils.rs +++ b/crates/starknet_integration_tests/src/config_utils.rs @@ -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, }; @@ -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(), @@ -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() diff --git a/crates/starknet_sequencer_node/src/components.rs b/crates/starknet_sequencer_node/src/components.rs index 165fa7df07..f3ddcda5e7 100644 --- a/crates/starknet_sequencer_node/src/components.rs +++ b/crates/starknet_sequencer_node/src/components.rs @@ -77,14 +77,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 diff --git a/crates/starknet_sequencer_node/src/config/component_config.rs b/crates/starknet_sequencer_node/src/config/component_config.rs index d3aaaf18bd..432cb17681 100644 --- a/crates/starknet_sequencer_node/src/config/component_config.rs +++ b/crates/starknet_sequencer_node/src/config/component_config.rs @@ -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(), } } diff --git a/crates/starknet_sequencer_node/src/config/component_execution_config.rs b/crates/starknet_sequencer_node/src/config/component_execution_config.rs index 2bbb54437c..d317b60c0d 100644 --- a/crates/starknet_sequencer_node/src/config/component_execution_config.rs +++ b/crates/starknet_sequencer_node/src/config/component_execution_config.rs @@ -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() } } @@ -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> { diff --git a/crates/starknet_sequencer_node/src/servers.rs b/crates/starknet_sequencer_node/src/servers.rs index b4e974c520..c40eb3f04e 100644 --- a/crates/starknet_sequencer_node/src/servers.rs +++ b/crates/starknet_sequencer_node/src/servers.rs @@ -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 );