diff --git a/crates/starknet_integration_tests/src/config_utils.rs b/crates/starknet_integration_tests/src/config_utils.rs index 4891fc28c5..90b7471a67 100644 --- a/crates/starknet_integration_tests/src/config_utils.rs +++ b/crates/starknet_integration_tests/src/config_utils.rs @@ -12,8 +12,8 @@ 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::{ - ComponentExecutionConfig, - ComponentExecutionMode, + ReactiveComponentExecutionConfig, + ReactiveComponentExecutionMode, }; use starknet_sequencer_node::config::node_config::SequencerNodeConfig; use starknet_sequencer_node::config::test_utils::RequiredParams; @@ -93,19 +93,20 @@ fn strip_config_prefix(input: &str) -> &str { .unwrap_or(input) } -// TODO(Nadin): Refactor the following functions to be static methods of ComponentExecutionConfig. -pub fn get_disabled_component_config() -> ComponentExecutionConfig { - ComponentExecutionConfig { - execution_mode: ComponentExecutionMode::Disabled, +// TODO(Nadin): Refactor the following functions to be static methods of +// ReactiveComponentExecutionConfig. +pub fn get_disabled_component_config() -> ReactiveComponentExecutionConfig { + ReactiveComponentExecutionConfig { + execution_mode: ReactiveComponentExecutionMode::Disabled, local_server_config: None, remote_client_config: None, remote_server_config: None, } } -pub fn get_remote_component_config(socket: SocketAddr) -> ComponentExecutionConfig { - ComponentExecutionConfig { - execution_mode: ComponentExecutionMode::Remote, +pub fn get_remote_component_config(socket: SocketAddr) -> ReactiveComponentExecutionConfig { + ReactiveComponentExecutionConfig { + execution_mode: ReactiveComponentExecutionMode::Remote, local_server_config: None, remote_client_config: Some(RemoteClientConfig { socket, ..RemoteClientConfig::default() }), remote_server_config: None, @@ -114,9 +115,9 @@ pub fn get_remote_component_config(socket: SocketAddr) -> ComponentExecutionConf pub fn get_local_with_remote_enabled_component_config( socket: SocketAddr, -) -> ComponentExecutionConfig { - ComponentExecutionConfig { - execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteEnabled, +) -> ReactiveComponentExecutionConfig { + ReactiveComponentExecutionConfig { + execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled, local_server_config: Some(LocalServerConfig::default()), remote_client_config: None, remote_server_config: Some(RemoteServerConfig { socket }), @@ -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 { let monitoring_endpoint_socket = get_available_socket().await; ComponentConfig { - http_server: ComponentExecutionConfig::http_server_default_config(), + http_server: ReactiveComponentExecutionConfig::http_server_default_config(), gateway: get_remote_component_config(gateway_socket), monitoring_endpoint: get_local_with_remote_enabled_component_config( monitoring_endpoint_socket, diff --git a/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs b/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs index 277b601fe2..cd60ca05b8 100644 --- a/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs +++ b/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs @@ -24,8 +24,8 @@ use starknet_mempool_p2p::config::MempoolP2pConfig; use starknet_mempool_p2p::MEMPOOL_TOPIC; use starknet_sequencer_node::config::component_config::ComponentConfig; use starknet_sequencer_node::config::component_execution_config::{ - ComponentExecutionConfig, - ComponentExecutionMode, + ReactiveComponentExecutionConfig, + ReactiveComponentExecutionMode, }; use starknet_sequencer_node::config::node_config::SequencerNodeConfig; use starknet_sequencer_node::servers::run_component_servers; @@ -58,13 +58,13 @@ async fn test_mempool_sends_tx_to_other_peer(mut tx_generator: MultiAccountTrans // Derive the configuration for the mempool node. let components = ComponentConfig { - consensus_manager: ComponentExecutionConfig { - execution_mode: ComponentExecutionMode::Disabled, + consensus_manager: ReactiveComponentExecutionConfig { + execution_mode: ReactiveComponentExecutionMode::Disabled, local_server_config: None, ..Default::default() }, - batcher: ComponentExecutionConfig { - execution_mode: ComponentExecutionMode::Disabled, + batcher: ReactiveComponentExecutionConfig { + execution_mode: ReactiveComponentExecutionMode::Disabled, local_server_config: None, ..Default::default() }, diff --git a/crates/starknet_sequencer_node/src/clients.rs b/crates/starknet_sequencer_node/src/clients.rs index ba3745f3ce..336bc32aec 100644 --- a/crates/starknet_sequencer_node/src/clients.rs +++ b/crates/starknet_sequencer_node/src/clients.rs @@ -38,7 +38,7 @@ use starknet_state_sync_types::communication::{ }; use crate::communication::SequencerNodeCommunication; -use crate::config::component_execution_config::ComponentExecutionMode; +use crate::config::component_execution_config::ReactiveComponentExecutionMode; use crate::config::node_config::SequencerNodeConfig; pub struct SequencerNodeClients { @@ -178,7 +178,7 @@ impl SequencerNodeClients { /// # Arguments /// /// * $execution_mode - A reference to the component's execution mode, i.e., type -/// &ComponentExecutionMode. +/// &ReactiveComponentExecutionMode. /// * $local_client_type - The type for the local client to create, e.g., LocalBatcherClient. The /// client type should have a function $local_client_type::new(tx: $channel_expr). /// * $remote_client_type - The type for the remote client to create, e.g., RemoteBatcherClient. The @@ -196,7 +196,7 @@ impl SequencerNodeClients { /// # Example /// /// ```rust,ignore -/// // Assuming ComponentExecutionMode, channels, and remote client configuration are defined, and +/// // Assuming ReactiveComponentExecutionMode, channels, and remote client configuration are defined, and /// // LocalBatcherClient and RemoteBatcherClient have new methods that accept a channel and config, /// // respectively. /// let batcher_client: Option> = create_client!( @@ -221,19 +221,19 @@ macro_rules! create_client { $remote_client_config:expr ) => { match *$execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled + | ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let local_client = Some(<$local_client_type>::new($channel_expr)); Some(Client::new(local_client, None)) } - ComponentExecutionMode::Remote => match $remote_client_config { + ReactiveComponentExecutionMode::Remote => match $remote_client_config { Some(ref config) => { let remote_client = Some(<$remote_client_type>::new(config.clone())); Some(Client::new(None, remote_client)) } None => None, }, - ComponentExecutionMode::Disabled => None, + ReactiveComponentExecutionMode::Disabled => None, } }; } diff --git a/crates/starknet_sequencer_node/src/components.rs b/crates/starknet_sequencer_node/src/components.rs index 266f37f15e..4186acf073 100644 --- a/crates/starknet_sequencer_node/src/components.rs +++ b/crates/starknet_sequencer_node/src/components.rs @@ -12,7 +12,7 @@ use starknet_monitoring_endpoint::monitoring_endpoint::{ }; use crate::clients::SequencerNodeClients; -use crate::config::component_execution_config::ComponentExecutionMode; +use crate::config::component_execution_config::ReactiveComponentExecutionMode; use crate::config::node_config::SequencerNodeConfig; use crate::version::VERSION_FULL; @@ -32,26 +32,26 @@ pub fn create_node_components( clients: &SequencerNodeClients, ) -> SequencerNodeComponents { let batcher = match config.components.batcher.execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled + | ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let mempool_client = clients.get_mempool_shared_client().expect("Mempool Client should be available"); Some(create_batcher(config.batcher_config.clone(), mempool_client)) } - ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None, + ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None, }; let consensus_manager = match config.components.consensus_manager.execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled + | ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let batcher_client = clients.get_batcher_shared_client().expect("Batcher Client should be available"); Some(ConsensusManager::new(config.consensus_manager_config.clone(), batcher_client)) } - ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None, + ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None, }; let gateway = match config.components.gateway.execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled + | ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let mempool_client = clients.get_mempool_shared_client().expect("Mempool Client should be available"); @@ -62,17 +62,17 @@ pub fn create_node_components( mempool_client, )) } - ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None, + ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None, }; let http_server = match config.components.http_server.execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled + | ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => { 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)) } - ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None, + ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None, }; let (mempool_p2p_propagator, mempool_p2p_runner) = match config @@ -80,35 +80,37 @@ pub fn create_node_components( .mempool_p2p .execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled + | ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let gateway_client = clients.get_gateway_shared_client().expect("Gateway Client should be available"); let (mempool_p2p_propagator, mempool_p2p_runner) = create_p2p_propagator_and_runner(config.mempool_p2p_config.clone(), gateway_client); (Some(mempool_p2p_propagator), Some(mempool_p2p_runner)) } - ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => (None, None), + ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => { + (None, None) + } }; let mempool = match config.components.mempool.execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled + | ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let mempool_p2p_propagator_client = clients .get_mempool_p2p_propagator_shared_client() .expect("Propagator Client should be available"); let mempool = create_mempool(mempool_p2p_propagator_client); Some(mempool) } - ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None, + ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None, }; let monitoring_endpoint = match config.components.monitoring_endpoint.execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteEnabled => Some( + ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => Some( create_monitoring_endpoint(config.monitoring_endpoint_config.clone(), VERSION_FULL), ), - ComponentExecutionMode::LocalExecutionWithRemoteDisabled => None, - ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None, + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled => None, + ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None, }; SequencerNodeComponents { diff --git a/crates/starknet_sequencer_node/src/config/component_config.rs b/crates/starknet_sequencer_node/src/config/component_config.rs index 975a8289cd..6373d07806 100644 --- a/crates/starknet_sequencer_node/src/config/component_config.rs +++ b/crates/starknet_sequencer_node/src/config/component_config.rs @@ -5,40 +5,41 @@ use papyrus_config::{ParamPath, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; -use crate::config::component_execution_config::ComponentExecutionConfig; +use crate::config::component_execution_config::ReactiveComponentExecutionConfig; /// The components configuration. #[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)] pub struct ComponentConfig { #[validate] - pub batcher: ComponentExecutionConfig, + pub batcher: ReactiveComponentExecutionConfig, #[validate] - pub consensus_manager: ComponentExecutionConfig, + pub consensus_manager: ReactiveComponentExecutionConfig, #[validate] - pub gateway: ComponentExecutionConfig, + pub gateway: ReactiveComponentExecutionConfig, #[validate] - pub http_server: ComponentExecutionConfig, + pub http_server: ReactiveComponentExecutionConfig, #[validate] - pub mempool: ComponentExecutionConfig, + pub mempool: ReactiveComponentExecutionConfig, #[validate] - pub mempool_p2p: ComponentExecutionConfig, + pub mempool_p2p: ReactiveComponentExecutionConfig, #[validate] - pub monitoring_endpoint: ComponentExecutionConfig, + pub monitoring_endpoint: ReactiveComponentExecutionConfig, #[validate] - pub state_sync: ComponentExecutionConfig, + pub state_sync: ReactiveComponentExecutionConfig, } impl Default for ComponentConfig { fn default() -> Self { Self { - batcher: ComponentExecutionConfig::batcher_default_config(), - consensus_manager: ComponentExecutionConfig::consensus_manager_default_config(), - gateway: ComponentExecutionConfig::gateway_default_config(), - http_server: ComponentExecutionConfig::http_server_default_config(), - mempool: ComponentExecutionConfig::mempool_default_config(), - mempool_p2p: ComponentExecutionConfig::mempool_p2p_default_config(), - monitoring_endpoint: ComponentExecutionConfig::monitoring_endpoint_default_config(), - state_sync: ComponentExecutionConfig::state_sync_default_config(), + 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(), + monitoring_endpoint: + ReactiveComponentExecutionConfig::monitoring_endpoint_default_config(), + state_sync: ReactiveComponentExecutionConfig::state_sync_default_config(), } } } 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 36307210bb..1757c8b1f6 100644 --- a/crates/starknet_sequencer_node/src/config/component_execution_config.rs +++ b/crates/starknet_sequencer_node/src/config/component_execution_config.rs @@ -12,27 +12,33 @@ use tracing::error; use validator::{Validate, ValidationError}; #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -pub enum ComponentExecutionMode { +pub enum ReactiveComponentExecutionMode { Disabled, Remote, LocalExecutionWithRemoteEnabled, LocalExecutionWithRemoteDisabled, } +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub enum ActiveComponentExecutionMode { + Disabled, + Enabled, +} + // TODO(Lev/Tsabary): When papyrus_config will support it, change to include communication config in // the enum. -/// The single component configuration. +/// Reactive component configuration. #[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)] -#[validate(schema(function = "validate_single_component_config"))] -pub struct ComponentExecutionConfig { - pub execution_mode: ComponentExecutionMode, +#[validate(schema(function = "validate_reactive_component_execution_config"))] +pub struct ReactiveComponentExecutionConfig { + pub execution_mode: ReactiveComponentExecutionMode, pub local_server_config: Option, pub remote_client_config: Option, pub remote_server_config: Option, } -impl SerializeConfig for ComponentExecutionConfig { +impl SerializeConfig for ReactiveComponentExecutionConfig { fn dump(&self) -> BTreeMap { let members = BTreeMap::from_iter([ser_param( "execution_mode", @@ -52,10 +58,10 @@ impl SerializeConfig for ComponentExecutionConfig { } } -impl Default for ComponentExecutionConfig { +impl Default for ReactiveComponentExecutionConfig { fn default() -> Self { Self { - execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteDisabled, + execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled, local_server_config: Some(LocalServerConfig::default()), remote_client_config: None, remote_server_config: None, @@ -63,11 +69,34 @@ impl Default for ComponentExecutionConfig { } } +/// Active component configuration. +#[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)] +pub struct ActiveComponentExecutionConfig { + pub execution_mode: ActiveComponentExecutionMode, +} + +impl SerializeConfig for ActiveComponentExecutionConfig { + fn dump(&self) -> BTreeMap { + BTreeMap::from_iter([ser_param( + "execution_mode", + &self.execution_mode, + "The component execution mode.", + ParamPrivacyInput::Public, + )]) + } +} + +impl Default for ActiveComponentExecutionConfig { + fn default() -> Self { + Self { execution_mode: ActiveComponentExecutionMode::Enabled } + } +} + /// Specific components default configurations. -impl ComponentExecutionConfig { +impl ReactiveComponentExecutionConfig { pub fn gateway_default_config() -> Self { Self { - execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteDisabled, + execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled, local_server_config: Some(LocalServerConfig::default()), remote_client_config: None, remote_server_config: None, @@ -79,7 +108,7 @@ impl ComponentExecutionConfig { // a workaround I've set the local one, but this should be addressed. pub fn http_server_default_config() -> Self { Self { - execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteEnabled, + execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled, local_server_config: Some(LocalServerConfig::default()), remote_client_config: None, remote_server_config: Some(RemoteServerConfig::default()), @@ -91,7 +120,7 @@ impl ComponentExecutionConfig { // one of them is set. As a workaround I've set the local one, but this should be addressed. pub fn monitoring_endpoint_default_config() -> Self { Self { - execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteEnabled, + execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled, local_server_config: Some(LocalServerConfig::default()), remote_client_config: None, remote_server_config: Some(RemoteServerConfig::default()), @@ -100,7 +129,7 @@ impl ComponentExecutionConfig { pub fn mempool_default_config() -> Self { Self { - execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteDisabled, + execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled, local_server_config: Some(LocalServerConfig::default()), remote_client_config: None, remote_server_config: None, @@ -109,7 +138,7 @@ impl ComponentExecutionConfig { pub fn batcher_default_config() -> Self { Self { - execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteDisabled, + execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled, local_server_config: Some(LocalServerConfig::default()), remote_client_config: None, remote_server_config: None, @@ -118,7 +147,7 @@ impl ComponentExecutionConfig { pub fn consensus_manager_default_config() -> Self { Self { - execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteDisabled, + execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled, local_server_config: Some(LocalServerConfig::default()), remote_client_config: None, remote_server_config: None, @@ -127,7 +156,7 @@ impl ComponentExecutionConfig { pub fn mempool_p2p_default_config() -> Self { Self { - execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteDisabled, + execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled, local_server_config: Some(LocalServerConfig::default()), remote_client_config: None, remote_server_config: None, @@ -136,7 +165,7 @@ impl ComponentExecutionConfig { pub fn state_sync_default_config() -> Self { Self { - execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteDisabled, + execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled, local_server_config: Some(LocalServerConfig::default()), remote_client_config: None, remote_server_config: None, @@ -144,8 +173,8 @@ impl ComponentExecutionConfig { } } -pub fn validate_single_component_config( - component_config: &ComponentExecutionConfig, +fn validate_reactive_component_execution_config( + component_config: &ReactiveComponentExecutionConfig, ) -> Result<(), ValidationError> { match ( component_config.execution_mode.clone(), @@ -153,10 +182,14 @@ pub fn validate_single_component_config( component_config.remote_client_config.is_some(), component_config.remote_server_config.is_some(), ) { - (ComponentExecutionMode::Disabled, false, false, false) => Ok(()), - (ComponentExecutionMode::Remote, false, true, false) => Ok(()), - (ComponentExecutionMode::LocalExecutionWithRemoteEnabled, true, false, true) => Ok(()), - (ComponentExecutionMode::LocalExecutionWithRemoteDisabled, true, false, false) => Ok(()), + (ReactiveComponentExecutionMode::Disabled, false, false, false) => Ok(()), + (ReactiveComponentExecutionMode::Remote, false, true, false) => Ok(()), + (ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled, true, false, true) => { + Ok(()) + } + (ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled, true, false, false) => { + Ok(()) + } (mode, local_server_config, remote_client_config, remote_server_config) => { error!( "Invalid component execution configuration: mode: {:?}, local_server_config: \ diff --git a/crates/starknet_sequencer_node/src/config/config_test.rs b/crates/starknet_sequencer_node/src/config/config_test.rs index 1975e0447a..8485df0247 100644 --- a/crates/starknet_sequencer_node/src/config/config_test.rs +++ b/crates/starknet_sequencer_node/src/config/config_test.rs @@ -17,7 +17,10 @@ use starknet_sequencer_infra::component_definitions::{ }; use validator::Validate; -use crate::config::component_execution_config::{ComponentExecutionConfig, ComponentExecutionMode}; +use crate::config::component_execution_config::{ + ReactiveComponentExecutionConfig, + ReactiveComponentExecutionMode, +}; use crate::config::node_config::{ SequencerNodeConfig, CONFIG_NON_POINTERS_WHITELIST, @@ -26,16 +29,21 @@ use crate::config::node_config::{ }; use crate::config::test_utils::{create_test_config_load_args, RequiredParams}; -const LOCAL_EXECUTION_MODE: ComponentExecutionMode = - ComponentExecutionMode::LocalExecutionWithRemoteDisabled; -const ENABLE_REMOTE_CONNECTION_MODE: ComponentExecutionMode = - ComponentExecutionMode::LocalExecutionWithRemoteEnabled; +const LOCAL_EXECUTION_MODE: ReactiveComponentExecutionMode = + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled; +const ENABLE_REMOTE_CONNECTION_MODE: ReactiveComponentExecutionMode = + ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled; -/// Test the validation of the struct ComponentExecutionConfig. +/// Test the validation of the struct ReactiveComponentExecutionConfig. /// Validates that execution mode of the component and the local/remote config are at sync. #[rstest] -#[case::local(ComponentExecutionMode::Disabled, None, None, None)] -#[case::local(ComponentExecutionMode::Remote, None, Some(RemoteClientConfig::default()), None)] +#[case::local(ReactiveComponentExecutionMode::Disabled, None, None, None)] +#[case::local( + ReactiveComponentExecutionMode::Remote, + None, + Some(RemoteClientConfig::default()), + None +)] #[case::local(LOCAL_EXECUTION_MODE, Some(LocalServerConfig::default()), None, None)] #[case::remote( ENABLE_REMOTE_CONNECTION_MODE, @@ -44,12 +52,12 @@ const ENABLE_REMOTE_CONNECTION_MODE: ComponentExecutionMode = Some(RemoteServerConfig::default()) )] fn test_valid_component_execution_config( - #[case] execution_mode: ComponentExecutionMode, + #[case] execution_mode: ReactiveComponentExecutionMode, #[case] local_server_config: Option, #[case] remote_client_config: Option, #[case] remote_server_config: Option, ) { - let component_exe_config = ComponentExecutionConfig { + let component_exe_config = ReactiveComponentExecutionConfig { execution_mode, local_server_config, remote_client_config, diff --git a/crates/starknet_sequencer_node/src/servers.rs b/crates/starknet_sequencer_node/src/servers.rs index 020849bbc2..b1eb61cfcd 100644 --- a/crates/starknet_sequencer_node/src/servers.rs +++ b/crates/starknet_sequencer_node/src/servers.rs @@ -25,7 +25,7 @@ use tracing::error; use crate::clients::SequencerNodeClients; use crate::communication::SequencerNodeCommunication; use crate::components::SequencerNodeComponents; -use crate::config::component_execution_config::ComponentExecutionMode; +use crate::config::component_execution_config::ReactiveComponentExecutionMode; use crate::config::node_config::SequencerNodeConfig; // Component servers that can run locally. @@ -66,7 +66,7 @@ pub struct SequencerNodeServers { /// # Arguments /// /// * `$execution_mode` - A reference to the component's execution mode, of type -/// `&ComponentExecutionMode`. +/// `&ReactiveComponentExecutionMode`. /// * `$local_client` - The local client to be used for the remote server initialization if the /// execution mode is `Remote`. /// * `$config` - The configuration for the remote server. @@ -94,7 +94,7 @@ pub struct SequencerNodeServers { macro_rules! create_remote_server { ($execution_mode:expr, $local_client:expr, $remote_server_config:expr) => { match *$execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { + ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let local_client = $local_client .expect("Local client should be set for inbound remote connections."); let remote_server_config = $remote_server_config @@ -106,9 +106,9 @@ macro_rules! create_remote_server { remote_server_config.clone(), ))) } - ComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ComponentExecutionMode::Remote - | ComponentExecutionMode::Disabled => None, + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled + | ReactiveComponentExecutionMode::Remote + | ReactiveComponentExecutionMode::Disabled => None, } }; } @@ -119,7 +119,7 @@ macro_rules! create_remote_server { /// # Arguments /// /// * $execution_mode - A reference to the component's execution mode, i.e., type -/// &ComponentExecutionMode. +/// &ReactiveComponentExecutionMode. /// * $component - The component that will be taken to initialize the server if the execution mode /// is enabled(LocalExecutionWithRemoteDisabled / LocalExecutionWithRemoteEnabled). /// * $Receiver - receiver side for the server. @@ -146,8 +146,8 @@ macro_rules! create_remote_server { macro_rules! create_local_server { ($execution_mode:expr, $component:expr, $receiver:expr) => { match *$execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled + | ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => { Some(Box::new(LocalComponentServer::new( $component .take() @@ -155,7 +155,9 @@ macro_rules! create_local_server { $receiver, ))) } - ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None, + ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => { + None + } } }; } @@ -166,7 +168,7 @@ macro_rules! create_local_server { /// # Arguments /// /// * $execution_mode - A reference to the component's execution mode, i.e., type -/// &ComponentExecutionMode. +/// &ReactiveComponentExecutionMode. /// * $component - The component that will be taken to initialize the server if the execution mode /// is enabled(LocalExecutionWithRemoteDisabled / LocalExecutionWithRemoteEnabled). /// @@ -179,7 +181,7 @@ macro_rules! create_local_server { /// # Example /// /// ```rust, ignore -/// // Assuming ComponentExecutionMode and components are defined, and WrapperServer +/// // Assuming ReactiveComponentExecutionMode and components are defined, and WrapperServer /// // has a new method that accepts a component. /// let consensus_manager_server = create_wrapper_server!( /// &config.components.consensus_manager.execution_mode, @@ -194,15 +196,17 @@ macro_rules! create_local_server { macro_rules! create_wrapper_server { ($execution_mode:expr, $component:expr) => { match *$execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { + ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled + | ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => { Some(Box::new(WrapperServer::new( $component .take() .expect(concat!(stringify!($component), " is not initialized.")), ))) } - ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None, + ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => { + None + } } }; }