Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sync): add lints to sync #1847

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions crates/papyrus_sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 7 additions & 2 deletions crates/papyrus_sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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()?;
Expand Down Expand Up @@ -678,6 +682,7 @@ fn stream_new_blocks<
max_stream_size: u32,
) -> impl Stream<Item = Result<SyncEvent, StateSyncError>> {
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?;
Expand Down Expand Up @@ -738,7 +743,7 @@ fn stream_new_state_diffs<TCentralSource: CentralSourceTrait + Sync + Send>(
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();
Expand Down Expand Up @@ -835,7 +840,7 @@ fn stream_new_compiled_classes<TCentralSource: CentralSourceTrait + Sync + Send>
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();
Expand Down
Loading