Skip to content

Commit

Permalink
chore(sync): add lints to sync (#1847)
Browse files Browse the repository at this point in the history
Lior banned `as` repo-wide, unless absolutely necessary.

Co-Authored-By: Gilad Chase <gilad@starkware.com>
  • Loading branch information
giladchase and Gilad Chase authored Nov 7, 2024
1 parent d675611 commit 5fe6be8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
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

0 comments on commit 5fe6be8

Please sign in to comment.