Skip to content

Commit

Permalink
feat(sync): create state sync components
Browse files Browse the repository at this point in the history
  • Loading branch information
noamsp-starkware committed Nov 27, 2024
1 parent 537f2b4 commit f08ecd8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/starknet_sequencer_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ starknet_mempool_types.workspace = true
starknet_monitoring_endpoint.workspace = true
starknet_sequencer_infra.workspace = true
starknet_sierra_compile.workspace = true
starknet_state_sync.workspace = true
starknet_state_sync_types.workspace = true
thiserror = { workspace = true, optional = true }
tokio.workspace = true
Expand Down
16 changes: 16 additions & 0 deletions crates/starknet_sequencer_node/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use starknet_monitoring_endpoint::monitoring_endpoint::{
create_monitoring_endpoint,
MonitoringEndpoint,
};
use starknet_state_sync::runner::StateSyncRunner;
use starknet_state_sync::{create_state_sync_and_runner, StateSync};

use crate::clients::SequencerNodeClients;
use crate::config::component_execution_config::ComponentExecutionMode;
Expand All @@ -25,6 +27,8 @@ pub struct SequencerNodeComponents {
pub monitoring_endpoint: Option<MonitoringEndpoint>,
pub mempool_p2p_propagator: Option<MempoolP2pPropagator>,
pub mempool_p2p_runner: Option<MempoolP2pRunner>,
pub state_sync: Option<StateSync>,
pub state_sync_runner: Option<StateSyncRunner>,
}

pub fn create_node_components(
Expand Down Expand Up @@ -111,6 +115,16 @@ pub fn create_node_components(
ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None,
};

let (state_sync, state_sync_runner) = match config.components.state_sync.execution_mode {
ComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
let (state_sync, state_sync_runner) =
create_state_sync_and_runner(config.state_sync_config.clone());
(Some(state_sync), Some(state_sync_runner))
}
ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => (None, None),
};

SequencerNodeComponents {
batcher,
consensus_manager,
Expand All @@ -120,5 +134,7 @@ pub fn create_node_components(
monitoring_endpoint,
mempool_p2p_propagator,
mempool_p2p_runner,
state_sync,
state_sync_runner,
}
}
4 changes: 4 additions & 0 deletions crates/starknet_sequencer_node/src/config/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use starknet_http_server::config::HttpServerConfig;
use starknet_mempool_p2p::config::MempoolP2pConfig;
use starknet_monitoring_endpoint::config::MonitoringEndpointConfig;
use starknet_sierra_compile::config::SierraToCasmCompilationConfig;
use starknet_state_sync::config::StateSyncConfig;
use validator::Validate;

use crate::config::component_config::ComponentConfig;
Expand Down Expand Up @@ -122,6 +123,8 @@ pub struct SequencerNodeConfig {
pub mempool_p2p_config: MempoolP2pConfig,
#[validate]
pub monitoring_endpoint_config: MonitoringEndpointConfig,
#[validate]
pub state_sync_config: StateSyncConfig,
}

impl SerializeConfig for SequencerNodeConfig {
Expand All @@ -142,6 +145,7 @@ impl SerializeConfig for SequencerNodeConfig {
self.monitoring_endpoint_config.dump(),
"monitoring_endpoint_config",
),
append_sub_config_name(self.state_sync_config.dump(), "state_sync_config"),
];

sub_configs.into_iter().flatten().collect()
Expand Down

0 comments on commit f08ecd8

Please sign in to comment.