diff --git a/crates/class-hash/src/lib.rs b/crates/class-hash/src/lib.rs index 2400fe0097..ff8459a3d5 100644 --- a/crates/class-hash/src/lib.rs +++ b/crates/class-hash/src/lib.rs @@ -433,17 +433,15 @@ pub fn prepare_json_contract_definition( .context("Program attribute was not an object")?; match vals.get_mut("accessible_scopes") { - Some(serde_json::Value::Array(array)) => { - if array.is_empty() { - vals.remove("accessible_scopes"); - } + Some(serde_json::Value::Array(array)) if array.is_empty() => { + vals.remove("accessible_scopes"); } + Some(serde_json::Value::Array(_)) | None => {} Some(_other) => { anyhow::bail!( r#"A program's attribute["accessible_scopes"] was not an array type."# ); } - None => {} } // We don't know what this type is supposed to be, but if its missing it is // null. diff --git a/crates/crypto/src/algebra/field/core.rs b/crates/crypto/src/algebra/field/core.rs index b5666430a8..5204473cf0 100644 --- a/crates/crypto/src/algebra/field/core.rs +++ b/crates/crypto/src/algebra/field/core.rs @@ -10,7 +10,7 @@ pub const fn const_adc(a: u64, b: u64, carry: u64) -> (u64, u64) { #[inline(always)] pub fn adc(a: &mut u64, b: u64, carry: u8) -> u8 { #[cfg(target_arch = "x86_64")] - unsafe { + { core::arch::x86_64::_addcarry_u64(carry, *a, b, a) } @@ -42,7 +42,7 @@ pub const fn const_sbb(a: u64, b: u64, borrow: u64) -> (u64, u64) { #[inline(always)] pub fn sbb(a: &mut u64, b: u64, borrow: u8) -> u8 { #[cfg(target_arch = "x86_64")] - unsafe { + { core::arch::x86_64::_subborrow_u64(borrow, *a, b, a) } diff --git a/crates/executor/src/types.rs b/crates/executor/src/types.rs index 25a8b06075..fac75f30a1 100644 --- a/crates/executor/src/types.rs +++ b/crates/executor/src/types.rs @@ -129,11 +129,9 @@ impl ConsensusPriceConverter { pub fn eth_l2_gas_price(&self) -> u128 { // Derive WEI price from the FRI price using the L1 gas price ratio. // l2_gas_price_wei = l2_gas_price_fri * l1_gas_price_wei / l1_gas_price_fri - if self.l1_gas_price_fri == 0 { - 0 - } else { - self.l2_gas_price_fri * self.l1_gas_price_wei / self.l1_gas_price_fri - } + (self.l2_gas_price_fri * self.l1_gas_price_wei) + .checked_div(self.l1_gas_price_fri) + .unwrap_or_default() } } diff --git a/crates/p2p/src/core/client.rs b/crates/p2p/src/core/client.rs index a5c9cb3da8..e761a06a9c 100644 --- a/crates/p2p/src/core/client.rs +++ b/crates/p2p/src/core/client.rs @@ -77,7 +77,7 @@ impl Client { while let Some(partial_result) = receiver.recv().await { let more_peers = partial_result.with_context(|| format!("Getting closest peers to {peer}"))?; - peers.extend(more_peers.into_iter()); + peers.extend(more_peers); } Ok(peers) diff --git a/crates/p2p/src/main_loop.rs b/crates/p2p/src/main_loop.rs index dee8fdcea7..016d98c7a1 100644 --- a/crates/p2p/src/main_loop.rs +++ b/crates/p2p/src/main_loop.rs @@ -427,14 +427,12 @@ where } kad::Event::RoutingUpdated { peer, is_new_peer, .. - } => { - if is_new_peer { - send_test_event( - &self._test_event_sender, - TestEvent::PeerAddedToDHT { remote: peer }, - ) - .await - } + } if is_new_peer => { + send_test_event( + &self._test_event_sender, + TestEvent::PeerAddedToDHT { remote: peer }, + ) + .await } _ => {} }, diff --git a/crates/pathfinder/src/state/sync/l2.rs b/crates/pathfinder/src/state/sync/l2.rs index d977f70918..f76c1202b6 100644 --- a/crates/pathfinder/src/state/sync/l2.rs +++ b/crates/pathfinder/src/state/sync/l2.rs @@ -782,7 +782,7 @@ pub async fn download_new_classes( let missing = new_classes .into_iter() - .zip(exists.into_iter()) + .zip(exists) .filter_map(|(class, exist)| (!exist).then_some(class)) .collect::>(); diff --git a/crates/rpc/src/error.rs b/crates/rpc/src/error.rs index ff2d2d2dbd..e98a871453 100644 --- a/crates/rpc/src/error.rs +++ b/crates/rpc/src/error.rs @@ -564,7 +564,7 @@ mod tests { mod rpc_error_subset { use assert_matches::assert_matches; - use super::super::{generate_rpc_error_subset, ApplicationError}; + use super::super::ApplicationError; #[test] fn no_variant() { diff --git a/crates/rpc/src/jsonrpc/router.rs b/crates/rpc/src/jsonrpc/router.rs index 0d843f0f1a..a5ffb713e0 100644 --- a/crates/rpc/src/jsonrpc/router.rs +++ b/crates/rpc/src/jsonrpc/router.rs @@ -383,7 +383,7 @@ where indexed_results.push(indexed_result) } - indexed_results.sort_by(|(index_a, _), (index_b, _)| index_a.cmp(index_b)); + indexed_results.sort_by_key(|(index, _)| *index); indexed_results.into_iter().map(|(_index, result)| result) } @@ -543,21 +543,21 @@ mod tests { )] #[case::invalid_request_object( json!({"jsonrpc": "2.0", "method": 1, "params": "bar"}), - json!({"jsonrpc": "2.0", "id": null, + json!({"jsonrpc": "2.0", "id": null, "error": {"code": -32600, "message": "Invalid request", "data": { "reason": "invalid type: integer `1`, expected a string at line 1 column 27" }}}), )] #[case::empty_batch( json!([]), - json!({"jsonrpc": "2.0", "id": null, + json!({"jsonrpc": "2.0", "id": null, "error": {"code": -32600, "message": "Invalid request", "data": { "reason": "A batch request must contain at least one request" }}}), )] #[case::invalid_batch_single( json!([1]), - json!([{"jsonrpc": "2.0", "id": null, + json!([{"jsonrpc": "2.0", "id": null, "error": {"code": -32600, "message": "Invalid request", "data": { "reason": "invalid type: integer `1`, expected struct Helper at line 1 column 1" }}} @@ -566,15 +566,15 @@ mod tests { #[case::invalid_batch_multiple( json!([1, 2, 3]), json!([ - {"jsonrpc": "2.0", "id": null, + {"jsonrpc": "2.0", "id": null, "error": {"code": -32600, "message": "Invalid request", "data": { "reason": "invalid type: integer `1`, expected struct Helper at line 1 column 1" }}}, - {"jsonrpc": "2.0", "id": null, + {"jsonrpc": "2.0", "id": null, "error": {"code": -32600, "message": "Invalid request", "data": { "reason": "invalid type: integer `2`, expected struct Helper at line 1 column 1" }}}, - {"jsonrpc": "2.0", "id": null, + {"jsonrpc": "2.0", "id": null, "error": {"code": -32600, "message": "Invalid request", "data": { "reason": "invalid type: integer `3`, expected struct Helper at line 1 column 1" }}}, @@ -592,7 +592,7 @@ mod tests { json!([ {"jsonrpc": "2.0", "result": 7, "id": "1"}, {"jsonrpc": "2.0", "result": 19, "id": "2"}, - {"jsonrpc": "2.0", "id": null, "error": + {"jsonrpc": "2.0", "id": null, "error": {"code": -32600, "message": "Invalid request", "data": { "reason": "missing field `jsonrpc` at line 1 column 13" }}}, diff --git a/crates/rpc/src/method/trace_block_transactions.rs b/crates/rpc/src/method/trace_block_transactions.rs index b585381dc1..1fd54903c7 100644 --- a/crates/rpc/src/method/trace_block_transactions.rs +++ b/crates/rpc/src/method/trace_block_transactions.rs @@ -237,7 +237,7 @@ pub async fn trace_block_transactions( let traces = trace .traces .into_iter() - .zip(transactions.into_iter()) + .zip(transactions) .map(|(trace, tx)| Ok((tx.hash, map_gateway_trace(tx, trace)?))) .collect::, TraceBlockTransactionsError>>()?; let output_format = if return_initial_reads { diff --git a/crates/storage/src/connection/state_update.rs b/crates/storage/src/connection/state_update.rs index 0b94def871..babd874bf8 100644 --- a/crates/storage/src/connection/state_update.rs +++ b/crates/storage/src/connection/state_update.rs @@ -228,8 +228,8 @@ impl Transaction<'_> { // cater for them here. This works because the sql only updates the row // if it is null. let deployed = contract_updates - .iter() - .filter_map(|(_, update)| match update.class { + .values() + .filter_map(|update| match update.class { Some(ContractClassUpdate::Deploy(x)) => Some(x), _ => None, }); @@ -266,7 +266,7 @@ impl Transaction<'_> { const PREFIX: &str = r" SELECT b1.number, b1.hash, b1.state_commitment, b2.state_commitment FROM block_headers b1 - LEFT OUTER JOIN block_headers b2 + LEFT OUTER JOIN block_headers b2 ON b2.number = b1.number - 1 "; @@ -436,7 +436,7 @@ impl Transaction<'_> { SELECT ch1.hash AS class_hash, ch1.compiled_class_hash AS casm_hash - FROM + FROM casm_class_hashes ch1 LEFT OUTER JOIN casm_class_hashes ch2 ON ch1.hash = ch2.hash AND ch2.block_number < ch1.block_number @@ -504,7 +504,7 @@ impl Transaction<'_> { pub fn highest_block_with_state_update(&self) -> anyhow::Result> { let mut stmt = self.inner().prepare_cached( r" - SELECT max(storage_update.last_block, nonce_update.last_block, class_definition.last_block) + SELECT max(storage_update.last_block, nonce_update.last_block, class_definition.last_block) FROM (SELECT max(block_number) last_block FROM storage_updates) storage_update, (SELECT max(block_number) last_block FROM nonce_updates) nonce_update, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 03199c42d7..3417ee5903 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.91.1" +channel = "1.95.0" components = ["rustfmt", "clippy"] profile = "minimal"