From 14cb7ce9401cf53490022592b754e203040b4877 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 13:25:00 +0000 Subject: [PATCH 01/15] Import Clippy config from Polkadot Signed-off-by: Oliver Tale-Yazdi --- .cargo/config.toml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000000..6cb38ecbc63 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,32 @@ +# +# An auto defined `clippy` feature was introduced, +# but it was found to clash with user defined features, +# so was renamed to `cargo-clippy`. +# +# If you want standard clippy run: +# RUSTFLAGS= cargo clippy +[target.'cfg(feature = "cargo-clippy")'] +rustflags = [ + "-Aclippy::all", + "-Dclippy::correctness", + "-Aclippy::if-same-then-else", + "-Aclippy::clone-double-ref", + "-Dclippy::complexity", + "-Aclippy::zero-prefixed-literal", # 00_1000_000 + "-Aclippy::type_complexity", # raison d'etre + "-Aclippy::nonminimal-bool", # maybe + "-Aclippy::borrowed-box", # Reasonable to fix this one + "-Aclippy::too-many-arguments", # (Turning this on would lead to) + "-Aclippy::unnecessary_cast", # Types may change + "-Aclippy::identity-op", # One case where we do 0 + + "-Aclippy::useless_conversion", # Types may change + "-Aclippy::unit_arg", # styalistic. + "-Aclippy::option-map-unit-fn", # styalistic + "-Aclippy::bind_instead_of_map", # styalistic + "-Aclippy::erasing_op", # E.g. 0 * DOLLARS + "-Aclippy::eq_op", # In tests we test equality. + "-Aclippy::while_immutable_condition", # false positives + "-Aclippy::needless_option_as_deref", # false positives + "-Aclippy::derivable_impls", # false positives + "-Aclippy::stable_sort_primitive", # prefer stable sort +] \ No newline at end of file From fa2f6aa6612f763c9b6a3bb5a4fe765b974706ab Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 13:41:19 +0000 Subject: [PATCH 02/15] Auto clippy fix Signed-off-by: Oliver Tale-Yazdi --- .../src/messages_benchmarking.rs | 4 +- .../src/parachains_benchmarking.rs | 2 +- bridges/modules/messages/src/benchmarking.rs | 12 +-- bridges/modules/messages/src/mock.rs | 2 +- bridges/modules/relayers/src/benchmarking.rs | 6 +- client/cli/src/lib.rs | 4 +- client/collator/src/lib.rs | 10 +- client/consensus/aura/src/import_queue.rs | 4 +- client/consensus/relay-chain/src/lib.rs | 4 +- client/network/src/tests.rs | 6 +- client/pov-recovery/src/lib.rs | 7 +- .../src/lib.rs | 6 +- .../src/collator_overseer.rs | 4 +- client/service/src/lib.rs | 2 +- .../collator-selection/src/benchmarking.rs | 6 +- pallets/collator-selection/src/lib.rs | 8 +- pallets/collator-selection/src/mock.rs | 10 +- pallets/collator-selection/src/tests.rs | 16 ++-- pallets/collator-selection/src/weights.rs | 96 +++++++++---------- pallets/dmp-queue/src/lib.rs | 21 ++-- pallets/dmp-queue/src/migration.rs | 2 +- pallets/parachain-system/src/lib.rs | 8 +- pallets/parachain-system/src/tests.rs | 15 ++- .../src/validate_block/tests.rs | 10 +- pallets/xcmp-queue/src/lib.rs | 2 +- pallets/xcmp-queue/src/migration.rs | 2 +- pallets/xcmp-queue/src/mock.rs | 2 +- pallets/xcmp-queue/src/tests.rs | 12 +-- pallets/xcmp-queue/src/weights.rs | 24 ++--- parachain-template/node/src/command.rs | 6 +- parachain-template/runtime/src/lib.rs | 4 +- parachains/common/src/impls.rs | 1 - parachains/pallets/parachain-info/src/lib.rs | 2 +- .../assets/common/src/foreign_creators.rs | 4 +- .../runtimes/assets/common/src/matching.rs | 4 +- .../runtimes/assets/statemine/src/lib.rs | 11 +-- .../assets/statemine/src/weights/xcm/mod.rs | 8 +- .../runtimes/assets/statemine/tests/tests.rs | 14 +-- .../runtimes/assets/statemint/src/lib.rs | 9 +- .../assets/statemint/src/weights/xcm/mod.rs | 8 +- .../runtimes/assets/statemint/tests/tests.rs | 10 +- .../runtimes/assets/test-utils/src/lib.rs | 6 +- .../assets/test-utils/src/test_cases.rs | 26 ++--- .../runtimes/assets/westmint/src/lib.rs | 9 +- .../assets/westmint/src/weights/xcm/mod.rs | 8 +- .../runtimes/assets/westmint/tests/tests.rs | 14 +-- .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 8 +- .../bridge-hub-kusama/src/weights/xcm/mod.rs | 8 +- .../bridge-hub-polkadot/src/lib.rs | 8 +- .../src/weights/xcm/mod.rs | 10 +- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 8 +- .../bridge-hub-rococo/src/weights/xcm/mod.rs | 8 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 6 +- .../bridge-hubs/test-utils/src/test_cases.rs | 4 +- .../src/fellowship/migration.rs | 4 +- .../src/fellowship/tracks.rs | 30 +++--- .../collectives-polkadot/src/impls.rs | 2 +- .../collectives-polkadot/src/lib.rs | 6 +- .../contracts/contracts-rococo/src/lib.rs | 2 +- parachains/runtimes/starters/shell/src/lib.rs | 2 +- parachains/runtimes/testing/penpal/src/lib.rs | 2 +- .../runtimes/testing/penpal/src/xcm_config.rs | 8 +- .../testing/rococo-parachain/src/lib.rs | 14 +-- .../src/chain_spec/bridge_hubs.rs | 2 +- polkadot-parachain/src/command.rs | 10 +- polkadot-parachain/src/rpc.rs | 2 +- polkadot-parachain/src/service.rs | 4 +- .../tests/benchmark_storage_works.rs | 4 +- polkadot-parachain/tests/common.rs | 4 +- polkadot-parachain/tests/purge_chain_works.rs | 2 +- primitives/timestamp/src/lib.rs | 4 +- primitives/utility/src/lib.rs | 18 ++-- test/client/src/block_builder.rs | 6 +- test/client/src/lib.rs | 1 - test/relay-sproof-builder/src/lib.rs | 2 +- .../service/benches/transaction_throughput.rs | 22 ++--- test/service/src/chain_spec.rs | 2 +- test/service/src/lib.rs | 8 +- 78 files changed, 325 insertions(+), 347 deletions(-) diff --git a/bridges/bin/runtime-common/src/messages_benchmarking.rs b/bridges/bin/runtime-common/src/messages_benchmarking.rs index b067523c305..5982ab90963 100644 --- a/bridges/bin/runtime-common/src/messages_benchmarking.rs +++ b/bridges/bin/runtime-common/src/messages_benchmarking.rs @@ -183,7 +183,7 @@ where let (_, bridged_header_hash) = insert_header_to_grandpa_pallet::(state_root); FromBridgedChainMessagesDeliveryProof { - bridged_header_hash: bridged_header_hash.into(), + bridged_header_hash, storage_proof, lane, } @@ -212,7 +212,7 @@ where insert_header_to_parachains_pallet::>>(state_root); FromBridgedChainMessagesDeliveryProof { - bridged_header_hash: bridged_header_hash.into(), + bridged_header_hash, storage_proof, lane, } diff --git a/bridges/bin/runtime-common/src/parachains_benchmarking.rs b/bridges/bin/runtime-common/src/parachains_benchmarking.rs index aad53673c3a..8a9b8547fbf 100644 --- a/bridges/bin/runtime-common/src/parachains_benchmarking.rs +++ b/bridges/bin/runtime-common/src/parachains_benchmarking.rs @@ -60,7 +60,7 @@ where TrieDBMutBuilderV1::::new(&mut mdb, &mut state_root).build(); // insert parachain heads - for (i, parachain) in parachains.into_iter().enumerate() { + for (i, parachain) in parachains.iter().enumerate() { let storage_key = parachain_head_storage_key_at_source(R::ParasPalletName::get(), *parachain); let leaf_data = if i == 0 { diff --git a/bridges/modules/messages/src/benchmarking.rs b/bridges/modules/messages/src/benchmarking.rs index aab8855a729..7db3ae64352 100644 --- a/bridges/modules/messages/src/benchmarking.rs +++ b/bridges/modules/messages/src/benchmarking.rs @@ -139,7 +139,7 @@ benchmarks_instance_pallet! { }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) verify { assert_eq!( - crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), + crate::InboundLanes::::get(T::bench_lane_id()).last_delivered_nonce(), 21, ); } @@ -172,7 +172,7 @@ benchmarks_instance_pallet! { }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 2, dispatch_weight) verify { assert_eq!( - crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), + crate::InboundLanes::::get(T::bench_lane_id()).last_delivered_nonce(), 22, ); } @@ -208,7 +208,7 @@ benchmarks_instance_pallet! { }); }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) verify { - let lane_state = crate::InboundLanes::::get(&T::bench_lane_id()); + let lane_state = crate::InboundLanes::::get(T::bench_lane_id()); assert_eq!(lane_state.last_delivered_nonce(), 21); assert_eq!(lane_state.last_confirmed_nonce, 20); } @@ -240,7 +240,7 @@ benchmarks_instance_pallet! { }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) verify { assert_eq!( - crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), + crate::InboundLanes::::get(T::bench_lane_id()).last_delivered_nonce(), 21, ); } @@ -274,7 +274,7 @@ benchmarks_instance_pallet! { }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) verify { assert_eq!( - crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), + crate::InboundLanes::::get(T::bench_lane_id()).last_delivered_nonce(), 21, ); } @@ -432,7 +432,7 @@ benchmarks_instance_pallet! { }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) verify { assert_eq!( - crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), + crate::InboundLanes::::get(T::bench_lane_id()).last_delivered_nonce(), 21, ); assert!(T::is_message_successfully_dispatched(21)); diff --git a/bridges/modules/messages/src/mock.rs b/bridges/modules/messages/src/mock.rs index 2e45d5b601f..7aab79ae4a9 100644 --- a/bridges/modules/messages/src/mock.rs +++ b/bridges/modules/messages/src/mock.rs @@ -185,7 +185,7 @@ impl crate::benchmarking::Config<()> for TestRuntime { // in mock run we only care about benchmarks correctness, not the benchmark results // => ignore size related arguments let (messages, total_dispatch_weight) = - params.message_nonces.into_iter().map(|n| message(n, REGULAR_PAYLOAD)).fold( + params.message_nonces.map(|n| message(n, REGULAR_PAYLOAD)).fold( (Vec::new(), Weight::zero()), |(mut messages, total_dispatch_weight), message| { let weight = REGULAR_PAYLOAD.declared_weight; diff --git a/bridges/modules/relayers/src/benchmarking.rs b/bridges/modules/relayers/src/benchmarking.rs index d66a11ff06d..dfdecad31af 100644 --- a/bridges/modules/relayers/src/benchmarking.rs +++ b/bridges/modules/relayers/src/benchmarking.rs @@ -104,7 +104,7 @@ benchmarks! { // create slash destination account let lane = LaneId([0, 0, 0, 0]); let slash_destination = RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain); - T::prepare_rewards_account(slash_destination.clone(), Zero::zero()); + T::prepare_rewards_account(slash_destination, Zero::zero()); }: { crate::Pallet::::slash_and_deregister(&relayer, slash_destination) } @@ -121,10 +121,10 @@ benchmarks! { let account_params = RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain); }: { - crate::Pallet::::register_relayer_reward(account_params.clone(), &relayer, One::one()); + crate::Pallet::::register_relayer_reward(account_params, &relayer, One::one()); } verify { - assert_eq!(RelayerRewards::::get(relayer, &account_params), Some(One::one())); + assert_eq!(RelayerRewards::::get(relayer, account_params), Some(One::one())); } impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::TestRuntime) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index a4daa9ee506..d77db6baedf 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -93,7 +93,7 @@ impl PurgeChainCmd { io::stdin().read_line(&mut input)?; let input = input.trim(); - match input.chars().nth(0) { + match input.chars().next() { Some('y') | Some('Y') => {}, _ => { println!("Aborted"); @@ -103,7 +103,7 @@ impl PurgeChainCmd { } for db_path in &db_paths { - match fs::remove_dir_all(&db_path) { + match fs::remove_dir_all(db_path) { Ok(_) => { println!("{:?} removed.", &db_path); }, diff --git a/client/collator/src/lib.rs b/client/collator/src/lib.rs index a931201f6cc..7b0af2f041e 100644 --- a/client/collator/src/lib.rs +++ b/client/collator/src/lib.rs @@ -272,7 +272,7 @@ where let compact_proof = match candidate .proof - .into_compact_proof::>(last_head.state_root().clone()) + .into_compact_proof::>(*last_head.state_root()) { Ok(proof) => proof, Err(e) => { @@ -451,7 +451,7 @@ mod tests { .build() .expect("Builds overseer"); - spawner.spawn("overseer", None, overseer.run().then(|_| async { () }).boxed()); + spawner.spawn("overseer", None, overseer.run().then(|_| async { }).boxed()); let collator_start = start_collator(StartCollatorParams { runtime_api: client.clone(), @@ -461,7 +461,7 @@ mod tests { spawner, para_id, key: CollatorPair::generate().0, - parachain_consensus: Box::new(DummyParachainConsensus { client: client.clone() }), + parachain_consensus: Box::new(DummyParachainConsensus { client: client }), }); block_on(collator_start); @@ -469,9 +469,7 @@ mod tests { .0 .expect("message should be send by `start_collator` above."); - let config = match msg { - CollationGenerationMessage::Initialize(config) => config, - }; + let CollationGenerationMessage::Initialize(config) = msg; let mut validation_data = PersistedValidationData::default(); validation_data.parent_head = header.encode().into(); diff --git a/client/consensus/aura/src/import_queue.rs b/client/consensus/aura/src/import_queue.rs index 862abfb349a..725e841881c 100644 --- a/client/consensus/aura/src/import_queue.rs +++ b/client/consensus/aura/src/import_queue.rs @@ -51,7 +51,7 @@ pub struct ImportQueueParams<'a, I, C, CIDP, S> { } /// Start an import queue for the Aura consensus algorithm. -pub fn import_queue<'a, P, Block, I, C, S, CIDP>( +pub fn import_queue( ImportQueueParams { block_import, client, @@ -59,7 +59,7 @@ pub fn import_queue<'a, P, Block, I, C, S, CIDP>( spawner, registry, telemetry, - }: ImportQueueParams<'a, I, C, CIDP, S>, + }: ImportQueueParams<'_, I, C, CIDP, S>, ) -> Result, sp_consensus::Error> where Block: BlockT, diff --git a/client/consensus/relay-chain/src/lib.rs b/client/consensus/relay-chain/src/lib.rs index a31a9ec8b2a..529b78c1319 100644 --- a/client/consensus/relay-chain/src/lib.rs +++ b/client/consensus/relay-chain/src/lib.rs @@ -161,7 +161,7 @@ where relay_parent: PHash, validation_data: &PersistedValidationData, ) -> Option> { - let proposer_future = self.proposer_factory.lock().init(&parent); + let proposer_future = self.proposer_factory.lock().init(parent); let proposer = proposer_future .await @@ -171,7 +171,7 @@ where .ok()?; let inherent_data = - self.inherent_data(parent.hash(), &validation_data, relay_parent).await?; + self.inherent_data(parent.hash(), validation_data, relay_parent).await?; let Proposal { block, storage_changes, proof } = proposer .propose( diff --git a/client/network/src/tests.rs b/client/network/src/tests.rs index eefb88f2f7b..08127fe390a 100644 --- a/client/network/src/tests.rs +++ b/client/network/src/tests.rs @@ -129,7 +129,7 @@ impl RelayChainInterface for DummyRelayChainInterface { para_id: 0u32.into(), relay_parent: PHash::random(), collator: CollatorPair::generate().0.public(), - persisted_validation_data_hash: PHash::random().into(), + persisted_validation_data_hash: PHash::random(), pov_hash: PHash::random(), erasure_root: PHash::random(), signature: sp_core::sr25519::Signature([0u8; 64]).into(), @@ -293,7 +293,7 @@ async fn make_gossip_message_and_header( para_id: 0u32.into(), relay_parent, collator: CollatorPair::generate().0.public(), - persisted_validation_data_hash: PHash::random().into(), + persisted_validation_data_hash: PHash::random(), pov_hash: PHash::random(), erasure_root: PHash::random(), signature: sp_core::sr25519::Signature([0u8; 64]).into(), @@ -484,7 +484,7 @@ async fn check_statement_seconded() { para_id: 0u32.into(), relay_parent: PHash::random(), collator: CollatorPair::generate().0.public(), - persisted_validation_data_hash: PHash::random().into(), + persisted_validation_data_hash: PHash::random(), pov_hash: PHash::random(), erasure_root: PHash::random(), signature: sp_core::sr25519::Signature([0u8; 64]).into(), diff --git a/client/pov-recovery/src/lib.rs b/client/pov-recovery/src/lib.rs index 7d92934c784..60e613be746 100644 --- a/client/pov-recovery/src/lib.rs +++ b/client/pov-recovery/src/lib.rs @@ -190,7 +190,7 @@ impl RecoveryQueue { /// Get the next hash for block recovery. pub async fn next_recovery(&mut self) -> Block::Hash { loop { - if let Some(_) = self.signaling_queue.next().await { + if (self.signaling_queue.next().await).is_some() { if let Some(hash) = self.recovery_queue.pop_front() { return hash } else { @@ -309,10 +309,7 @@ where /// Block is no longer waiting for recovery fn clear_waiting_recovery(&mut self, block_hash: &Block::Hash) { - self.candidates.get_mut(block_hash).map(|candidate| { - // Prevents triggering an already enqueued recovery request - candidate.waiting_recovery = false; - }); + if let Some(candidate) = self.candidates.get_mut(block_hash) { candidate.waiting_recovery = false; } } /// Handle a finalized block with the given `block_number`. diff --git a/client/relay-chain-inprocess-interface/src/lib.rs b/client/relay-chain-inprocess-interface/src/lib.rs index f230a23bd25..c1e19bd20b6 100644 --- a/client/relay-chain-inprocess-interface/src/lib.rs +++ b/client/relay-chain-inprocess-interface/src/lib.rs @@ -241,7 +241,7 @@ where self.full_client .import_notification_stream() .filter_map(|notification| async move { - notification.is_new_best.then(|| notification.header) + notification.is_new_best.then_some(notification.header) }); Ok(Box::pin(notifications_stream)) } @@ -428,7 +428,7 @@ mod tests { ( client.clone(), block, - RelayChainInProcessInterface::new(client, backend.clone(), dummy_network, mock_handle), + RelayChainInProcessInterface::new(client, backend, dummy_network, mock_handle), ) } @@ -483,7 +483,7 @@ mod tests { let hash = block.hash(); let ext = construct_transfer_extrinsic( - &*client, + &client, sp_keyring::Sr25519Keyring::Alice, sp_keyring::Sr25519Keyring::Bob, 1000, diff --git a/client/relay-chain-minimal-node/src/collator_overseer.rs b/client/relay-chain-minimal-node/src/collator_overseer.rs index a2ad87fa758..b488db962f3 100644 --- a/client/relay-chain-minimal-node/src/collator_overseer.rs +++ b/client/relay-chain-minimal-node/src/collator_overseer.rs @@ -76,7 +76,7 @@ pub(crate) struct CollatorOverseerGenArgs<'a> { pub peer_set_protocol_names: PeerSetProtocolNames, } -fn build_overseer<'a>( +fn build_overseer( connector: OverseerConnector, CollatorOverseerGenArgs { runtime_client, @@ -90,7 +90,7 @@ fn build_overseer<'a>( collator_pair, req_protocol_names, peer_set_protocol_names, - }: CollatorOverseerGenArgs<'a>, + }: CollatorOverseerGenArgs<'_>, ) -> Result< (Overseer, Arc>, OverseerHandle), RelayChainError, diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 894db91ba8f..ac18cb39fcf 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -441,7 +441,7 @@ where ) .await .map_err(|e| format!("{e:?}"))? - .ok_or_else(|| "Could not find parachain head in relay chain")?; + .ok_or("Could not find parachain head in relay chain")?; let target_block = B::Header::decode(&mut &validation_data.parent_head.0[..]) .map_err(|e| format!("Failed to decode parachain head: {e}"))?; diff --git a/pallets/collator-selection/src/benchmarking.rs b/pallets/collator-selection/src/benchmarking.rs index 8a222511137..6b386f7d697 100644 --- a/pallets/collator-selection/src/benchmarking.rs +++ b/pallets/collator-selection/src/benchmarking.rs @@ -129,7 +129,7 @@ benchmarks! { T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: { assert_ok!( - >::set_desired_candidates(origin, max.clone()) + >::set_desired_candidates(origin, max) ); } verify { @@ -142,7 +142,7 @@ benchmarks! { T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: { assert_ok!( - >::set_candidacy_bond(origin, bond_amount.clone()) + >::set_candidacy_bond(origin, bond_amount) ); } verify { @@ -162,7 +162,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let bond: BalanceOf = T::Currency::minimum_balance() * 2u32.into(); - T::Currency::make_free_balance_be(&caller, bond.clone()); + T::Currency::make_free_balance_be(&caller, bond); >::set_keys( RawOrigin::Signed(caller.clone()).into(), diff --git a/pallets/collator-selection/src/lib.rs b/pallets/collator-selection/src/lib.rs index 3dba6846cc3..a727e21f0fd 100644 --- a/pallets/collator-selection/src/lib.rs +++ b/pallets/collator-selection/src/lib.rs @@ -238,8 +238,8 @@ pub mod pallet { "genesis desired_candidates are more than T::MaxCandidates", ); - >::put(&self.desired_candidates); - >::put(&self.candidacy_bond); + >::put(self.desired_candidates); + >::put(self.candidacy_bond); >::put(bounded_invulnerables); } } @@ -326,7 +326,7 @@ pub mod pallet { if max > T::MaxCandidates::get() { log::warn!("max > T::MaxCandidates; you might need to run benchmarks again"); } - >::put(&max); + >::put(max); Self::deposit_event(Event::NewDesiredCandidates { desired_candidates: max }); Ok(().into()) } @@ -339,7 +339,7 @@ pub mod pallet { bond: BalanceOf, ) -> DispatchResultWithPostInfo { T::UpdateOrigin::ensure_origin(origin)?; - >::put(&bond); + >::put(bond); Self::deposit_event(Event::NewCandidacyBond { bond_amount: bond }); Ok(().into()) } diff --git a/pallets/collator-selection/src/mock.rs b/pallets/collator-selection/src/mock.rs index ac776e3d216..5470e4037ec 100644 --- a/pallets/collator-selection/src/mock.rs +++ b/pallets/collator-selection/src/mock.rs @@ -152,12 +152,12 @@ pub struct TestSessionHandler; impl pallet_session::SessionHandler for TestSessionHandler { const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID]; fn on_genesis_session(keys: &[(u64, Ks)]) { - SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::>()) + SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::>()) } fn on_new_session(_: bool, keys: &[(u64, Ks)], _: &[(u64, Ks)]) { SessionChangeBlock::set(System::block_number()); dbg!(keys.len()); - SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::>()) + SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::>()) } fn on_before_session_ending() {} fn on_disabled(_: u32) {} @@ -195,11 +195,7 @@ parameter_types! { pub struct IsRegistered; impl ValidatorRegistration for IsRegistered { fn is_registered(id: &u64) -> bool { - if *id == 7u64 { - false - } else { - true - } + *id != 7u64 } } diff --git a/pallets/collator-selection/src/tests.rs b/pallets/collator-selection/src/tests.rs index 459b107ecc5..0ae3e3d5a18 100644 --- a/pallets/collator-selection/src/tests.rs +++ b/pallets/collator-selection/src/tests.rs @@ -45,7 +45,7 @@ fn it_should_set_invulnerables() { // cannot set with non-root. assert_noop!( - CollatorSelection::set_invulnerables(RuntimeOrigin::signed(1), new_set.clone()), + CollatorSelection::set_invulnerables(RuntimeOrigin::signed(1), new_set), BadOrigin ); @@ -54,7 +54,7 @@ fn it_should_set_invulnerables() { assert_noop!( CollatorSelection::set_invulnerables( RuntimeOrigin::signed(RootAccount::get()), - invulnerables.clone() + invulnerables ), Error::::ValidatorNotRegistered ); @@ -184,8 +184,8 @@ fn cannot_register_dupe_candidate() { #[test] fn cannot_register_as_candidate_if_poor() { new_test_ext().execute_with(|| { - assert_eq!(Balances::free_balance(&3), 100); - assert_eq!(Balances::free_balance(&33), 0); + assert_eq!(Balances::free_balance(3), 100); + assert_eq!(Balances::free_balance(33), 0); // works assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3))); @@ -208,14 +208,14 @@ fn register_as_candidate_works() { assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); // take two endowed, non-invulnerables accounts. - assert_eq!(Balances::free_balance(&3), 100); - assert_eq!(Balances::free_balance(&4), 100); + assert_eq!(Balances::free_balance(3), 100); + assert_eq!(Balances::free_balance(4), 100); assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3))); assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4))); - assert_eq!(Balances::free_balance(&3), 90); - assert_eq!(Balances::free_balance(&4), 90); + assert_eq!(Balances::free_balance(3), 90); + assert_eq!(Balances::free_balance(4), 90); assert_eq!(CollatorSelection::candidates().len(), 2); }); diff --git a/pallets/collator-selection/src/weights.rs b/pallets/collator-selection/src/weights.rs index 32e816b5dbe..47014dfa82e 100644 --- a/pallets/collator-selection/src/weights.rs +++ b/pallets/collator-selection/src/weights.rs @@ -39,93 +39,93 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn set_invulnerables(b: u32) -> Weight { - Weight::from_parts(18_563_000 as u64, 0) + Weight::from_parts(18_563_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(68_000 as u64, 0).saturating_mul(b as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(Weight::from_parts(68_000_u64, 0).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } fn set_desired_candidates() -> Weight { - Weight::from_parts(16_363_000 as u64, 0).saturating_add(T::DbWeight::get().writes(1 as u64)) + Weight::from_parts(16_363_000_u64, 0).saturating_add(T::DbWeight::get().writes(1_u64)) } fn set_candidacy_bond() -> Weight { - Weight::from_parts(16_840_000 as u64, 0).saturating_add(T::DbWeight::get().writes(1 as u64)) + Weight::from_parts(16_840_000_u64, 0).saturating_add(T::DbWeight::get().writes(1_u64)) } fn register_as_candidate(c: u32) -> Weight { - Weight::from_parts(71_196_000 as u64, 0) + Weight::from_parts(71_196_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(198_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_parts(198_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } fn leave_intent(c: u32) -> Weight { - Weight::from_parts(55_336_000 as u64, 0) + Weight::from_parts(55_336_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(151_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_parts(151_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } fn note_author() -> Weight { - Weight::from_parts(71_461_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + Weight::from_parts(71_461_000_u64, 0) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } fn new_session(r: u32, c: u32) -> Weight { - Weight::from_parts(0 as u64, 0) + Weight::from_parts(0_u64, 0) // Standard Error: 1_010_000 - .saturating_add(Weight::from_parts(109_961_000 as u64, 0).saturating_mul(r as u64)) + .saturating_add(Weight::from_parts(109_961_000_u64, 0).saturating_mul(r as u64)) // Standard Error: 1_010_000 - .saturating_add(Weight::from_parts(151_952_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(c as u64))) - .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(c as u64))) + .saturating_add(Weight::from_parts(151_952_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().reads(2_u64.saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(2_u64.saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(2_u64.saturating_mul(c as u64))) } } // For backwards compatibility and tests impl WeightInfo for () { fn set_invulnerables(b: u32) -> Weight { - Weight::from_parts(18_563_000 as u64, 0) + Weight::from_parts(18_563_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(68_000 as u64, 0).saturating_mul(b as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + .saturating_add(Weight::from_parts(68_000_u64, 0).saturating_mul(b as u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn set_desired_candidates() -> Weight { - Weight::from_parts(16_363_000 as u64, 0) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + Weight::from_parts(16_363_000_u64, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn set_candidacy_bond() -> Weight { - Weight::from_parts(16_840_000 as u64, 0) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + Weight::from_parts(16_840_000_u64, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn register_as_candidate(c: u32) -> Weight { - Weight::from_parts(71_196_000 as u64, 0) + Weight::from_parts(71_196_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(198_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_parts(198_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } fn leave_intent(c: u32) -> Weight { - Weight::from_parts(55_336_000 as u64, 0) + Weight::from_parts(55_336_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(151_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_parts(151_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } fn note_author() -> Weight { - Weight::from_parts(71_461_000 as u64, 0) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + Weight::from_parts(71_461_000_u64, 0) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } fn new_session(r: u32, c: u32) -> Weight { - Weight::from_parts(0 as u64, 0) + Weight::from_parts(0_u64, 0) // Standard Error: 1_010_000 - .saturating_add(Weight::from_parts(109_961_000 as u64, 0).saturating_mul(r as u64)) + .saturating_add(Weight::from_parts(109_961_000_u64, 0).saturating_mul(r as u64)) // Standard Error: 1_010_000 - .saturating_add(Weight::from_parts(151_952_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(c as u64))) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(c as u64))) + .saturating_add(Weight::from_parts(151_952_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(r as u64))) + .saturating_add(RocksDbWeight::get().reads(2_u64.saturating_mul(c as u64))) + .saturating_add(RocksDbWeight::get().writes(2_u64.saturating_mul(r as u64))) + .saturating_add(RocksDbWeight::get().writes(2_u64.saturating_mul(c as u64))) } } diff --git a/pallets/dmp-queue/src/lib.rs b/pallets/dmp-queue/src/lib.rs index 3b0d54c7bdb..0f4c8c5cc6d 100644 --- a/pallets/dmp-queue/src/lib.rs +++ b/pallets/dmp-queue/src/lib.rs @@ -766,19 +766,19 @@ mod tests { new_test_ext().execute_with(|| { let enqueued = vec![msg(1000), msg(1001)]; enqueue(&enqueued); - let weight_used = handle_messages(&vec![msg(1002)], Weight::from_parts(1500, 1500)); + let weight_used = handle_messages(&[msg(1002)], Weight::from_parts(1500, 1500)); assert_eq!(weight_used, Weight::from_parts(1000, 1000)); assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(1001),]); assert_eq!(pages_queued(), 2); assert_eq!(PageIndex::::get().begin_used, 0); - let weight_used = handle_messages(&vec![msg(1003)], Weight::from_parts(1500, 1500)); + let weight_used = handle_messages(&[msg(1003)], Weight::from_parts(1500, 1500)); assert_eq!(weight_used, Weight::from_parts(1001, 1001)); assert_eq!(take_trace(), vec![msg_complete(1001), msg_limit_reached(1002),]); assert_eq!(pages_queued(), 2); assert_eq!(PageIndex::::get().begin_used, 1); - let weight_used = handle_messages(&vec![msg(1004)], Weight::from_parts(1500, 1500)); + let weight_used = handle_messages(&[msg(1004)], Weight::from_parts(1500, 1500)); assert_eq!(weight_used, Weight::from_parts(1002, 1002)); assert_eq!(take_trace(), vec![msg_complete(1002), msg_limit_reached(1003),]); assert_eq!(pages_queued(), 2); @@ -877,9 +877,9 @@ mod tests { #[test] fn on_idle_should_service_queue() { new_test_ext().execute_with(|| { - enqueue(&vec![msg(1000), msg(1001)]); - enqueue(&vec![msg(1002), msg(1003)]); - enqueue(&vec![msg(1004), msg(1005)]); + enqueue(&[msg(1000), msg(1001)]); + enqueue(&[msg(1002), msg(1003)]); + enqueue(&[msg(1004), msg(1005)]); let weight_used = DmpQueue::on_idle(1, Weight::from_parts(6000, 6000)); assert_eq!(weight_used, Weight::from_parts(5010, 5010)); @@ -901,12 +901,11 @@ mod tests { #[test] fn handle_max_messages_per_block() { new_test_ext().execute_with(|| { - enqueue(&vec![msg(1000), msg(1001)]); - enqueue(&vec![msg(1002), msg(1003)]); - enqueue(&vec![msg(1004), msg(1005)]); + enqueue(&[msg(1000), msg(1001)]); + enqueue(&[msg(1002), msg(1003)]); + enqueue(&[msg(1004), msg(1005)]); let incoming = (0..MAX_MESSAGES_PER_BLOCK) - .into_iter() .map(|i| msg(1006 + i as u64)) .collect::>(); handle_messages(&incoming, Weight::from_parts(25000, 25000)); @@ -914,7 +913,6 @@ mod tests { assert_eq!( take_trace(), (0..MAX_MESSAGES_PER_BLOCK) - .into_iter() .map(|i| msg_complete(1000 + i as u64)) .collect::>(), ); @@ -924,7 +922,6 @@ mod tests { assert_eq!( take_trace(), (MAX_MESSAGES_PER_BLOCK..MAX_MESSAGES_PER_BLOCK + 6) - .into_iter() .map(|i| msg_complete(1000 + i as u64)) .collect::>(), ); diff --git a/pallets/dmp-queue/src/migration.rs b/pallets/dmp-queue/src/migration.rs index b360f5a7bd4..5e1d357e142 100644 --- a/pallets/dmp-queue/src/migration.rs +++ b/pallets/dmp-queue/src/migration.rs @@ -74,7 +74,7 @@ pub fn migrate_to_v1() -> Weight { } }; - if let Err(_) = Configuration::::translate(|pre| pre.map(translate)) { + if Configuration::::translate(|pre| pre.map(translate)).is_err() { log::error!( target: "dmp_queue", "unexpected error when performing translation of the QueueConfig type during storage upgrade to v2" diff --git a/pallets/parachain-system/src/lib.rs b/pallets/parachain-system/src/lib.rs index 4025368904b..da5e445d99f 100644 --- a/pallets/parachain-system/src/lib.rs +++ b/pallets/parachain-system/src/lib.rs @@ -474,7 +474,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; AuthorizedUpgrade::::put(CodeUpgradeAuthorization { - code_hash: code_hash.clone(), + code_hash, check_version, }); @@ -753,7 +753,7 @@ impl Pallet { let authorization = AuthorizedUpgrade::::get().ok_or(Error::::NothingAuthorized)?; // ensure that the actual hash matches the authorized hash - let actual_hash = T::Hashing::hash(&code[..]); + let actual_hash = T::Hashing::hash(code); ensure!(actual_hash == authorization.code_hash, Error::::Unauthorized); // check versions if required as part of the authorization @@ -941,10 +941,10 @@ impl Pallet { // `running_mqc_heads`. Otherwise, in a block where no messages were sent in a channel // it won't get into next block's `last_mqc_heads` and thus will be all zeros, which // would corrupt the message queue chain. - for &(ref sender, ref channel) in ingress_channels { + for (sender, channel) in ingress_channels { let cur_head = running_mqc_heads .entry(sender) - .or_insert_with(|| last_mqc_heads.get(&sender).cloned().unwrap_or_default()) + .or_insert_with(|| last_mqc_heads.get(sender).cloned().unwrap_or_default()) .head(); let target_head = channel.mqc_head.unwrap_or_default(); diff --git a/pallets/parachain-system/src/tests.rs b/pallets/parachain-system/src/tests.rs index 70e4c106bf2..7598b106871 100755 --- a/pallets/parachain-system/src/tests.rs +++ b/pallets/parachain-system/src/tests.rs @@ -304,7 +304,7 @@ impl BlockTests { // begin initialization System::reset_events(); - System::initialize(&n, &Default::default(), &Default::default()); + System::initialize(n, &Default::default(), &Default::default()); // now mess with the storage the way validate_block does let mut sproof_builder = RelayStateSproofBuilder::default(); @@ -357,11 +357,9 @@ impl BlockTests { ParachainSystem::on_finalize(*n); // did block execution set new validation code? - if NewValidationCode::::exists() { - if self.pending_upgrade.is_some() { - panic!("attempted to set validation code while upgrade was pending"); - } - } + if NewValidationCode::::exists() && self.pending_upgrade.is_some() { + panic!("attempted to set validation code while upgrade was pending"); + } // clean up System::finalize(); @@ -404,7 +402,7 @@ fn events() { let events = System::events(); assert_eq!( events[0].event, - RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionStored.into()) + RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionStored) ); }, ) @@ -417,7 +415,6 @@ fn events() { events[0].event, RuntimeEvent::ParachainSystem( crate::Event::ValidationFunctionApplied { relay_chain_block_num: 1234 } - .into() ) ); }, @@ -491,7 +488,7 @@ fn aborted_upgrade() { let events = System::events(); assert_eq!( events[0].event, - RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionDiscarded.into()) + RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionDiscarded) ); }, ); diff --git a/pallets/parachain-system/src/validate_block/tests.rs b/pallets/parachain-system/src/validate_block/tests.rs index 2c39188a085..4801b62e7b5 100644 --- a/pallets/parachain-system/src/validate_block/tests.rs +++ b/pallets/parachain-system/src/validate_block/tests.rs @@ -41,7 +41,7 @@ fn call_validate_block_encoded_header( relay_parent_number: 1, relay_parent_storage_root, }, - &WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"), + WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"), ) .map(|v| v.head_data.0) } @@ -191,7 +191,7 @@ fn validate_block_invalid_parent_hash() { .unwrap_err(); } else { let output = Command::new(env::current_exe().unwrap()) - .args(&["validate_block_invalid_parent_hash", "--", "--nocapture"]) + .args(["validate_block_invalid_parent_hash", "--", "--nocapture"]) .env("RUN_TEST", "1") .output() .expect("Runs the test"); @@ -213,7 +213,7 @@ fn validate_block_fails_on_invalid_validation_data() { call_validate_block(parent_head, block, Hash::random()).unwrap_err(); } else { let output = Command::new(env::current_exe().unwrap()) - .args(&["validate_block_fails_on_invalid_validation_data", "--", "--nocapture"]) + .args(["validate_block_fails_on_invalid_validation_data", "--", "--nocapture"]) .env("RUN_TEST", "1") .output() .expect("Runs the test"); @@ -242,7 +242,7 @@ fn check_inherent_fails_on_validate_block_as_expected() { .unwrap_err(); } else { let output = Command::new(env::current_exe().unwrap()) - .args(&["check_inherent_fails_on_validate_block_as_expected", "--", "--nocapture"]) + .args(["check_inherent_fails_on_validate_block_as_expected", "--", "--nocapture"]) .env("RUN_TEST", "1") .output() .expect("Runs the test"); @@ -276,7 +276,7 @@ fn check_inherents_are_unsigned_and_before_all_other_extrinsics() { .unwrap_err(); } else { let output = Command::new(env::current_exe().unwrap()) - .args(&[ + .args([ "check_inherents_are_unsigned_and_before_all_other_extrinsics", "--", "--nocapture", diff --git a/pallets/xcmp-queue/src/lib.rs b/pallets/xcmp-queue/src/lib.rs index df2b78ebc20..0dc76aa80a1 100644 --- a/pallets/xcmp-queue/src/lib.rs +++ b/pallets/xcmp-queue/src/lib.rs @@ -538,7 +538,7 @@ impl Pallet { return false } s.extend_from_slice(&data[..]); - return true + true }); if appended { Ok((details.last_index - details.first_index - 1) as u32) diff --git a/pallets/xcmp-queue/src/migration.rs b/pallets/xcmp-queue/src/migration.rs index f6ece1da1a8..fd1301b9491 100644 --- a/pallets/xcmp-queue/src/migration.rs +++ b/pallets/xcmp-queue/src/migration.rs @@ -94,7 +94,7 @@ pub fn migrate_to_v2() -> Weight { } }; - if let Err(_) = QueueConfig::::translate(|pre| pre.map(translate)) { + if QueueConfig::::translate(|pre| pre.map(translate)).is_err() { log::error!( target: super::LOG_TARGET, "unexpected error when performing translation of the QueueConfig type during storage upgrade to v2" diff --git a/pallets/xcmp-queue/src/mock.rs b/pallets/xcmp-queue/src/mock.rs index 0d7d6eda00b..2e70e65392a 100644 --- a/pallets/xcmp-queue/src/mock.rs +++ b/pallets/xcmp-queue/src/mock.rs @@ -120,7 +120,7 @@ impl cumulus_pallet_parachain_system::Config for Test { parameter_types! { pub const RelayChain: MultiLocation = MultiLocation::parent(); - pub UniversalLocation: InteriorMultiLocation = X1(Parachain(1u32.into())).into(); + pub UniversalLocation: InteriorMultiLocation = X1(Parachain(1u32)); pub UnitWeightCost: Weight = Weight::from_parts(1_000_000, 1024); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; diff --git a/pallets/xcmp-queue/src/tests.rs b/pallets/xcmp-queue/src/tests.rs index 952a2758f30..ad0fa906da3 100644 --- a/pallets/xcmp-queue/src/tests.rs +++ b/pallets/xcmp-queue/src/tests.rs @@ -23,7 +23,7 @@ use sp_runtime::traits::BadOrigin; fn one_message_does_not_panic() { new_test_ext().execute_with(|| { let message_format = XcmpMessageFormat::ConcatenatedVersionedXcm.encode(); - let messages = vec![(Default::default(), 1u32.into(), message_format.as_slice())]; + let messages = vec![(Default::default(), 1u32, message_format.as_slice())]; // This shouldn't cause a panic XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX); @@ -128,7 +128,7 @@ fn suspend_xcm_execution_works() { .encode(); let mut message_format = XcmpMessageFormat::ConcatenatedVersionedXcm.encode(); message_format.extend(xcm.clone()); - let messages = vec![(ParaId::from(999), 1u32.into(), message_format.as_slice())]; + let messages = vec![(ParaId::from(999), 1u32, message_format.as_slice())]; // This should have executed the incoming XCM, because it came from a system parachain XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX); @@ -136,7 +136,7 @@ fn suspend_xcm_execution_works() { let queued_xcm = InboundXcmpMessages::::get(ParaId::from(999), 1u32); assert!(queued_xcm.is_empty()); - let messages = vec![(ParaId::from(2000), 1u32.into(), message_format.as_slice())]; + let messages = vec![(ParaId::from(2000), 1u32, message_format.as_slice())]; // This shouldn't have executed the incoming XCM XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX); @@ -294,7 +294,7 @@ fn xcmp_queue_does_not_consume_dest_or_msg_on_not_applicable() { // XcmpQueue - check dest is really not applicable let dest = (Parent, Parent, Parent); - let mut dest_wrapper = Some(dest.clone().into()); + let mut dest_wrapper = Some(dest.into()); let mut msg_wrapper = Some(message.clone()); assert_eq!( Err(SendError::NotApplicable), @@ -302,7 +302,7 @@ fn xcmp_queue_does_not_consume_dest_or_msg_on_not_applicable() { ); // check wrapper were not consumed - assert_eq!(Some(dest.clone().into()), dest_wrapper.take()); + assert_eq!(Some(dest.into()), dest_wrapper.take()); assert_eq!(Some(message.clone()), msg_wrapper.take()); // another try with router chain with asserting sender @@ -322,7 +322,7 @@ fn xcmp_queue_consumes_dest_and_msg_on_ok_validate() { // XcmpQueue - check dest/msg is valid let dest = (Parent, X1(Parachain(5555))); - let mut dest_wrapper = Some(dest.clone().into()); + let mut dest_wrapper = Some(dest.into()); let mut msg_wrapper = Some(message.clone()); assert!(::validate(&mut dest_wrapper, &mut msg_wrapper).is_ok()); diff --git a/pallets/xcmp-queue/src/weights.rs b/pallets/xcmp-queue/src/weights.rs index b275982b003..cbb29ac3ae3 100644 --- a/pallets/xcmp-queue/src/weights.rs +++ b/pallets/xcmp-queue/src/weights.rs @@ -18,31 +18,31 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: XcmpQueue QueueConfig (r:1 w:1) fn set_config_with_u32() -> Weight { - Weight::from_parts(2_717_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + Weight::from_parts(2_717_000_u64, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } // Storage: XcmpQueue QueueConfig (r:1 w:1) fn set_config_with_weight() -> Weight { - Weight::from_parts(2_717_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + Weight::from_parts(2_717_000_u64, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } impl WeightInfo for () { // Storage: XcmpQueue QueueConfig (r:1 w:1) fn set_config_with_u32() -> Weight { - Weight::from_parts(2_717_000 as u64, 0) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + Weight::from_parts(2_717_000_u64, 0) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } // Storage: XcmpQueue QueueConfig (r:1 w:1) fn set_config_with_weight() -> Weight { - Weight::from_parts(2_717_000 as u64, 0) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + Weight::from_parts(2_717_000_u64, 0) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/parachain-template/node/src/command.rs b/parachain-template/node/src/command.rs index 20ac62ec4a5..c3e79ebe387 100644 --- a/parachain-template/node/src/command.rs +++ b/parachain-template/node/src/command.rs @@ -268,13 +268,13 @@ pub fn run() -> Result<()> { runner.run_node_until_exit(|config| async move { let hwbench = (!cli.no_hardware_benchmarks).then_some( config.database.path().map(|database_path| { - let _ = std::fs::create_dir_all(&database_path); + let _ = std::fs::create_dir_all(database_path); sc_sysinfo::gather_hwbench(Some(database_path)) })).flatten(); let para_id = chain_spec::Extensions::try_get(&*config.chain_spec) .map(|e| e.para_id) - .ok_or_else(|| "Could not find parachain ID in chain-spec.")?; + .ok_or("Could not find parachain ID in chain-spec.")?; let polkadot_cli = RelayChainCli::new( &config, @@ -301,7 +301,7 @@ pub fn run() -> Result<()> { info!("Parachain genesis state: {}", genesis_state); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); - if !collator_options.relay_chain_rpc_urls.is_empty() && cli.relay_chain_args.len() > 0 { + if !collator_options.relay_chain_rpc_urls.is_empty() && !cli.relay_chain_args.is_empty() { warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options."); } diff --git a/parachain-template/runtime/src/lib.rs b/parachain-template/runtime/src/lib.rs index 61839e0a621..3c24b39d64d 100644 --- a/parachain-template/runtime/src/lib.rs +++ b/parachain-template/runtime/src/lib.rs @@ -686,13 +686,13 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch}; use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime {} diff --git a/parachains/common/src/impls.rs b/parachains/common/src/impls.rs index cc89a248e2e..d9998755212 100644 --- a/parachains/common/src/impls.rs +++ b/parachains/common/src/impls.rs @@ -278,7 +278,6 @@ mod tests { } let asset_location = SomeSiblingParachain::get() - .clone() .pushed_with_interior(GeneralIndex(42)) .expect("multilocation will only have 2 junctions; qed"); let asset = MultiAsset { id: Concrete(asset_location), fun: 1_000_000u128.into() }; diff --git a/parachains/pallets/parachain-info/src/lib.rs b/parachains/pallets/parachain-info/src/lib.rs index d61387aaeb6..93ef5bfcfeb 100644 --- a/parachains/pallets/parachain-info/src/lib.rs +++ b/parachains/pallets/parachain-info/src/lib.rs @@ -53,7 +53,7 @@ pub mod pallet { #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { - >::put(&self.parachain_id); + >::put(self.parachain_id); } } diff --git a/parachains/runtimes/assets/common/src/foreign_creators.rs b/parachains/runtimes/assets/common/src/foreign_creators.rs index 3d7567409f6..dbdf4301d66 100644 --- a/parachains/runtimes/assets/common/src/foreign_creators.rs +++ b/parachains/runtimes/assets/common/src/foreign_creators.rs @@ -43,7 +43,7 @@ where asset_location: &MultiLocation, ) -> sp_std::result::Result { let origin_location = EnsureXcm::::try_origin(origin.clone())?; - if !IsForeign::contains(&asset_location, &origin_location) { + if !IsForeign::contains(asset_location, &origin_location) { return Err(origin) } AccountOf::convert(origin_location).map_err(|_| origin) @@ -51,6 +51,6 @@ where #[cfg(feature = "runtime-benchmarks")] fn try_successful_origin(a: &MultiLocation) -> Result { - Ok(pallet_xcm::Origin::Xcm(a.clone()).into()) + Ok(pallet_xcm::Origin::Xcm(*a).into()) } } diff --git a/parachains/runtimes/assets/common/src/matching.rs b/parachains/runtimes/assets/common/src/matching.rs index a5e030412b9..a82d28a086c 100644 --- a/parachains/runtimes/assets/common/src/matching.rs +++ b/parachains/runtimes/assets/common/src/matching.rs @@ -61,7 +61,7 @@ impl> ContainsPair bool { log::trace!(target: "xcm::contains", "IsForeignConcreteAsset asset: {:?}, origin: {:?}", asset, origin); - matches!(asset.id, Concrete(ref id) if IsForeign::contains(id, &origin)) + matches!(asset.id, Concrete(ref id) if IsForeign::contains(id, origin)) } } @@ -73,7 +73,7 @@ impl> ContainsPair { fn contains(&a: &MultiLocation, b: &MultiLocation) -> bool { // `a` needs to be from `b` at least - if !a.starts_with(&b) { + if !a.starts_with(b) { return false } diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index 961a9300a56..eacd865200b 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -213,7 +213,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -1026,7 +1026,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -1062,7 +1062,6 @@ impl_runtime_apis! { id: Concrete(GeneralIndex(i as u128).into()), fun: Fungible(fungibles_amount * i as u128), } - .into() }) .chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) .chain((0..holding_non_fungibles).map(|i| MultiAsset { @@ -1082,7 +1081,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( KsmLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(KsmLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; @@ -1097,7 +1096,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(KsmLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } @@ -1201,7 +1200,7 @@ cumulus_pallet_parachain_system::register_validate_block! { #[cfg(feature = "state-trie-version-1")] parameter_types! { // The deposit configuration for the singed migration. Specially if you want to allow any signed account to do the migration (see `SignedFilter`, these deposits should be high) - pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS; + pub const MigrationSignedDepositPerItem: Balance = CENTS; pub const MigrationSignedDepositBase: Balance = 2_000 * CENTS; pub const MigrationMaxKeyLen: u32 = 512; } diff --git a/parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs b/parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs index 877a54ba848..0bb10d30606 100644 --- a/parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs +++ b/parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs @@ -34,7 +34,7 @@ impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -53,7 +53,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -65,7 +65,7 @@ impl XcmWeightInfo for StatemineXcmWeight { // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -123,7 +123,7 @@ impl XcmWeightInfo for StatemineXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } diff --git a/parachains/runtimes/assets/statemine/tests/tests.rs b/parachains/runtimes/assets/statemine/tests/tests.rs index b9001a35a99..d2e033eacec 100644 --- a/parachains/runtimes/assets/statemine/tests/tests.rs +++ b/parachains/runtimes/assets/statemine/tests/tests.rs @@ -77,7 +77,7 @@ fn test_asset_xcm_trader() { // Lets pay with: asset_amount_needed + asset_amount_extra let asset_amount_extra = 100_u128; let asset: MultiAsset = - (asset_multilocation.clone(), asset_amount_needed + asset_amount_extra).into(); + (asset_multilocation, asset_amount_needed + asset_amount_extra).into(); let mut trader = ::Trader::new(); @@ -150,7 +150,7 @@ fn test_asset_xcm_trader_with_refund() { // lets calculate amount needed let amount_bought = WeightToFee::weight_to_fee(&bought); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Make sure buy_weight does not return an error assert_ok!(trader.buy_weight(bought, asset.clone().into())); @@ -224,7 +224,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() { "we are testing what happens when the amount does not exceed ED" ); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Buy weight should return an error assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); @@ -277,11 +277,11 @@ fn test_that_buying_ed_refund_does_not_refund() { // We know we will have to buy at least ED, so lets make sure first it will // fail with a payment of less than ED - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); // Now lets buy ED at least - let asset: MultiAsset = (asset_multilocation.clone(), ExistentialDeposit::get()).into(); + let asset: MultiAsset = (asset_multilocation, ExistentialDeposit::get()).into(); // Buy weight should work assert_ok!(trader.buy_weight(bought, asset.into())); @@ -416,7 +416,7 @@ fn test_assets_balances_api_works() { let foreign_asset_minimum_asset_balance = 3333333_u128; assert_ok!(ForeignAssets::force_create( RuntimeHelper::::root_origin(), - foreign_asset_id_multilocation.clone().into(), + foreign_asset_id_multilocation, AccountId::from(SOME_ASSET_ADMIN).into(), false, foreign_asset_minimum_asset_balance @@ -425,7 +425,7 @@ fn test_assets_balances_api_works() { // We first mint enough asset for the account to exist for assets assert_ok!(ForeignAssets::mint( RuntimeHelper::::origin_of(AccountId::from(SOME_ASSET_ADMIN)), - foreign_asset_id_multilocation.clone().into(), + foreign_asset_id_multilocation, AccountId::from(ALICE).into(), 6 * foreign_asset_minimum_asset_balance )); diff --git a/parachains/runtimes/assets/statemint/src/lib.rs b/parachains/runtimes/assets/statemint/src/lib.rs index aa90ca7a157..b697a7902a7 100644 --- a/parachains/runtimes/assets/statemint/src/lib.rs +++ b/parachains/runtimes/assets/statemint/src/lib.rs @@ -223,7 +223,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -925,7 +925,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -960,7 +960,6 @@ impl_runtime_apis! { id: Concrete(GeneralIndex(i as u128).into()), fun: Fungible(fungibles_amount * i as u128), } - .into() }) .chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) .chain((0..holding_non_fungibles).map(|i| MultiAsset { @@ -980,7 +979,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( DotLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(DotLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(DotLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; } @@ -994,7 +993,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(DotLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } diff --git a/parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs b/parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs index 1b4a2bcfdd7..f2ea6d85a50 100644 --- a/parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs +++ b/parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs @@ -34,7 +34,7 @@ impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -53,7 +53,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -65,7 +65,7 @@ impl XcmWeightInfo for StatemintXcmWeight { // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -123,7 +123,7 @@ impl XcmWeightInfo for StatemintXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } diff --git a/parachains/runtimes/assets/statemint/tests/tests.rs b/parachains/runtimes/assets/statemint/tests/tests.rs index 7bbed6bb54a..13e7e85b149 100644 --- a/parachains/runtimes/assets/statemint/tests/tests.rs +++ b/parachains/runtimes/assets/statemint/tests/tests.rs @@ -80,7 +80,7 @@ fn test_asset_xcm_trader() { // Lets pay with: asset_amount_needed + asset_amount_extra let asset_amount_extra = 100_u128; let asset: MultiAsset = - (asset_multilocation.clone(), asset_amount_needed + asset_amount_extra).into(); + (asset_multilocation, asset_amount_needed + asset_amount_extra).into(); let mut trader = ::Trader::new(); @@ -156,7 +156,7 @@ fn test_asset_xcm_trader_with_refund() { // lets calculate amount needed let amount_bought = WeightToFee::weight_to_fee(&bought); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Make sure buy_weight does not return an error assert_ok!(trader.buy_weight(bought, asset.clone().into())); @@ -233,7 +233,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() { "we are testing what happens when the amount does not exceed ED" ); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Buy weight should return an error assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); @@ -286,11 +286,11 @@ fn test_that_buying_ed_refund_does_not_refund() { // We know we will have to buy at least ED, so lets make sure first it will // fail with a payment of less than ED - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); // Now lets buy ED at least - let asset: MultiAsset = (asset_multilocation.clone(), ExistentialDeposit::get()).into(); + let asset: MultiAsset = (asset_multilocation, ExistentialDeposit::get()).into(); // Buy weight should work assert_ok!(trader.buy_weight(bought, asset.into())); diff --git a/parachains/runtimes/assets/test-utils/src/lib.rs b/parachains/runtimes/assets/test-utils/src/lib.rs index 1e0b31f18a3..167e83f48d7 100644 --- a/parachains/runtimes/assets/test-utils/src/lib.rs +++ b/parachains/runtimes/assets/test-utils/src/lib.rs @@ -134,12 +134,12 @@ impl< .unwrap(); } - pallet_balances::GenesisConfig:: { balances: self.balances.into() } + pallet_balances::GenesisConfig:: { balances: self.balances } .assimilate_storage(&mut t) .unwrap(); pallet_collator_selection::GenesisConfig:: { - invulnerables: self.collators.clone().into(), + invulnerables: self.collators.clone(), candidacy_bond: Default::default(), desired_candidates: Default::default(), } @@ -388,7 +388,7 @@ pub fn mock_open_hrmp_channel< let inherent_data = { let mut inherent_data = InherentData::default(); let system_inherent_data = ParachainInherentData { - validation_data: vfp.clone(), + validation_data: vfp, relay_chain_state, downward_messages: Default::default(), horizontal_messages: Default::default(), diff --git a/parachains/runtimes/assets/test-utils/src/test_cases.rs b/parachains/runtimes/assets/test-utils/src/test_cases.rs index 954ff0d7589..a599db82713 100644 --- a/parachains/runtimes/assets/test-utils/src/test_cases.rs +++ b/parachains/runtimes/assets/test-utils/src/test_cases.rs @@ -134,7 +134,7 @@ pub fn teleports_for_native_asset_works< BuyExecution { fees: MultiAsset { id: Concrete(native_asset_id), - fun: Fungible(buy_execution_fee_amount_eta.into()), + fun: Fungible(buy_execution_fee_amount_eta), }, weight_limit: Limited(Weight::from_parts(303531000, 65536)), }, @@ -190,7 +190,7 @@ pub fn teleports_for_native_asset_works< RuntimeHelper::::origin_of(target_account.clone()), dest, dest_beneficiary, - (native_asset_id, native_asset_to_teleport_away.clone().into()), + (native_asset_id, native_asset_to_teleport_away.into()), None, )); // check balances @@ -235,7 +235,7 @@ pub fn teleports_for_native_asset_works< RuntimeHelper::::origin_of(target_account.clone()), dest, dest_beneficiary, - (native_asset_id, native_asset_to_teleport_away.clone().into()), + (native_asset_id, native_asset_to_teleport_away.into()), Some((runtime_para_id, other_para_id)), )); @@ -366,7 +366,7 @@ pub fn teleports_for_foreign_assets_works< WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 0)); let buy_execution_fee = MultiAsset { id: Concrete(MultiLocation::parent()), - fun: Fungible(buy_execution_fee_amount.into()), + fun: Fungible(buy_execution_fee_amount), }; let teleported_foreign_asset_amount = 10000000000000; @@ -376,7 +376,7 @@ pub fn teleports_for_foreign_assets_works< .with_session_keys(collator_session_keys.session_keys()) .with_balances(vec![ ( - foreign_creator_as_account_id.clone(), + foreign_creator_as_account_id, existential_deposit + (buy_execution_fee_amount * 2).into(), ), (target_account.clone(), existential_deposit), @@ -441,7 +441,7 @@ pub fn teleports_for_foreign_assets_works< BuyExecution { fees: MultiAsset { id: Concrete(MultiLocation::parent()), - fun: Fungible(buy_execution_fee_amount.into()), + fun: Fungible(buy_execution_fee_amount), }, weight_limit: Limited(Weight::from_parts(403531000, 65536)), }, @@ -536,7 +536,7 @@ pub fn teleports_for_foreign_assets_works< RuntimeHelper::::origin_of(target_account.clone()), dest, dest_beneficiary, - (foreign_asset_id_multilocation, asset_to_teleport_away.clone().into()), + (foreign_asset_id_multilocation, asset_to_teleport_away), Some((runtime_para_id, foreign_para_id)), )); @@ -788,7 +788,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works< .execute_with(|| { // create some asset class let asset_minimum_asset_balance = 3333333_u128; - let asset_id_as_multilocation = AssetIdConverter::reverse_ref(&asset_id).unwrap(); + let asset_id_as_multilocation = AssetIdConverter::reverse_ref(asset_id).unwrap(); assert_ok!(>::force_create( RuntimeHelper::::root_origin(), asset_id.into(), @@ -869,7 +869,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works< id: charlie_account.clone().into() }), }, - (asset_id_as_multilocation, 1 * asset_minimum_asset_balance), + (asset_id_as_multilocation, asset_minimum_asset_balance), ), XcmError::FailedToTransactAsset(Into::<&str>::into( sp_runtime::TokenError::CannotCreate @@ -890,7 +890,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works< parents: 0, interior: X1(AccountId32 { network: None, id: bob_account.clone().into() }), }, - (asset_id_as_multilocation, 1 * asset_minimum_asset_balance), + (asset_id_as_multilocation, asset_minimum_asset_balance), ), Ok(_) )); @@ -908,7 +908,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works< asset_id.into(), &bob_account ), - (1 * asset_minimum_asset_balance).into() + asset_minimum_asset_balance.into() ); assert_eq!( >::balance( @@ -1130,7 +1130,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor // lets simulate this was triggered by relay chain from local consensus sibling parachain let xcm = Xcm(vec![ WithdrawAsset(buy_execution_fee.clone().into()), - BuyExecution { fees: buy_execution_fee.clone().into(), weight_limit: Unlimited }, + BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited }, Transact { origin_kind: OriginKind::Xcm, require_weight_at_most: Weight::from_parts(40_000_000_000, 8000), @@ -1247,7 +1247,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor }); let xcm = Xcm(vec![ WithdrawAsset(buy_execution_fee.clone().into()), - BuyExecution { fees: buy_execution_fee.clone().into(), weight_limit: Unlimited }, + BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited }, Transact { origin_kind: OriginKind::Xcm, require_weight_at_most: Weight::from_parts(20_000_000_000, 8000), diff --git a/parachains/runtimes/assets/westmint/src/lib.rs b/parachains/runtimes/assets/westmint/src/lib.rs index c237c8dc5cf..d5ac6103d97 100644 --- a/parachains/runtimes/assets/westmint/src/lib.rs +++ b/parachains/runtimes/assets/westmint/src/lib.rs @@ -199,7 +199,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -1038,7 +1038,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -1073,7 +1073,6 @@ impl_runtime_apis! { id: Concrete(GeneralIndex(i as u128).into()), fun: Fungible(fungibles_amount * i as u128), } - .into() }) .chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) .chain((0..holding_non_fungibles).map(|i| MultiAsset { @@ -1093,7 +1092,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( WestendLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WestendLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(WestendLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; @@ -1108,7 +1107,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(WestendLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } diff --git a/parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs b/parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs index 5daa3acbcce..a49b8a1c578 100644 --- a/parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs +++ b/parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs @@ -34,7 +34,7 @@ impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -53,7 +53,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -65,7 +65,7 @@ impl XcmWeightInfo for WestmintXcmWeight { // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -123,7 +123,7 @@ impl XcmWeightInfo for WestmintXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } diff --git a/parachains/runtimes/assets/westmint/tests/tests.rs b/parachains/runtimes/assets/westmint/tests/tests.rs index 3ef09d14e52..1c00c3e8f2d 100644 --- a/parachains/runtimes/assets/westmint/tests/tests.rs +++ b/parachains/runtimes/assets/westmint/tests/tests.rs @@ -84,7 +84,7 @@ fn test_asset_xcm_trader() { // Lets pay with: asset_amount_needed + asset_amount_extra let asset_amount_extra = 100_u128; let asset: MultiAsset = - (asset_multilocation.clone(), asset_amount_needed + asset_amount_extra).into(); + (asset_multilocation, asset_amount_needed + asset_amount_extra).into(); let mut trader = ::Trader::new(); @@ -156,7 +156,7 @@ fn test_asset_xcm_trader_with_refund() { // lets calculate amount needed let amount_bought = WeightToFee::weight_to_fee(&bought); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Make sure buy_weight does not return an error assert_ok!(trader.buy_weight(bought, asset.clone().into())); @@ -230,7 +230,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() { "we are testing what happens when the amount does not exceed ED" ); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Buy weight should return an error assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); @@ -282,11 +282,11 @@ fn test_that_buying_ed_refund_does_not_refund() { // We know we will have to buy at least ED, so lets make sure first it will // fail with a payment of less than ED - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); // Now lets buy ED at least - let asset: MultiAsset = (asset_multilocation.clone(), ExistentialDeposit::get()).into(); + let asset: MultiAsset = (asset_multilocation, ExistentialDeposit::get()).into(); // Buy weight should work assert_ok!(trader.buy_weight(bought, asset.into())); @@ -421,7 +421,7 @@ fn test_assets_balances_api_works() { let foreign_asset_minimum_asset_balance = 3333333_u128; assert_ok!(ForeignAssets::force_create( RuntimeHelper::::root_origin(), - foreign_asset_id_multilocation.clone().into(), + foreign_asset_id_multilocation, AccountId::from(SOME_ASSET_ADMIN).into(), false, foreign_asset_minimum_asset_balance @@ -430,7 +430,7 @@ fn test_assets_balances_api_works() { // We first mint enough asset for the account to exist for assets assert_ok!(ForeignAssets::mint( RuntimeHelper::::origin_of(AccountId::from(SOME_ASSET_ADMIN)), - foreign_asset_id_multilocation.clone().into(), + foreign_asset_id_multilocation, AccountId::from(ALICE).into(), 6 * foreign_asset_minimum_asset_balance )); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index 952c3147306..ec9d9f09e41 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -254,7 +254,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -615,7 +615,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -653,7 +653,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( KsmRelayLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmRelayLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(KsmRelayLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; } @@ -667,7 +667,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(KsmRelayLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs index 7cf23e0610b..c8a1748be63 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs @@ -34,7 +34,7 @@ impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -53,7 +53,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -65,7 +65,7 @@ impl XcmWeightInfo for BridgeHubKusamaXcmWeight { // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -123,7 +123,7 @@ impl XcmWeightInfo for BridgeHubKusamaXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index dfc08b4c184..b701645ed17 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -254,7 +254,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -615,7 +615,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -653,7 +653,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( DotRelayLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(DotRelayLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(DotRelayLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; } @@ -667,7 +667,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(DotRelayLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs index e9b1c70bf6a..6e58e2d6bfa 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs @@ -34,7 +34,7 @@ impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -53,7 +53,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -65,7 +65,7 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight { // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -123,7 +123,7 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } @@ -150,7 +150,7 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight { _xcm: &Xcm<()>, ) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(200_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(200_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::initiate_teleport()); hardcoded_weight.min(weight) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 21f02ce4765..15e34472fc6 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -274,7 +274,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -888,7 +888,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -926,7 +926,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( RelayLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(RelayLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(RelayLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; } @@ -940,7 +940,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(RelayLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index a0aaac56f5a..8a63a4453e7 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -35,7 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -54,7 +54,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -66,7 +66,7 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -124,7 +124,7 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 0773dca274e..fe5873f7e11 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -347,11 +347,11 @@ impl WeightInfo { // Storage: BridgeWococoMessages OutboundMessages (r:0 w:1) // Proof: BridgeWococoMessages OutboundMessages (max_values: None, max_size: Some(2621472), added: 2623947, mode: MaxEncodedLen) pub(crate) fn export_message(x: u32, ) -> Weight { - Weight::from_parts(31_677_716 as u64, 0) + Weight::from_parts(31_677_716_u64, 0) // Standard Error: 4_158 .saturating_add(Weight::from_parts(123_901, 0).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: diff --git a/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs b/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs index 5cdc2af9968..82ac363daed 100644 --- a/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs +++ b/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs @@ -166,7 +166,7 @@ pub fn handle_export_message_from_system_parachain_to_outbound_queue_works< // check queue before assert_eq!( pallet_bridge_messages::OutboundLanes::::try_get( - &expected_lane_id + expected_lane_id ), Err(()) ); @@ -190,7 +190,7 @@ pub fn handle_export_message_from_system_parachain_to_outbound_queue_works< // check queue after assert_eq!( pallet_bridge_messages::OutboundLanes::::try_get( - &expected_lane_id + expected_lane_id ), Ok(OutboundLaneData { oldest_unpruned_nonce: 1, diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/migration.rs b/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/migration.rs index 5056abb2e22..71ad62f70b3 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/migration.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/migration.rs @@ -27,7 +27,7 @@ pub(crate) mod import_kusama_fellowship { #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; - const TARGET: &'static str = "runtime::migration::import_fellowship"; + const TARGET: &str = "runtime::migration::import_fellowship"; parameter_types! { // The Fellowship addresses from Kusama state. @@ -250,7 +250,7 @@ pub mod tests { assert!(IdToIndex::::get(0, &who).is_some()); assert!(IdToIndex::::get(rank + 1, &who).is_none()); let index = IdToIndex::::get(rank, &who).unwrap(); - assert_eq!(IndexToId::::get(rank, &index).unwrap(), who); + assert_eq!(IndexToId::::get(rank, index).unwrap(), who); assert_eq!( Members::::get(&who).unwrap(), MemberRecord::new(rank) diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/tracks.rs b/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/tracks.rs index 5d75bde9e18..1f728279485 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/tracks.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/tracks.rs @@ -54,7 +54,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -76,7 +76,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -98,7 +98,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -120,7 +120,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -142,7 +142,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -160,11 +160,11 @@ impl pallet_referenda::TracksInfo for TracksInfo { pallet_referenda::TrackInfo { name: "experts", max_deciding: 10, - decision_deposit: 1 * DOLLARS, + decision_deposit: DOLLARS, prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -182,11 +182,11 @@ impl pallet_referenda::TracksInfo for TracksInfo { pallet_referenda::TrackInfo { name: "senior experts", max_deciding: 10, - decision_deposit: 1 * DOLLARS, + decision_deposit: DOLLARS, prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -204,11 +204,11 @@ impl pallet_referenda::TracksInfo for TracksInfo { pallet_referenda::TrackInfo { name: "masters", max_deciding: 10, - decision_deposit: 1 * DOLLARS, + decision_deposit: DOLLARS, prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -226,11 +226,11 @@ impl pallet_referenda::TracksInfo for TracksInfo { pallet_referenda::TrackInfo { name: "senior masters", max_deciding: 10, - decision_deposit: 1 * DOLLARS, + decision_deposit: DOLLARS, prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -248,11 +248,11 @@ impl pallet_referenda::TracksInfo for TracksInfo { pallet_referenda::TrackInfo { name: "grand masters", max_deciding: 10, - decision_deposit: 1 * DOLLARS, + decision_deposit: DOLLARS, prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs b/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs index f70fb30bff7..3b2ffd58ebc 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs @@ -59,7 +59,7 @@ where let pallet_acc: AccountIdOf = PalletAccount::get(); let treasury_acc: AccountIdOf = TreasuryAccount::get(); - >::resolve_creating(&pallet_acc.clone(), amount); + >::resolve_creating(&pallet_acc, amount); let result = >::teleport_assets( <::RuntimeOrigin>::signed(pallet_acc.into()), diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs index e0f95cb052b..b902e694a15 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs @@ -216,7 +216,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -843,7 +843,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -899,7 +899,7 @@ impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { .create_inherent_data() .expect("Could not create the timestamp inherent data"); - inherent_data.check_extrinsics(&block) + inherent_data.check_extrinsics(block) } } diff --git a/parachains/runtimes/contracts/contracts-rococo/src/lib.rs b/parachains/runtimes/contracts/contracts-rococo/src/lib.rs index adeee2b5229..2718484fed6 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/lib.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/lib.rs @@ -639,7 +639,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( diff --git a/parachains/runtimes/starters/shell/src/lib.rs b/parachains/runtimes/starters/shell/src/lib.rs index a05a78863c4..fc87a26f8ee 100644 --- a/parachains/runtimes/starters/shell/src/lib.rs +++ b/parachains/runtimes/starters/shell/src/lib.rs @@ -222,7 +222,7 @@ impl sp_runtime::traits::SignedExtension for DisallowSigned { info: &DispatchInfoOf, len: usize, ) -> Result { - Ok(self.validate(who, call, info, len).map(|_| ())?) + self.validate(who, call, info, len).map(|_| ()) } fn validate( &self, diff --git a/parachains/runtimes/testing/penpal/src/lib.rs b/parachains/runtimes/testing/penpal/src/lib.rs index 7ade3bd2f63..5a5cb423d43 100644 --- a/parachains/runtimes/testing/penpal/src/lib.rs +++ b/parachains/runtimes/testing/penpal/src/lib.rs @@ -783,7 +783,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( diff --git a/parachains/runtimes/testing/penpal/src/xcm_config.rs b/parachains/runtimes/testing/penpal/src/xcm_config.rs index 89cfc2ced65..1121105edbf 100644 --- a/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -225,12 +225,12 @@ pub trait Reserve { // Takes the chain part of a MultiAsset impl Reserve for MultiAsset { fn reserve(&self) -> Option { - if let AssetId::Concrete(location) = self.id.clone() { + if let AssetId::Concrete(location) = self.id { let first_interior = location.first_interior(); let parents = location.parent_count(); - match (parents, first_interior.clone()) { - (0, Some(Parachain(id))) => Some(MultiLocation::new(0, X1(Parachain(id.clone())))), - (1, Some(Parachain(id))) => Some(MultiLocation::new(1, X1(Parachain(id.clone())))), + match (parents, first_interior) { + (0, Some(Parachain(id))) => Some(MultiLocation::new(0, X1(Parachain(*id)))), + (1, Some(Parachain(id))) => Some(MultiLocation::new(1, X1(Parachain(*id)))), (1, _) => Some(MultiLocation::parent()), _ => None, } diff --git a/parachains/runtimes/testing/rococo-parachain/src/lib.rs b/parachains/runtimes/testing/rococo-parachain/src/lib.rs index 1a26290f2a3..de814756433 100644 --- a/parachains/runtimes/testing/rococo-parachain/src/lib.rs +++ b/parachains/runtimes/testing/rococo-parachain/src/lib.rs @@ -219,10 +219,10 @@ impl pallet_timestamp::Config for Runtime { } parameter_types! { - pub const ExistentialDeposit: u128 = 1 * MILLIROC; - pub const TransferFee: u128 = 1 * MILLIROC; - pub const CreationFee: u128 = 1 * MILLIROC; - pub const TransactionByteFee: u128 = 1 * MICROROC; + pub const ExistentialDeposit: u128 = MILLIROC; + pub const TransferFee: u128 = MILLIROC; + pub const CreationFee: u128 = MILLIROC; + pub const TransactionByteFee: u128 = MICROROC; } impl pallet_balances::Config for Runtime { @@ -503,11 +503,11 @@ impl cumulus_ping::Config for Runtime { } parameter_types! { - pub const AssetDeposit: Balance = 1 * ROC; - pub const AssetAccountDeposit: Balance = 1 * ROC; + pub const AssetDeposit: Balance = ROC; + pub const AssetAccountDeposit: Balance = ROC; pub const ApprovalDeposit: Balance = 100 * MILLIROC; pub const AssetsStringLimit: u32 = 50; - pub const MetadataDepositBase: Balance = 1 * ROC; + pub const MetadataDepositBase: Balance = ROC; pub const MetadataDepositPerByte: Balance = 10 * MILLIROC; pub const UnitBody: BodyId = BodyId::Unit; } diff --git a/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/polkadot-parachain/src/chain_spec/bridge_hubs.rs index e11f7f6e53f..e8f7d9d065d 100644 --- a/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -272,7 +272,7 @@ pub mod rococo { para_id, bridges_pallet_owner_seed .as_ref() - .map(|seed| get_account_id_from_seed::(&seed)), + .map(|seed| get_account_id_from_seed::(seed)), ) }, Vec::new(), diff --git a/polkadot-parachain/src/command.rs b/polkadot-parachain/src/command.rs index 52a742f1527..7effcbf3cd2 100644 --- a/polkadot-parachain/src/command.rs +++ b/polkadot-parachain/src/command.rs @@ -85,7 +85,7 @@ impl RuntimeResolver for PathBuf { } fn runtime(id: &str) -> Runtime { - let id = id.replace("_", "-"); + let id = id.replace('_', "-"); let (_, id, para_id) = extract_parachain_id(&id); if id.starts_with("shell") { @@ -240,7 +240,7 @@ fn load_spec(id: &str) -> std::result::Result, String> { Runtime::ContractsRococo => Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path)?), Runtime::BridgeHub(bridge_hub_runtime_type) => - bridge_hub_runtime_type.chain_spec_from_json_file(path.into())?, + bridge_hub_runtime_type.chain_spec_from_json_file(path)?, Runtime::Penpal(_para_id) => Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?), Runtime::Default => Box::new( @@ -813,13 +813,13 @@ pub fn run() -> Result<()> { runner.run_node_until_exit(|config| async move { let hwbench = (!cli.no_hardware_benchmarks).then_some( config.database.path().map(|database_path| { - let _ = std::fs::create_dir_all(&database_path); + let _ = std::fs::create_dir_all(database_path); sc_sysinfo::gather_hwbench(Some(database_path)) })).flatten(); let para_id = chain_spec::Extensions::try_get(&*config.chain_spec) .map(|e| e.para_id) - .ok_or_else(|| "Could not find parachain extension in chain-spec.")?; + .ok_or("Could not find parachain extension in chain-spec.")?; let polkadot_cli = RelayChainCli::new( &config, @@ -848,7 +848,7 @@ pub fn run() -> Result<()> { info!("Parachain genesis state: {}", genesis_state); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); - if !collator_options.relay_chain_rpc_urls.is_empty() && cli.relaychain_args.len() > 0 { + if !collator_options.relay_chain_rpc_urls.is_empty() && !cli.relaychain_args.is_empty() { warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options."); } diff --git a/polkadot-parachain/src/rpc.rs b/polkadot-parachain/src/rpc.rs index 43752fd8d12..c2eeaf38608 100644 --- a/polkadot-parachain/src/rpc.rs +++ b/polkadot-parachain/src/rpc.rs @@ -70,7 +70,7 @@ where module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?; - module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; + module.merge(StateMigration::new(client, backend, deny_unsafe).into_rpc())?; Ok(module) } diff --git a/polkadot-parachain/src/service.rs b/polkadot-parachain/src/service.rs index 803d0987844..c8370d070a6 100644 --- a/polkadot-parachain/src/service.rs +++ b/polkadot-parachain/src/service.rs @@ -858,7 +858,7 @@ where sc_client_api::StateBackendFor: sp_api::StateBackend, { cumulus_client_consensus_relay_chain::import_queue( - client.clone(), + client, block_import, |_, _| async { Ok(()) }, &task_manager.spawn_essential_handle(), @@ -1103,7 +1103,7 @@ where Box::new(RelayChainVerifier::new(client.clone(), |_, _| async { Ok(()) })) as Box<_>; let verifier = Verifier { - client: client.clone(), + client, relay_chain_verifier, aura_verifier: BuildOnAccess::Uninitialized(Some(Box::new(aura_verifier))), _phantom: PhantomData, diff --git a/polkadot-parachain/tests/benchmark_storage_works.rs b/polkadot-parachain/tests/benchmark_storage_works.rs index 916d65c0a1b..b1c05609217 100644 --- a/polkadot-parachain/tests/benchmark_storage_works.rs +++ b/polkadot-parachain/tests/benchmark_storage_works.rs @@ -8,7 +8,7 @@ use std::{ use tempfile::tempdir; /// The runtimes that this command supports. -static RUNTIMES: [&'static str; 3] = ["westmint", "statemine", "statemint"]; +static RUNTIMES: [&str; 3] = ["westmint", "statemine", "statemint"]; /// The `benchmark storage` command works for the dev runtimes. #[test] @@ -31,7 +31,7 @@ fn benchmark_storage_works() { /// Invoke the `benchmark storage` sub-command for the given database and runtime. fn benchmark_storage(db: &str, runtime: &str, base_path: &Path) -> ExitStatus { Command::new(cargo_bin("polkadot-parachain")) - .args(&["benchmark", "storage", "--chain", runtime]) + .args(["benchmark", "storage", "--chain", runtime]) .arg("--db") .arg(db) .arg("--weight-path") diff --git a/polkadot-parachain/tests/common.rs b/polkadot-parachain/tests/common.rs index 71b7fb42cd2..d8ecfe9bcbe 100644 --- a/polkadot-parachain/tests/common.rs +++ b/polkadot-parachain/tests/common.rs @@ -117,12 +117,12 @@ pub fn find_ws_url_from_output(read: impl Read + Send) -> (String, String) { line.expect("failed to obtain next line from stdout for WS address discovery"); data.push_str(&line); - data.push_str("\n"); + data.push('\n'); // does the line contain our port (we expect this specific output from substrate). let sock_addr = match line.split_once("Running JSON-RPC server: addr=") { None => return None, - Some((_, after)) => after.split_once(",").unwrap().0, + Some((_, after)) => after.split_once(',').unwrap().0, }; Some(format!("ws://{}", sock_addr)) diff --git a/polkadot-parachain/tests/purge_chain_works.rs b/polkadot-parachain/tests/purge_chain_works.rs index 34a51dcff84..2f4609273da 100644 --- a/polkadot-parachain/tests/purge_chain_works.rs +++ b/polkadot-parachain/tests/purge_chain_works.rs @@ -38,7 +38,7 @@ async fn purge_chain_works() { assert!(base_dir.path().join("polkadot/chains/dev/db/full").exists()); let status = Command::new(cargo_bin("polkadot-parachain")) - .args(&["purge-chain", "-d"]) + .args(["purge-chain", "-d"]) .arg(base_dir.path()) .arg("-y") .status() diff --git a/primitives/timestamp/src/lib.rs b/primitives/timestamp/src/lib.rs index ddc2fe340dd..932656d9b0f 100644 --- a/primitives/timestamp/src/lib.rs +++ b/primitives/timestamp/src/lib.rs @@ -99,7 +99,7 @@ mod tests { relay_parent_number: 1, relay_parent_storage_root, }, - &WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"), + WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"), ) .map(|v| Header::decode(&mut &v.head_data.0[..]).expect("Decodes `Header`.")) } @@ -175,7 +175,7 @@ mod tests { (slot_timestamp * 10, false), ] { let output = Command::new(env::current_exe().unwrap()) - .args(&["check_timestamp_inherent_works", "--", "--nocapture"]) + .args(["check_timestamp_inherent_works", "--", "--nocapture"]) .env("RUN_TEST", "1") .env("TIMESTAMP", timestamp.to_string()) .output() diff --git a/primitives/utility/src/lib.rs b/primitives/utility/src/lib.rs index d3a7c77aed2..7d0e8a51edc 100644 --- a/primitives/utility/src/lib.rs +++ b/primitives/utility/src/lib.rs @@ -163,7 +163,7 @@ impl< // Get the local asset id in which we can pay for fees let (local_asset_id, _) = - Matcher::matches_fungibles(&first).map_err(|_| XcmError::AssetNotFound)?; + Matcher::matches_fungibles(first).map_err(|_| XcmError::AssetNotFound)?; // Calculate how much we should charge in the asset_id for such amount of weight // Require at least a payment of minimum_balance @@ -181,7 +181,7 @@ impl< .map_err(|_| XcmError::Overflow)?; // Convert to the same kind of multiasset, with the required fungible balance - let required = first.id.clone().into_multiasset(asset_balance.into()); + let required = first.id.into_multiasset(asset_balance.into()); // Substract payment let unused = payment.checked_sub(required.clone()).map_err(|_| XcmError::TooExpensive)?; @@ -204,7 +204,7 @@ impl< { // Get the local asset id in which we can refund fees let (local_asset_id, outstanding_balance) = - Matcher::matches_fungibles(&(id.clone(), fun).into()).ok()?; + Matcher::matches_fungibles(&(id, fun).into()).ok()?; let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id); @@ -234,7 +234,7 @@ impl< // Construct outstanding_concrete_asset with the same location id and substracted balance let outstanding_concrete_asset: MultiAsset = - (id.clone(), outstanding_minus_substracted).into(); + (id, outstanding_minus_substracted).into(); // Substract from existing weight and balance weight_outstanding = weight_outstanding.saturating_sub(weight); @@ -365,7 +365,7 @@ mod tests { // ParentAsUmp - check dest is really not applicable let dest = (Parent, Parent, Parent); - let mut dest_wrapper = Some(dest.clone().into()); + let mut dest_wrapper = Some(dest.into()); let mut msg_wrapper = Some(message.clone()); assert_eq!( Err(SendError::NotApplicable), @@ -373,7 +373,7 @@ mod tests { ); // check wrapper were not consumed - assert_eq!(Some(dest.clone().into()), dest_wrapper.take()); + assert_eq!(Some(dest.into()), dest_wrapper.take()); assert_eq!(Some(message.clone()), msg_wrapper.take()); // another try with router chain with asserting sender @@ -393,7 +393,7 @@ mod tests { // ParentAsUmp - check dest/msg is valid let dest = (Parent, Here); - let mut dest_wrapper = Some(dest.clone().into()); + let mut dest_wrapper = Some(dest.into()); let mut msg_wrapper = Some(message.clone()); assert!( as SendXcm>::validate( &mut dest_wrapper, @@ -529,7 +529,7 @@ mod tests { // prepare test data let asset: MultiAsset = (Here, AMOUNT).into(); - let payment = Assets::from(asset.clone()); + let payment = Assets::from(asset); let weight_to_buy = Weight::from_parts(1_000, 1_000); // lets do first call (success) @@ -537,7 +537,7 @@ mod tests { // lets do second call (error) assert_eq!( - trader.buy_weight(weight_to_buy, payment.clone()), + trader.buy_weight(weight_to_buy, payment), Err(XcmError::NotWithdrawable) ); } diff --git a/test/client/src/block_builder.rs b/test/client/src/block_builder.rs index 13b20df6be6..0c0c5c4e9c7 100644 --- a/test/client/src/block_builder.rs +++ b/test/client/src/block_builder.rs @@ -64,13 +64,13 @@ pub trait InitBlockBuilder { ) -> sc_block_builder::BlockBuilder; } -fn init_block_builder<'a>( - client: &'a Client, +fn init_block_builder( + client: &Client, at: Hash, validation_data: Option>, relay_sproof_builder: RelayStateSproofBuilder, timestamp: u64, -) -> BlockBuilder<'a, Block, Client, Backend> { +) -> BlockBuilder<'_, Block, Client, Backend> { let mut block_builder = client .new_block_at(at, Default::default(), true) .expect("Creates new block builder for test runtime"); diff --git a/test/client/src/lib.rs b/test/client/src/lib.rs index 4008dca350d..4027a056d55 100644 --- a/test/client/src/lib.rs +++ b/test/client/src/lib.rs @@ -199,5 +199,4 @@ pub fn validate_block( &validation_params.encode(), ) .map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`.")) - .map_err(|err| err.into()) } diff --git a/test/relay-sproof-builder/src/lib.rs b/test/relay-sproof-builder/src/lib.rs index decc6ee3aa0..b5fc0c7f08f 100644 --- a/test/relay-sproof-builder/src/lib.rs +++ b/test/relay-sproof-builder/src/lib.rs @@ -171,7 +171,7 @@ impl RelayStateSproofBuilder { } } - let root = backend.root().clone(); + let root = *backend.root(); let proof = sp_state_machine::prove_read(backend, relevant_keys).expect("prove read"); (root, proof) } diff --git a/test/service/benches/transaction_throughput.rs b/test/service/benches/transaction_throughput.rs index 1c3f841fe23..48bf49487e6 100644 --- a/test/service/benches/transaction_throughput.rs +++ b/test/service/benches/transaction_throughput.rs @@ -46,7 +46,7 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec accounts .iter() .enumerate() - .map(|(i, a)| { + .flat_map(|(i, a)| { vec![ // Reset the nonce by removing any funds construct_extrinsic( @@ -54,7 +54,7 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec SudoCall::sudo { call: Box::new( BalancesCall::force_set_balance { - who: AccountId::from(a.public()).into(), + who: AccountId::from(a.public()), new_free: 0, } .into(), @@ -69,7 +69,7 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec SudoCall::sudo { call: Box::new( BalancesCall::force_set_balance { - who: AccountId::from(a.public()).into(), + who: AccountId::from(a.public()), new_free: 1_000_000_000_000 * ExistentialDeposit::get(), } .into(), @@ -80,7 +80,6 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec ), ] }) - .flatten() .map(OpaqueExtrinsic::from) .collect() } @@ -92,20 +91,19 @@ fn create_benchmark_extrinsics( ) -> Vec { accounts .iter() - .map(|account| { + .flat_map(|account| { (0..extrinsics_per_account).map(move |nonce| { construct_extrinsic( client, BalancesCall::transfer_allow_death { - dest: Bob.to_account_id().into(), - value: 1 * ExistentialDeposit::get(), + dest: Bob.to_account_id(), + value: ExistentialDeposit::get(), }, account.clone(), Some(nonce as u32), ) }) }) - .flatten() .map(OpaqueExtrinsic::from) .collect() } @@ -208,27 +206,27 @@ fn transaction_throughput_benchmarks(c: &mut Criterion) { |b| { b.iter_batched( || { - let prepare_extrinsics = create_account_extrinsics(&*dave.client, &accounts); + let prepare_extrinsics = create_account_extrinsics(&dave.client, &accounts); benchmark_handle.block_on(future::join_all( prepare_extrinsics.into_iter().map(|tx| { submit_tx_and_wait_for_inclusion( &dave.transaction_pool, tx, - &*dave.client, + &dave.client, true, ) }), )); - create_benchmark_extrinsics(&*dave.client, &accounts, extrinsics_per_account) + create_benchmark_extrinsics(&dave.client, &accounts, extrinsics_per_account) }, |extrinsics| { benchmark_handle.block_on(future::join_all(extrinsics.into_iter().map(|tx| { submit_tx_and_wait_for_inclusion( &dave.transaction_pool, tx, - &*dave.client, + &dave.client, false, ) }))); diff --git a/test/service/src/chain_spec.rs b/test/service/src/chain_spec.rs index e1399e97a36..b01804fd923 100644 --- a/test/service/src/chain_spec.rs +++ b/test/service/src/chain_spec.rs @@ -39,7 +39,7 @@ pub struct GenesisExt { impl sp_runtime::BuildStorage for GenesisExt { fn assimilate_storage(&self, storage: &mut sp_core::storage::Storage) -> Result<(), String> { sp_state_machine::BasicExternalities::execute_with_storage(storage, || { - sp_io::storage::set(cumulus_test_runtime::TEST_RUNTIME_UPGRADE_KEY, &vec![1, 2, 3, 4]); + sp_io::storage::set(cumulus_test_runtime::TEST_RUNTIME_UPGRADE_KEY, &[1, 2, 3, 4]); cumulus_test_runtime::ParachainId::set(&self.para_id); }); diff --git a/test/service/src/lib.rs b/test/service/src/lib.rs index 662f04487aa..b24e71936a0 100644 --- a/test/service/src/lib.rs +++ b/test/service/src/lib.rs @@ -630,7 +630,7 @@ impl TestNodeBuilder { let parachain_config = node_config( self.storage_update_func_parachain.unwrap_or_else(|| Box::new(|| ())), self.tokio_handle.clone(), - self.key.clone(), + self.key, self.parachain_nodes, self.parachain_nodes_exclusive, self.para_id, @@ -667,7 +667,7 @@ impl TestNodeBuilder { .await .expect("could not create Cumulus test service"); - let peer_id = network.local_peer_id().clone(); + let peer_id = network.local_peer_id(); let addr = MultiaddrWithPeerId { multiaddr, peer_id }; TestNode { task_manager, client, network, addr, rpc_handlers, transaction_pool } @@ -690,7 +690,7 @@ pub fn node_config( is_collator: bool, ) -> Result { let base_path = BasePath::new_temp_dir()?; - let root = base_path.path().join(format!("cumulus_test_service_{}", key.to_string())); + let root = base_path.path().join(format!("cumulus_test_service_{}", key)); let role = if is_collator { Role::Authority } else { Role::Full }; let key_seed = key.to_seed(); let mut spec = Box::new(chain_spec::get_chain_spec(para_id)); @@ -786,7 +786,7 @@ impl TestNode { function: impl Into, caller: Sr25519Keyring, ) -> Result { - let extrinsic = construct_extrinsic(&*self.client, function, caller.pair(), Some(0)); + let extrinsic = construct_extrinsic(&self.client, function, caller.pair(), Some(0)); self.rpc_handlers.send_transaction(extrinsic.into()).await } From 054c41d8b8aef1e932d3e7ca36e2b61b49fc1c95 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 13:44:49 +0000 Subject: [PATCH 03/15] No tabs in comments Signed-off-by: Oliver Tale-Yazdi --- client/pov-recovery/src/lib.rs | 2 +- parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/pov-recovery/src/lib.rs b/client/pov-recovery/src/lib.rs index 60e613be746..0e7842cb3eb 100644 --- a/client/pov-recovery/src/lib.rs +++ b/client/pov-recovery/src/lib.rs @@ -40,7 +40,7 @@ //! 4a. After it is recovered, we restore the block and import it. //! //! 4b. Since we are trying to recover pending candidates, availability is not guaranteed. If the block -//! PoV is not yet available, we retry. +//! PoV is not yet available, we retry. //! //! If we need to recover multiple PoV blocks (which should hopefully not happen in real life), we //! make sure that the blocks are imported in the correct order. diff --git a/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs b/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs index 82ac363daed..5f419fe789f 100644 --- a/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs +++ b/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs @@ -243,8 +243,8 @@ macro_rules! include_handle_export_message_from_system_parachain_to_outbound_que /// Test-case makes sure that Runtime can route XCM messages received in inbound queue, /// We just test here `MessageDispatch` configuration. /// We expect that runtime can route messages: -/// 1. to Parent (relay chain) -/// 2. to Sibling parachain +/// 1. to Parent (relay chain) +/// 2. to Sibling parachain pub fn message_dispatch_routing_works< Runtime, XcmConfig, From 8c0609677f3ea040f77fffd5be6facf7c3fec95c Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 13:51:43 +0000 Subject: [PATCH 04/15] Prefer matches Signed-off-by: Oliver Tale-Yazdi --- parachains/runtimes/assets/common/src/matching.rs | 14 ++++---------- .../runtimes/assets/statemine/src/xcm_config.rs | 9 ++++----- .../runtimes/assets/statemint/src/xcm_config.rs | 7 +++---- .../runtimes/assets/westmint/src/xcm_config.rs | 7 +++---- .../bridge-hub-kusama/src/xcm_config.rs | 7 +++---- .../bridge-hub-polkadot/src/xcm_config.rs | 7 +++---- .../bridge-hub-rococo/src/xcm_config.rs | 7 +++---- .../collectives-polkadot/src/xcm_config.rs | 7 +++---- 8 files changed, 26 insertions(+), 39 deletions(-) diff --git a/parachains/runtimes/assets/common/src/matching.rs b/parachains/runtimes/assets/common/src/matching.rs index a82d28a086c..7db6a682a72 100644 --- a/parachains/runtimes/assets/common/src/matching.rs +++ b/parachains/runtimes/assets/common/src/matching.rs @@ -42,10 +42,7 @@ impl> Contains for StartsWithExplicitGlobalConsensus { fn contains(t: &MultiLocation) -> bool { - match t.interior.global_consensus() { - Ok(requested_network) if requested_network.eq(&Network::get()) => true, - _ => false, - } + matches!(t.interior.global_consensus(), Ok(requested_network) if requested_network.eq(&Network::get())) } } @@ -79,12 +76,9 @@ impl> ContainsPair // here we check if sibling match a { - MultiLocation { parents: 1, interior } => match interior.first() { - Some(Parachain(sibling_para_id)) - if sibling_para_id.ne(&u32::from(SelfParaId::get())) => - true, - _ => false, - }, + MultiLocation { parents: 1, interior } => + matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get()))) + , _ => false, } } diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index 45f95ee07d4..e732817a80a 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -197,7 +197,7 @@ impl Contains for SafeCallFilter { } } - match call { + matches!(call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | RuntimeCall::System( frame_system::Call::set_heap_pages { .. } | @@ -338,10 +338,9 @@ impl Contains for SafeCallFilter { pallet_uniques::Call::set_accept_ownership { .. } | pallet_uniques::Call::set_collection_max_supply { .. } | pallet_uniques::Call::set_price { .. } | - pallet_uniques::Call::buy_item { .. }, - ) => true, - _ => false, - } + pallet_uniques::Call::buy_item { .. } + ) + ) } } diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs index 9d31bc0da60..ac81aaadcbb 100644 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemint/src/xcm_config.rs @@ -166,7 +166,7 @@ impl Contains for SafeCallFilter { } } - match call { + matches!(call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | RuntimeCall::System( frame_system::Call::set_heap_pages { .. } | @@ -242,9 +242,8 @@ impl Contains for SafeCallFilter { pallet_uniques::Call::set_collection_max_supply { .. } | pallet_uniques::Call::set_price { .. } | pallet_uniques::Call::buy_item { .. }, - ) => true, - _ => false, - } + ) + ) } } diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index d9987a627ae..0e8926a4f2c 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -191,7 +191,7 @@ impl Contains for SafeCallFilter { } } - match call { + matches!(call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | RuntimeCall::System( frame_system::Call::set_heap_pages { .. } | @@ -337,9 +337,8 @@ impl Contains for SafeCallFilter { pallet_uniques::Call::set_collection_max_supply { .. } | pallet_uniques::Call::set_price { .. } | pallet_uniques::Call::buy_item { .. }, - ) => true, - _ => false, - } + ) + ) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 7b395a4d4e3..b3f292fdc3b 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -129,7 +129,7 @@ impl Contains for SafeCallFilter { } } - match call { + matches!(call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | RuntimeCall::System( frame_system::Call::set_heap_pages { .. } | @@ -149,9 +149,8 @@ impl Contains for SafeCallFilter { RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | RuntimeCall::XcmpQueue(..) | RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true, - _ => false, - } + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) + ) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index d063fda2c13..cc7a81f0858 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -132,7 +132,7 @@ impl Contains for SafeCallFilter { } } - match call { + matches!(call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | RuntimeCall::System( frame_system::Call::set_heap_pages { .. } | @@ -152,9 +152,8 @@ impl Contains for SafeCallFilter { RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | RuntimeCall::XcmpQueue(..) | RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true, - _ => false, - } + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) + ) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 91fd15136bb..59c64290710 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -152,7 +152,7 @@ impl Contains for SafeCallFilter { } } - match call { + matches!(call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | RuntimeCall::System( frame_system::Call::set_heap_pages { .. } | @@ -184,9 +184,8 @@ impl Contains for SafeCallFilter { BridgeGrandpaWococoInstance, >::initialize { .. - }) => true, - _ => false, - } + }) + ) } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index b2b93d88ffe..d398a17008c 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -137,7 +137,7 @@ impl Contains for SafeCallFilter { } } - match call { + matches!(call, RuntimeCall::System( frame_system::Call::set_heap_pages { .. } | frame_system::Call::set_code { .. } | @@ -186,9 +186,8 @@ impl Contains for SafeCallFilter { pallet_ranked_collective::Call::promote_member { .. } | pallet_ranked_collective::Call::demote_member { .. } | pallet_ranked_collective::Call::remove_member { .. }, - ) => true, - _ => false, - } + ) + ) } } From 7574da238355394b439f0bbb7ff37dc84d740160 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 13:55:05 +0000 Subject: [PATCH 05/15] Dont drop references Signed-off-by: Oliver Tale-Yazdi --- client/consensus/common/src/parachain_consensus.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/client/consensus/common/src/parachain_consensus.rs b/client/consensus/common/src/parachain_consensus.rs index 734f682d25b..b46c042f1ba 100644 --- a/client/consensus/common/src/parachain_consensus.rs +++ b/client/consensus/common/src/parachain_consensus.rs @@ -325,7 +325,6 @@ async fn handle_new_block_imported( match parachain.block_status(unset_hash) { Ok(BlockStatus::InChainWithState) => { - drop(unset_best_header); let unset_best_header = unset_best_header_opt .take() .expect("We checked above that the value is set; qed"); From 1916b0f686405600fb9543325e9ca2bb5ad4cb5c Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 14:08:25 +0000 Subject: [PATCH 06/15] Trivial Signed-off-by: Oliver Tale-Yazdi --- client/collator/src/lib.rs | 8 +++++--- client/consensus/common/src/level_monitor.rs | 2 +- client/consensus/common/src/tests.rs | 10 ++-------- parachains/runtimes/assets/statemine/tests/tests.rs | 11 +++-------- parachains/runtimes/assets/statemint/tests/tests.rs | 11 +++-------- parachains/runtimes/assets/westmint/tests/tests.rs | 11 +++-------- primitives/parachain-inherent/src/mock.rs | 6 ++++-- test/service/src/chain_spec.rs | 1 - 8 files changed, 21 insertions(+), 39 deletions(-) diff --git a/client/collator/src/lib.rs b/client/collator/src/lib.rs index 7b0af2f041e..d668b3b2054 100644 --- a/client/collator/src/lib.rs +++ b/client/collator/src/lib.rs @@ -461,7 +461,7 @@ mod tests { spawner, para_id, key: CollatorPair::generate().0, - parachain_consensus: Box::new(DummyParachainConsensus { client: client }), + parachain_consensus: Box::new(DummyParachainConsensus { client }), }); block_on(collator_start); @@ -471,8 +471,10 @@ mod tests { let CollationGenerationMessage::Initialize(config) = msg; - let mut validation_data = PersistedValidationData::default(); - validation_data.parent_head = header.encode().into(); + let validation_data = PersistedValidationData { + parent_head: header.encode().into(), + .. Default::default() + }; let relay_parent = Default::default(); let collation = block_on((config.collator)(relay_parent, &validation_data)) diff --git a/client/consensus/common/src/level_monitor.rs b/client/consensus/common/src/level_monitor.rs index 3576ced1858..ebdfaaf26ca 100644 --- a/client/consensus/common/src/level_monitor.rs +++ b/client/consensus/common/src/level_monitor.rs @@ -22,7 +22,7 @@ use std::{ sync::Arc, }; -const LOG_TARGET: &'static str = "level-monitor"; +const LOG_TARGET: &str = "level-monitor"; /// Value good enough to be used with parachains using the current backend implementation /// that ships with Substrate. This value may change in the future. diff --git a/client/consensus/common/src/tests.rs b/client/consensus/common/src/tests.rs index 23516d96388..f1bc4d42b8a 100644 --- a/client/consensus/common/src/tests.rs +++ b/client/consensus/common/src/tests.rs @@ -337,7 +337,7 @@ fn follow_new_best_with_dummy_recovery_works() { Some(recovery_chan_tx), ); - let block = build_block(&*client.clone(), None, None); + let block = build_block(&*client, None, None); let block_clone = block.clone(); let client_clone = client.clone(); @@ -547,7 +547,6 @@ fn do_not_set_best_block_to_older_block() { let client = Arc::new(TestClientBuilder::with_backend(backend).build()); let blocks = (0..NUM_BLOCKS) - .into_iter() .map(|_| build_and_import_block(client.clone(), true)) .collect::>(); @@ -559,7 +558,6 @@ fn do_not_set_best_block_to_older_block() { let consensus = run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {}), None); - let client2 = client.clone(); let work = async move { new_best_heads_sender .unbounded_send(blocks[NUM_BLOCKS - 2].header().clone()) @@ -579,7 +577,7 @@ fn do_not_set_best_block_to_older_block() { }); // Build and import a new best block. - build_and_import_block(client2.clone(), true); + build_and_import_block(client, true); } #[test] @@ -607,7 +605,6 @@ fn prune_blocks_on_level_overflow() { let id0 = block0.header.hash(); let blocks1 = (0..LEVEL_LIMIT) - .into_iter() .map(|i| { build_and_import_block_ext( &*client, @@ -622,7 +619,6 @@ fn prune_blocks_on_level_overflow() { let id10 = blocks1[0].header.hash(); let blocks2 = (0..2) - .into_iter() .map(|i| { build_and_import_block_ext( &*client, @@ -720,7 +716,6 @@ fn restore_limit_monitor() { let id00 = block00.header.hash(); let blocks1 = (0..LEVEL_LIMIT + 1) - .into_iter() .map(|i| { build_and_import_block_ext( &*client, @@ -735,7 +730,6 @@ fn restore_limit_monitor() { let id10 = blocks1[0].header.hash(); let _ = (0..LEVEL_LIMIT) - .into_iter() .map(|i| { build_and_import_block_ext( &*client, diff --git a/parachains/runtimes/assets/statemine/tests/tests.rs b/parachains/runtimes/assets/statemine/tests/tests.rs index d2e033eacec..a328391ca54 100644 --- a/parachains/runtimes/assets/statemine/tests/tests.rs +++ b/parachains/runtimes/assets/statemine/tests/tests.rs @@ -82,14 +82,9 @@ fn test_asset_xcm_trader() { let mut trader = ::Trader::new(); // Lets buy_weight and make sure buy_weight does not return an error - match trader.buy_weight(bought, asset.into()) { - Ok(unused_assets) => { - // Check whether a correct amount of unused assets is returned - assert_ok!(unused_assets - .ensure_contains(&(asset_multilocation, asset_amount_extra).into())); - }, - Err(e) => assert!(false, "Expected Ok(_). Got {:#?}", e), - } + let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok"); + // Check whether a correct amount of unused assets is returned + assert_ok!(unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into())); // Drop trader drop(trader); diff --git a/parachains/runtimes/assets/statemint/tests/tests.rs b/parachains/runtimes/assets/statemint/tests/tests.rs index 13e7e85b149..067799f46f4 100644 --- a/parachains/runtimes/assets/statemint/tests/tests.rs +++ b/parachains/runtimes/assets/statemint/tests/tests.rs @@ -85,14 +85,9 @@ fn test_asset_xcm_trader() { let mut trader = ::Trader::new(); // Lets buy_weight and make sure buy_weight does not return an error - match trader.buy_weight(bought, asset.into()) { - Ok(unused_assets) => { - // Check whether a correct amount of unused assets is returned - assert_ok!(unused_assets - .ensure_contains(&(asset_multilocation, asset_amount_extra).into())); - }, - Err(e) => assert!(false, "Expected Ok(_). Got {:#?}", e), - } + let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok"); + // Check whether a correct amount of unused assets is returned + assert_ok!(unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into())); // Drop trader drop(trader); diff --git a/parachains/runtimes/assets/westmint/tests/tests.rs b/parachains/runtimes/assets/westmint/tests/tests.rs index 1c00c3e8f2d..5c274f7bb51 100644 --- a/parachains/runtimes/assets/westmint/tests/tests.rs +++ b/parachains/runtimes/assets/westmint/tests/tests.rs @@ -89,14 +89,9 @@ fn test_asset_xcm_trader() { let mut trader = ::Trader::new(); // Lets buy_weight and make sure buy_weight does not return an error - match trader.buy_weight(bought, asset.into()) { - Ok(unused_assets) => { - // Check whether a correct amount of unused assets is returned - assert_ok!(unused_assets - .ensure_contains(&(asset_multilocation, asset_amount_extra).into())); - }, - Err(e) => assert!(false, "Expected Ok(_). Got {:#?}", e), - } + let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok"); + // Check whether a correct amount of unused assets is returned + assert_ok!(unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into())); // Drop trader drop(trader); diff --git a/primitives/parachain-inherent/src/mock.rs b/primitives/parachain-inherent/src/mock.rs index a26ee114ef7..2ae9ed481ef 100644 --- a/primitives/parachain-inherent/src/mock.rs +++ b/primitives/parachain-inherent/src/mock.rs @@ -160,8 +160,10 @@ impl> InherentDataProvider self.relay_offset + self.relay_blocks_per_para_block * self.current_para_block; // Use the "sproof" (spoof proof) builder to build valid mock state root and proof. - let mut sproof_builder = RelayStateSproofBuilder::default(); - sproof_builder.para_id = self.xcm_config.para_id; + let mut sproof_builder = RelayStateSproofBuilder { + para_id: self.xcm_config.para_id, + ..Default::default() + }; // Process the downward messages and set up the correct head let mut downward_messages = Vec::new(); diff --git a/test/service/src/chain_spec.rs b/test/service/src/chain_spec.rs index b01804fd923..5ae77084b6c 100644 --- a/test/service/src/chain_spec.rs +++ b/test/service/src/chain_spec.rs @@ -125,7 +125,6 @@ fn testnet_genesis( code: cumulus_test_runtime::WASM_BINARY .expect("WASM binary was not build, please build it!") .to_vec(), - ..Default::default() }, parachain_system: Default::default(), balances: cumulus_test_runtime::BalancesConfig { From 7da17c182b6aa71d44df6efa164bc00dc59ae486 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 14:23:26 +0000 Subject: [PATCH 07/15] Refactor Signed-off-by: Oliver Tale-Yazdi --- pallets/parachain-system/src/lib.rs | 30 +++++++++---------- .../runtimes/assets/test-utils/src/lib.rs | 16 +++++----- .../collectives-polkadot/src/impls.rs | 7 ++--- polkadot-parachain/src/command.rs | 6 ++-- .../parachain-inherent/src/client_side.rs | 25 ++++++++-------- 5 files changed, 40 insertions(+), 44 deletions(-) diff --git a/pallets/parachain-system/src/lib.rs b/pallets/parachain-system/src/lib.rs index da5e445d99f..a2b0be76981 100644 --- a/pallets/parachain-system/src/lib.rs +++ b/pallets/parachain-system/src/lib.rs @@ -1090,22 +1090,20 @@ impl Pallet { // may change so that the message is no longer valid. // // However, changing this setting is expected to be rare. - match Self::host_configuration() { - Some(cfg) => - if message.len() > cfg.max_upward_message_size as usize { - return Err(MessageSendError::TooBig) - }, - None => { - // This storage field should carry over from the previous block. So if it's None - // then it must be that this is an edge-case where a message is attempted to be - // sent at the first block. - // - // Let's pass this message through. I think it's not unreasonable to expect that - // the message is not huge and it comes through, but if it doesn't it can be - // returned back to the sender. - // - // Thus fall through here. - }, + if let Some(cfg) = Self::host_configuration() { + if message.len() > cfg.max_upward_message_size as usize { + return Err(MessageSendError::TooBig) + } + } else { + // This storage field should carry over from the previous block. So if it's None + // then it must be that this is an edge-case where a message is attempted to be + // sent at the first block. + // + // Let's pass this message through. I think it's not unreasonable to expect that + // the message is not huge and it comes through, but if it doesn't it can be + // returned back to the sender. + // + // Thus fall through here. }; >::append(message.clone()); diff --git a/parachains/runtimes/assets/test-utils/src/lib.rs b/parachains/runtimes/assets/test-utils/src/lib.rs index 167e83f48d7..700a6f259a6 100644 --- a/parachains/runtimes/assets/test-utils/src/lib.rs +++ b/parachains/runtimes/assets/test-utils/src/lib.rs @@ -303,11 +303,9 @@ impl RuntimeHelper .find_map(|e| match e { pallet_xcm::Event::Attempted(outcome) => Some(outcome), _ => None, - }); - match outcome { - Some(outcome) => assert_outcome(outcome), - None => assert!(false, "No `pallet_xcm::Event::Attempted(outcome)` event found!"), - } + }).expect("No `pallet_xcm::Event::Attempted(outcome)` event found!"); + + assert_outcome(outcome); } } @@ -362,8 +360,11 @@ pub fn mock_open_hrmp_channel< recipient: ParaId, ) { let n = 1_u32; - let mut sproof_builder = RelayStateSproofBuilder::default(); - sproof_builder.para_id = sender; + let mut sproof_builder = RelayStateSproofBuilder { + para_id: sender, + hrmp_egress_channel_index: Some(vec![recipient]), + ..Default::default() + }; sproof_builder.hrmp_channels.insert( HrmpChannelId { sender, recipient }, AbridgedHrmpChannel { @@ -375,7 +376,6 @@ pub fn mock_open_hrmp_channel< mqc_head: None, }, ); - sproof_builder.hrmp_egress_channel_index = Some(vec![recipient]); let (relay_parent_storage_root, relay_chain_state) = sproof_builder.into_state_root_and_proof(); let vfp = PersistedValidationData { diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs b/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs index 3b2ffd58ebc..3b45d2824d9 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs @@ -73,10 +73,9 @@ where 0, ); - match result { - Err(err) => log::warn!("Failed to teleport slashed assets: {:?}", err), - _ => (), - }; + if let Err(err) = result { + log::warn!("Failed to teleport slashed assets: {:?}", err); + } } } diff --git a/polkadot-parachain/src/command.rs b/polkadot-parachain/src/command.rs index 7effcbf3cd2..32986b522ca 100644 --- a/polkadot-parachain/src/command.rs +++ b/polkadot-parachain/src/command.rs @@ -258,12 +258,10 @@ fn extract_parachain_id(id: &str) -> (&str, &str, Option) { const KUSAMA_TEST_PARA_PREFIX: &str = "penpal-kusama-"; const POLKADOT_TEST_PARA_PREFIX: &str = "penpal-polkadot-"; - let (norm_id, orig_id, para) = if id.starts_with(KUSAMA_TEST_PARA_PREFIX) { - let suffix = &id[KUSAMA_TEST_PARA_PREFIX.len()..]; + let (norm_id, orig_id, para) = if let Some(suffix) = id.strip_prefix(KUSAMA_TEST_PARA_PREFIX) { let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix"); (&id[..KUSAMA_TEST_PARA_PREFIX.len() - 1], id, Some(para_id)) - } else if id.starts_with(POLKADOT_TEST_PARA_PREFIX) { - let suffix = &id[POLKADOT_TEST_PARA_PREFIX.len()..]; + } else if let Some(suffix) = id.strip_prefix(POLKADOT_TEST_PARA_PREFIX) { let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix"); (&id[..POLKADOT_TEST_PARA_PREFIX.len() - 1], id, Some(para_id)) } else { diff --git a/primitives/parachain-inherent/src/client_side.rs b/primitives/parachain-inherent/src/client_side.rs index 6f2cd5eb504..1a1506dcbbd 100644 --- a/primitives/parachain-inherent/src/client_side.rs +++ b/primitives/parachain-inherent/src/client_side.rs @@ -92,18 +92,19 @@ async fn collect_relay_storage_proof( .ok()? .unwrap_or_default(); - let mut relevant_keys = Vec::new(); - relevant_keys.push(relay_well_known_keys::CURRENT_BLOCK_RANDOMNESS.to_vec()); - relevant_keys.push(relay_well_known_keys::ONE_EPOCH_AGO_RANDOMNESS.to_vec()); - relevant_keys.push(relay_well_known_keys::TWO_EPOCHS_AGO_RANDOMNESS.to_vec()); - relevant_keys.push(relay_well_known_keys::CURRENT_SLOT.to_vec()); - relevant_keys.push(relay_well_known_keys::ACTIVE_CONFIG.to_vec()); - relevant_keys.push(relay_well_known_keys::dmq_mqc_head(para_id)); - relevant_keys.push(relay_well_known_keys::relay_dispatch_queue_size(para_id)); - relevant_keys.push(relay_well_known_keys::hrmp_ingress_channel_index(para_id)); - relevant_keys.push(relay_well_known_keys::hrmp_egress_channel_index(para_id)); - relevant_keys.push(relay_well_known_keys::upgrade_go_ahead_signal(para_id)); - relevant_keys.push(relay_well_known_keys::upgrade_restriction_signal(para_id)); + let mut relevant_keys = vec![ + relay_well_known_keys::CURRENT_BLOCK_RANDOMNESS.to_vec(), + relay_well_known_keys::ONE_EPOCH_AGO_RANDOMNESS.to_vec(), + relay_well_known_keys::TWO_EPOCHS_AGO_RANDOMNESS.to_vec(), + relay_well_known_keys::CURRENT_SLOT.to_vec(), + relay_well_known_keys::ACTIVE_CONFIG.to_vec(), + relay_well_known_keys::dmq_mqc_head(para_id), + relay_well_known_keys::relay_dispatch_queue_size(para_id), + relay_well_known_keys::hrmp_ingress_channel_index(para_id), + relay_well_known_keys::hrmp_egress_channel_index(para_id), + relay_well_known_keys::upgrade_go_ahead_signal(para_id), + relay_well_known_keys::upgrade_restriction_signal(para_id), + ]; relevant_keys.extend(ingress_channels.into_iter().map(|sender| { relay_well_known_keys::hrmp_channels(HrmpChannelId { sender, recipient: para_id }) })); From 08f6e907cc46423d8dcb20b2a5f85178fadac881 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 14:23:34 +0000 Subject: [PATCH 08/15] fmt Signed-off-by: Oliver Tale-Yazdi --- .../src/messages_benchmarking.rs | 12 +- client/collator/src/lib.rs | 26 +- client/pov-recovery/src/lib.rs | 4 +- pallets/collator-selection/src/weights.rs | 6 +- pallets/dmp-queue/src/lib.rs | 5 +- pallets/parachain-system/src/lib.rs | 5 +- pallets/parachain-system/src/tests.rs | 10 +- .../runtimes/assets/common/src/matching.rs | 5 +- .../assets/statemine/src/weights/xcm/mod.rs | 3 +- .../assets/statemine/src/xcm_config.rs | 272 +++++++++-------- .../runtimes/assets/statemine/tests/tests.rs | 4 +- .../assets/statemint/src/weights/xcm/mod.rs | 3 +- .../assets/statemint/src/xcm_config.rs | 146 +++++---- .../runtimes/assets/statemint/tests/tests.rs | 4 +- .../runtimes/assets/test-utils/src/lib.rs | 5 +- .../assets/westmint/src/weights/xcm/mod.rs | 3 +- .../assets/westmint/src/xcm_config.rs | 277 +++++++++--------- .../runtimes/assets/westmint/tests/tests.rs | 4 +- .../bridge-hub-kusama/src/weights/xcm/mod.rs | 3 +- .../bridge-hub-kusama/src/xcm_config.rs | 39 ++- .../src/weights/xcm/mod.rs | 3 +- .../bridge-hub-polkadot/src/xcm_config.rs | 39 ++- .../bridge-hub-rococo/src/weights/xcm/mod.rs | 3 +- .../bridge-hub-rococo/src/xcm_config.rs | 59 ++-- .../collectives-polkadot/src/xcm_config.rs | 87 +++--- primitives/parachain-inherent/src/mock.rs | 6 +- primitives/utility/src/lib.rs | 8 +- 27 files changed, 499 insertions(+), 542 deletions(-) diff --git a/bridges/bin/runtime-common/src/messages_benchmarking.rs b/bridges/bin/runtime-common/src/messages_benchmarking.rs index 5982ab90963..9d90f12ed5c 100644 --- a/bridges/bin/runtime-common/src/messages_benchmarking.rs +++ b/bridges/bin/runtime-common/src/messages_benchmarking.rs @@ -182,11 +182,7 @@ where // update runtime storage let (_, bridged_header_hash) = insert_header_to_grandpa_pallet::(state_root); - FromBridgedChainMessagesDeliveryProof { - bridged_header_hash, - storage_proof, - lane, - } + FromBridgedChainMessagesDeliveryProof { bridged_header_hash, storage_proof, lane } } /// Prepare proof of messages delivery for the `receive_messages_delivery_proof` call. @@ -211,11 +207,7 @@ where let (_, bridged_header_hash) = insert_header_to_parachains_pallet::>>(state_root); - FromBridgedChainMessagesDeliveryProof { - bridged_header_hash, - storage_proof, - lane, - } + FromBridgedChainMessagesDeliveryProof { bridged_header_hash, storage_proof, lane } } /// Prepare in-memory message delivery proof, without inserting anything to the runtime storage. diff --git a/client/collator/src/lib.rs b/client/collator/src/lib.rs index d668b3b2054..9e3b4953c0a 100644 --- a/client/collator/src/lib.rs +++ b/client/collator/src/lib.rs @@ -270,16 +270,14 @@ where let (header, extrinsics) = candidate.block.deconstruct(); - let compact_proof = match candidate - .proof - .into_compact_proof::>(*last_head.state_root()) - { - Ok(proof) => proof, - Err(e) => { - tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e); - return None - }, - }; + let compact_proof = + match candidate.proof.into_compact_proof::>(*last_head.state_root()) { + Ok(proof) => proof, + Err(e) => { + tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e); + return None + }, + }; // Create the parachain block data for the validators. let b = ParachainBlockData::::new(header, extrinsics, compact_proof); @@ -451,7 +449,7 @@ mod tests { .build() .expect("Builds overseer"); - spawner.spawn("overseer", None, overseer.run().then(|_| async { }).boxed()); + spawner.spawn("overseer", None, overseer.run().then(|_| async {}).boxed()); let collator_start = start_collator(StartCollatorParams { runtime_api: client.clone(), @@ -471,10 +469,8 @@ mod tests { let CollationGenerationMessage::Initialize(config) = msg; - let validation_data = PersistedValidationData { - parent_head: header.encode().into(), - .. Default::default() - }; + let validation_data = + PersistedValidationData { parent_head: header.encode().into(), ..Default::default() }; let relay_parent = Default::default(); let collation = block_on((config.collator)(relay_parent, &validation_data)) diff --git a/client/pov-recovery/src/lib.rs b/client/pov-recovery/src/lib.rs index 0e7842cb3eb..cba798e8585 100644 --- a/client/pov-recovery/src/lib.rs +++ b/client/pov-recovery/src/lib.rs @@ -309,7 +309,9 @@ where /// Block is no longer waiting for recovery fn clear_waiting_recovery(&mut self, block_hash: &Block::Hash) { - if let Some(candidate) = self.candidates.get_mut(block_hash) { candidate.waiting_recovery = false; } + if let Some(candidate) = self.candidates.get_mut(block_hash) { + candidate.waiting_recovery = false; + } } /// Handle a finalized block with the given `block_number`. diff --git a/pallets/collator-selection/src/weights.rs b/pallets/collator-selection/src/weights.rs index 47014dfa82e..874cec8ae36 100644 --- a/pallets/collator-selection/src/weights.rs +++ b/pallets/collator-selection/src/weights.rs @@ -91,12 +91,10 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn set_desired_candidates() -> Weight { - Weight::from_parts(16_363_000_u64, 0) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + Weight::from_parts(16_363_000_u64, 0).saturating_add(RocksDbWeight::get().writes(1_u64)) } fn set_candidacy_bond() -> Weight { - Weight::from_parts(16_840_000_u64, 0) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + Weight::from_parts(16_840_000_u64, 0).saturating_add(RocksDbWeight::get().writes(1_u64)) } fn register_as_candidate(c: u32) -> Weight { Weight::from_parts(71_196_000_u64, 0) diff --git a/pallets/dmp-queue/src/lib.rs b/pallets/dmp-queue/src/lib.rs index 0f4c8c5cc6d..082fceaf14c 100644 --- a/pallets/dmp-queue/src/lib.rs +++ b/pallets/dmp-queue/src/lib.rs @@ -905,9 +905,8 @@ mod tests { enqueue(&[msg(1002), msg(1003)]); enqueue(&[msg(1004), msg(1005)]); - let incoming = (0..MAX_MESSAGES_PER_BLOCK) - .map(|i| msg(1006 + i as u64)) - .collect::>(); + let incoming = + (0..MAX_MESSAGES_PER_BLOCK).map(|i| msg(1006 + i as u64)).collect::>(); handle_messages(&incoming, Weight::from_parts(25000, 25000)); assert_eq!( diff --git a/pallets/parachain-system/src/lib.rs b/pallets/parachain-system/src/lib.rs index a2b0be76981..36ef8d57195 100644 --- a/pallets/parachain-system/src/lib.rs +++ b/pallets/parachain-system/src/lib.rs @@ -473,10 +473,7 @@ pub mod pallet { check_version: bool, ) -> DispatchResult { ensure_root(origin)?; - AuthorizedUpgrade::::put(CodeUpgradeAuthorization { - code_hash, - check_version, - }); + AuthorizedUpgrade::::put(CodeUpgradeAuthorization { code_hash, check_version }); Self::deposit_event(Event::UpgradeAuthorized { code_hash }); Ok(()) diff --git a/pallets/parachain-system/src/tests.rs b/pallets/parachain-system/src/tests.rs index 7598b106871..a4b1c275b7a 100755 --- a/pallets/parachain-system/src/tests.rs +++ b/pallets/parachain-system/src/tests.rs @@ -358,8 +358,8 @@ impl BlockTests { // did block execution set new validation code? if NewValidationCode::::exists() && self.pending_upgrade.is_some() { - panic!("attempted to set validation code while upgrade was pending"); - } + panic!("attempted to set validation code while upgrade was pending"); + } // clean up System::finalize(); @@ -413,9 +413,9 @@ fn events() { let events = System::events(); assert_eq!( events[0].event, - RuntimeEvent::ParachainSystem( - crate::Event::ValidationFunctionApplied { relay_chain_block_num: 1234 } - ) + RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionApplied { + relay_chain_block_num: 1234 + }) ); }, ); diff --git a/parachains/runtimes/assets/common/src/matching.rs b/parachains/runtimes/assets/common/src/matching.rs index 7db6a682a72..964f25cda35 100644 --- a/parachains/runtimes/assets/common/src/matching.rs +++ b/parachains/runtimes/assets/common/src/matching.rs @@ -76,9 +76,8 @@ impl> ContainsPair // here we check if sibling match a { - MultiLocation { parents: 1, interior } => - matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get()))) - , + MultiLocation { parents: 1, interior } => + matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get()))), _ => false, } } diff --git a/parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs b/parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs index 0bb10d30606..23322418d2a 100644 --- a/parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs +++ b/parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs @@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index e732817a80a..c7273942a42 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -197,148 +197,144 @@ impl Contains for SafeCallFilter { } } - matches!(call, + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Assets( + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Assets( + pallet_assets::Call::create { .. } | + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::ForeignAssets( pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::ForeignAssets( - pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::set_metadata { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::Nfts( + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::set_metadata { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::Nfts( pallet_nfts::Call::create { .. } | - pallet_nfts::Call::force_create { .. } | - pallet_nfts::Call::destroy { .. } | - pallet_nfts::Call::mint { .. } | - pallet_nfts::Call::force_mint { .. } | - pallet_nfts::Call::burn { .. } | - pallet_nfts::Call::transfer { .. } | - pallet_nfts::Call::lock_item_transfer { .. } | - pallet_nfts::Call::unlock_item_transfer { .. } | - pallet_nfts::Call::lock_collection { .. } | - pallet_nfts::Call::transfer_ownership { .. } | - pallet_nfts::Call::set_team { .. } | - pallet_nfts::Call::force_collection_owner { .. } | - pallet_nfts::Call::force_collection_config { .. } | - pallet_nfts::Call::approve_transfer { .. } | - pallet_nfts::Call::cancel_approval { .. } | - pallet_nfts::Call::clear_all_transfer_approvals { .. } | - pallet_nfts::Call::lock_item_properties { .. } | - pallet_nfts::Call::set_attribute { .. } | - pallet_nfts::Call::force_set_attribute { .. } | - pallet_nfts::Call::clear_attribute { .. } | - pallet_nfts::Call::approve_item_attributes { .. } | - pallet_nfts::Call::cancel_item_attributes_approval { .. } | - pallet_nfts::Call::set_metadata { .. } | - pallet_nfts::Call::clear_metadata { .. } | - pallet_nfts::Call::set_collection_metadata { .. } | - pallet_nfts::Call::clear_collection_metadata { .. } | - pallet_nfts::Call::set_accept_ownership { .. } | - pallet_nfts::Call::set_collection_max_supply { .. } | - pallet_nfts::Call::update_mint_settings { .. } | - pallet_nfts::Call::set_price { .. } | - pallet_nfts::Call::buy_item { .. } | - pallet_nfts::Call::pay_tips { .. } | - pallet_nfts::Call::create_swap { .. } | - pallet_nfts::Call::cancel_swap { .. } | - pallet_nfts::Call::claim_swap { .. }, - ) | - RuntimeCall::Uniques( + pallet_nfts::Call::force_create { .. } | + pallet_nfts::Call::destroy { .. } | + pallet_nfts::Call::mint { .. } | + pallet_nfts::Call::force_mint { .. } | + pallet_nfts::Call::burn { .. } | + pallet_nfts::Call::transfer { .. } | + pallet_nfts::Call::lock_item_transfer { .. } | + pallet_nfts::Call::unlock_item_transfer { .. } | + pallet_nfts::Call::lock_collection { .. } | + pallet_nfts::Call::transfer_ownership { .. } | + pallet_nfts::Call::set_team { .. } | + pallet_nfts::Call::force_collection_owner { .. } | + pallet_nfts::Call::force_collection_config { .. } | + pallet_nfts::Call::approve_transfer { .. } | + pallet_nfts::Call::cancel_approval { .. } | + pallet_nfts::Call::clear_all_transfer_approvals { .. } | + pallet_nfts::Call::lock_item_properties { .. } | + pallet_nfts::Call::set_attribute { .. } | + pallet_nfts::Call::force_set_attribute { .. } | + pallet_nfts::Call::clear_attribute { .. } | + pallet_nfts::Call::approve_item_attributes { .. } | + pallet_nfts::Call::cancel_item_attributes_approval { .. } | + pallet_nfts::Call::set_metadata { .. } | + pallet_nfts::Call::clear_metadata { .. } | + pallet_nfts::Call::set_collection_metadata { .. } | + pallet_nfts::Call::clear_collection_metadata { .. } | + pallet_nfts::Call::set_accept_ownership { .. } | + pallet_nfts::Call::set_collection_max_supply { .. } | + pallet_nfts::Call::update_mint_settings { .. } | + pallet_nfts::Call::set_price { .. } | + pallet_nfts::Call::buy_item { .. } | + pallet_nfts::Call::pay_tips { .. } | + pallet_nfts::Call::create_swap { .. } | + pallet_nfts::Call::cancel_swap { .. } | + pallet_nfts::Call::claim_swap { .. }, + ) | RuntimeCall::Uniques( pallet_uniques::Call::create { .. } | - pallet_uniques::Call::force_create { .. } | - pallet_uniques::Call::destroy { .. } | - pallet_uniques::Call::mint { .. } | - pallet_uniques::Call::burn { .. } | - pallet_uniques::Call::transfer { .. } | - pallet_uniques::Call::freeze { .. } | - pallet_uniques::Call::thaw { .. } | - pallet_uniques::Call::freeze_collection { .. } | - pallet_uniques::Call::thaw_collection { .. } | - pallet_uniques::Call::transfer_ownership { .. } | - pallet_uniques::Call::set_team { .. } | - pallet_uniques::Call::approve_transfer { .. } | - pallet_uniques::Call::cancel_approval { .. } | - pallet_uniques::Call::force_item_status { .. } | - pallet_uniques::Call::set_attribute { .. } | - pallet_uniques::Call::clear_attribute { .. } | - pallet_uniques::Call::set_metadata { .. } | - pallet_uniques::Call::clear_metadata { .. } | - pallet_uniques::Call::set_collection_metadata { .. } | - pallet_uniques::Call::clear_collection_metadata { .. } | - pallet_uniques::Call::set_accept_ownership { .. } | - pallet_uniques::Call::set_collection_max_supply { .. } | - pallet_uniques::Call::set_price { .. } | - pallet_uniques::Call::buy_item { .. } + pallet_uniques::Call::force_create { .. } | + pallet_uniques::Call::destroy { .. } | + pallet_uniques::Call::mint { .. } | + pallet_uniques::Call::burn { .. } | + pallet_uniques::Call::transfer { .. } | + pallet_uniques::Call::freeze { .. } | + pallet_uniques::Call::thaw { .. } | + pallet_uniques::Call::freeze_collection { .. } | + pallet_uniques::Call::thaw_collection { .. } | + pallet_uniques::Call::transfer_ownership { .. } | + pallet_uniques::Call::set_team { .. } | + pallet_uniques::Call::approve_transfer { .. } | + pallet_uniques::Call::cancel_approval { .. } | + pallet_uniques::Call::force_item_status { .. } | + pallet_uniques::Call::set_attribute { .. } | + pallet_uniques::Call::clear_attribute { .. } | + pallet_uniques::Call::set_metadata { .. } | + pallet_uniques::Call::clear_metadata { .. } | + pallet_uniques::Call::set_collection_metadata { .. } | + pallet_uniques::Call::clear_collection_metadata { .. } | + pallet_uniques::Call::set_accept_ownership { .. } | + pallet_uniques::Call::set_collection_max_supply { .. } | + pallet_uniques::Call::set_price { .. } | + pallet_uniques::Call::buy_item { .. } ) ) } diff --git a/parachains/runtimes/assets/statemine/tests/tests.rs b/parachains/runtimes/assets/statemine/tests/tests.rs index a328391ca54..57cd502857c 100644 --- a/parachains/runtimes/assets/statemine/tests/tests.rs +++ b/parachains/runtimes/assets/statemine/tests/tests.rs @@ -84,7 +84,9 @@ fn test_asset_xcm_trader() { // Lets buy_weight and make sure buy_weight does not return an error let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok"); // Check whether a correct amount of unused assets is returned - assert_ok!(unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into())); + assert_ok!( + unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into()) + ); // Drop trader drop(trader); diff --git a/parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs b/parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs index f2ea6d85a50..768f2b152cd 100644 --- a/parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs +++ b/parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs @@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs index ac81aaadcbb..9a426853fb7 100644 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemint/src/xcm_config.rs @@ -166,82 +166,80 @@ impl Contains for SafeCallFilter { } } - matches!(call, + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. } | - pallet_collator_selection::Call::set_invulnerables { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Assets( - pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::Uniques( + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. } | + pallet_collator_selection::Call::set_invulnerables { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Assets( + pallet_assets::Call::create { .. } | + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::Uniques( pallet_uniques::Call::create { .. } | - pallet_uniques::Call::force_create { .. } | - pallet_uniques::Call::destroy { .. } | - pallet_uniques::Call::mint { .. } | - pallet_uniques::Call::burn { .. } | - pallet_uniques::Call::transfer { .. } | - pallet_uniques::Call::freeze { .. } | - pallet_uniques::Call::thaw { .. } | - pallet_uniques::Call::freeze_collection { .. } | - pallet_uniques::Call::thaw_collection { .. } | - pallet_uniques::Call::transfer_ownership { .. } | - pallet_uniques::Call::set_team { .. } | - pallet_uniques::Call::approve_transfer { .. } | - pallet_uniques::Call::cancel_approval { .. } | - pallet_uniques::Call::force_item_status { .. } | - pallet_uniques::Call::set_attribute { .. } | - pallet_uniques::Call::clear_attribute { .. } | - pallet_uniques::Call::set_metadata { .. } | - pallet_uniques::Call::clear_metadata { .. } | - pallet_uniques::Call::set_collection_metadata { .. } | - pallet_uniques::Call::clear_collection_metadata { .. } | - pallet_uniques::Call::set_accept_ownership { .. } | - pallet_uniques::Call::set_collection_max_supply { .. } | - pallet_uniques::Call::set_price { .. } | - pallet_uniques::Call::buy_item { .. }, + pallet_uniques::Call::force_create { .. } | + pallet_uniques::Call::destroy { .. } | + pallet_uniques::Call::mint { .. } | + pallet_uniques::Call::burn { .. } | + pallet_uniques::Call::transfer { .. } | + pallet_uniques::Call::freeze { .. } | + pallet_uniques::Call::thaw { .. } | + pallet_uniques::Call::freeze_collection { .. } | + pallet_uniques::Call::thaw_collection { .. } | + pallet_uniques::Call::transfer_ownership { .. } | + pallet_uniques::Call::set_team { .. } | + pallet_uniques::Call::approve_transfer { .. } | + pallet_uniques::Call::cancel_approval { .. } | + pallet_uniques::Call::force_item_status { .. } | + pallet_uniques::Call::set_attribute { .. } | + pallet_uniques::Call::clear_attribute { .. } | + pallet_uniques::Call::set_metadata { .. } | + pallet_uniques::Call::clear_metadata { .. } | + pallet_uniques::Call::set_collection_metadata { .. } | + pallet_uniques::Call::clear_collection_metadata { .. } | + pallet_uniques::Call::set_accept_ownership { .. } | + pallet_uniques::Call::set_collection_max_supply { .. } | + pallet_uniques::Call::set_price { .. } | + pallet_uniques::Call::buy_item { .. }, ) ) } diff --git a/parachains/runtimes/assets/statemint/tests/tests.rs b/parachains/runtimes/assets/statemint/tests/tests.rs index 067799f46f4..87242682b15 100644 --- a/parachains/runtimes/assets/statemint/tests/tests.rs +++ b/parachains/runtimes/assets/statemint/tests/tests.rs @@ -87,7 +87,9 @@ fn test_asset_xcm_trader() { // Lets buy_weight and make sure buy_weight does not return an error let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok"); // Check whether a correct amount of unused assets is returned - assert_ok!(unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into())); + assert_ok!( + unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into()) + ); // Drop trader drop(trader); diff --git a/parachains/runtimes/assets/test-utils/src/lib.rs b/parachains/runtimes/assets/test-utils/src/lib.rs index 700a6f259a6..4a67e661322 100644 --- a/parachains/runtimes/assets/test-utils/src/lib.rs +++ b/parachains/runtimes/assets/test-utils/src/lib.rs @@ -303,8 +303,9 @@ impl RuntimeHelper .find_map(|e| match e { pallet_xcm::Event::Attempted(outcome) => Some(outcome), _ => None, - }).expect("No `pallet_xcm::Event::Attempted(outcome)` event found!"); - + }) + .expect("No `pallet_xcm::Event::Attempted(outcome)` event found!"); + assert_outcome(outcome); } } diff --git a/parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs b/parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs index a49b8a1c578..8247f75d5dd 100644 --- a/parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs +++ b/parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs @@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index 0e8926a4f2c..051ea565c8f 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -191,152 +191,147 @@ impl Contains for SafeCallFilter { } } - matches!(call, + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility( - pallet_utility::Call::as_derivative { .. } | - pallet_utility::Call::batch { .. } | - pallet_utility::Call::batch_all { .. }, - ) | - RuntimeCall::Assets( + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility( + pallet_utility::Call::as_derivative { .. } | + pallet_utility::Call::batch { .. } | + pallet_utility::Call::batch_all { .. }, + ) | RuntimeCall::Assets( pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::ForeignAssets( + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::ForeignAssets( pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::set_metadata { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::Nfts( + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::set_metadata { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::Nfts( pallet_nfts::Call::create { .. } | - pallet_nfts::Call::force_create { .. } | - pallet_nfts::Call::destroy { .. } | - pallet_nfts::Call::mint { .. } | - pallet_nfts::Call::force_mint { .. } | - pallet_nfts::Call::burn { .. } | - pallet_nfts::Call::transfer { .. } | - pallet_nfts::Call::lock_item_transfer { .. } | - pallet_nfts::Call::unlock_item_transfer { .. } | - pallet_nfts::Call::lock_collection { .. } | - pallet_nfts::Call::transfer_ownership { .. } | - pallet_nfts::Call::set_team { .. } | - pallet_nfts::Call::force_collection_owner { .. } | - pallet_nfts::Call::force_collection_config { .. } | - pallet_nfts::Call::approve_transfer { .. } | - pallet_nfts::Call::cancel_approval { .. } | - pallet_nfts::Call::clear_all_transfer_approvals { .. } | - pallet_nfts::Call::lock_item_properties { .. } | - pallet_nfts::Call::set_attribute { .. } | - pallet_nfts::Call::force_set_attribute { .. } | - pallet_nfts::Call::clear_attribute { .. } | - pallet_nfts::Call::approve_item_attributes { .. } | - pallet_nfts::Call::cancel_item_attributes_approval { .. } | - pallet_nfts::Call::set_metadata { .. } | - pallet_nfts::Call::clear_metadata { .. } | - pallet_nfts::Call::set_collection_metadata { .. } | - pallet_nfts::Call::clear_collection_metadata { .. } | - pallet_nfts::Call::set_accept_ownership { .. } | - pallet_nfts::Call::set_collection_max_supply { .. } | - pallet_nfts::Call::update_mint_settings { .. } | - pallet_nfts::Call::set_price { .. } | - pallet_nfts::Call::buy_item { .. } | - pallet_nfts::Call::pay_tips { .. } | - pallet_nfts::Call::create_swap { .. } | - pallet_nfts::Call::cancel_swap { .. } | - pallet_nfts::Call::claim_swap { .. }, - ) | - RuntimeCall::Uniques( + pallet_nfts::Call::force_create { .. } | + pallet_nfts::Call::destroy { .. } | + pallet_nfts::Call::mint { .. } | + pallet_nfts::Call::force_mint { .. } | + pallet_nfts::Call::burn { .. } | + pallet_nfts::Call::transfer { .. } | + pallet_nfts::Call::lock_item_transfer { .. } | + pallet_nfts::Call::unlock_item_transfer { .. } | + pallet_nfts::Call::lock_collection { .. } | + pallet_nfts::Call::transfer_ownership { .. } | + pallet_nfts::Call::set_team { .. } | + pallet_nfts::Call::force_collection_owner { .. } | + pallet_nfts::Call::force_collection_config { .. } | + pallet_nfts::Call::approve_transfer { .. } | + pallet_nfts::Call::cancel_approval { .. } | + pallet_nfts::Call::clear_all_transfer_approvals { .. } | + pallet_nfts::Call::lock_item_properties { .. } | + pallet_nfts::Call::set_attribute { .. } | + pallet_nfts::Call::force_set_attribute { .. } | + pallet_nfts::Call::clear_attribute { .. } | + pallet_nfts::Call::approve_item_attributes { .. } | + pallet_nfts::Call::cancel_item_attributes_approval { .. } | + pallet_nfts::Call::set_metadata { .. } | + pallet_nfts::Call::clear_metadata { .. } | + pallet_nfts::Call::set_collection_metadata { .. } | + pallet_nfts::Call::clear_collection_metadata { .. } | + pallet_nfts::Call::set_accept_ownership { .. } | + pallet_nfts::Call::set_collection_max_supply { .. } | + pallet_nfts::Call::update_mint_settings { .. } | + pallet_nfts::Call::set_price { .. } | + pallet_nfts::Call::buy_item { .. } | + pallet_nfts::Call::pay_tips { .. } | + pallet_nfts::Call::create_swap { .. } | + pallet_nfts::Call::cancel_swap { .. } | + pallet_nfts::Call::claim_swap { .. }, + ) | RuntimeCall::Uniques( pallet_uniques::Call::create { .. } | - pallet_uniques::Call::force_create { .. } | - pallet_uniques::Call::destroy { .. } | - pallet_uniques::Call::mint { .. } | - pallet_uniques::Call::burn { .. } | - pallet_uniques::Call::transfer { .. } | - pallet_uniques::Call::freeze { .. } | - pallet_uniques::Call::thaw { .. } | - pallet_uniques::Call::freeze_collection { .. } | - pallet_uniques::Call::thaw_collection { .. } | - pallet_uniques::Call::transfer_ownership { .. } | - pallet_uniques::Call::set_team { .. } | - pallet_uniques::Call::approve_transfer { .. } | - pallet_uniques::Call::cancel_approval { .. } | - pallet_uniques::Call::force_item_status { .. } | - pallet_uniques::Call::set_attribute { .. } | - pallet_uniques::Call::clear_attribute { .. } | - pallet_uniques::Call::set_metadata { .. } | - pallet_uniques::Call::clear_metadata { .. } | - pallet_uniques::Call::set_collection_metadata { .. } | - pallet_uniques::Call::clear_collection_metadata { .. } | - pallet_uniques::Call::set_accept_ownership { .. } | - pallet_uniques::Call::set_collection_max_supply { .. } | - pallet_uniques::Call::set_price { .. } | - pallet_uniques::Call::buy_item { .. }, + pallet_uniques::Call::force_create { .. } | + pallet_uniques::Call::destroy { .. } | + pallet_uniques::Call::mint { .. } | + pallet_uniques::Call::burn { .. } | + pallet_uniques::Call::transfer { .. } | + pallet_uniques::Call::freeze { .. } | + pallet_uniques::Call::thaw { .. } | + pallet_uniques::Call::freeze_collection { .. } | + pallet_uniques::Call::thaw_collection { .. } | + pallet_uniques::Call::transfer_ownership { .. } | + pallet_uniques::Call::set_team { .. } | + pallet_uniques::Call::approve_transfer { .. } | + pallet_uniques::Call::cancel_approval { .. } | + pallet_uniques::Call::force_item_status { .. } | + pallet_uniques::Call::set_attribute { .. } | + pallet_uniques::Call::clear_attribute { .. } | + pallet_uniques::Call::set_metadata { .. } | + pallet_uniques::Call::clear_metadata { .. } | + pallet_uniques::Call::set_collection_metadata { .. } | + pallet_uniques::Call::clear_collection_metadata { .. } | + pallet_uniques::Call::set_accept_ownership { .. } | + pallet_uniques::Call::set_collection_max_supply { .. } | + pallet_uniques::Call::set_price { .. } | + pallet_uniques::Call::buy_item { .. }, ) ) } diff --git a/parachains/runtimes/assets/westmint/tests/tests.rs b/parachains/runtimes/assets/westmint/tests/tests.rs index 5c274f7bb51..740edc0c20b 100644 --- a/parachains/runtimes/assets/westmint/tests/tests.rs +++ b/parachains/runtimes/assets/westmint/tests/tests.rs @@ -91,7 +91,9 @@ fn test_asset_xcm_trader() { // Lets buy_weight and make sure buy_weight does not return an error let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok"); // Check whether a correct amount of unused assets is returned - assert_ok!(unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into())); + assert_ok!( + unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into()) + ); // Drop trader drop(trader); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs index c8a1748be63..9d11b07e54e 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs @@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index b3f292fdc3b..615ae9cf05c 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -129,27 +129,26 @@ impl Contains for SafeCallFilter { } } - matches!(call, + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) ) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs index 6e58e2d6bfa..27bdb510ba0 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs @@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index cc7a81f0858..0a206edfefe 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -132,27 +132,26 @@ impl Contains for SafeCallFilter { } } - matches!(call, + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) ) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index 8a63a4453e7..9efbef18363 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -34,8 +34,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 59c64290710..c4430bfd92c 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -152,39 +152,34 @@ impl Contains for SafeCallFilter { } } - matches!(call, + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::< - Runtime, - BridgeGrandpaRococoInstance, - >::initialize { - .. - }) | - RuntimeCall::BridgeWococoGrandpa(pallet_bridge_grandpa::Call::< - Runtime, - BridgeGrandpaWococoInstance, - >::initialize { - .. - }) + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::< + Runtime, + BridgeGrandpaRococoInstance, + >::initialize { .. }) | + RuntimeCall::BridgeWococoGrandpa(pallet_bridge_grandpa::Call::< + Runtime, + BridgeGrandpaWococoInstance, + >::initialize { .. }) ) } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index d398a17008c..55629b2e43b 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -137,55 +137,52 @@ impl Contains for SafeCallFilter { } } - matches!(call, + matches!( + call, RuntimeCall::System( frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Alliance( - // `init_members` accepts unbounded vecs as arguments, - // but the call can be initiated only by root origin. - pallet_alliance::Call::init_members { .. } | - pallet_alliance::Call::vote { .. } | - pallet_alliance::Call::disband { .. } | - pallet_alliance::Call::set_rule { .. } | - pallet_alliance::Call::announce { .. } | - pallet_alliance::Call::remove_announcement { .. } | - pallet_alliance::Call::join_alliance { .. } | - pallet_alliance::Call::nominate_ally { .. } | - pallet_alliance::Call::elevate_ally { .. } | - pallet_alliance::Call::give_retirement_notice { .. } | - pallet_alliance::Call::retire { .. } | - pallet_alliance::Call::kick_member { .. } | - pallet_alliance::Call::close { .. } | - pallet_alliance::Call::abdicate_fellow_status { .. }, - ) | - RuntimeCall::AllianceMotion( + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Alliance( + // `init_members` accepts unbounded vecs as arguments, + // but the call can be initiated only by root origin. + pallet_alliance::Call::init_members { .. } | + pallet_alliance::Call::vote { .. } | + pallet_alliance::Call::disband { .. } | + pallet_alliance::Call::set_rule { .. } | + pallet_alliance::Call::announce { .. } | + pallet_alliance::Call::remove_announcement { .. } | + pallet_alliance::Call::join_alliance { .. } | + pallet_alliance::Call::nominate_ally { .. } | + pallet_alliance::Call::elevate_ally { .. } | + pallet_alliance::Call::give_retirement_notice { .. } | + pallet_alliance::Call::retire { .. } | + pallet_alliance::Call::kick_member { .. } | + pallet_alliance::Call::close { .. } | + pallet_alliance::Call::abdicate_fellow_status { .. }, + ) | RuntimeCall::AllianceMotion( pallet_collective::Call::vote { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::FellowshipCollective( + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | RuntimeCall::FellowshipCollective( pallet_ranked_collective::Call::add_member { .. } | - pallet_ranked_collective::Call::promote_member { .. } | - pallet_ranked_collective::Call::demote_member { .. } | - pallet_ranked_collective::Call::remove_member { .. }, + pallet_ranked_collective::Call::promote_member { .. } | + pallet_ranked_collective::Call::demote_member { .. } | + pallet_ranked_collective::Call::remove_member { .. }, ) ) } diff --git a/primitives/parachain-inherent/src/mock.rs b/primitives/parachain-inherent/src/mock.rs index 2ae9ed481ef..00dff40800f 100644 --- a/primitives/parachain-inherent/src/mock.rs +++ b/primitives/parachain-inherent/src/mock.rs @@ -160,10 +160,8 @@ impl> InherentDataProvider self.relay_offset + self.relay_blocks_per_para_block * self.current_para_block; // Use the "sproof" (spoof proof) builder to build valid mock state root and proof. - let mut sproof_builder = RelayStateSproofBuilder { - para_id: self.xcm_config.para_id, - ..Default::default() - }; + let mut sproof_builder = + RelayStateSproofBuilder { para_id: self.xcm_config.para_id, ..Default::default() }; // Process the downward messages and set up the correct head let mut downward_messages = Vec::new(); diff --git a/primitives/utility/src/lib.rs b/primitives/utility/src/lib.rs index 7d0e8a51edc..e71eab178a8 100644 --- a/primitives/utility/src/lib.rs +++ b/primitives/utility/src/lib.rs @@ -233,8 +233,7 @@ impl< let asset_balance: u128 = asset_balance.saturated_into(); // Construct outstanding_concrete_asset with the same location id and substracted balance - let outstanding_concrete_asset: MultiAsset = - (id, outstanding_minus_substracted).into(); + let outstanding_concrete_asset: MultiAsset = (id, outstanding_minus_substracted).into(); // Substract from existing weight and balance weight_outstanding = weight_outstanding.saturating_sub(weight); @@ -536,9 +535,6 @@ mod tests { assert_ok!(trader.buy_weight(weight_to_buy, payment.clone())); // lets do second call (error) - assert_eq!( - trader.buy_weight(weight_to_buy, payment), - Err(XcmError::NotWithdrawable) - ); + assert_eq!(trader.buy_weight(weight_to_buy, payment), Err(XcmError::NotWithdrawable)); } } From fedab5a7f0203dca70d56e5538b4a5bc8be85ecc Mon Sep 17 00:00:00 2001 From: alvicsam Date: Thu, 4 May 2023 16:30:46 +0200 Subject: [PATCH 09/15] add clippy to ci --- scripts/ci/gitlab/pipeline/test.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index 0ef51ae2e6d..a67c15eec6b 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -97,3 +97,11 @@ cargo-check-benches: artifacts: false script: - time cargo check --all --benches + +cargo-clippy: + stage: test + extends: + - .docker-env + - .common-refs + script: + - SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo clippy --locked --all-targets From a4507e31665a311a197f4cc7a27b3bbe085adc28 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 17:00:09 +0200 Subject: [PATCH 10/15] Clippy reborrow Signed-off-by: Oliver Tale-Yazdi --- client/consensus/common/src/parachain_consensus.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/consensus/common/src/parachain_consensus.rs b/client/consensus/common/src/parachain_consensus.rs index b46c042f1ba..78f4e45cd81 100644 --- a/client/consensus/common/src/parachain_consensus.rs +++ b/client/consensus/common/src/parachain_consensus.rs @@ -432,8 +432,11 @@ async fn handle_new_best_parachain_head( } } -async fn import_block_as_new_best(hash: Block::Hash, header: Block::Header, parachain: &P) -where +async fn import_block_as_new_best( + hash: Block::Hash, + header: Block::Header, + mut parachain: &P, +) where Block: BlockT, P: UsageProvider + Send + Sync + BlockBackend, for<'a> &'a P: BlockImport, @@ -455,7 +458,7 @@ where block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(true)); block_import_params.import_existing = true; - if let Err(err) = (&*parachain).import_block(block_import_params).await { + if let Err(err) = parachain.import_block(block_import_params).await { tracing::warn!( target: LOG_TARGET, block_hash = ?hash, From 1b2f2dad956cdbc5531ebad378d288b9a0f476b7 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 17:14:06 +0200 Subject: [PATCH 11/15] Update client/pov-recovery/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- client/pov-recovery/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/client/pov-recovery/src/lib.rs b/client/pov-recovery/src/lib.rs index cba798e8585..e55289d5a36 100644 --- a/client/pov-recovery/src/lib.rs +++ b/client/pov-recovery/src/lib.rs @@ -310,6 +310,7 @@ where /// Block is no longer waiting for recovery fn clear_waiting_recovery(&mut self, block_hash: &Block::Hash) { if let Some(candidate) = self.candidates.get_mut(block_hash) { + // Prevents triggering an already enqueued recovery request candidate.waiting_recovery = false; } } From c37803865a7a88e390d781a70c3554490175b8bc Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 17:14:14 +0200 Subject: [PATCH 12/15] Update client/pov-recovery/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- client/pov-recovery/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/pov-recovery/src/lib.rs b/client/pov-recovery/src/lib.rs index e55289d5a36..62f31b6c061 100644 --- a/client/pov-recovery/src/lib.rs +++ b/client/pov-recovery/src/lib.rs @@ -190,7 +190,7 @@ impl RecoveryQueue { /// Get the next hash for block recovery. pub async fn next_recovery(&mut self) -> Block::Hash { loop { - if (self.signaling_queue.next().await).is_some() { + if self.signaling_queue.next().await.is_some() { if let Some(hash) = self.recovery_queue.pop_front() { return hash } else { From 774399b57cfacc55fa08f7159a98fa770f3ba7b2 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 18:28:06 +0200 Subject: [PATCH 13/15] Partially revert 'Prefer matches' Using matches! instead of match does give less compiler checks as per review from @chevdor. Partially reverts 8c0609677f3ea040f77fffd5be6facf7c3fec95c Signed-off-by: Oliver Tale-Yazdi --- .../assets/statemine/src/xcm_config.rs | 277 +++++++++--------- .../bridge-hub-kusama/src/xcm_config.rs | 42 +-- .../bridge-hub-rococo/src/xcm_config.rs | 62 ++-- .../collectives-polkadot/src/xcm_config.rs | 92 +++--- 4 files changed, 245 insertions(+), 228 deletions(-) diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index c7273942a42..45f95ee07d4 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -197,146 +197,151 @@ impl Contains for SafeCallFilter { } } - matches!( - call, + match call { RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Assets( - pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | RuntimeCall::ForeignAssets( + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | + RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Assets( pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::set_metadata { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | RuntimeCall::Nfts( + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | + RuntimeCall::ForeignAssets( + pallet_assets::Call::create { .. } | + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::set_metadata { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | + RuntimeCall::Nfts( pallet_nfts::Call::create { .. } | - pallet_nfts::Call::force_create { .. } | - pallet_nfts::Call::destroy { .. } | - pallet_nfts::Call::mint { .. } | - pallet_nfts::Call::force_mint { .. } | - pallet_nfts::Call::burn { .. } | - pallet_nfts::Call::transfer { .. } | - pallet_nfts::Call::lock_item_transfer { .. } | - pallet_nfts::Call::unlock_item_transfer { .. } | - pallet_nfts::Call::lock_collection { .. } | - pallet_nfts::Call::transfer_ownership { .. } | - pallet_nfts::Call::set_team { .. } | - pallet_nfts::Call::force_collection_owner { .. } | - pallet_nfts::Call::force_collection_config { .. } | - pallet_nfts::Call::approve_transfer { .. } | - pallet_nfts::Call::cancel_approval { .. } | - pallet_nfts::Call::clear_all_transfer_approvals { .. } | - pallet_nfts::Call::lock_item_properties { .. } | - pallet_nfts::Call::set_attribute { .. } | - pallet_nfts::Call::force_set_attribute { .. } | - pallet_nfts::Call::clear_attribute { .. } | - pallet_nfts::Call::approve_item_attributes { .. } | - pallet_nfts::Call::cancel_item_attributes_approval { .. } | - pallet_nfts::Call::set_metadata { .. } | - pallet_nfts::Call::clear_metadata { .. } | - pallet_nfts::Call::set_collection_metadata { .. } | - pallet_nfts::Call::clear_collection_metadata { .. } | - pallet_nfts::Call::set_accept_ownership { .. } | - pallet_nfts::Call::set_collection_max_supply { .. } | - pallet_nfts::Call::update_mint_settings { .. } | - pallet_nfts::Call::set_price { .. } | - pallet_nfts::Call::buy_item { .. } | - pallet_nfts::Call::pay_tips { .. } | - pallet_nfts::Call::create_swap { .. } | - pallet_nfts::Call::cancel_swap { .. } | - pallet_nfts::Call::claim_swap { .. }, - ) | RuntimeCall::Uniques( + pallet_nfts::Call::force_create { .. } | + pallet_nfts::Call::destroy { .. } | + pallet_nfts::Call::mint { .. } | + pallet_nfts::Call::force_mint { .. } | + pallet_nfts::Call::burn { .. } | + pallet_nfts::Call::transfer { .. } | + pallet_nfts::Call::lock_item_transfer { .. } | + pallet_nfts::Call::unlock_item_transfer { .. } | + pallet_nfts::Call::lock_collection { .. } | + pallet_nfts::Call::transfer_ownership { .. } | + pallet_nfts::Call::set_team { .. } | + pallet_nfts::Call::force_collection_owner { .. } | + pallet_nfts::Call::force_collection_config { .. } | + pallet_nfts::Call::approve_transfer { .. } | + pallet_nfts::Call::cancel_approval { .. } | + pallet_nfts::Call::clear_all_transfer_approvals { .. } | + pallet_nfts::Call::lock_item_properties { .. } | + pallet_nfts::Call::set_attribute { .. } | + pallet_nfts::Call::force_set_attribute { .. } | + pallet_nfts::Call::clear_attribute { .. } | + pallet_nfts::Call::approve_item_attributes { .. } | + pallet_nfts::Call::cancel_item_attributes_approval { .. } | + pallet_nfts::Call::set_metadata { .. } | + pallet_nfts::Call::clear_metadata { .. } | + pallet_nfts::Call::set_collection_metadata { .. } | + pallet_nfts::Call::clear_collection_metadata { .. } | + pallet_nfts::Call::set_accept_ownership { .. } | + pallet_nfts::Call::set_collection_max_supply { .. } | + pallet_nfts::Call::update_mint_settings { .. } | + pallet_nfts::Call::set_price { .. } | + pallet_nfts::Call::buy_item { .. } | + pallet_nfts::Call::pay_tips { .. } | + pallet_nfts::Call::create_swap { .. } | + pallet_nfts::Call::cancel_swap { .. } | + pallet_nfts::Call::claim_swap { .. }, + ) | + RuntimeCall::Uniques( pallet_uniques::Call::create { .. } | - pallet_uniques::Call::force_create { .. } | - pallet_uniques::Call::destroy { .. } | - pallet_uniques::Call::mint { .. } | - pallet_uniques::Call::burn { .. } | - pallet_uniques::Call::transfer { .. } | - pallet_uniques::Call::freeze { .. } | - pallet_uniques::Call::thaw { .. } | - pallet_uniques::Call::freeze_collection { .. } | - pallet_uniques::Call::thaw_collection { .. } | - pallet_uniques::Call::transfer_ownership { .. } | - pallet_uniques::Call::set_team { .. } | - pallet_uniques::Call::approve_transfer { .. } | - pallet_uniques::Call::cancel_approval { .. } | - pallet_uniques::Call::force_item_status { .. } | - pallet_uniques::Call::set_attribute { .. } | - pallet_uniques::Call::clear_attribute { .. } | - pallet_uniques::Call::set_metadata { .. } | - pallet_uniques::Call::clear_metadata { .. } | - pallet_uniques::Call::set_collection_metadata { .. } | - pallet_uniques::Call::clear_collection_metadata { .. } | - pallet_uniques::Call::set_accept_ownership { .. } | - pallet_uniques::Call::set_collection_max_supply { .. } | - pallet_uniques::Call::set_price { .. } | - pallet_uniques::Call::buy_item { .. } - ) - ) + pallet_uniques::Call::force_create { .. } | + pallet_uniques::Call::destroy { .. } | + pallet_uniques::Call::mint { .. } | + pallet_uniques::Call::burn { .. } | + pallet_uniques::Call::transfer { .. } | + pallet_uniques::Call::freeze { .. } | + pallet_uniques::Call::thaw { .. } | + pallet_uniques::Call::freeze_collection { .. } | + pallet_uniques::Call::thaw_collection { .. } | + pallet_uniques::Call::transfer_ownership { .. } | + pallet_uniques::Call::set_team { .. } | + pallet_uniques::Call::approve_transfer { .. } | + pallet_uniques::Call::cancel_approval { .. } | + pallet_uniques::Call::force_item_status { .. } | + pallet_uniques::Call::set_attribute { .. } | + pallet_uniques::Call::clear_attribute { .. } | + pallet_uniques::Call::set_metadata { .. } | + pallet_uniques::Call::clear_metadata { .. } | + pallet_uniques::Call::set_collection_metadata { .. } | + pallet_uniques::Call::clear_collection_metadata { .. } | + pallet_uniques::Call::set_accept_ownership { .. } | + pallet_uniques::Call::set_collection_max_supply { .. } | + pallet_uniques::Call::set_price { .. } | + pallet_uniques::Call::buy_item { .. }, + ) => true, + _ => false, + } } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 615ae9cf05c..7b395a4d4e3 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -129,27 +129,29 @@ impl Contains for SafeCallFilter { } } - matches!( - call, + match call { RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) - ) + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | + RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true, + _ => false, + } } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index c4430bfd92c..91fd15136bb 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -152,35 +152,41 @@ impl Contains for SafeCallFilter { } } - matches!( - call, + match call { RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::< - Runtime, - BridgeGrandpaRococoInstance, - >::initialize { .. }) | - RuntimeCall::BridgeWococoGrandpa(pallet_bridge_grandpa::Call::< - Runtime, - BridgeGrandpaWococoInstance, - >::initialize { .. }) - ) + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | + RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::< + Runtime, + BridgeGrandpaRococoInstance, + >::initialize { + .. + }) | + RuntimeCall::BridgeWococoGrandpa(pallet_bridge_grandpa::Call::< + Runtime, + BridgeGrandpaWococoInstance, + >::initialize { + .. + }) => true, + _ => false, + } } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index 55629b2e43b..b2b93d88ffe 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -137,54 +137,58 @@ impl Contains for SafeCallFilter { } } - matches!( - call, + match call { RuntimeCall::System( frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Alliance( - // `init_members` accepts unbounded vecs as arguments, - // but the call can be initiated only by root origin. - pallet_alliance::Call::init_members { .. } | - pallet_alliance::Call::vote { .. } | - pallet_alliance::Call::disband { .. } | - pallet_alliance::Call::set_rule { .. } | - pallet_alliance::Call::announce { .. } | - pallet_alliance::Call::remove_announcement { .. } | - pallet_alliance::Call::join_alliance { .. } | - pallet_alliance::Call::nominate_ally { .. } | - pallet_alliance::Call::elevate_ally { .. } | - pallet_alliance::Call::give_retirement_notice { .. } | - pallet_alliance::Call::retire { .. } | - pallet_alliance::Call::kick_member { .. } | - pallet_alliance::Call::close { .. } | - pallet_alliance::Call::abdicate_fellow_status { .. }, - ) | RuntimeCall::AllianceMotion( + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | + RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | + RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Alliance( + // `init_members` accepts unbounded vecs as arguments, + // but the call can be initiated only by root origin. + pallet_alliance::Call::init_members { .. } | + pallet_alliance::Call::vote { .. } | + pallet_alliance::Call::disband { .. } | + pallet_alliance::Call::set_rule { .. } | + pallet_alliance::Call::announce { .. } | + pallet_alliance::Call::remove_announcement { .. } | + pallet_alliance::Call::join_alliance { .. } | + pallet_alliance::Call::nominate_ally { .. } | + pallet_alliance::Call::elevate_ally { .. } | + pallet_alliance::Call::give_retirement_notice { .. } | + pallet_alliance::Call::retire { .. } | + pallet_alliance::Call::kick_member { .. } | + pallet_alliance::Call::close { .. } | + pallet_alliance::Call::abdicate_fellow_status { .. }, + ) | + RuntimeCall::AllianceMotion( pallet_collective::Call::vote { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | RuntimeCall::FellowshipCollective( + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | + RuntimeCall::FellowshipCollective( pallet_ranked_collective::Call::add_member { .. } | - pallet_ranked_collective::Call::promote_member { .. } | - pallet_ranked_collective::Call::demote_member { .. } | - pallet_ranked_collective::Call::remove_member { .. }, - ) - ) + pallet_ranked_collective::Call::promote_member { .. } | + pallet_ranked_collective::Call::demote_member { .. } | + pallet_ranked_collective::Call::remove_member { .. }, + ) => true, + _ => false, + } } } From cda5cb0c2e55898279185baa6df2afc0d7fc14cb Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 18:42:01 +0200 Subject: [PATCH 14/15] Update .cargo/config.toml Co-authored-by: Chevdor --- .cargo/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 6cb38ecbc63..66b28b3485d 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -29,4 +29,4 @@ rustflags = [ "-Aclippy::needless_option_as_deref", # false positives "-Aclippy::derivable_impls", # false positives "-Aclippy::stable_sort_primitive", # prefer stable sort -] \ No newline at end of file +] From 7dee28853d3d1f0ddb3c37af21cd5b64e18b9afb Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 4 May 2023 23:11:08 +0200 Subject: [PATCH 15/15] =?UTF-8?q?Revert=20revert=20=F0=9F=92=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Should be fine to use matches! macro since it is an explicit whitelist, not wildcard matching. --- .../assets/statemine/src/xcm_config.rs | 277 +++++++++--------- .../bridge-hub-kusama/src/xcm_config.rs | 42 ++- .../bridge-hub-rococo/src/xcm_config.rs | 62 ++-- .../collectives-polkadot/src/xcm_config.rs | 92 +++--- 4 files changed, 228 insertions(+), 245 deletions(-) diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index 45f95ee07d4..c7273942a42 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -197,151 +197,146 @@ impl Contains for SafeCallFilter { } } - match call { + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Assets( + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Assets( + pallet_assets::Call::create { .. } | + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::ForeignAssets( pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::ForeignAssets( - pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::set_metadata { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::Nfts( + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::set_metadata { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::Nfts( pallet_nfts::Call::create { .. } | - pallet_nfts::Call::force_create { .. } | - pallet_nfts::Call::destroy { .. } | - pallet_nfts::Call::mint { .. } | - pallet_nfts::Call::force_mint { .. } | - pallet_nfts::Call::burn { .. } | - pallet_nfts::Call::transfer { .. } | - pallet_nfts::Call::lock_item_transfer { .. } | - pallet_nfts::Call::unlock_item_transfer { .. } | - pallet_nfts::Call::lock_collection { .. } | - pallet_nfts::Call::transfer_ownership { .. } | - pallet_nfts::Call::set_team { .. } | - pallet_nfts::Call::force_collection_owner { .. } | - pallet_nfts::Call::force_collection_config { .. } | - pallet_nfts::Call::approve_transfer { .. } | - pallet_nfts::Call::cancel_approval { .. } | - pallet_nfts::Call::clear_all_transfer_approvals { .. } | - pallet_nfts::Call::lock_item_properties { .. } | - pallet_nfts::Call::set_attribute { .. } | - pallet_nfts::Call::force_set_attribute { .. } | - pallet_nfts::Call::clear_attribute { .. } | - pallet_nfts::Call::approve_item_attributes { .. } | - pallet_nfts::Call::cancel_item_attributes_approval { .. } | - pallet_nfts::Call::set_metadata { .. } | - pallet_nfts::Call::clear_metadata { .. } | - pallet_nfts::Call::set_collection_metadata { .. } | - pallet_nfts::Call::clear_collection_metadata { .. } | - pallet_nfts::Call::set_accept_ownership { .. } | - pallet_nfts::Call::set_collection_max_supply { .. } | - pallet_nfts::Call::update_mint_settings { .. } | - pallet_nfts::Call::set_price { .. } | - pallet_nfts::Call::buy_item { .. } | - pallet_nfts::Call::pay_tips { .. } | - pallet_nfts::Call::create_swap { .. } | - pallet_nfts::Call::cancel_swap { .. } | - pallet_nfts::Call::claim_swap { .. }, - ) | - RuntimeCall::Uniques( + pallet_nfts::Call::force_create { .. } | + pallet_nfts::Call::destroy { .. } | + pallet_nfts::Call::mint { .. } | + pallet_nfts::Call::force_mint { .. } | + pallet_nfts::Call::burn { .. } | + pallet_nfts::Call::transfer { .. } | + pallet_nfts::Call::lock_item_transfer { .. } | + pallet_nfts::Call::unlock_item_transfer { .. } | + pallet_nfts::Call::lock_collection { .. } | + pallet_nfts::Call::transfer_ownership { .. } | + pallet_nfts::Call::set_team { .. } | + pallet_nfts::Call::force_collection_owner { .. } | + pallet_nfts::Call::force_collection_config { .. } | + pallet_nfts::Call::approve_transfer { .. } | + pallet_nfts::Call::cancel_approval { .. } | + pallet_nfts::Call::clear_all_transfer_approvals { .. } | + pallet_nfts::Call::lock_item_properties { .. } | + pallet_nfts::Call::set_attribute { .. } | + pallet_nfts::Call::force_set_attribute { .. } | + pallet_nfts::Call::clear_attribute { .. } | + pallet_nfts::Call::approve_item_attributes { .. } | + pallet_nfts::Call::cancel_item_attributes_approval { .. } | + pallet_nfts::Call::set_metadata { .. } | + pallet_nfts::Call::clear_metadata { .. } | + pallet_nfts::Call::set_collection_metadata { .. } | + pallet_nfts::Call::clear_collection_metadata { .. } | + pallet_nfts::Call::set_accept_ownership { .. } | + pallet_nfts::Call::set_collection_max_supply { .. } | + pallet_nfts::Call::update_mint_settings { .. } | + pallet_nfts::Call::set_price { .. } | + pallet_nfts::Call::buy_item { .. } | + pallet_nfts::Call::pay_tips { .. } | + pallet_nfts::Call::create_swap { .. } | + pallet_nfts::Call::cancel_swap { .. } | + pallet_nfts::Call::claim_swap { .. }, + ) | RuntimeCall::Uniques( pallet_uniques::Call::create { .. } | - pallet_uniques::Call::force_create { .. } | - pallet_uniques::Call::destroy { .. } | - pallet_uniques::Call::mint { .. } | - pallet_uniques::Call::burn { .. } | - pallet_uniques::Call::transfer { .. } | - pallet_uniques::Call::freeze { .. } | - pallet_uniques::Call::thaw { .. } | - pallet_uniques::Call::freeze_collection { .. } | - pallet_uniques::Call::thaw_collection { .. } | - pallet_uniques::Call::transfer_ownership { .. } | - pallet_uniques::Call::set_team { .. } | - pallet_uniques::Call::approve_transfer { .. } | - pallet_uniques::Call::cancel_approval { .. } | - pallet_uniques::Call::force_item_status { .. } | - pallet_uniques::Call::set_attribute { .. } | - pallet_uniques::Call::clear_attribute { .. } | - pallet_uniques::Call::set_metadata { .. } | - pallet_uniques::Call::clear_metadata { .. } | - pallet_uniques::Call::set_collection_metadata { .. } | - pallet_uniques::Call::clear_collection_metadata { .. } | - pallet_uniques::Call::set_accept_ownership { .. } | - pallet_uniques::Call::set_collection_max_supply { .. } | - pallet_uniques::Call::set_price { .. } | - pallet_uniques::Call::buy_item { .. }, - ) => true, - _ => false, - } + pallet_uniques::Call::force_create { .. } | + pallet_uniques::Call::destroy { .. } | + pallet_uniques::Call::mint { .. } | + pallet_uniques::Call::burn { .. } | + pallet_uniques::Call::transfer { .. } | + pallet_uniques::Call::freeze { .. } | + pallet_uniques::Call::thaw { .. } | + pallet_uniques::Call::freeze_collection { .. } | + pallet_uniques::Call::thaw_collection { .. } | + pallet_uniques::Call::transfer_ownership { .. } | + pallet_uniques::Call::set_team { .. } | + pallet_uniques::Call::approve_transfer { .. } | + pallet_uniques::Call::cancel_approval { .. } | + pallet_uniques::Call::force_item_status { .. } | + pallet_uniques::Call::set_attribute { .. } | + pallet_uniques::Call::clear_attribute { .. } | + pallet_uniques::Call::set_metadata { .. } | + pallet_uniques::Call::clear_metadata { .. } | + pallet_uniques::Call::set_collection_metadata { .. } | + pallet_uniques::Call::clear_collection_metadata { .. } | + pallet_uniques::Call::set_accept_ownership { .. } | + pallet_uniques::Call::set_collection_max_supply { .. } | + pallet_uniques::Call::set_price { .. } | + pallet_uniques::Call::buy_item { .. } + ) + ) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 7b395a4d4e3..615ae9cf05c 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -129,29 +129,27 @@ impl Contains for SafeCallFilter { } } - match call { + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true, - _ => false, - } + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) + ) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 91fd15136bb..c4430bfd92c 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -152,41 +152,35 @@ impl Contains for SafeCallFilter { } } - match call { + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::< - Runtime, - BridgeGrandpaRococoInstance, - >::initialize { - .. - }) | - RuntimeCall::BridgeWococoGrandpa(pallet_bridge_grandpa::Call::< - Runtime, - BridgeGrandpaWococoInstance, - >::initialize { - .. - }) => true, - _ => false, - } + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::< + Runtime, + BridgeGrandpaRococoInstance, + >::initialize { .. }) | + RuntimeCall::BridgeWococoGrandpa(pallet_bridge_grandpa::Call::< + Runtime, + BridgeGrandpaWococoInstance, + >::initialize { .. }) + ) } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index b2b93d88ffe..55629b2e43b 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -137,58 +137,54 @@ impl Contains for SafeCallFilter { } } - match call { + matches!( + call, RuntimeCall::System( frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Alliance( - // `init_members` accepts unbounded vecs as arguments, - // but the call can be initiated only by root origin. - pallet_alliance::Call::init_members { .. } | - pallet_alliance::Call::vote { .. } | - pallet_alliance::Call::disband { .. } | - pallet_alliance::Call::set_rule { .. } | - pallet_alliance::Call::announce { .. } | - pallet_alliance::Call::remove_announcement { .. } | - pallet_alliance::Call::join_alliance { .. } | - pallet_alliance::Call::nominate_ally { .. } | - pallet_alliance::Call::elevate_ally { .. } | - pallet_alliance::Call::give_retirement_notice { .. } | - pallet_alliance::Call::retire { .. } | - pallet_alliance::Call::kick_member { .. } | - pallet_alliance::Call::close { .. } | - pallet_alliance::Call::abdicate_fellow_status { .. }, - ) | - RuntimeCall::AllianceMotion( + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::DmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Alliance( + // `init_members` accepts unbounded vecs as arguments, + // but the call can be initiated only by root origin. + pallet_alliance::Call::init_members { .. } | + pallet_alliance::Call::vote { .. } | + pallet_alliance::Call::disband { .. } | + pallet_alliance::Call::set_rule { .. } | + pallet_alliance::Call::announce { .. } | + pallet_alliance::Call::remove_announcement { .. } | + pallet_alliance::Call::join_alliance { .. } | + pallet_alliance::Call::nominate_ally { .. } | + pallet_alliance::Call::elevate_ally { .. } | + pallet_alliance::Call::give_retirement_notice { .. } | + pallet_alliance::Call::retire { .. } | + pallet_alliance::Call::kick_member { .. } | + pallet_alliance::Call::close { .. } | + pallet_alliance::Call::abdicate_fellow_status { .. }, + ) | RuntimeCall::AllianceMotion( pallet_collective::Call::vote { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::FellowshipCollective( + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | RuntimeCall::FellowshipCollective( pallet_ranked_collective::Call::add_member { .. } | - pallet_ranked_collective::Call::promote_member { .. } | - pallet_ranked_collective::Call::demote_member { .. } | - pallet_ranked_collective::Call::remove_member { .. }, - ) => true, - _ => false, - } + pallet_ranked_collective::Call::promote_member { .. } | + pallet_ranked_collective::Call::demote_member { .. } | + pallet_ranked_collective::Call::remove_member { .. }, + ) + ) } }