Skip to content

Commit

Permalink
feat(starknet_state_sync): run state sync servers
Browse files Browse the repository at this point in the history
  • Loading branch information
noamsp-starkware committed Dec 8, 2024
1 parent dc4306c commit 11314a3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 22 additions & 0 deletions crates/starknet_sequencer_node/src/servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 => {
Expand Down Expand Up @@ -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.");

Expand Down
4 changes: 3 additions & 1 deletion crates/starknet_state_sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,3 +42,5 @@ impl ComponentRequestHandler<StateSyncRequest, StateSyncResponse> for StateSync
pub type LocalStateSyncServer =
LocalComponentServer<StateSync, StateSyncRequest, StateSyncResponse>;
pub type RemoteStateSyncServer = RemoteComponentServer<StateSyncRequest, StateSyncResponse>;

impl ComponentStarter for StateSync {}

0 comments on commit 11314a3

Please sign in to comment.