Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions packages/canlog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ where
}

fn sort_asc(&mut self) {
self.entries.sort_by(|a, b| a.timestamp.cmp(&b.timestamp));
self.entries.sort_by_key(|a| a.timestamp);
}

fn sort_desc(&mut self) {
self.entries.sort_by(|a, b| b.timestamp.cmp(&a.timestamp));
self.entries.sort_by_key(|b| std::cmp::Reverse(b.timestamp));
}
}

Expand Down
2 changes: 1 addition & 1 deletion rs/bitcoin/adapter/src/blockchainstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ mod test {
);

let mut tips = crate::header_cache::test::get_tips(&state.header_cache);
tips.sort_by(|x, y| y.work.cmp(&x.work));
tips.sort_by_key(|y| std::cmp::Reverse(y.work));
assert_eq!(tips.len(), 2);
assert_eq!(tips[0].header.block_hash(), *last_fork_hash);
assert_eq!(tips[1].header.block_hash(), *last_chain_hash);
Expand Down
1 change: 1 addition & 0 deletions rs/bitcoin/adapter/src/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct BtcServiceImpl<Network: BlockchainNetwork> {
impl TryFrom<BtcServiceGetSuccessorsRequest> for GetSuccessorsRequest {
type Error = Status;

#[allow(clippy::result_large_err)]
fn try_from(request: BtcServiceGetSuccessorsRequest) -> Result<Self, Self::Error> {
let anchor = BlockHash::from_slice(request.anchor.as_slice())
.map_err(|_| Status::unknown("Failed to parse anchor hash!"))?;
Expand Down
2 changes: 1 addition & 1 deletion rs/bitcoin/ckbtc/minter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ fn reimburse_canceled_requests<R: CanisterRuntime>(
requests.len(),
state.retrieve_btc_min_amount
);
for (request, fee) in requests.into_iter().zip(fees.into_iter()) {
for (request, fee) in requests.into_iter().zip(fees) {
if let Some(account) = request.reimbursement_account {
let amount = request.amount.saturating_sub(fee);
if amount > 0 {
Expand Down
2 changes: 1 addition & 1 deletion rs/bitcoin/ckbtc/minter/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ impl CkBtcSetup {
pub fn print_minter_canister_logs(&self) {
let log = self.env.canister_log(self.minter_id);
let mut records = log.records().iter().collect::<Vec<_>>();
records.sort_by(|a, b| a.idx.cmp(&b.idx));
records.sort_by_key(|a| a.idx);
for entry in records {
println!(
"[{}] {}: {}",
Expand Down
2 changes: 1 addition & 1 deletion rs/consensus/certification/src/certifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ mod tests {
.collect();

// sort by heights
certs.sort_by(|s1, s2| s1.height.cmp(&s2.height));
certs.sort_by_key(|s| s.height);

assert_eq!(certs[0].height, Height::from(3));
assert_eq!(certs[1].height, Height::from(4));
Expand Down
4 changes: 2 additions & 2 deletions rs/consensus/idkg/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,8 @@ pub(crate) fn get_dealings_and_support(
) -> (BTreeMap<NodeId, SignedIDkgDealing>, Vec<IDkgDealingSupport>) {
let dealings = env.nodes.create_and_verify_signed_dealings(params);
let supports = dealings
.iter()
.flat_map(|(_, dealing)| {
.values()
.flat_map(|dealing| {
env.nodes.filter_by_receivers(&params).map(|signer| {
let c: Arc<dyn ConsensusCrypto> = signer.crypto();
let sig_share = c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,8 @@ pub fn prove_chunking<R: RngCore + CryptoRng>(
let xpowers = Scalar::xpowers(&second_challenge, NUM_ZK_REPETITIONS);

let mut z_r = Vec::with_capacity(first_challenge.len());
let mut delta_idx = 1;

for e_i in first_challenge.iter() {
for (delta_idx, e_i) in (1_usize..).zip(first_challenge.iter()) {
let mut xpow_e_ij = Vec::with_capacity(e_i.len());
for j in 0..e_i.len() {
xpow_e_ij.push(Scalar::muln_usize_vartime(&xpowers, &e_i[j]));
Expand All @@ -306,8 +305,6 @@ pub fn prove_chunking<R: RngCore + CryptoRng>(
let z_rk = Scalar::muln_vartime(&witness.scalars_r, &xpow_e_ij) + &delta[delta_idx];

z_r.push(z_rk);

delta_idx += 1;
}

let z_beta = Scalar::muln_vartime(&beta, &xpowers) + &delta[0];
Expand Down
6 changes: 3 additions & 3 deletions rs/crypto/tests/canister_threshold_idkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3665,7 +3665,7 @@ mod reshare_key_transcript {

let nodes_involved_in_resharing: Nodes = source_subnet_nodes
.into_filtered_by_receivers(&source_receivers)
.chain(target_subnet_nodes.into_iter())
.chain(target_subnet_nodes)
.collect();
let initial_dealings = {
let signed_dealings = nodes_involved_in_resharing
Expand Down Expand Up @@ -3751,7 +3751,7 @@ mod reshare_key_transcript {

let nodes_involved_in_resharing: Nodes = source_subnet_nodes
.into_filtered_by_receivers(&source_receivers)
.chain(target_subnet_nodes.into_iter())
.chain(target_subnet_nodes)
.collect();
let reshared_key_transcript = nodes_involved_in_resharing
.run_idkg_and_create_and_verify_transcript(&reshare_params, rng);
Expand Down Expand Up @@ -3807,7 +3807,7 @@ mod reshare_key_transcript {

let nodes_involved_in_resharing: Nodes = source_subnet_nodes
.into_filtered_by_receivers(&source_receivers)
.chain(target_subnet_nodes.into_iter())
.chain(target_subnet_nodes)
.collect();
let reshared_key_transcript = nodes_involved_in_resharing
.run_idkg_and_create_and_verify_transcript(&reshare_params, rng);
Expand Down
4 changes: 2 additions & 2 deletions rs/ethereum/cketh/minter/src/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ impl Log {
}

pub fn sort_asc(&mut self) {
self.entries.sort_by(|a, b| a.timestamp.cmp(&b.timestamp));
self.entries.sort_by_key(|a| a.timestamp);
}

pub fn sort_desc(&mut self) {
self.entries.sort_by(|a, b| b.timestamp.cmp(&a.timestamp));
self.entries.sort_by_key(|b| std::cmp::Reverse(b.timestamp));
}
}

Expand Down
2 changes: 1 addition & 1 deletion rs/ethereum/cketh/test_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ impl CkEthSetup {
let log = self.env.canister_log(self.minter_id);

let mut records = log.records().iter().collect::<Vec<_>>();
records.sort_by(|a, b| a.idx.cmp(&b.idx));
records.sort_by_key(|a| a.idx);
records
.into_iter()
.map(|log| CanisterLog {
Expand Down
4 changes: 2 additions & 2 deletions rs/ethereum/ledger-suite-orchestrator/src/logs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ impl Log {
}

pub fn sort_asc(&mut self) {
self.entries.sort_by(|a, b| a.timestamp.cmp(&b.timestamp));
self.entries.sort_by_key(|a| a.timestamp);
}

pub fn sort_desc(&mut self) {
self.entries.sort_by(|a, b| b.timestamp.cmp(&a.timestamp));
self.entries.sort_by_key(|b| std::cmp::Reverse(b.timestamp));
}
}
8 changes: 3 additions & 5 deletions rs/execution_environment/src/scheduler/tests/scheduling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,9 @@ fn scheduler_can_deplete_induction_pool_given_enough_execution_rounds(
available_messages,
instructions_per_round / instructions_per_message,
);
let required_rounds = if minimum_executed_messages != 0 {
available_messages / minimum_executed_messages + 1
} else {
1
};
let required_rounds = available_messages
.checked_div(minimum_executed_messages)
.map_or(1, |v| v + 1);
for _ in 0..required_rounds {
test.execute_round(ExecutionRoundType::OrdinaryRound);
}
Expand Down
1 change: 1 addition & 0 deletions rs/https_outcalls/consensus/src/pool_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2360,6 +2360,7 @@ pub mod test {

// `make_new_requests` will try to dispatch contexts to the adapter shim.
// Accept any number of `send` calls and treat them as no-ops.
#[allow(clippy::result_large_err)]
shim_mock.expect_send().returning(|_| Ok(()));

let mut sequence = Sequence::new();
Expand Down
2 changes: 2 additions & 0 deletions rs/interfaces/mocks/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
//! `VetKdArgs<'a>` (`'_` is forbidden, named lifetimes cannot be declared, and
//! elision does not work inside the macro).

#![allow(clippy::result_large_err)]

use ic_crypto_interfaces_sig_verification::BasicSigVerifierByPublicKey;
use ic_interfaces::crypto::{
BasicSigVerifier, BasicSigner, CheckKeysWithRegistryError, CurrentNodePublicKeysError,
Expand Down
1 change: 1 addition & 0 deletions rs/ledger_suite/icp/index/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ fn append_blocks(new_blocks: Vec<EncodedBlock>) -> Result<(), String> {
// the index of the next block that we
// are going to append
let mut block_index = with_blocks(|blocks| blocks.len());
#[allow(clippy::explicit_counter_loop)]
for block in new_blocks {
// append the encoded block to the block log
with_blocks(|blocks| {
Expand Down
5 changes: 2 additions & 3 deletions rs/ledger_suite/icp/index/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,8 @@ fn assert_ledger_index_parity_query_blocks_and_query_encoded_blocks(
// - the `created_at_time` field of the unencoded block is set to the `timestamp` field
// of the block
// - all the other fields of the blocks match
for (ledger_block, unencoded_ledger_block) in ledger_blocks
.into_iter()
.zip(ledger_unencoded_blocks.into_iter())
for (ledger_block, unencoded_ledger_block) in
ledger_blocks.into_iter().zip(ledger_unencoded_blocks)
{
if ledger_block != unencoded_ledger_block {
if ledger_block.transaction.created_at_time.is_none() {
Expand Down
7 changes: 3 additions & 4 deletions rs/ledger_suite/icp/ledger/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ fn assert_candid_block_equals_icp_ledger_block(
icp_ledger_blocks: Vec<Block>,
) {
assert_eq!(candid_blocks.len(), icp_ledger_blocks.len());
for (cb, lb) in candid_blocks.into_iter().zip(icp_ledger_blocks.into_iter()) {
for (cb, lb) in candid_blocks.into_iter().zip(icp_ledger_blocks) {
assert_eq!(
cb.parent_hash.map(|x| x.to_vec()),
lb.parent_hash.map(|x| x.as_slice().to_vec())
Expand Down Expand Up @@ -1209,9 +1209,8 @@ fn test_block_transformation() {
assert_eq!(certificate_pre_upgrade, certificate_post_upgrade);

//Go through all blocks and make sure the blocks fetched before the upgrade are the same as after the upgrade
for (block_pre_upgrade, block_post_upgrade) in resp_pre_upgrade
.into_iter()
.zip(resp_post_upgrade.into_iter())
for (block_pre_upgrade, block_post_upgrade) in
resp_pre_upgrade.into_iter().zip(resp_post_upgrade)
{
assert_eq!(block_pre_upgrade, block_post_upgrade);
assert_eq!(
Expand Down
1 change: 1 addition & 0 deletions rs/ledger_suite/icrc1/archive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ fn icrc3_get_blocks(reqs: Vec<GetBlocksRequest>) -> GetBlocksResult {
}
let length = length.min(max_length);
let decoded_block_range = decode_block_range(start, length, decode_icrc1_block);
#[allow(clippy::explicit_counter_loop)]
for block in decoded_block_range {
blocks.push(BlockWithId {
id: id.clone(),
Expand Down
1 change: 1 addition & 0 deletions rs/ledger_suite/icrc1/index-ng/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ fn append_blocks(new_blocks: Vec<GenericBlock>) -> Result<(), SyncError> {
// the index of the next block that we
// are going to append
let mut block_index = with_blocks(|blocks| blocks.len());
#[allow(clippy::explicit_counter_loop)]
for block in new_blocks {
append_block(block_index, block)?;
block_index += 1;
Expand Down
2 changes: 1 addition & 1 deletion rs/ledger_suite/icrc1/index-ng/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ fn assert_ledger_index_parity(env: &StateMachine, ledger_id: CanisterId, index_i
for (index, (ledger_block, index_block)) in ledger_blocks
.blocks
.into_iter()
.zip(index_blocks.blocks.into_iter())
.zip(index_blocks.blocks)
.enumerate()
{
// If the hash matches then they are the same block.
Expand Down
4 changes: 2 additions & 2 deletions rs/ledger_suite/icrc1/ledger/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ fn test_icrc3_get_blocks() {
for (local_index, (actual_block, expected_block)) in actual_res
.blocks
.into_iter()
.zip(expected_res.blocks.into_iter())
.zip(expected_res.blocks)
.enumerate()
{
check_old_vs_icrc3_blocks(
Expand Down Expand Up @@ -1285,7 +1285,7 @@ fn test_icrc3_get_blocks() {
for (block_index, (actual_block, expected_block)) in actual_archived_blocks
.blocks
.into_iter()
.zip(expected_archived_blocks.blocks.into_iter())
.zip(expected_archived_blocks.blocks)
.enumerate()
{
check_old_vs_icrc3_blocks(block_index, expected_block.clone(), actual_block.clone());
Expand Down
4 changes: 2 additions & 2 deletions rs/ledger_suite/tests/sm-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ where
let mut prev_hash = None;

// Check that the hash chain is correct.
for block in archived_blocks.into_iter().chain(resp.blocks.into_iter()) {
for block in archived_blocks.into_iter().chain(resp.blocks) {
assert_eq!(
prev_hash,
get_phash(&block).expect("cannot get the hash of the previous block")
Expand Down Expand Up @@ -2069,7 +2069,7 @@ pub fn icrc1_test_block_transformation<T, Tokens>(
for (block_pre_upgrade, block_post_upgrade) in resp_pre_upgrade
.blocks
.into_iter()
.zip(resp_post_upgrade.blocks.into_iter())
.zip(resp_post_upgrade.blocks)
{
assert!(
equivalent_values(&block_pre_upgrade, &block_post_upgrade),
Expand Down
1 change: 1 addition & 0 deletions rs/monitoring/adapter_metrics/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl Metrics {

#[tonic::async_trait]
impl AdapterMetricsService for Metrics {
#[allow(clippy::result_large_err)]
async fn scrape(
&self,
_request: Request<ScrapeRequest>,
Expand Down
2 changes: 1 addition & 1 deletion rs/nervous_system/agent/src/sns/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl SwapCanister {
if new_sns_neuron_recipes.sns_neuron_recipes.is_empty() {
return Ok(sns_neuron_recipes);
} else {
sns_neuron_recipes.extend(new_sns_neuron_recipes.sns_neuron_recipes.into_iter())
sns_neuron_recipes.extend(new_sns_neuron_recipes.sns_neuron_recipes)
}
}
Err(ListAllSnsNeuronRecipesError::TooManyRecipes(
Expand Down
5 changes: 2 additions & 3 deletions rs/nervous_system/integration_tests/tests/sns_lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ async fn test_sns_lifecycle(
.await
.unwrap();

stream::iter(nns_neuron_controller_principal_ids.into_iter())
stream::iter(nns_neuron_controller_principal_ids)
.then(|controller_principal_id| {
let pocket_ic = &pocket_ic;
async move {
Expand Down Expand Up @@ -1589,8 +1589,7 @@ async fn test_sns_lifecycle(
permissions: &[sns_pb::NeuronPermission],
) -> Vec<sns_pb::NeuronPermission> {
let mut permissions = permissions.to_vec();
permissions
.sort_by(|x, y| y.principal.unwrap().cmp(&x.principal.unwrap()));
permissions.sort_by_key(|y| std::cmp::Reverse(y.principal.unwrap()));
permissions
}
let claimer_permissions = nervous_system_parameters
Expand Down
13 changes: 5 additions & 8 deletions rs/nns/cmc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,15 +964,12 @@ fn compute_average_icp_xdr_rate_at_time(
let size = filtered_rates.len() as u64;
// If there are rates that meet the age requirement, compute the sum and compute
// the average.
if size > 0 {
let sum: u64 = filtered_rates.into_iter().sum();
Some(IcpXdrConversionRate {
timestamp_seconds: day * 86_400, // Start of the current day.
xdr_permyriad_per_icp: sum / size, // The average of the valid data points.
let sum: u64 = filtered_rates.into_iter().sum();
sum.checked_div(size)
.map(|xdr_permyriad_per_icp| IcpXdrConversionRate {
timestamp_seconds: day * 86_400, // Start of the current day.
xdr_permyriad_per_icp, // The average of the valid data points.
})
} else {
None
}
}

#[update(hidden = true)]
Expand Down
30 changes: 13 additions & 17 deletions rs/nns/governance/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4660,17 +4660,15 @@ impl Governance {
));
}
}
Command::Follow(follow) => {
if follow.followees.len() > MAX_FOLLOWEES_PER_TOPIC {
return Err(GovernanceError::new_with_message(
ErrorType::InvalidCommand,
format!(
"Too many followees: {} (max: {})",
follow.followees.len(),
MAX_FOLLOWEES_PER_TOPIC
),
));
}
Command::Follow(follow) if follow.followees.len() > MAX_FOLLOWEES_PER_TOPIC => {
return Err(GovernanceError::new_with_message(
ErrorType::InvalidCommand,
format!(
"Too many followees: {} (max: {})",
follow.followees.len(),
MAX_FOLLOWEES_PER_TOPIC
),
));
}
Command::SetFollowing(set_following) => {
set_following.validate_intrinsically()?;
Expand Down Expand Up @@ -4955,12 +4953,10 @@ impl Governance {
Self::validate_add_or_remove_data_centers_payload(&update.payload)
.map_err(invalid_proposal_error)?;
}
ValidNnsFunction::SplitSubnet => {
if !are_subnet_splitting_proposals_enabled() {
return Err(invalid_proposal_error(String::from(
"Subnet Splitting proposals not yet enabled",
)));
}
ValidNnsFunction::SplitSubnet if !are_subnet_splitting_proposals_enabled() => {
return Err(invalid_proposal_error(String::from(
"Subnet Splitting proposals not yet enabled",
)));
}
_ => {}
};
Expand Down
2 changes: 1 addition & 1 deletion rs/nns/governance/src/governance/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ fn set_up_chain<R: Rng>(
let previous_neuron_indices = (neuron_index - num_half_followees - 1)..neuron_index;
let followee_neuron_ids = previous_neuron_indices
.map(|index| neuron_ids[index as usize])
.chain(not_voting_neuron_ids.clone().into_iter())
.chain(not_voting_neuron_ids.clone())
.collect::<Vec<_>>();

let followees = hashmap! {topic.into() => Followees {followees: followee_neuron_ids}};
Expand Down
Loading
Loading