diff --git a/config/sequencer/default_config.json b/config/sequencer/default_config.json index b5941df09d..dfbb72e416 100644 --- a/config/sequencer/default_config.json +++ b/config/sequencer/default_config.json @@ -564,6 +564,56 @@ "privacy": "Public", "value": "0.0.0.0:8080" }, + "components.state_sync.execution_mode": { + "description": "The component execution mode.", + "privacy": "Public", + "value": "LocalExecutionWithRemoteDisabled" + }, + "components.state_sync.local_server_config.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": false + }, + "components.state_sync.local_server_config.channel_buffer_size": { + "description": "The communication channel buffer size.", + "privacy": "Public", + "value": 32 + }, + "components.state_sync.remote_client_config.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, + "components.state_sync.remote_client_config.idle_connections": { + "description": "The maximum number of idle connections to keep alive.", + "privacy": "Public", + "value": 18446744073709551615 + }, + "components.state_sync.remote_client_config.idle_timeout": { + "description": "The duration in seconds to keep an idle connection open before closing.", + "privacy": "Public", + "value": 90 + }, + "components.state_sync.remote_client_config.retries": { + "description": "The max number of retries for sending a message.", + "privacy": "Public", + "value": 3 + }, + "components.state_sync.remote_client_config.socket": { + "description": "The remote component server socket.", + "privacy": "Public", + "value": "0.0.0.0:8080" + }, + "components.state_sync.remote_server_config.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, + "components.state_sync.remote_server_config.socket": { + "description": "The remote component server socket.", + "privacy": "Public", + "value": "0.0.0.0:8080" + }, "consensus_manager_config.consensus_config.consensus_delay": { "description": "Delay (seconds) before starting consensus to give time for network peering.", "privacy": "Public", diff --git a/crates/starknet_sequencer_node/src/clients.rs b/crates/starknet_sequencer_node/src/clients.rs index 4ef7440f01..ba3745f3ce 100644 --- a/crates/starknet_sequencer_node/src/clients.rs +++ b/crates/starknet_sequencer_node/src/clients.rs @@ -29,6 +29,13 @@ use starknet_mempool_types::communication::{ SharedMempoolClient, }; use starknet_sequencer_infra::component_client::{Client, LocalComponentClient}; +use starknet_state_sync_types::communication::{ + LocalStateSyncClient, + RemoteStateSyncClient, + SharedStateSyncClient, + StateSyncRequest, + StateSyncResponse, +}; use crate::communication::SequencerNodeCommunication; use crate::config::component_execution_config::ComponentExecutionMode; @@ -41,6 +48,7 @@ pub struct SequencerNodeClients { // TODO (Lev): Change to Option>. mempool_p2p_propagator_client: Option>, + state_sync_client: Option>, } /// A macro to retrieve a shared client (either local or remote) from a specified field in a struct, @@ -148,6 +156,19 @@ impl SequencerNodeClients { None => None, } } + + pub fn get_state_sync_shared_client(&self) -> Option { + get_shared_client!(self, state_sync_client) + } + + pub fn get_state_sync_local_client( + &self, + ) -> Option> { + match &self.state_sync_client { + Some(client) => client.get_local_client(), + None => None, + } + } } /// A macro for creating a component client, determined by the component's execution mode. Returns a @@ -250,10 +271,20 @@ pub fn create_node_clients( channels.take_mempool_p2p_propagator_tx(), config.components.mempool_p2p.remote_client_config ); + + let state_sync_client = create_client!( + &config.components.state_sync.execution_mode, + LocalStateSyncClient, + RemoteStateSyncClient, + channels.take_state_sync_tx(), + config.components.state_sync.remote_client_config + ); + SequencerNodeClients { batcher_client, mempool_client, gateway_client, mempool_p2p_propagator_client, + state_sync_client, } } diff --git a/crates/starknet_sequencer_node/src/config/component_config.rs b/crates/starknet_sequencer_node/src/config/component_config.rs index fa5d3fcfc6..975a8289cd 100644 --- a/crates/starknet_sequencer_node/src/config/component_config.rs +++ b/crates/starknet_sequencer_node/src/config/component_config.rs @@ -24,6 +24,8 @@ pub struct ComponentConfig { pub mempool_p2p: ComponentExecutionConfig, #[validate] pub monitoring_endpoint: ComponentExecutionConfig, + #[validate] + pub state_sync: ComponentExecutionConfig, } impl Default for ComponentConfig { @@ -36,6 +38,7 @@ impl Default for ComponentConfig { 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(), } } } @@ -50,6 +53,7 @@ impl SerializeConfig for ComponentConfig { append_sub_config_name(self.mempool.dump(), "mempool"), append_sub_config_name(self.mempool_p2p.dump(), "mempool_p2p"), append_sub_config_name(self.monitoring_endpoint.dump(), "monitoring_endpoint"), + append_sub_config_name(self.state_sync.dump(), "state_sync"), ]; sub_configs.into_iter().flatten().collect() 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 61a8a1d0ee..36307210bb 100644 --- a/crates/starknet_sequencer_node/src/config/component_execution_config.rs +++ b/crates/starknet_sequencer_node/src/config/component_execution_config.rs @@ -133,6 +133,15 @@ impl ComponentExecutionConfig { remote_server_config: None, } } + + pub fn state_sync_default_config() -> Self { + Self { + execution_mode: ComponentExecutionMode::LocalExecutionWithRemoteDisabled, + local_server_config: Some(LocalServerConfig::default()), + remote_client_config: None, + remote_server_config: None, + } + } } pub fn validate_single_component_config(