From e5576a45817ff938f1cc659d168422bd155d63cd Mon Sep 17 00:00:00 2001 From: Noam Spiegelstein Date: Wed, 27 Nov 2024 12:53:04 +0200 Subject: [PATCH] feat(sync): create state sync channels --- Cargo.lock | 1 + crates/starknet_sequencer_node/Cargo.toml | 1 + .../starknet_sequencer_node/src/communication.rs | 14 ++++++++++++++ 3 files changed, 16 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 331f7419e6..3fddafbc6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10644,6 +10644,7 @@ dependencies = [ "starknet_sequencer_infra", "starknet_sequencer_node", "starknet_sierra_compile", + "starknet_state_sync_types", "thiserror", "tokio", "tracing", diff --git a/crates/starknet_sequencer_node/Cargo.toml b/crates/starknet_sequencer_node/Cargo.toml index dfbd5cc9f4..29aa72a10a 100644 --- a/crates/starknet_sequencer_node/Cargo.toml +++ b/crates/starknet_sequencer_node/Cargo.toml @@ -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_types.workspace = true thiserror = { workspace = true, optional = true } tokio.workspace = true tracing.workspace = true diff --git a/crates/starknet_sequencer_node/src/communication.rs b/crates/starknet_sequencer_node/src/communication.rs index 50157228d4..812b72ab99 100644 --- a/crates/starknet_sequencer_node/src/communication.rs +++ b/crates/starknet_sequencer_node/src/communication.rs @@ -3,6 +3,7 @@ use starknet_gateway_types::communication::GatewayRequestAndResponseSender; use starknet_mempool_p2p_types::communication::MempoolP2pPropagatorRequestAndResponseSender; use starknet_mempool_types::communication::MempoolRequestAndResponseSender; use starknet_sequencer_infra::component_definitions::ComponentCommunication; +use starknet_state_sync_types::communication::StateSyncRequestAndResponseSender; use tokio::sync::mpsc::{channel, Receiver, Sender}; pub struct SequencerNodeCommunication { @@ -11,6 +12,7 @@ pub struct SequencerNodeCommunication { mempool_channel: ComponentCommunication, mempool_p2p_propagator_channel: ComponentCommunication, + state_sync_channel: ComponentCommunication, } impl SequencerNodeCommunication { @@ -48,6 +50,14 @@ impl SequencerNodeCommunication { pub fn take_mempool_rx(&mut self) -> Receiver { self.mempool_channel.take_rx() } + + pub fn take_state_sync_tx(&mut self) -> Sender { + self.state_sync_channel.take_tx() + } + + pub fn take_state_sync_rx(&mut self) -> Receiver { + self.state_sync_channel.take_rx() + } } pub fn create_node_channels() -> SequencerNodeCommunication { @@ -64,6 +74,9 @@ pub fn create_node_channels() -> SequencerNodeCommunication { let (tx_mempool_p2p_propagator, rx_mempool_p2p_propagator) = channel::(DEFAULT_INVOCATIONS_QUEUE_SIZE); + let (tx_state_sync, rx_state_sync) = + channel::(DEFAULT_INVOCATIONS_QUEUE_SIZE); + SequencerNodeCommunication { batcher_channel: ComponentCommunication::new(Some(tx_batcher), Some(rx_batcher)), gateway_channel: ComponentCommunication::new(Some(tx_gateway), Some(rx_gateway)), @@ -72,5 +85,6 @@ pub fn create_node_channels() -> SequencerNodeCommunication { Some(tx_mempool_p2p_propagator), Some(rx_mempool_p2p_propagator), ), + state_sync_channel: ComponentCommunication::new(Some(tx_state_sync), Some(rx_state_sync)), } }