diff --git a/Cargo.lock b/Cargo.lock index f7b39f1bab..5d9e9d4161 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7575,6 +7575,7 @@ dependencies = [ "serde", "starknet-types-core", "starknet_api", + "starknet_state_sync_types", "static_assertions", "thiserror", "tokio", diff --git a/crates/papyrus_node/src/run.rs b/crates/papyrus_node/src/run.rs index e26b379759..6cf1b19356 100644 --- a/crates/papyrus_node/src/run.rs +++ b/crates/papyrus_node/src/run.rs @@ -7,6 +7,7 @@ use std::process::exit; use std::sync::Arc; use std::time::Duration; +use futures::StreamExt; use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerConfig; use papyrus_common::metrics::COLLECT_PROFILING_METRICS; use papyrus_common::pending_classes::PendingClasses; @@ -304,6 +305,7 @@ async fn spawn_sync_client( storage_reader, storage_writer, p2p_sync_client_channels, + futures::stream::pending().boxed(), ); tokio::spawn(async move { Ok(p2p_sync.run().await?) }) } diff --git a/crates/papyrus_p2p_sync/Cargo.toml b/crates/papyrus_p2p_sync/Cargo.toml index 653fbd259b..f39a8bc76b 100644 --- a/crates/papyrus_p2p_sync/Cargo.toml +++ b/crates/papyrus_p2p_sync/Cargo.toml @@ -22,6 +22,7 @@ papyrus_storage.workspace = true rand.workspace = true serde.workspace = true starknet_api.workspace = true +starknet_state_sync_types.workspace = true starknet-types-core.workspace = true thiserror.workspace = true tokio.workspace = true diff --git a/crates/papyrus_p2p_sync/src/client/mod.rs b/crates/papyrus_p2p_sync/src/client/mod.rs index 01e13465f7..0ff1dd955e 100644 --- a/crates/papyrus_p2p_sync/src/client/mod.rs +++ b/crates/papyrus_p2p_sync/src/client/mod.rs @@ -19,6 +19,7 @@ use std::time::Duration; use class::ClassStreamBuilder; use futures::channel::mpsc::SendError; +use futures::stream::BoxStream; use futures::Stream; use header::HeaderStreamBuilder; use papyrus_common::pending_classes::ApiContractClass; @@ -40,11 +41,13 @@ use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; use starknet_api::core::ClassHash; use starknet_api::transaction::FullTransaction; +use starknet_state_sync_types::state_sync_types::SyncBlock; use state_diff::StateDiffStreamBuilder; use stream_builder::{DataStreamBuilder, DataStreamResult}; use tokio_stream::StreamExt; use tracing::instrument; use transaction::TransactionStreamFactory; + const STEP: u64 = 1; const ALLOWED_SIGNATURES_LENGTH: usize = 1; @@ -226,6 +229,8 @@ pub struct P2PSyncClient { storage_reader: StorageReader, storage_writer: StorageWriter, p2p_sync_channels: P2PSyncClientChannels, + #[allow(dead_code)] + internal_blocks_receiver: BoxStream<'static, (BlockNumber, SyncBlock)>, } impl P2PSyncClient { @@ -234,8 +239,9 @@ impl P2PSyncClient { storage_reader: StorageReader, storage_writer: StorageWriter, p2p_sync_channels: P2PSyncClientChannels, + internal_blocks_receiver: BoxStream<'static, (BlockNumber, SyncBlock)>, ) -> Self { - Self { config, storage_reader, storage_writer, p2p_sync_channels } + Self { config, storage_reader, storage_writer, p2p_sync_channels, internal_blocks_receiver } } #[instrument(skip(self), level = "debug", err)] diff --git a/crates/papyrus_p2p_sync/src/client/test_utils.rs b/crates/papyrus_p2p_sync/src/client/test_utils.rs index 006ce510f9..038dd78191 100644 --- a/crates/papyrus_p2p_sync/src/client/test_utils.rs +++ b/crates/papyrus_p2p_sync/src/client/test_utils.rs @@ -112,6 +112,7 @@ pub fn setup() -> TestArgs { storage_reader.clone(), storage_writer, p2p_sync_channels, + futures::stream::pending().boxed(), ); TestArgs { p2p_sync, @@ -194,6 +195,7 @@ pub async fn run_test(max_query_lengths: HashMap, actions: Vec