diff --git a/runtime/parachains/src/configuration/tests.rs b/runtime/parachains/src/configuration/tests.rs index 65695cab58a6..2d89aebc19d3 100644 --- a/runtime/parachains/src/configuration/tests.rs +++ b/runtime/parachains/src/configuration/tests.rs @@ -127,10 +127,7 @@ fn pending_next_session_but_we_upgrade_once_more() { assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100)); assert_eq!(Configuration::config(), initial_config); - assert_eq!( - PendingConfigs::::get(), - vec![(2, intermediate_config.clone())] - ); + assert_eq!(PendingConfigs::::get(), vec![(2, intermediate_config.clone())]); on_new_session(1); @@ -148,10 +145,7 @@ fn pending_next_session_but_we_upgrade_once_more() { on_new_session(2); assert_eq!(Configuration::config(), intermediate_config); - assert_eq!( - PendingConfigs::::get(), - vec![(3, final_config.clone())] - ); + assert_eq!(PendingConfigs::::get(), vec![(3, final_config.clone())]); on_new_session(3); @@ -175,10 +169,7 @@ fn scheduled_session_config_update_while_next_session_pending() { assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100)); assert_eq!(Configuration::config(), initial_config); - assert_eq!( - PendingConfigs::::get(), - vec![(2, intermediate_config.clone())] - ); + assert_eq!(PendingConfigs::::get(), vec![(2, intermediate_config.clone())]); on_new_session(1); @@ -197,10 +188,7 @@ fn scheduled_session_config_update_while_next_session_pending() { on_new_session(2); assert_eq!(Configuration::config(), intermediate_config); - assert_eq!( - PendingConfigs::::get(), - vec![(3, final_config.clone())] - ); + assert_eq!(PendingConfigs::::get(), vec![(3, final_config.clone())]); on_new_session(3); @@ -514,10 +502,7 @@ fn setting_pending_config_members() { Configuration::set_pvf_voting_ttl(RuntimeOrigin::root(), new_config.pvf_voting_ttl) .unwrap(); - assert_eq!( - PendingConfigs::::get(), - vec![(shared::SESSION_DELAY, new_config)], - ); + assert_eq!(PendingConfigs::::get(), vec![(shared::SESSION_DELAY, new_config)],); }) } diff --git a/runtime/parachains/src/dmp.rs b/runtime/parachains/src/dmp.rs index de7bb859671a..03a767eb428f 100644 --- a/runtime/parachains/src/dmp.rs +++ b/runtime/parachains/src/dmp.rs @@ -151,9 +151,7 @@ impl Pallet { return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) } - if DownwardMessageQueues::::decode_len(para).unwrap_or(0) > - MAX_MESSAGE_QUEUE_SIZE - { + if DownwardMessageQueues::::decode_len(para).unwrap_or(0) > MAX_MESSAGE_QUEUE_SIZE { return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) } @@ -178,9 +176,7 @@ impl Pallet { return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) } - if DownwardMessageQueues::::decode_len(para).unwrap_or(0) > - MAX_MESSAGE_QUEUE_SIZE - { + if DownwardMessageQueues::::decode_len(para).unwrap_or(0) > MAX_MESSAGE_QUEUE_SIZE { return Err(QueueDownwardMessageError::ExceedsMaxMessageSize) } diff --git a/runtime/parachains/src/hrmp.rs b/runtime/parachains/src/hrmp.rs index 708b6725188d..fe87f85db757 100644 --- a/runtime/parachains/src/hrmp.rs +++ b/runtime/parachains/src/hrmp.rs @@ -583,8 +583,8 @@ pub mod pallet { ) -> DispatchResult { let origin = ensure_parachain(::RuntimeOrigin::from(origin))?; ensure!( - HrmpOpenChannelRequestsList::::decode_len().unwrap_or_default() - as u32 <= open_requests, + HrmpOpenChannelRequestsList::::decode_len().unwrap_or_default() as u32 <= + open_requests, Error::::WrongWitness ); Self::cancel_open_request(origin, channel_id.clone())?; @@ -684,10 +684,10 @@ impl Pallet { // we need a few extra bits of data to weigh this -- all of this is read internally // anyways, so no overhead. - let ingress_count = HrmpIngressChannelsIndex::::decode_len(outgoing_para) - .unwrap_or_default() as u32; - let egress_count = HrmpEgressChannelsIndex::::decode_len(outgoing_para) - .unwrap_or_default() as u32; + let ingress_count = + HrmpIngressChannelsIndex::::decode_len(outgoing_para).unwrap_or_default() as u32; + let egress_count = + HrmpEgressChannelsIndex::::decode_len(outgoing_para).unwrap_or_default() as u32; w = w.saturating_add(::WeightInfo::force_clean_hrmp( ingress_count, egress_count, @@ -1103,8 +1103,7 @@ impl Pallet { // // Note that having the latest entry greater than the current block number is a logical // error. - let mut recipient_digest = - HrmpChannelDigests::::get(&channel_id.recipient); + let mut recipient_digest = HrmpChannelDigests::::get(&channel_id.recipient); if let Some(cur_block_digest) = recipient_digest .last_mut() .filter(|(block_no, _)| *block_no == now) @@ -1161,8 +1160,7 @@ impl Pallet { Error::::OpenHrmpChannelAlreadyExists, ); - let egress_cnt = - HrmpEgressChannelsIndex::::decode_len(&origin).unwrap_or(0) as u32; + let egress_cnt = HrmpEgressChannelsIndex::::decode_len(&origin).unwrap_or(0) as u32; let open_req_cnt = HrmpOpenChannelRequestCount::::get(&origin); let channel_num_limit = if >::is_parathread(origin) { config.hrmp_max_parathread_outbound_channels @@ -1239,8 +1237,7 @@ impl Pallet { } else { config.hrmp_max_parachain_inbound_channels }; - let ingress_cnt = - HrmpIngressChannelsIndex::::decode_len(&origin).unwrap_or(0) as u32; + let ingress_cnt = HrmpIngressChannelsIndex::::decode_len(&origin).unwrap_or(0) as u32; let accepted_cnt = HrmpAcceptedChannelRequestCount::::get(&origin); ensure!( ingress_cnt + accepted_cnt < channel_num_limit, @@ -1367,8 +1364,7 @@ impl Pallet { // The ingress channels vector is sorted, thus `mqc_heads` is sorted as well. let mut mqc_heads = Vec::with_capacity(sender_set.len()); for sender in sender_set { - let channel_metadata = - HrmpChannels::::get(&HrmpChannelId { sender, recipient }); + let channel_metadata = HrmpChannels::::get(&HrmpChannelId { sender, recipient }); let mqc_head = channel_metadata .and_then(|metadata| metadata.mqc_head) .unwrap_or(Hash::default()); @@ -1437,12 +1433,8 @@ impl Pallet { }; assert_eq!( - HrmpOpenChannelRequests::::iter() - .map(|(k, _)| k) - .collect::>(), - HrmpOpenChannelRequestsList::::get() - .into_iter() - .collect::>(), + HrmpOpenChannelRequests::::iter().map(|(k, _)| k).collect::>(), + HrmpOpenChannelRequestsList::::get().into_iter().collect::>(), ); // verify that the set of keys in `HrmpOpenChannelRequestCount` corresponds to the set @@ -1457,9 +1449,7 @@ impl Pallet { .map(|(k, _)| k.sender) .collect::>(), ); - for (open_channel_initiator, expected_num) in - HrmpOpenChannelRequestCount::::iter() - { + for (open_channel_initiator, expected_num) in HrmpOpenChannelRequestCount::::iter() { let actual_num = HrmpOpenChannelRequests::::iter() .filter(|(ch, _)| ch.sender == open_channel_initiator) .count() as u32; @@ -1477,9 +1467,7 @@ impl Pallet { .map(|(k, _)| k.recipient) .collect::>(), ); - for (channel_recipient, expected_num) in - HrmpAcceptedChannelRequestCount::::iter() - { + for (channel_recipient, expected_num) in HrmpAcceptedChannelRequestCount::::iter() { let actual_num = HrmpOpenChannelRequests::::iter() .filter(|(ch, v)| ch.recipient == channel_recipient && v.confirmed) .count() as u32; @@ -1487,12 +1475,8 @@ impl Pallet { } assert_eq!( - HrmpCloseChannelRequests::::iter() - .map(|(k, _)| k) - .collect::>(), - HrmpCloseChannelRequestsList::::get() - .into_iter() - .collect::>(), + HrmpCloseChannelRequests::::iter().map(|(k, _)| k).collect::>(), + HrmpCloseChannelRequestsList::::get().into_iter().collect::>(), ); // A HRMP watermark can be None for an onboarded parachain. However, an offboarded parachain diff --git a/runtime/parachains/src/paras/mod.rs b/runtime/parachains/src/paras/mod.rs index 8758a21d10ac..420ed3e6409e 100644 --- a/runtime/parachains/src/paras/mod.rs +++ b/runtime/parachains/src/paras/mod.rs @@ -1319,8 +1319,8 @@ impl Pallet { // The height of any changes we no longer should keep around. let pruning_height = now - (code_retention_period + One::one()); - let pruning_tasks_done = PastCodePruning::::mutate( - |pruning_tasks: &mut Vec<(_, T::BlockNumber)>| { + let pruning_tasks_done = + PastCodePruning::::mutate(|pruning_tasks: &mut Vec<(_, T::BlockNumber)>| { let (pruning_tasks_done, pruning_tasks_to_do) = { // find all past code that has just exited the pruning window. let up_to_idx = @@ -1356,8 +1356,7 @@ impl Pallet { } pruning_tasks_done as u64 - }, - ); + }); // 1 read for the meta for each pruning task, 1 read for the config // 2 writes: updating the meta and pruning the code @@ -1385,10 +1384,8 @@ impl Pallet { // account weight for `UpgradeCooldowns::get`. weight += T::DbWeight::get().reads(1); - let cooldowns_expired = UpgradeCooldowns::::get() - .iter() - .take_while(|&(_, at)| at <= &now) - .count(); + let cooldowns_expired = + UpgradeCooldowns::::get().iter().take_while(|&(_, at)| at <= &now).count(); // reserve weight for `initializer_finalize`: // - 1 read and 1 write for `UpgradeCooldowns::mutate`. @@ -1403,13 +1400,11 @@ impl Pallet { /// /// See `process_scheduled_upgrade_changes` for more details. fn process_scheduled_upgrade_cooldowns(now: T::BlockNumber) { - UpgradeCooldowns::::mutate( - |upgrade_cooldowns: &mut Vec<(ParaId, T::BlockNumber)>| { - for &(para, _) in upgrade_cooldowns.iter().take_while(|&(_, at)| at <= &now) { - UpgradeRestrictionSignal::::remove(¶); - } - }, - ); + UpgradeCooldowns::::mutate(|upgrade_cooldowns: &mut Vec<(ParaId, T::BlockNumber)>| { + for &(para, _) in upgrade_cooldowns.iter().take_while(|&(_, at)| at <= &now) { + UpgradeRestrictionSignal::::remove(¶); + } + }); } /// Goes over all PVF votes in progress, reinitializes ballots, increments ages and prunes the diff --git a/runtime/parachains/src/paras/tests.rs b/runtime/parachains/src/paras/tests.rs index a86f98383fdf..89acfc9bc9b9 100644 --- a/runtime/parachains/src/paras/tests.rs +++ b/runtime/parachains/src/paras/tests.rs @@ -286,17 +286,11 @@ fn para_past_code_pruning_in_initialize() { } let pruned_at: BlockNumber = included_block + code_retention_period + 1; - assert_eq!( - PastCodeHash::::get(&(id, at_block)), - Some(validation_code.hash()) - ); + assert_eq!(PastCodeHash::::get(&(id, at_block)), Some(validation_code.hash())); check_code_is_stored(&validation_code); run_to_block(pruned_at - 1, None); - assert_eq!( - PastCodeHash::::get(&(id, at_block)), - Some(validation_code.hash()) - ); + assert_eq!(PastCodeHash::::get(&(id, at_block)), Some(validation_code.hash())); assert_eq!(Paras::past_code_meta(&id).most_recent_change(), Some(at_block)); check_code_is_stored(&validation_code); @@ -440,10 +434,7 @@ fn code_upgrade_applied_after_delay() { assert_eq!(FutureCodeUpgrades::::get(¶_id), Some(expected_at)); assert_eq!(FutureCodeHash::::get(¶_id), Some(new_code.hash())); assert_eq!(UpcomingUpgrades::::get(), vec![(para_id, expected_at)]); - assert_eq!( - UpgradeCooldowns::::get(), - vec![(para_id, next_possible_upgrade_at)] - ); + assert_eq!(UpgradeCooldowns::::get(), vec![(para_id, next_possible_upgrade_at)]); assert_eq!(Paras::current_code(¶_id), Some(original_code.clone())); check_code_is_stored(&original_code); check_code_is_stored(&new_code); @@ -461,10 +452,7 @@ fn code_upgrade_applied_after_delay() { assert!(Paras::past_code_meta(¶_id).most_recent_change().is_none()); assert_eq!(FutureCodeUpgrades::::get(¶_id), Some(expected_at)); assert_eq!(FutureCodeHash::::get(¶_id), Some(new_code.hash())); - assert_eq!( - UpgradeGoAheadSignal::::get(¶_id), - Some(UpgradeGoAhead::GoAhead) - ); + assert_eq!(UpgradeGoAheadSignal::::get(¶_id), Some(UpgradeGoAhead::GoAhead)); assert_eq!(Paras::current_code(¶_id), Some(original_code.clone())); check_code_is_stored(&original_code); check_code_is_stored(&new_code); @@ -541,10 +529,7 @@ fn code_upgrade_applied_after_delay_even_when_late() { assert_eq!(FutureCodeUpgrades::::get(¶_id), Some(expected_at)); assert_eq!(FutureCodeHash::::get(¶_id), Some(new_code.hash())); assert_eq!(UpcomingUpgrades::::get(), vec![(para_id, expected_at)]); - assert_eq!( - UpgradeCooldowns::::get(), - vec![(para_id, next_possible_upgrade_at)] - ); + assert_eq!(UpgradeCooldowns::::get(), vec![(para_id, next_possible_upgrade_at)]); assert!(UpgradeGoAheadSignal::::get(¶_id).is_none()); assert_eq!(Paras::current_code(¶_id), Some(original_code.clone())); @@ -557,10 +542,7 @@ fn code_upgrade_applied_after_delay_even_when_late() { // the upgrade. { // The signal should be set to go-ahead until the new head is actually processed. - assert_eq!( - UpgradeGoAheadSignal::::get(¶_id), - Some(UpgradeGoAhead::GoAhead), - ); + assert_eq!(UpgradeGoAheadSignal::::get(¶_id), Some(UpgradeGoAhead::GoAhead),); Paras::note_new_head(para_id, Default::default(), expected_at + 4); @@ -615,10 +597,7 @@ fn submit_code_change_when_not_allowed_is_err() { run_to_block(1, None); Paras::schedule_code_upgrade(para_id, new_code.clone(), 1, &Configuration::config()); - assert_eq!( - FutureCodeUpgrades::::get(¶_id), - Some(1 + validation_upgrade_delay) - ); + assert_eq!(FutureCodeUpgrades::::get(¶_id), Some(1 + validation_upgrade_delay)); assert_eq!(FutureCodeHash::::get(¶_id), Some(new_code.hash())); check_code_is_stored(&new_code); @@ -688,10 +667,7 @@ fn upgrade_restriction_elapsed_doesnt_mean_can_upgrade() { UpgradeRestrictionSignal::::get(¶_id), Some(UpgradeRestriction::Present), ); - assert_eq!( - FutureCodeUpgrades::::get(¶_id), - Some(0 + validation_upgrade_delay) - ); + assert_eq!(FutureCodeUpgrades::::get(¶_id), Some(0 + validation_upgrade_delay)); assert!(!Paras::can_upgrade_validation_code(para_id)); run_to_block(31, None); @@ -702,10 +678,7 @@ fn upgrade_restriction_elapsed_doesnt_mean_can_upgrade() { // And scheduling another upgrade does not do anything. `expected_at` is still the same. Paras::schedule_code_upgrade(para_id, newer_code.clone(), 30, &Configuration::config()); - assert_eq!( - FutureCodeUpgrades::::get(¶_id), - Some(0 + validation_upgrade_delay) - ); + assert_eq!(FutureCodeUpgrades::::get(¶_id), Some(0 + validation_upgrade_delay)); }); } @@ -1643,10 +1616,7 @@ fn add_trusted_validation_code_insta_approval() { // Verify that the code upgrade has `expected_at` set to `26`. This is the behavior // equal to that of `pvf_checking_enabled: false`. - assert_eq!( - FutureCodeUpgrades::::get(¶_id), - Some(1 + validation_upgrade_delay) - ); + assert_eq!(FutureCodeUpgrades::::get(¶_id), Some(1 + validation_upgrade_delay)); // Verify that the required events were emitted. EventValidator::new() diff --git a/runtime/parachains/src/ump.rs b/runtime/parachains/src/ump.rs index 956e1a099c89..0a6fc06db9b4 100644 --- a/runtime/parachains/src/ump.rs +++ b/runtime/parachains/src/ump.rs @@ -414,9 +414,7 @@ impl Pallet { v.remove(i); } }); - NextDispatchRoundStartWith::::mutate(|v| { - *v = v.filter(|p| p == outgoing_para) - }); + NextDispatchRoundStartWith::::mutate(|v| *v = v.filter(|p| p == outgoing_para)); ::WeightInfo::clean_ump_after_outgoing() } @@ -435,8 +433,7 @@ impl Pallet { }) } - let (mut para_queue_count, mut para_queue_size) = - RelayDispatchQueueSize::::get(¶); + let (mut para_queue_count, mut para_queue_size) = RelayDispatchQueueSize::::get(¶); for (idx, msg) in upward_messages.into_iter().enumerate() { let msg_size = msg.len() as u32; @@ -478,17 +475,12 @@ impl Pallet { .iter() .fold((0, 0), |(cnt, size), d| (cnt + 1, size + d.len() as u32)); - RelayDispatchQueues::::mutate(¶, |v| { - v.extend(upward_messages.into_iter()) - }); + RelayDispatchQueues::::mutate(¶, |v| v.extend(upward_messages.into_iter())); - RelayDispatchQueueSize::::mutate( - ¶, - |(ref mut cnt, ref mut size)| { - *cnt += extra_count; - *size += extra_size; - }, - ); + RelayDispatchQueueSize::::mutate(¶, |(ref mut cnt, ref mut size)| { + *cnt += extra_count; + *size += extra_size; + }); NeedsDispatch::::mutate(|v| { if let Err(i) = v.binary_search(¶) { diff --git a/runtime/parachains/src/ump/tests.rs b/runtime/parachains/src/ump/tests.rs index 452b4ca1cfd9..60cc02ff0ff7 100644 --- a/runtime/parachains/src/ump/tests.rs +++ b/runtime/parachains/src/ump/tests.rs @@ -96,14 +96,12 @@ fn assert_storage_consistency_exhaustive() { // since we wipe the empty queues the sets of paras in queue contents, queue sizes and // need dispatch set should all be equal. - let queue_contents_set = RelayDispatchQueues::::iter() - .map(|(k, _)| k) - .collect::>(); + let queue_contents_set = + RelayDispatchQueues::::iter().map(|(k, _)| k).collect::>(); let queue_sizes_set = RelayDispatchQueueSize::::iter() .map(|(k, _)| k) .collect::>(); - let needs_dispatch_set = - NeedsDispatch::::get().into_iter().collect::>(); + let needs_dispatch_set = NeedsDispatch::::get().into_iter().collect::>(); assert_eq!(queue_contents_set, queue_sizes_set); assert_eq!(queue_contents_set, needs_dispatch_set); diff --git a/xcm/pallet-xcm/src/migration.rs b/xcm/pallet-xcm/src/migration.rs index 98fb09c4019f..247b9f8adaca 100644 --- a/xcm/pallet-xcm/src/migration.rs +++ b/xcm/pallet-xcm/src/migration.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use crate::{Config, Pallet, VersionNotifyTargets }; +use crate::{Config, Pallet, VersionNotifyTargets}; use frame_support::{ pallet_prelude::*, traits::{OnRuntimeUpgrade, StorageVersion},