diff --git a/crates/starknet_sequencer_node/src/servers.rs b/crates/starknet_sequencer_node/src/servers.rs index 020849bbc2..80795d0f2b 100644 --- a/crates/starknet_sequencer_node/src/servers.rs +++ b/crates/starknet_sequencer_node/src/servers.rs @@ -20,6 +20,8 @@ use starknet_sequencer_infra::component_server::{ WrapperServer, }; use starknet_sequencer_infra::errors::ComponentServerError; +use starknet_state_sync::runner::StateSyncRunnerServer; +use starknet_state_sync::{LocalStateSyncServer, RemoteStateSyncServer}; use tracing::error; use crate::clients::SequencerNodeClients; @@ -34,6 +36,7 @@ struct LocalServers { pub(crate) gateway: Option>, pub(crate) mempool: Option>, pub(crate) mempool_p2p_propagator: Option>, + pub(crate) state_sync: Option>, } // Component servers that wrap a component without a server. @@ -42,6 +45,7 @@ struct WrapperServers { pub(crate) http_server: Option>, pub(crate) monitoring_endpoint: Option>, pub(crate) mempool_p2p_runner: Option>, + pub(crate) state_sync_runner: Option>, } // Component servers that can run remotely. @@ -51,6 +55,7 @@ pub struct RemoteServers { pub gateway: Option>, pub mempool: Option>, pub mempool_p2p_propagator: Option>, + pub state_sync: Option>, } pub struct SequencerNodeServers { @@ -232,11 +237,18 @@ fn create_local_servers( components.mempool_p2p_propagator, communication.take_mempool_p2p_propagator_rx() ); + let state_sync_server = create_local_server!( + &config.components.state_sync.execution_mode, + components.state_sync, + communication.take_state_sync_rx() + ); + LocalServers { batcher: batcher_server, gateway: gateway_server, mempool: mempool_server, mempool_p2p_propagator: mempool_p2p_propagator_server, + state_sync: state_sync_server, } } @@ -271,11 +283,20 @@ pub fn create_remote_servers( mempool_p2p_propagator_client, config.components.mempool_p2p.remote_server_config ); + + let state_sync_client = clients.get_state_sync_local_client(); + let state_sync_server = create_remote_server!( + &config.components.state_sync.execution_mode, + state_sync_client, + config.components.state_sync.remote_server_config + ); + RemoteServers { batcher: batcher_server, gateway: gateway_server, mempool: mempool_server, mempool_p2p_propagator: mempool_p2p_propagator_server, + state_sync: state_sync_server, } } @@ -301,11 +322,18 @@ fn create_wrapper_servers( &config.components.mempool_p2p.execution_mode, components.mempool_p2p_runner ); + + let state_sync_runner_server = create_wrapper_server!( + &config.components.state_sync.execution_mode, + components.state_sync_runner + ); + WrapperServers { consensus_manager: consensus_manager_server, http_server, monitoring_endpoint: monitoring_endpoint_server, mempool_p2p_runner: mempool_p2p_runner_server, + state_sync_runner: state_sync_runner_server, } } diff --git a/crates/starknet_state_sync/src/lib.rs b/crates/starknet_state_sync/src/lib.rs index 598404ad97..66ca7f8fe9 100644 --- a/crates/starknet_state_sync/src/lib.rs +++ b/crates/starknet_state_sync/src/lib.rs @@ -5,6 +5,7 @@ use async_trait::async_trait; use futures::channel::{mpsc, oneshot}; use futures::SinkExt; use starknet_sequencer_infra::component_definitions::ComponentRequestHandler; +use starknet_sequencer_infra::component_server::{LocalComponentServer, RemoteComponentServer}; use starknet_state_sync_types::communication::{StateSyncRequest, StateSyncResponse}; use starknet_state_sync_types::errors::StateSyncError; @@ -37,3 +38,7 @@ impl ComponentRequestHandler for StateSync }) } } + +pub type LocalStateSyncServer = + LocalComponentServer; +pub type RemoteStateSyncServer = RemoteComponentServer; diff --git a/crates/starknet_state_sync/src/runner/mod.rs b/crates/starknet_state_sync/src/runner/mod.rs index 8294407d02..ac14205c5b 100644 --- a/crates/starknet_state_sync/src/runner/mod.rs +++ b/crates/starknet_state_sync/src/runner/mod.rs @@ -14,6 +14,7 @@ use papyrus_storage::state::StateStorageReader; use papyrus_storage::{open_storage, StorageReader}; use starknet_api::block::BlockNumber; use starknet_sequencer_infra::component_definitions::ComponentStarter; +use starknet_sequencer_infra::component_server::WrapperServer; use starknet_sequencer_infra::errors::ComponentError; use starknet_state_sync_types::communication::{ StateSyncRequest, @@ -143,5 +144,6 @@ impl StateSyncRunner { } } +pub type StateSyncRunnerServer = WrapperServer; // TODO(shahak): fill with a proper version, or allow not specifying the node version. const VERSION_FULL: &str = "";