Skip to content

Commit

Permalink
feat(sync): create state sync channels
Browse files Browse the repository at this point in the history
  • Loading branch information
noamsp-starkware committed Nov 27, 2024
1 parent 9421def commit e5576a4
Show file tree
Hide file tree
Showing 3 changed files with 16 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_types.workspace = true
thiserror = { workspace = true, optional = true }
tokio.workspace = true
tracing.workspace = true
Expand Down
14 changes: 14 additions & 0 deletions crates/starknet_sequencer_node/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -11,6 +12,7 @@ pub struct SequencerNodeCommunication {
mempool_channel: ComponentCommunication<MempoolRequestAndResponseSender>,
mempool_p2p_propagator_channel:
ComponentCommunication<MempoolP2pPropagatorRequestAndResponseSender>,
state_sync_channel: ComponentCommunication<StateSyncRequestAndResponseSender>,
}

impl SequencerNodeCommunication {
Expand Down Expand Up @@ -48,6 +50,14 @@ impl SequencerNodeCommunication {
pub fn take_mempool_rx(&mut self) -> Receiver<MempoolRequestAndResponseSender> {
self.mempool_channel.take_rx()
}

pub fn take_state_sync_tx(&mut self) -> Sender<StateSyncRequestAndResponseSender> {
self.state_sync_channel.take_tx()
}

pub fn take_state_sync_rx(&mut self) -> Receiver<StateSyncRequestAndResponseSender> {
self.state_sync_channel.take_rx()
}
}

pub fn create_node_channels() -> SequencerNodeCommunication {
Expand All @@ -64,6 +74,9 @@ pub fn create_node_channels() -> SequencerNodeCommunication {
let (tx_mempool_p2p_propagator, rx_mempool_p2p_propagator) =
channel::<MempoolP2pPropagatorRequestAndResponseSender>(DEFAULT_INVOCATIONS_QUEUE_SIZE);

let (tx_state_sync, rx_state_sync) =
channel::<StateSyncRequestAndResponseSender>(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)),
Expand All @@ -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)),
}
}

0 comments on commit e5576a4

Please sign in to comment.