From 295c5c1bf607ef1c2b67567fdbc15d3b14228ebc Mon Sep 17 00:00:00 2001 From: Gilad Chase Date: Tue, 5 Nov 2024 20:09:02 +0200 Subject: [PATCH] chore(sync): add lints to sync Lior banned `as` repo-wide, unless absolutely necessary. --- crates/papyrus_sync/Cargo.toml | 6 ++---- crates/papyrus_sync/src/lib.rs | 9 +++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/papyrus_sync/Cargo.toml b/crates/papyrus_sync/Cargo.toml index 0237d111e4..50ee6603f5 100644 --- a/crates/papyrus_sync/Cargo.toml +++ b/crates/papyrus_sync/Cargo.toml @@ -41,7 +41,5 @@ starknet_api = { workspace = true, features = ["testing"] } starknet_client = { workspace = true, features = ["testing"] } tokio-stream.workspace = true -[lints.rust] -# See [here](https://github.com/taiki-e/cargo-llvm-cov/issues/370) for a discussion on why this is -# needed (from rust 1.80). -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] } +[lints] +workspace = true diff --git a/crates/papyrus_sync/src/lib.rs b/crates/papyrus_sync/src/lib.rs index 5159b774a0..9082deccc0 100644 --- a/crates/papyrus_sync/src/lib.rs +++ b/crates/papyrus_sync/src/lib.rs @@ -404,6 +404,7 @@ impl< fields(block_hash = format_args!("{:#064x}", block.header.block_hash.0)), err )] + #[allow(clippy::as_conversions)] // FIXME: use int metrics so `as f64` may be removed. fn store_block( &mut self, block_number: BlockNumber, @@ -445,6 +446,7 @@ impl< #[latency_histogram("sync_store_state_diff_latency_seconds", false)] #[instrument(skip(self, state_diff, deployed_contract_class_definitions), level = "debug", err)] + #[allow(clippy::as_conversions)] // FIXME: use int metrics so `as f64` may be removed. fn store_state_diff( &mut self, block_number: BlockNumber, @@ -501,6 +503,7 @@ impl< let txn = self.writer.begin_rw_txn()?; // TODO: verifications - verify casm corresponds to a class on storage. match txn.append_casm(&class_hash, &compiled_class) { + #[allow(clippy::as_conversions)] // FIXME: use int metrics so `as f64` may be removed. Ok(txn) => { txn.commit()?; let compiled_class_marker = @@ -546,6 +549,7 @@ impl< l2_hash: expected_hash, }); } + #[allow(clippy::as_conversions)] // FIXME: use int metrics so `as f64` may be removed. if txn.get_base_layer_block_marker()? != block_number.unchecked_next() { info!("Verified block {block_number} hash against base layer."); txn.update_base_layer_block_marker(&block_number.unchecked_next())?.commit()?; @@ -678,6 +682,7 @@ fn stream_new_blocks< max_stream_size: u32, ) -> impl Stream> { try_stream! { + #[allow(clippy::as_conversions)] // FIXME: use int metrics so `as f64` may be removed. loop { let header_marker = reader.begin_ro_txn()?.get_header_marker()?; let latest_central_block = central_source.get_latest_block().await?; @@ -738,7 +743,7 @@ fn stream_new_state_diffs( tokio::time::sleep(block_propagation_sleep_duration).await; continue; } - let up_to = min(last_block_number, BlockNumber(state_marker.0 + max_stream_size as u64)); + let up_to = min(last_block_number, BlockNumber(state_marker.0 + u64::from(max_stream_size))); debug!("Downloading state diffs [{} - {}).", state_marker, up_to); let state_diff_stream = central_source.stream_state_updates(state_marker, up_to).fuse(); @@ -835,7 +840,7 @@ fn stream_new_compiled_classes tokio::time::sleep(block_propagation_sleep_duration).await; continue; } - let up_to = min(state_marker, BlockNumber(from.0 + max_stream_size as u64)); + let up_to = min(state_marker, BlockNumber(from.0 + u64::from(max_stream_size))); debug!("Downloading compiled classes of blocks [{} - {}).", from, up_to); let compiled_classes_stream = central_source.stream_compiled_classes(from, up_to).fuse();