From 466876daa42ae7d25f79ed06fd082d039dab675d Mon Sep 17 00:00:00 2001 From: Noam Spiegelstein Date: Sun, 8 Dec 2024 22:04:59 +0200 Subject: [PATCH] feat(starknet_state_sync): run state sync servers --- crates/starknet_sequencer_node/src/servers.rs | 22 +++++++++++++++++++ crates/starknet_state_sync/src/lib.rs | 4 +++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/starknet_sequencer_node/src/servers.rs b/crates/starknet_sequencer_node/src/servers.rs index 80795d0f2b..0be7fd063b 100644 --- a/crates/starknet_sequencer_node/src/servers.rs +++ b/crates/starknet_sequencer_node/src/servers.rs @@ -383,6 +383,13 @@ pub async fn run_component_servers(servers: SequencerNodeServers) -> anyhow::Res // MempoolP2pRunner server. let mempool_p2p_runner_future = get_server_future(servers.wrapper_servers.mempool_p2p_runner); + // StateSync servers. + let local_state_sync_future = get_server_future(servers.local_servers.state_sync); + let remote_state_sync_future = get_server_future(servers.remote_servers.state_sync); + + // StateSyncRunner server. + let state_sync_runner_future = get_server_future(servers.wrapper_servers.state_sync_runner); + // Start servers. let local_batcher_handle = tokio::spawn(local_batcher_future); let remote_batcher_handle = tokio::spawn(remote_batcher_future); @@ -396,6 +403,9 @@ pub async fn run_component_servers(servers: SequencerNodeServers) -> anyhow::Res let local_mempool_p2p_propagator_handle = tokio::spawn(local_mempool_p2p_propagator_future); let remote_mempool_p2p_propagator_handle = tokio::spawn(remote_mempool_p2p_propagator_future); let mempool_p2p_runner_handle = tokio::spawn(mempool_p2p_runner_future); + let local_state_sync_handle = tokio::spawn(local_state_sync_future); + let remote_state_sync_handle = tokio::spawn(remote_state_sync_future); + let state_sync_runner_handle = tokio::spawn(state_sync_runner_future); let result = tokio::select! { res = local_batcher_handle => { @@ -446,6 +456,18 @@ pub async fn run_component_servers(servers: SequencerNodeServers) -> anyhow::Res error!("Mempool P2P Runner Server stopped."); res? } + res = local_state_sync_handle => { + error!("Local State Sync Server stopped."); + res? + } + res = remote_state_sync_handle => { + error!("Remote State Sync Server stopped."); + res? + } + res = state_sync_runner_handle => { + error!("State Sync Runner Server stopped."); + res? + } }; error!("Servers ended with unexpected Ok."); diff --git a/crates/starknet_state_sync/src/lib.rs b/crates/starknet_state_sync/src/lib.rs index 66ca7f8fe9..68e709338c 100644 --- a/crates/starknet_state_sync/src/lib.rs +++ b/crates/starknet_state_sync/src/lib.rs @@ -4,7 +4,7 @@ pub mod runner; 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_definitions::{ComponentRequestHandler, ComponentStarter}; use starknet_sequencer_infra::component_server::{LocalComponentServer, RemoteComponentServer}; use starknet_state_sync_types::communication::{StateSyncRequest, StateSyncResponse}; use starknet_state_sync_types::errors::StateSyncError; @@ -42,3 +42,5 @@ impl ComponentRequestHandler for StateSync pub type LocalStateSyncServer = LocalComponentServer; pub type RemoteStateSyncServer = RemoteComponentServer; + +impl ComponentStarter for StateSync {}