From f04418f1f2abe98d63fed19ddf623243a7feb975 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Mon, 22 Aug 2022 16:37:41 +0200 Subject: [PATCH 1/5] [WIP][ci] add auto cargo-fmt --- .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 78a189fbce5..9b07006a413 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,6 +69,11 @@ variables: - if: $CI_COMMIT_REF_NAME =~ /^release-parachains-v[0-9].*$/ # i.e. release-parachains-v1.0, release-parachains-v2.1rc1, release-parachains-v3000 - if: $CI_COMMIT_REF_NAME =~ /^polkadot-v[0-9]+\.[0-9]+.*$/ # i.e. polkadot-v1.0.99, polkadot-v2.1rc1 +.pr-refs: &pr-refs + # these jobs run always* + rules: + - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs + .publish-refs: &publish-refs rules: - if: $CI_COMMIT_REF_NAME == "master" @@ -107,6 +112,21 @@ variables: tags: - kubernetes-parity-build +#### stage: .pre + +cargo-fmt: + stage: .pre + <<: *pr-refs + <<: *kubernetes-env + before_script: + - echo PROJECT_NAME=$CI_PROJECT_NAME > fmt.env + - echo PR_BRANCH_NAME=$(curl -s https://api.github.com/repos/paritytech/${CI_PROJECT_NAME}/pulls/${CI_COMMIT_REF_NAME} | jq -r ".head.ref") >> fmt.env + script: + - cargo fmt --check + artifacts: + reports: + dotenv: fmt.env + #### stage: test test-linux-stable: @@ -601,3 +621,17 @@ cancel-pipeline: project: "parity/infrastructure/ci_cd/pipeline-stopper" # remove branch, when pipeline-stopper for substrate and polakdot is updated to the same branch branch: "as-improve" + +# this job will automatically format code and rerun pipeline if cargo-fmt job fails +auto-fmt: + stage: .post + rules: + - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs + when: on_failure + needs: + - job: cargo-fmt + variables: + PROJECT_NAME: "${CI_PROJECT_NAME}" + PR_BRANCH_NAME: "${PR_BRANCH_NAME}" + trigger: + project: "parity/infrastructure/ci_cd/auto-fmt" From 438abec70d8eb419302b5ee56550db3528379a13 Mon Sep 17 00:00:00 2001 From: paritytech-ci Date: Mon, 22 Aug 2022 14:39:02 +0000 Subject: [PATCH 2/5] [ci] Apply cargo-fmt --- client/cli/src/lib.rs | 2 +- client/collator/src/lib.rs | 8 +- .../common/src/parachain_consensus.rs | 16 +- client/consensus/common/src/tests.rs | 10 +- client/consensus/relay-chain/src/lib.rs | 2 +- client/network/src/lib.rs | 25 ++-- .../src/active_candidate_recovery.rs | 2 +- client/pov-recovery/src/lib.rs | 27 ++-- .../src/lib.rs | 2 +- client/relay-chain-rpc-interface/src/lib.rs | 2 +- client/service/src/lib.rs | 2 +- pallets/dmp-queue/src/lib.rs | 9 +- .../parachain-system/proc-macro/src/lib.rs | 9 +- pallets/parachain-system/src/lib.rs | 19 +-- .../src/relay_state_snapshot.rs | 2 +- .../src/validate_block/implementation.rs | 5 +- pallets/xcmp-queue/src/lib.rs | 72 ++++----- pallets/xcmp-queue/src/mock.rs | 4 +- parachain-template/node/src/command.rs | 10 +- parachain-template/runtime/src/xcm_config.rs | 10 +- parachains/common/src/impls.rs | 4 +- parachains/common/src/xcm_config.rs | 10 +- .../runtimes/assets/statemine/src/lib.rs | 80 +++++----- .../runtimes/assets/statemint/src/lib.rs | 80 +++++----- .../runtimes/assets/westmint/src/lib.rs | 80 +++++----- .../collectives-polkadot/src/lib.rs | 12 +- .../runtimes/testing/penpal/src/xcm_config.rs | 16 +- polkadot-parachain/src/command.rs | 140 +++++++++++------- polkadot-parachain/tests/common.rs | 2 +- primitives/timestamp/src/lib.rs | 4 +- primitives/utility/src/lib.rs | 2 +- .../relay-validation-worker-provider/build.rs | 4 +- test/service/src/lib.rs | 2 +- test/service/tests/runtime_upgrade.rs | 2 +- 34 files changed, 365 insertions(+), 311 deletions(-) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 9fea382a7ee..b6126f604aa 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -96,7 +96,7 @@ impl PurgeChainCmd { Some('y') | Some('Y') => {}, _ => { println!("Aborted"); - return Ok(()) + return Ok(()); }, } } diff --git a/client/collator/src/lib.rs b/client/collator/src/lib.rs index 80650ff72e1..af321625724 100644 --- a/client/collator/src/lib.rs +++ b/client/collator/src/lib.rs @@ -164,7 +164,7 @@ where target: LOG_TARGET, "Could not fetch `CollectCollationInfo` runtime api version." ); - return Ok(None) + return Ok(None); }, }; @@ -228,13 +228,13 @@ where error = ?e, "Could not decode the head data." ); - return None + return None; }, }; let last_head_hash = last_head.hash(); if !self.check_block_status(last_head_hash, &last_head) { - return None + return None; } tracing::info!( @@ -258,7 +258,7 @@ where Ok(proof) => proof, Err(e) => { tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e); - return None + return None; }, }; diff --git a/client/consensus/common/src/parachain_consensus.rs b/client/consensus/common/src/parachain_consensus.rs index ccdfb17b671..77d6c53be1e 100644 --- a/client/consensus/common/src/parachain_consensus.rs +++ b/client/consensus/common/src/parachain_consensus.rs @@ -74,7 +74,7 @@ where Ok(finalized_heads_stream) => finalized_heads_stream, Err(err) => { tracing::error!(target: LOG_TARGET, error = ?err, "Unable to retrieve finalized heads stream."); - return + return; }, }; @@ -83,7 +83,7 @@ where h } else { tracing::debug!(target: "cumulus-consensus", "Stopping following finalized head."); - return + return; }; let header = match Block::Header::decode(&mut &finalized_head[..]) { @@ -94,7 +94,7 @@ where error = ?err, "Could not decode parachain header while following finalized heads.", ); - continue + continue; }, }; @@ -179,7 +179,7 @@ async fn follow_new_best( Ok(best_heads_stream) => best_heads_stream.fuse(), Err(err) => { tracing::error!(target: LOG_TARGET, error = ?err, "Unable to retrieve best heads stream."); - return + return; }, }; @@ -253,12 +253,12 @@ async fn handle_new_block_imported( }; let unset_hash = if notification.header.number() < unset_best_header.number() { - return + return; } else if notification.header.number() == unset_best_header.number() { let unset_hash = unset_best_header.hash(); if unset_hash != notification.hash { - return + return; } else { unset_hash } @@ -303,7 +303,7 @@ async fn handle_new_best_parachain_head( error = ?err, "Could not decode Parachain header while following best heads.", ); - return + return; }, }; @@ -367,7 +367,7 @@ where "Skipping importing block as new best block, because there already exists a \ best block with an higher number", ); - return + return; } // Make it the new best block diff --git a/client/consensus/common/src/tests.rs b/client/consensus/common/src/tests.rs index 23729abebb4..f20cde0e5e1 100644 --- a/client/consensus/common/src/tests.rs +++ b/client/consensus/common/src/tests.rs @@ -136,7 +136,7 @@ fn follow_new_best_works() { loop { Delay::new(Duration::from_millis(100)).await; if block.hash() == client.usage_info().chain.best_hash { - break + break; } } }; @@ -170,7 +170,7 @@ fn follow_finalized_works() { loop { Delay::new(Duration::from_millis(100)).await; if block.hash() == client.usage_info().chain.finalized_hash { - break + break; } } }; @@ -217,7 +217,7 @@ fn follow_finalized_does_not_stop_on_unknown_block() { loop { Delay::new(Duration::from_millis(100)).await; if block.hash() == client.usage_info().chain.finalized_hash { - break + break; } } }; @@ -262,7 +262,7 @@ fn follow_new_best_sets_best_after_it_is_imported() { loop { Delay::new(Duration::from_millis(100)).await; if block.hash() == client.usage_info().chain.best_hash { - break + break; } } @@ -287,7 +287,7 @@ fn follow_new_best_sets_best_after_it_is_imported() { loop { Delay::new(Duration::from_millis(100)).await; if unknown_block.hash() == client.usage_info().chain.best_hash { - break + break; } } }; diff --git a/client/consensus/relay-chain/src/lib.rs b/client/consensus/relay-chain/src/lib.rs index 20d3b7cc757..c089e4a9849 100644 --- a/client/consensus/relay-chain/src/lib.rs +++ b/client/consensus/relay-chain/src/lib.rs @@ -210,7 +210,7 @@ where "Error importing build block.", ); - return None + return None; } Some(ParachainCandidate { block, proof }) diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs index 7e906da1b1d..fd0e15e6a2f 100644 --- a/client/network/src/lib.rs +++ b/client/network/src/lib.rs @@ -96,7 +96,7 @@ impl BlockAnnounceData { h } else { tracing::debug!(target: LOG_TARGET, "`CompactStatement` isn't the candidate variant!",); - return Err(Validation::Failure { disconnect: true }) + return Err(Validation::Failure { disconnect: true }); }; if *candidate_hash != self.receipt.hash() { @@ -104,7 +104,7 @@ impl BlockAnnounceData { target: LOG_TARGET, "Receipt candidate hash doesn't match candidate hash in statement", ); - return Err(Validation::Failure { disconnect: true }) + return Err(Validation::Failure { disconnect: true }); } if HeadData(encoded_header).hash() != self.receipt.descriptor.para_head { @@ -112,7 +112,7 @@ impl BlockAnnounceData { target: LOG_TARGET, "Receipt para head hash doesn't match the hash of the header in the block announcement", ); - return Err(Validation::Failure { disconnect: true }) + return Err(Validation::Failure { disconnect: true }); } Ok(()) @@ -151,7 +151,7 @@ impl BlockAnnounceData { "Block announcement justification signer is a validator index out of bound", ); - return Ok(Validation::Failure { disconnect: true }) + return Ok(Validation::Failure { disconnect: true }); }, }; @@ -162,7 +162,7 @@ impl BlockAnnounceData { "Block announcement justification signature is invalid.", ); - return Ok(Validation::Failure { disconnect: true }) + return Ok(Validation::Failure { disconnect: true }); } Ok(Validation::Success { is_new_best: true }) @@ -176,7 +176,7 @@ impl TryFrom<&'_ CollationSecondedSignal> for BlockAnnounceData { let receipt = if let Statement::Seconded(receipt) = signal.statement.payload() { receipt.to_plain() } else { - return Err(()) + return Err(()); }; Ok(BlockAnnounceData { @@ -341,24 +341,25 @@ where .unwrap_or(false); if relay_chain_is_syncing { - return Ok(Validation::Success { is_new_best: false }) + return Ok(Validation::Success { is_new_best: false }); } if data.is_empty() { - return block_announce_validator.handle_empty_block_announce_data(header).await + return block_announce_validator.handle_empty_block_announce_data(header).await; } let block_announce_data = match BlockAnnounceData::decode_all(&mut data.as_slice()) { Ok(r) => r, - Err(err) => + Err(err) => { return Err(Box::new(BlockAnnounceError(format!( "Can not decode the `BlockAnnounceData`: {:?}", err - ))) as Box<_>), + ))) as Box<_>) + }, }; if let Err(e) = block_announce_data.validate(header_encoded) { - return Ok(e) + return Ok(e); } let relay_parent = block_announce_data.receipt.descriptor.relay_parent; @@ -439,7 +440,7 @@ async fn wait_to_announce( block = ?block_hash, "Wait to announce stopped, because sender was dropped.", ); - return + return; }, }; diff --git a/client/pov-recovery/src/active_candidate_recovery.rs b/client/pov-recovery/src/active_candidate_recovery.rs index a269a26f821..466931c02e8 100644 --- a/client/pov-recovery/src/active_candidate_recovery.rs +++ b/client/pov-recovery/src/active_candidate_recovery.rs @@ -102,7 +102,7 @@ impl ActiveCandidateRecovery { loop { if let Some(res) = self.recoveries.next().await { self.candidates.remove(&res.0); - return res + return res; } else { futures::pending!() } diff --git a/client/pov-recovery/src/lib.rs b/client/pov-recovery/src/lib.rs index aeff69d56c5..394542f11c9 100644 --- a/client/pov-recovery/src/lib.rs +++ b/client/pov-recovery/src/lib.rs @@ -96,8 +96,9 @@ impl RecoveryDelay { fn as_delay(self) -> Delay { match self { Self::WithMax { max } => Delay::new(max.mul_f64(thread_rng().gen())), - Self::WithMinAndMax { min, max } => - Delay::new(min + max.saturating_sub(min).mul_f64(thread_rng().gen())), + Self::WithMinAndMax { min, max } => { + Delay::new(min + max.saturating_sub(min).mul_f64(thread_rng().gen())) + }, } } } @@ -166,12 +167,12 @@ where error = ?e, "Failed to decode parachain header from pending candidate", ); - return + return; }, }; if *header.number() <= self.parachain_client.usage_info().chain.finalized_number { - return + return; } let hash = header.hash(); @@ -186,7 +187,7 @@ where block_hash = ?hash, "Failed to get block status", ); - return + return; }, } @@ -202,7 +203,7 @@ where ) .is_some() { - return + return; } // Delay the recovery by some random time to not spam the relay chain. @@ -260,7 +261,7 @@ where Some(data) => data, None => { self.clear_waiting_for_parent(block_hash); - return + return; }, }; @@ -274,7 +275,7 @@ where self.clear_waiting_for_parent(block_hash); - return + return; }, }; @@ -289,7 +290,7 @@ where self.clear_waiting_for_parent(block_hash); - return + return; }, }; @@ -308,7 +309,7 @@ where ); self.waiting_for_parent.entry(parent).or_default().push(block); - return + return; } else { tracing::debug!( target: "cumulus-consensus", @@ -319,7 +320,7 @@ where self.clear_waiting_for_parent(block_hash); - return + return; } }, Err(error) => { @@ -332,7 +333,7 @@ where self.clear_waiting_for_parent(block_hash); - return + return; }, // Any other status is fine to "ignore/accept" _ => (), @@ -385,7 +386,7 @@ where Ok(pending_candidate_stream) => pending_candidate_stream.fuse(), Err(err) => { tracing::error!(target: LOG_TARGET, error = ?err, "Unable to retrieve pending candidate stream."); - return + return; }, }; diff --git a/client/relay-chain-inprocess-interface/src/lib.rs b/client/relay-chain-inprocess-interface/src/lib.rs index d713ab9cf38..e168651a2aa 100644 --- a/client/relay-chain-inprocess-interface/src/lib.rs +++ b/client/relay-chain-inprocess-interface/src/lib.rs @@ -270,7 +270,7 @@ where let block_id = BlockId::Hash(hash); if backend.blockchain().status(block_id)? == BlockStatus::InChain { - return Ok(BlockCheckStatus::InChain) + return Ok(BlockCheckStatus::InChain); } let listener = client.import_notification_stream(); diff --git a/client/relay-chain-rpc-interface/src/lib.rs b/client/relay-chain-rpc-interface/src/lib.rs index f295c693ecd..6f2ab73da6d 100644 --- a/client/relay-chain-rpc-interface/src/lib.rs +++ b/client/relay-chain-rpc-interface/src/lib.rs @@ -170,7 +170,7 @@ impl RelayChainInterface for RelayChainRpcInterface { let mut head_stream = self.rpc_client.get_imported_heads_stream().await?; if self.rpc_client.chain_get_header(Some(wait_for_hash)).await?.is_some() { - return Ok(()) + return Ok(()); } let mut timeout = futures_timer::Delay::new(Duration::from_secs(TIMEOUT_IN_SECONDS)).fuse(); diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 5ca73a530a3..0152cc5cfbe 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -199,7 +199,7 @@ where // relay chain if blocks are not announced on parachain. This will be enabled again once // /~https://github.com/paritytech/cumulus/issues/545 is finished. if collator_options.relay_chain_rpc_url.is_some() { - return Ok(()) + return Ok(()); } let overseer_handle = relay_chain_interface diff --git a/pallets/dmp-queue/src/lib.rs b/pallets/dmp-queue/src/lib.rs index a811bf54054..748c6e95b76 100644 --- a/pallets/dmp-queue/src/lib.rs +++ b/pallets/dmp-queue/src/lib.rs @@ -199,7 +199,7 @@ pub mod pallet { Err(..) => { // Too much weight needed - put the remaining messages back and bail Pages::::insert(page_index.begin_used, &page[i..]); - return used + return used; }, } } @@ -241,8 +241,9 @@ pub mod pallet { Ok(Ok(x)) => { let outcome = T::XcmExecutor::execute_xcm(Parent, x, limit); match outcome { - Outcome::Error(XcmError::WeightLimitReached(required)) => - Err((message_id, required)), + Outcome::Error(XcmError::WeightLimitReached(required)) => { + Err((message_id, required)) + }, outcome => { let weight_used = outcome.weight_used(); Self::deposit_event(Event::ExecutedDownward { message_id, outcome }); @@ -300,7 +301,7 @@ pub mod pallet { page_index.overweight_count += 1; // Not needed for control flow, but only to ensure that the compiler // understands that we won't attempt to re-use `data` later. - continue + continue; } else { // not overweight. stop executing inline and enqueue normally // from here on. diff --git a/pallets/parachain-system/proc-macro/src/lib.rs b/pallets/parachain-system/proc-macro/src/lib.rs index 855d7fed484..3168ee1fe78 100644 --- a/pallets/parachain-system/proc-macro/src/lib.rs +++ b/pallets/parachain-system/proc-macro/src/lib.rs @@ -69,13 +69,13 @@ impl Parse for Input { } else if lookahead.peek(keywords::CheckInherents) { parse_inner::(input, &mut check_inherents)?; } else { - return Err(lookahead.error()) + return Err(lookahead.error()); } } let rest = input.parse::()?; if !rest.is_empty() { - return Err(Error::new(rest.span(), "Unexpected input data")) + return Err(Error::new(rest.span(), "Unexpected input data")); } Ok(Self { @@ -88,8 +88,9 @@ impl Parse for Input { fn crate_() -> Result { match crate_name("cumulus-pallet-parachain-system") { - Ok(FoundCrate::Itself) => - Ok(syn::Ident::new("cumulus_pallet_parachain_system", Span::call_site())), + Ok(FoundCrate::Itself) => { + Ok(syn::Ident::new("cumulus_pallet_parachain_system", Span::call_site())) + }, Ok(FoundCrate::Name(name)) => Ok(Ident::new(&name, Span::call_site())), Err(e) => Err(Error::new(Span::call_site(), e)), } diff --git a/pallets/parachain-system/src/lib.rs b/pallets/parachain-system/src/lib.rs index b9056d5dcad..30683d55ded 100644 --- a/pallets/parachain-system/src/lib.rs +++ b/pallets/parachain-system/src/lib.rs @@ -200,7 +200,7 @@ pub mod pallet { false, "host configuration is promised to set until `on_finalize`; qed", ); - return + return; }, }; let relevant_messaging_state = match Self::relevant_messaging_state() { @@ -211,7 +211,7 @@ pub mod pallet { "relevant messaging state is promised to be set until `on_finalize`; \ qed", ); - return + return; }, }; @@ -693,11 +693,11 @@ pub mod pallet { provides: vec![hash.as_ref().to_vec()], longevity: TransactionLongevity::max_value(), propagate: true, - }) + }); } } if let Call::set_validation_data { .. } = call { - return Ok(Default::default()) + return Ok(Default::default()); } Err(InvalidTransaction::Call.into()) } @@ -732,7 +732,7 @@ impl GetChannelInfo for Pallet { let channels = match Self::relevant_messaging_state() { None => { log::warn!("calling `get_channel_status` with no RelevantMessagingState?!"); - return ChannelStatus::Closed + return ChannelStatus::Closed; }, Some(d) => d.egress_channels, }; @@ -749,7 +749,7 @@ impl GetChannelInfo for Pallet { let meta = &channels[index].1; if meta.msg_count + 1 > meta.max_capacity { // The channel is at its capacity. Skip it for now. - return ChannelStatus::Full + return ChannelStatus::Full; } let max_size_now = meta.max_total_size - meta.total_size; let max_size_ever = meta.max_message_size; @@ -1043,10 +1043,11 @@ impl Pallet { // // However, changing this setting is expected to be rare. match Self::host_configuration() { - Some(cfg) => + Some(cfg) => { if message.len() > cfg.max_upward_message_size as usize { - return Err(MessageSendError::TooBig) - }, + 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 diff --git a/pallets/parachain-system/src/relay_state_snapshot.rs b/pallets/parachain-system/src/relay_state_snapshot.rs index 5b6a1ad3df9..cd925ca09a0 100644 --- a/pallets/parachain-system/src/relay_state_snapshot.rs +++ b/pallets/parachain-system/src/relay_state_snapshot.rs @@ -154,7 +154,7 @@ impl RelayChainStateProof { ) -> Result { let db = proof.into_memory_db::>(); if !db.contains(&relay_parent_storage_root, EMPTY_PREFIX) { - return Err(Error::RootMismatch) + return Err(Error::RootMismatch); } let trie_backend = TrieBackendBuilder::new(db, relay_parent_storage_root).build(); diff --git a/pallets/parachain-system/src/validate_block/implementation.rs b/pallets/parachain-system/src/validate_block/implementation.rs index f37622688de..2429ddec7c1 100644 --- a/pallets/parachain-system/src/validate_block/implementation.rs +++ b/pallets/parachain-system/src/validate_block/implementation.rs @@ -120,8 +120,9 @@ where .iter() .filter_map(|e| e.call().is_sub_type()) .find_map(|c| match c { - crate::Call::set_validation_data { data: validation_data } => - Some(validation_data.clone()), + crate::Call::set_validation_data { data: validation_data } => { + Some(validation_data.clone()) + }, _ => None, }) .expect("Could not find `set_validation_data` inherent"); diff --git a/pallets/xcmp-queue/src/lib.rs b/pallets/xcmp-queue/src/lib.rs index 2b1bdac2b8b..bf0cacea828 100644 --- a/pallets/xcmp-queue/src/lib.rs +++ b/pallets/xcmp-queue/src/lib.rs @@ -496,7 +496,7 @@ impl Pallet { let max_message_size = T::ChannelInfo::get_channel_max(recipient).ok_or(MessageSendError::NoChannel)?; if data.len() > max_message_size { - return Err(MessageSendError::TooBig) + return Err(MessageSendError::TooBig); } let mut s = >::get(); @@ -507,18 +507,18 @@ impl Pallet { s.last_mut().expect("can't be empty; a new element was just pushed; qed") }; let have_active = details.last_index > details.first_index; - let appended = have_active && - >::mutate(recipient, details.last_index - 1, |s| { - if XcmpMessageFormat::decode_with_depth_limit(MAX_XCM_DECODE_DEPTH, &mut &s[..]) != - Ok(format) + let appended = have_active + && >::mutate(recipient, details.last_index - 1, |s| { + if XcmpMessageFormat::decode_with_depth_limit(MAX_XCM_DECODE_DEPTH, &mut &s[..]) + != Ok(format) { - return false + return false; } if s.len() + data.len() > max_message_size { - return false + return false; } s.extend_from_slice(&data[..]); - return true + return true; }); if appended { Ok((details.last_index - details.first_index - 1) as u32) @@ -606,18 +606,22 @@ impl Pallet { let location = (1, Parachain(sender.into())); match T::XcmExecutor::execute_xcm(location, xcm, max_weight) { - Outcome::Error(e) => - (Err(e), Event::Fail { message_hash: Some(hash), error: e, weight: 0 }), - Outcome::Complete(w) => - (Ok(w), Event::Success { message_hash: Some(hash), weight: w }), + Outcome::Error(e) => { + (Err(e), Event::Fail { message_hash: Some(hash), error: e, weight: 0 }) + }, + Outcome::Complete(w) => { + (Ok(w), Event::Success { message_hash: Some(hash), weight: w }) + }, // As far as the caller is concerned, this was dispatched without error, so // we just report the weight used. - Outcome::Incomplete(w, e) => - (Ok(w), Event::Fail { message_hash: Some(hash), error: e, weight: w }), + Outcome::Incomplete(w, e) => { + (Ok(w), Event::Fail { message_hash: Some(hash), error: e, weight: w }) + }, } }, - Err(()) => - (Err(XcmError::UnhandledXcmVersion), Event::BadVersion { message_hash: Some(hash) }), + Err(()) => { + (Err(XcmError::UnhandledXcmVersion), Event::BadVersion { message_hash: Some(hash) }) + }, }; Self::deposit_event(event); result @@ -664,7 +668,7 @@ impl Pallet { // That message didn't get processed this time because of being // too heavy. We leave it around for next time and bail. remaining_fragments = last_remaining_fragments; - break + break; }, Err(error) => { log::error!( @@ -692,7 +696,7 @@ impl Pallet { // That message didn't get processed this time because of being // too heavy. We leave it around for next time and bail. remaining_fragments = last_remaining_fragments; - break + break; }, Err(false) => { // Message invalid; don't attempt to retry @@ -766,7 +770,7 @@ impl Pallet { let mut status = >::get(); // <- sorted. if status.is_empty() { - return 0 + return 0; } let QueueConfigData { @@ -790,8 +794,8 @@ impl Pallet { // send more, heavier messages. let mut shuffle_index = 0; - while shuffle_index < shuffled.len() && - max_weight.saturating_sub(weight_used) >= threshold_weight + while shuffle_index < shuffled.len() + && max_weight.saturating_sub(weight_used) >= threshold_weight { let index = shuffled[shuffle_index]; let sender = status[index].sender; @@ -804,7 +808,7 @@ impl Pallet { if suspended && !is_controller { shuffle_index += 1; - continue + continue; } if weight_available != max_weight { @@ -841,8 +845,8 @@ impl Pallet { }; weight_used += weight_processed; - if status[index].message_metadata.len() as u32 <= resume_threshold && - status[index].state == InboundState::Suspended + if status[index].message_metadata.len() as u32 <= resume_threshold + && status[index].state == InboundState::Suspended { // Resume let r = Self::send_signal(sender, ChannelSignal::Resume); @@ -853,12 +857,12 @@ impl Pallet { // If there are more and we're making progress, we process them after we've given the // other channels a look in. If we've still not unlocked all weight, then we set them // up for processing a second time anyway. - if !status[index].message_metadata.is_empty() && - (weight_processed > 0 || weight_available != max_weight) + if !status[index].message_metadata.is_empty() + && (weight_processed > 0 || weight_available != max_weight) { if shuffle_index + 1 == shuffled.len() { // Only this queue left. Just run around this loop once more. - continue + continue; } shuffled.push(index); } @@ -923,7 +927,7 @@ impl XcmpMessageHandler for Pallet { Ok(f) => f, Err(_) => { debug_assert!(false, "Unknown XCMP message format. Silently dropping message"); - continue + continue; }, }; if format == XcmpMessageFormat::Signals { @@ -998,10 +1002,10 @@ impl XcmpMessageSource for Pallet { if result.len() == max_message_count { // We check this condition in the beginning of the loop so that we don't include // a message where the limit is 0. - break + break; } if outbound_state == OutboundState::Suspended { - continue + continue; } let (max_size_now, max_size_ever) = match T::ChannelInfo::get_channel_status(para_id) { ChannelStatus::Closed => { @@ -1014,7 +1018,7 @@ impl XcmpMessageSource for Pallet { >::remove(para_id); } *status = OutboundChannelDetails::new(para_id); - continue + continue; }, ChannelStatus::Full => continue, ChannelStatus::Ready(n, e) => (n, e), @@ -1027,7 +1031,7 @@ impl XcmpMessageSource for Pallet { signals_exist = false; page } else { - continue + continue; } } else if last_index > first_index { let page = >::get(para_id, first_index); @@ -1036,10 +1040,10 @@ impl XcmpMessageSource for Pallet { first_index += 1; page } else { - continue + continue; } } else { - continue + continue; }; if first_index == last_index { first_index = 0; diff --git a/pallets/xcmp-queue/src/mock.rs b/pallets/xcmp-queue/src/mock.rs index 60aff179b82..538a27a81e8 100644 --- a/pallets/xcmp-queue/src/mock.rs +++ b/pallets/xcmp-queue/src/mock.rs @@ -167,8 +167,8 @@ impl ConvertOrigin for SystemParachainAsSuperuser Result { let origin = origin.into(); - if kind == OriginKind::Superuser && - matches!( + if kind == OriginKind::Superuser + && matches!( origin, MultiLocation { parents: 1, diff --git a/parachain-template/node/src/command.rs b/parachain-template/node/src/command.rs index 735af3e42ab..b8994f09cb9 100644 --- a/parachain-template/node/src/command.rs +++ b/parachain-template/node/src/command.rs @@ -202,14 +202,15 @@ pub fn run() -> Result<()> { let runner = cli.create_runner(cmd)?; // Switch on the concrete benchmark sub-command- match cmd { - BenchmarkCmd::Pallet(cmd) => + BenchmarkCmd::Pallet(cmd) => { if cfg!(feature = "runtime-benchmarks") { runner.sync_run(|config| cmd.run::(config)) } else { Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." .into()) - }, + } + }, BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { let partials = new_partial::( &config, @@ -227,8 +228,9 @@ pub fn run() -> Result<()> { cmd.run(config, partials.client.clone(), db, storage) }), - BenchmarkCmd::Machine(cmd) => - runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), + BenchmarkCmd::Machine(cmd) => { + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) + }, // NOTE: this allows the Client to leniently implement // new benchmark commands without requiring a companion MR. #[allow(unreachable_patterns)] diff --git a/parachain-template/runtime/src/xcm_config.rs b/parachain-template/runtime/src/xcm_config.rs index 2ec84d18871..1ab9c27f9cc 100644 --- a/parachain-template/runtime/src/xcm_config.rs +++ b/parachain-template/runtime/src/xcm_config.rs @@ -127,20 +127,20 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { InitiateReserveWithdraw { reserve: MultiLocation { parents: 1, interior: Here }, .. - } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } | - TransferReserveAsset { + } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } + | TransferReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } ) }) { - return Err(()) // Deny + return Err(()); // Deny } // An unexpected reserve transfer has arrived from the Relay Chain. Generally, `IsReserve` // should not allow this, but we just log it here. - if matches!(origin, MultiLocation { parents: 1, interior: Here }) && - message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) + if matches!(origin, MultiLocation { parents: 1, interior: Here }) + && message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) { log::warn!( target: "xcm::barriers", diff --git a/parachains/common/src/impls.rs b/parachains/common/src/impls.rs index 4a2411c2cf3..cdce89f15e8 100644 --- a/parachains/common/src/impls.rs +++ b/parachains/common/src/impls.rs @@ -103,8 +103,8 @@ pub struct AssetsFrom(PhantomData); impl> FilterAssetLocation for AssetsFrom { fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { let loc = T::get(); - &loc == origin && - matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } + &loc == origin + && matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } if asset_loc.match_and_split(&loc).is_some()) } } diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index d56876d60ca..0a2b37a76cf 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -47,20 +47,20 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { InitiateReserveWithdraw { reserve: MultiLocation { parents: 1, interior: Here }, .. - } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } | - TransferReserveAsset { + } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } + | TransferReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } ) }) { - return Err(()) // Deny + return Err(()); // Deny } // An unexpected reserve transfer has arrived from the Relay Chain. Generally, `IsReserve` // should not allow this, but we just log it here. - if matches!(origin, MultiLocation { parents: 1, interior: Here }) && - message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) + if matches!(origin, MultiLocation { parents: 1, interior: Here }) + && message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) { log::warn!( target: "xcm::barrier", diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index 9bbfabea2fa..4a66f616423 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -319,57 +319,61 @@ impl InstanceFilter for ProxyType { fn filter(&self, c: &Call) -> bool { match self { ProxyType::Any => true, - ProxyType::NonTransfer => - !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }), + ProxyType::NonTransfer => { + !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }) + }, ProxyType::CancelProxy => matches!( c, - Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) | - Call::Utility { .. } | Call::Multisig { .. } + Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) + | Call::Utility { .. } + | Call::Multisig { .. } ), ProxyType::Assets => { matches!( c, - Call::Assets { .. } | - Call::Utility { .. } | Call::Multisig { .. } | - Call::Uniques { .. } + Call::Assets { .. } + | Call::Utility { .. } | Call::Multisig { .. } + | Call::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - Call::Assets(pallet_assets::Call::create { .. }) | - Call::Assets(pallet_assets::Call::destroy { .. }) | - Call::Assets(pallet_assets::Call::transfer_ownership { .. }) | - Call::Assets(pallet_assets::Call::set_team { .. }) | - Call::Assets(pallet_assets::Call::set_metadata { .. }) | - Call::Assets(pallet_assets::Call::clear_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::create { .. }) | - Call::Uniques(pallet_uniques::Call::destroy { .. }) | - Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | - Call::Uniques(pallet_uniques::Call::set_team { .. }) | - Call::Uniques(pallet_uniques::Call::set_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::set_attribute { .. }) | - Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) | - Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | - Call::Utility { .. } | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::create { .. }) + | Call::Assets(pallet_assets::Call::destroy { .. }) + | Call::Assets(pallet_assets::Call::transfer_ownership { .. }) + | Call::Assets(pallet_assets::Call::set_team { .. }) + | Call::Assets(pallet_assets::Call::set_metadata { .. }) + | Call::Assets(pallet_assets::Call::clear_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::create { .. }) + | Call::Uniques(pallet_uniques::Call::destroy { .. }) + | Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) + | Call::Uniques(pallet_uniques::Call::set_team { .. }) + | Call::Uniques(pallet_uniques::Call::set_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::set_attribute { .. }) + | Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) + | Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) + | Call::Utility { .. } + | Call::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - Call::Assets(pallet_assets::Call::mint { .. }) | - Call::Assets(pallet_assets::Call::burn { .. }) | - Call::Assets(pallet_assets::Call::freeze { .. }) | - Call::Assets(pallet_assets::Call::thaw { .. }) | - Call::Assets(pallet_assets::Call::freeze_asset { .. }) | - Call::Assets(pallet_assets::Call::thaw_asset { .. }) | - Call::Uniques(pallet_uniques::Call::mint { .. }) | - Call::Uniques(pallet_uniques::Call::burn { .. }) | - Call::Uniques(pallet_uniques::Call::freeze { .. }) | - Call::Uniques(pallet_uniques::Call::thaw { .. }) | - Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) | - Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) | - Call::Utility { .. } | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::mint { .. }) + | Call::Assets(pallet_assets::Call::burn { .. }) + | Call::Assets(pallet_assets::Call::freeze { .. }) + | Call::Assets(pallet_assets::Call::thaw { .. }) + | Call::Assets(pallet_assets::Call::freeze_asset { .. }) + | Call::Assets(pallet_assets::Call::thaw_asset { .. }) + | Call::Uniques(pallet_uniques::Call::mint { .. }) + | Call::Uniques(pallet_uniques::Call::burn { .. }) + | Call::Uniques(pallet_uniques::Call::freeze { .. }) + | Call::Uniques(pallet_uniques::Call::thaw { .. }) + | Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) + | Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) + | Call::Utility { .. } + | Call::Multisig { .. } ), ProxyType::Collator => matches!( c, diff --git a/parachains/runtimes/assets/statemint/src/lib.rs b/parachains/runtimes/assets/statemint/src/lib.rs index be579e1215e..60de6cbb98d 100644 --- a/parachains/runtimes/assets/statemint/src/lib.rs +++ b/parachains/runtimes/assets/statemint/src/lib.rs @@ -349,57 +349,61 @@ impl InstanceFilter for ProxyType { fn filter(&self, c: &Call) -> bool { match self { ProxyType::Any => true, - ProxyType::NonTransfer => - !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }), + ProxyType::NonTransfer => { + !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }) + }, ProxyType::CancelProxy => matches!( c, - Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) | - Call::Utility { .. } | Call::Multisig { .. } + Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) + | Call::Utility { .. } + | Call::Multisig { .. } ), ProxyType::Assets => { matches!( c, - Call::Assets { .. } | - Call::Utility { .. } | Call::Multisig { .. } | - Call::Uniques { .. } + Call::Assets { .. } + | Call::Utility { .. } | Call::Multisig { .. } + | Call::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - Call::Assets(pallet_assets::Call::create { .. }) | - Call::Assets(pallet_assets::Call::destroy { .. }) | - Call::Assets(pallet_assets::Call::transfer_ownership { .. }) | - Call::Assets(pallet_assets::Call::set_team { .. }) | - Call::Assets(pallet_assets::Call::set_metadata { .. }) | - Call::Assets(pallet_assets::Call::clear_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::create { .. }) | - Call::Uniques(pallet_uniques::Call::destroy { .. }) | - Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | - Call::Uniques(pallet_uniques::Call::set_team { .. }) | - Call::Uniques(pallet_uniques::Call::set_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::set_attribute { .. }) | - Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) | - Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | - Call::Utility { .. } | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::create { .. }) + | Call::Assets(pallet_assets::Call::destroy { .. }) + | Call::Assets(pallet_assets::Call::transfer_ownership { .. }) + | Call::Assets(pallet_assets::Call::set_team { .. }) + | Call::Assets(pallet_assets::Call::set_metadata { .. }) + | Call::Assets(pallet_assets::Call::clear_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::create { .. }) + | Call::Uniques(pallet_uniques::Call::destroy { .. }) + | Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) + | Call::Uniques(pallet_uniques::Call::set_team { .. }) + | Call::Uniques(pallet_uniques::Call::set_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::set_attribute { .. }) + | Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) + | Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) + | Call::Utility { .. } + | Call::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - Call::Assets(pallet_assets::Call::mint { .. }) | - Call::Assets(pallet_assets::Call::burn { .. }) | - Call::Assets(pallet_assets::Call::freeze { .. }) | - Call::Assets(pallet_assets::Call::thaw { .. }) | - Call::Assets(pallet_assets::Call::freeze_asset { .. }) | - Call::Assets(pallet_assets::Call::thaw_asset { .. }) | - Call::Uniques(pallet_uniques::Call::mint { .. }) | - Call::Uniques(pallet_uniques::Call::burn { .. }) | - Call::Uniques(pallet_uniques::Call::freeze { .. }) | - Call::Uniques(pallet_uniques::Call::thaw { .. }) | - Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) | - Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) | - Call::Utility { .. } | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::mint { .. }) + | Call::Assets(pallet_assets::Call::burn { .. }) + | Call::Assets(pallet_assets::Call::freeze { .. }) + | Call::Assets(pallet_assets::Call::thaw { .. }) + | Call::Assets(pallet_assets::Call::freeze_asset { .. }) + | Call::Assets(pallet_assets::Call::thaw_asset { .. }) + | Call::Uniques(pallet_uniques::Call::mint { .. }) + | Call::Uniques(pallet_uniques::Call::burn { .. }) + | Call::Uniques(pallet_uniques::Call::freeze { .. }) + | Call::Uniques(pallet_uniques::Call::thaw { .. }) + | Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) + | Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) + | Call::Utility { .. } + | Call::Multisig { .. } ), ProxyType::Collator => matches!( c, diff --git a/parachains/runtimes/assets/westmint/src/lib.rs b/parachains/runtimes/assets/westmint/src/lib.rs index a67de1fc01e..f6d5a6b84d3 100644 --- a/parachains/runtimes/assets/westmint/src/lib.rs +++ b/parachains/runtimes/assets/westmint/src/lib.rs @@ -314,57 +314,61 @@ impl InstanceFilter for ProxyType { fn filter(&self, c: &Call) -> bool { match self { ProxyType::Any => true, - ProxyType::NonTransfer => - !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }), + ProxyType::NonTransfer => { + !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }) + }, ProxyType::CancelProxy => matches!( c, - Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) | - Call::Utility { .. } | Call::Multisig { .. } + Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) + | Call::Utility { .. } + | Call::Multisig { .. } ), ProxyType::Assets => { matches!( c, - Call::Assets { .. } | - Call::Utility { .. } | Call::Multisig { .. } | - Call::Uniques { .. } + Call::Assets { .. } + | Call::Utility { .. } | Call::Multisig { .. } + | Call::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - Call::Assets(pallet_assets::Call::create { .. }) | - Call::Assets(pallet_assets::Call::destroy { .. }) | - Call::Assets(pallet_assets::Call::transfer_ownership { .. }) | - Call::Assets(pallet_assets::Call::set_team { .. }) | - Call::Assets(pallet_assets::Call::set_metadata { .. }) | - Call::Assets(pallet_assets::Call::clear_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::create { .. }) | - Call::Uniques(pallet_uniques::Call::destroy { .. }) | - Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | - Call::Uniques(pallet_uniques::Call::set_team { .. }) | - Call::Uniques(pallet_uniques::Call::set_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::set_attribute { .. }) | - Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) | - Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | - Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | - Call::Utility { .. } | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::create { .. }) + | Call::Assets(pallet_assets::Call::destroy { .. }) + | Call::Assets(pallet_assets::Call::transfer_ownership { .. }) + | Call::Assets(pallet_assets::Call::set_team { .. }) + | Call::Assets(pallet_assets::Call::set_metadata { .. }) + | Call::Assets(pallet_assets::Call::clear_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::create { .. }) + | Call::Uniques(pallet_uniques::Call::destroy { .. }) + | Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) + | Call::Uniques(pallet_uniques::Call::set_team { .. }) + | Call::Uniques(pallet_uniques::Call::set_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::set_attribute { .. }) + | Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) + | Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) + | Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) + | Call::Utility { .. } + | Call::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - Call::Assets(pallet_assets::Call::mint { .. }) | - Call::Assets(pallet_assets::Call::burn { .. }) | - Call::Assets(pallet_assets::Call::freeze { .. }) | - Call::Assets(pallet_assets::Call::thaw { .. }) | - Call::Assets(pallet_assets::Call::freeze_asset { .. }) | - Call::Assets(pallet_assets::Call::thaw_asset { .. }) | - Call::Uniques(pallet_uniques::Call::mint { .. }) | - Call::Uniques(pallet_uniques::Call::burn { .. }) | - Call::Uniques(pallet_uniques::Call::freeze { .. }) | - Call::Uniques(pallet_uniques::Call::thaw { .. }) | - Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) | - Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) | - Call::Utility { .. } | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::mint { .. }) + | Call::Assets(pallet_assets::Call::burn { .. }) + | Call::Assets(pallet_assets::Call::freeze { .. }) + | Call::Assets(pallet_assets::Call::thaw { .. }) + | Call::Assets(pallet_assets::Call::freeze_asset { .. }) + | Call::Assets(pallet_assets::Call::thaw_asset { .. }) + | Call::Uniques(pallet_uniques::Call::mint { .. }) + | Call::Uniques(pallet_uniques::Call::burn { .. }) + | Call::Uniques(pallet_uniques::Call::freeze { .. }) + | Call::Uniques(pallet_uniques::Call::thaw { .. }) + | Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) + | Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) + | Call::Utility { .. } + | Call::Multisig { .. } ), ProxyType::Collator => matches!( c, diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs index cd947446e26..222e1cdae73 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs @@ -296,8 +296,9 @@ impl InstanceFilter for ProxyType { ProxyType::NonTransfer => !matches!(c, Call::Balances { .. }), ProxyType::CancelProxy => matches!( c, - Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) | - Call::Utility { .. } | Call::Multisig { .. } + Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) + | Call::Utility { .. } + | Call::Multisig { .. } ), ProxyType::Collator => matches!( c, @@ -305,9 +306,10 @@ impl InstanceFilter for ProxyType { ), ProxyType::Alliance => matches!( c, - Call::AllianceMotion { .. } | - Call::Alliance { .. } | - Call::Utility { .. } | Call::Multisig { .. } + Call::AllianceMotion { .. } + | Call::Alliance { .. } + | Call::Utility { .. } + | Call::Multisig { .. } ), } } diff --git a/parachains/runtimes/testing/penpal/src/xcm_config.rs b/parachains/runtimes/testing/penpal/src/xcm_config.rs index 3fb2192cd7a..bd9933f7010 100644 --- a/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -188,19 +188,19 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { InitiateReserveWithdraw { reserve: MultiLocation { parents: 1, interior: Here }, .. - } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } | - TransferReserveAsset { + } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } + | TransferReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } ) }) { - return Err(()) // Deny + return Err(()); // Deny } // allow reserve transfers to arrive from relay chain - if matches!(origin, MultiLocation { parents: 1, interior: Here }) && - message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) + if matches!(origin, MultiLocation { parents: 1, interior: Here }) + && message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) { log::warn!( target: "xcm::barriers", @@ -236,8 +236,8 @@ pub struct AssetsFrom(PhantomData); impl> FilterAssetLocation for AssetsFrom { fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { let loc = T::get(); - &loc == origin && - matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } + &loc == origin + && matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } if asset_loc.match_and_split(&loc).is_some()) } } @@ -301,7 +301,7 @@ impl FilterAssetLocation for MultiNativeAsset { fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { if let Some(ref reserve) = asset.reserve() { if reserve == origin { - return true + return true; } } false diff --git a/polkadot-parachain/src/command.rs b/polkadot-parachain/src/command.rs index 18050c037bf..78fad30d950 100644 --- a/polkadot-parachain/src/command.rs +++ b/polkadot-parachain/src/command.rs @@ -117,20 +117,24 @@ fn load_spec(id: &str) -> std::result::Result, String> { let (id, _, para_id) = extract_parachain_id(id); Ok(match id { // - Defaul-like - "staging" => - Box::new(chain_spec::rococo_parachain::staging_rococo_parachain_local_config()), - "tick" => + "staging" => { + Box::new(chain_spec::rococo_parachain::staging_rococo_parachain_local_config()) + }, + "tick" => { Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/tick.json")[..], - )?), - "trick" => + )?) + }, + "trick" => { Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/trick.json")[..], - )?), - "track" => + )?) + }, + "track" => { Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/track.json")[..], - )?), + )?) + }, // -- Starters "shell" => Box::new(chain_spec::shell::get_shell_chain_spec()), @@ -167,29 +171,36 @@ fn load_spec(id: &str) -> std::result::Result, String> { )?), // -- Polkadot Collectives - "collectives-polkadot-dev" => - Box::new(chain_spec::collectives::collectives_polkadot_development_config()), - "collectives-polkadot-local" => - Box::new(chain_spec::collectives::collectives_polkadot_local_config()), - "collectives-polkadot" => + "collectives-polkadot-dev" => { + Box::new(chain_spec::collectives::collectives_polkadot_development_config()) + }, + "collectives-polkadot-local" => { + Box::new(chain_spec::collectives::collectives_polkadot_local_config()) + }, + "collectives-polkadot" => { Box::new(chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/collectives-polkadot.json")[..], - )?), - "collectives-westend" => + )?) + }, + "collectives-westend" => { Box::new(chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/collectives-westend.json")[..], - )?), + )?) + }, // -- Contracts on Rococo - "contracts-rococo-dev" => - Box::new(chain_spec::contracts::contracts_rococo_development_config()), - "contracts-rococo-local" => - Box::new(chain_spec::contracts::contracts_rococo_local_config()), + "contracts-rococo-dev" => { + Box::new(chain_spec::contracts::contracts_rococo_development_config()) + }, + "contracts-rococo-local" => { + Box::new(chain_spec::contracts::contracts_rococo_local_config()) + }, "contracts-rococo-genesis" => Box::new(chain_spec::contracts::contracts_rococo_config()), - "contracts-rococo" => + "contracts-rococo" => { Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/contracts-rococo.json")[..], - )?), + )?) + }, // -- Penpall "penpal-kusama" => Box::new(chain_spec::penpal::get_penpal_chain_spec( @@ -211,23 +222,30 @@ fn load_spec(id: &str) -> std::result::Result, String> { path => { let path: PathBuf = path.into(); match path.runtime() { - Runtime::Statemint => - Box::new(chain_spec::statemint::StatemintChainSpec::from_json_file(path)?), - Runtime::Statemine => - Box::new(chain_spec::statemint::StatemineChainSpec::from_json_file(path)?), - Runtime::Westmint => - Box::new(chain_spec::statemint::WestmintChainSpec::from_json_file(path)?), + Runtime::Statemint => { + Box::new(chain_spec::statemint::StatemintChainSpec::from_json_file(path)?) + }, + Runtime::Statemine => { + Box::new(chain_spec::statemint::StatemineChainSpec::from_json_file(path)?) + }, + Runtime::Westmint => { + Box::new(chain_spec::statemint::WestmintChainSpec::from_json_file(path)?) + }, Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => Box::new( chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_file(path)?, ), - Runtime::Shell => - Box::new(chain_spec::shell::ShellChainSpec::from_json_file(path)?), - Runtime::Seedling => - Box::new(chain_spec::seedling::SeedlingChainSpec::from_json_file(path)?), - Runtime::ContractsRococo => - Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path)?), - Runtime::Penpal(_para_id) => - Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?), + Runtime::Shell => { + Box::new(chain_spec::shell::ShellChainSpec::from_json_file(path)?) + }, + Runtime::Seedling => { + Box::new(chain_spec::seedling::SeedlingChainSpec::from_json_file(path)?) + }, + Runtime::ContractsRococo => { + Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path)?) + }, + Runtime::Penpal(_para_id) => { + Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?) + }, Runtime::Default => Box::new( chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_file(path)?, ), @@ -298,8 +316,9 @@ impl SubstrateCli for Cli { Runtime::Statemint => &statemint_runtime::VERSION, Runtime::Statemine => &statemine_runtime::VERSION, Runtime::Westmint => &westmint_runtime::VERSION, - Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => - &collectives_polkadot_runtime::VERSION, + Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => { + &collectives_polkadot_runtime::VERSION + }, Runtime::Shell => &shell_runtime::VERSION, Runtime::Seedling => &seedling_runtime::VERSION, Runtime::ContractsRococo => &contracts_rococo_runtime::VERSION, @@ -548,16 +567,19 @@ pub fn run() -> Result<()> { // Switch on the concrete benchmark sub-command- match cmd { - BenchmarkCmd::Pallet(cmd) => + BenchmarkCmd::Pallet(cmd) => { if cfg!(feature = "runtime-benchmarks") { runner.sync_run(|config| match config.chain_spec.runtime() { - Runtime::Statemine => - cmd.run::(config), + Runtime::Statemine => { + cmd.run::(config) + }, Runtime::Westmint => cmd.run::(config), - Runtime::Statemint => - cmd.run::(config), - Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => - cmd.run::(config), + Runtime::Statemint => { + cmd.run::(config) + }, + Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => { + cmd.run::(config) + }, _ => Err(format!( "Chain '{:?}' doesn't support benchmarking", config.chain_spec.runtime() @@ -568,7 +590,8 @@ pub fn run() -> Result<()> { Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." .into()) - }, + } + }, BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { construct_benchmark_partials!(config, |partials| cmd.run(partials.client)) }), @@ -580,8 +603,9 @@ pub fn run() -> Result<()> { cmd.run(config, partials.client.clone(), db, storage) }) }), - BenchmarkCmd::Machine(cmd) => - runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), + BenchmarkCmd::Machine(cmd) => { + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) + }, // NOTE: this allows the Client to leniently implement // new benchmark commands without requiring a companion MR. #[allow(unreachable_patterns)] @@ -607,13 +631,14 @@ pub fn run() -> Result<()> { Runtime::Statemint => runner.async_run(|config| { Ok((cmd.run::(config), task_manager)) }), - Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => + Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => { runner.async_run(|config| { Ok(( cmd.run::(config), task_manager, )) - }), + }) + }, Runtime::Shell => runner.async_run(|config| { Ok((cmd.run::(config), task_manager)) }), @@ -691,15 +716,16 @@ pub fn run() -> Result<()> { .await .map(|r| r.0) .map_err(Into::into), - Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => + Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => { crate::service::start_generic_aura_node::< collectives_polkadot_runtime::RuntimeApi, AuraId, >(config, polkadot_config, collator_options, id, hwbench) .await .map(|r| r.0) - .map_err(Into::into), - Runtime::Shell => + .map_err(Into::into) + }, + Runtime::Shell => { crate::service::start_shell_node::( config, polkadot_config, @@ -709,7 +735,8 @@ pub fn run() -> Result<()> { ) .await .map(|r| r.0) - .map_err(Into::into), + .map_err(Into::into) + }, Runtime::Seedling => crate::service::start_shell_node::< seedling_runtime::RuntimeApi, >(config, polkadot_config, collator_options, id, hwbench) @@ -726,7 +753,7 @@ pub fn run() -> Result<()> { .await .map(|r| r.0) .map_err(Into::into), - Runtime::Penpal(_) | Runtime::Default => + Runtime::Penpal(_) | Runtime::Default => { crate::service::start_rococo_parachain_node( config, polkadot_config, @@ -736,7 +763,8 @@ pub fn run() -> Result<()> { ) .await .map(|r| r.0) - .map_err(Into::into), + .map_err(Into::into) + }, } }) }, diff --git a/polkadot-parachain/tests/common.rs b/polkadot-parachain/tests/common.rs index 7b9dffae386..325400d97aa 100644 --- a/polkadot-parachain/tests/common.rs +++ b/polkadot-parachain/tests/common.rs @@ -43,7 +43,7 @@ pub fn wait_for(child: &mut Child, secs: u64) -> Result { let result = wait_timeout::ChildExt::wait_timeout(child, Duration::from_secs(secs - 5)) .map_err(|_| ())?; if let Some(exit_status) = result { - return Ok(exit_status) + return Ok(exit_status); } } eprintln!("Took too long to exit (> {} seconds). Killing...", secs); diff --git a/primitives/timestamp/src/lib.rs b/primitives/timestamp/src/lib.rs index 5822503ac17..31c789b771d 100644 --- a/primitives/timestamp/src/lib.rs +++ b/primitives/timestamp/src/lib.rs @@ -61,8 +61,8 @@ impl InherentDataProvider { pub fn provide_inherent_data(&self, inherent_data: &mut InherentData) -> Result<(), Error> { // As the parachain starts building at around `relay_chain_slot + 1` we use that slot to // calculate the timestamp. - let data: InherentType = ((*self.relay_chain_slot + 1) * - self.relay_chain_slot_duration.as_millis() as u64) + let data: InherentType = ((*self.relay_chain_slot + 1) + * self.relay_chain_slot_duration.as_millis() as u64) .into(); inherent_data.put_data(INHERENT_IDENTIFIER, &data) diff --git a/primitives/utility/src/lib.rs b/primitives/utility/src/lib.rs index ea7a81f327d..0a517c78bea 100644 --- a/primitives/utility/src/lib.rs +++ b/primitives/utility/src/lib.rs @@ -112,7 +112,7 @@ impl< // Make sure we dont enter twice if self.0.is_some() { - return Err(XcmError::NotWithdrawable) + return Err(XcmError::NotWithdrawable); } // We take the very first multiasset from payment diff --git a/test/relay-validation-worker-provider/build.rs b/test/relay-validation-worker-provider/build.rs index 9b5247bcbe5..875955eba39 100644 --- a/test/relay-validation-worker-provider/build.rs +++ b/test/relay-validation-worker-provider/build.rs @@ -28,7 +28,7 @@ const SKIP_ENV: &str = "SKIP_BUILD"; fn main() { if env::var(SKIP_ENV).is_ok() { - return + return; } let out_dir = PathBuf::from(env::var("OUT_DIR").expect("`OUT_DIR` is set by cargo")); @@ -47,7 +47,7 @@ fn find_cargo_lock() -> PathBuf { loop { if path.join("Cargo.lock").exists() { - return path.join("Cargo.lock") + return path.join("Cargo.lock"); } if !path.pop() { diff --git a/test/service/src/lib.rs b/test/service/src/lib.rs index 9132983e3eb..a33a4264a6a 100644 --- a/test/service/src/lib.rs +++ b/test/service/src/lib.rs @@ -183,7 +183,7 @@ async fn build_relay_chain_interface( ) -> RelayChainResult> { if let Some(relay_chain_url) = collator_options.relay_chain_rpc_url { let client = create_client_and_start_worker(relay_chain_url, task_manager).await?; - return Ok(Arc::new(RelayChainRpcInterface::new(client)) as Arc<_>) + return Ok(Arc::new(RelayChainRpcInterface::new(client)) as Arc<_>); } let relay_chain_full_node = polkadot_test_service::new_full( diff --git a/test/service/tests/runtime_upgrade.rs b/test/service/tests/runtime_upgrade.rs index 37eb82d8e04..da83beec294 100644 --- a/test/service/tests/runtime_upgrade.rs +++ b/test/service/tests/runtime_upgrade.rs @@ -95,7 +95,7 @@ async fn test_runtime_upgrade() { .expect("Runtime version exists"); if expected_runtime_version == runtime_version { - break + break; } } } From c106c46e7440ede207e06ff05e6a8dde554a0171 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Mon, 22 Aug 2022 17:07:52 +0200 Subject: [PATCH 3/5] use fmt nightly --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9b07006a413..69cb4b451fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -122,7 +122,7 @@ cargo-fmt: - echo PROJECT_NAME=$CI_PROJECT_NAME > fmt.env - echo PR_BRANCH_NAME=$(curl -s https://api.github.com/repos/paritytech/${CI_PROJECT_NAME}/pulls/${CI_COMMIT_REF_NAME} | jq -r ".head.ref") >> fmt.env script: - - cargo fmt --check + - cargo +nightly fmt --check artifacts: reports: dotenv: fmt.env From be9c22fb56a9c696f9a43bc6c5bc3828af984d35 Mon Sep 17 00:00:00 2001 From: paritytech-ci Date: Mon, 22 Aug 2022 15:08:59 +0000 Subject: [PATCH 4/5] [ci] Apply cargo-fmt --- client/cli/src/lib.rs | 2 +- client/collator/src/lib.rs | 8 +- .../common/src/parachain_consensus.rs | 16 +- client/consensus/common/src/tests.rs | 10 +- client/consensus/relay-chain/src/lib.rs | 2 +- client/network/src/lib.rs | 25 ++-- .../src/active_candidate_recovery.rs | 2 +- client/pov-recovery/src/lib.rs | 27 ++-- .../src/lib.rs | 2 +- client/relay-chain-rpc-interface/src/lib.rs | 2 +- client/service/src/lib.rs | 2 +- pallets/dmp-queue/src/lib.rs | 9 +- .../parachain-system/proc-macro/src/lib.rs | 9 +- pallets/parachain-system/src/lib.rs | 19 ++- .../src/relay_state_snapshot.rs | 2 +- .../src/validate_block/implementation.rs | 5 +- pallets/xcmp-queue/src/lib.rs | 72 +++++---- pallets/xcmp-queue/src/mock.rs | 4 +- parachain-template/node/src/command.rs | 10 +- parachain-template/runtime/src/xcm_config.rs | 10 +- parachains/common/src/impls.rs | 4 +- parachains/common/src/xcm_config.rs | 10 +- .../runtimes/assets/statemine/src/lib.rs | 80 +++++----- .../runtimes/assets/statemint/src/lib.rs | 80 +++++----- .../runtimes/assets/westmint/src/lib.rs | 80 +++++----- .../collectives-polkadot/src/lib.rs | 12 +- .../runtimes/testing/penpal/src/xcm_config.rs | 16 +- polkadot-parachain/src/command.rs | 140 +++++++----------- polkadot-parachain/tests/common.rs | 2 +- primitives/timestamp/src/lib.rs | 4 +- primitives/utility/src/lib.rs | 2 +- .../relay-validation-worker-provider/build.rs | 4 +- test/service/src/lib.rs | 2 +- test/service/tests/runtime_upgrade.rs | 2 +- 34 files changed, 311 insertions(+), 365 deletions(-) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index b6126f604aa..9fea382a7ee 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -96,7 +96,7 @@ impl PurgeChainCmd { Some('y') | Some('Y') => {}, _ => { println!("Aborted"); - return Ok(()); + return Ok(()) }, } } diff --git a/client/collator/src/lib.rs b/client/collator/src/lib.rs index af321625724..80650ff72e1 100644 --- a/client/collator/src/lib.rs +++ b/client/collator/src/lib.rs @@ -164,7 +164,7 @@ where target: LOG_TARGET, "Could not fetch `CollectCollationInfo` runtime api version." ); - return Ok(None); + return Ok(None) }, }; @@ -228,13 +228,13 @@ where error = ?e, "Could not decode the head data." ); - return None; + return None }, }; let last_head_hash = last_head.hash(); if !self.check_block_status(last_head_hash, &last_head) { - return None; + return None } tracing::info!( @@ -258,7 +258,7 @@ where Ok(proof) => proof, Err(e) => { tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e); - return None; + return None }, }; diff --git a/client/consensus/common/src/parachain_consensus.rs b/client/consensus/common/src/parachain_consensus.rs index 77d6c53be1e..ccdfb17b671 100644 --- a/client/consensus/common/src/parachain_consensus.rs +++ b/client/consensus/common/src/parachain_consensus.rs @@ -74,7 +74,7 @@ where Ok(finalized_heads_stream) => finalized_heads_stream, Err(err) => { tracing::error!(target: LOG_TARGET, error = ?err, "Unable to retrieve finalized heads stream."); - return; + return }, }; @@ -83,7 +83,7 @@ where h } else { tracing::debug!(target: "cumulus-consensus", "Stopping following finalized head."); - return; + return }; let header = match Block::Header::decode(&mut &finalized_head[..]) { @@ -94,7 +94,7 @@ where error = ?err, "Could not decode parachain header while following finalized heads.", ); - continue; + continue }, }; @@ -179,7 +179,7 @@ async fn follow_new_best( Ok(best_heads_stream) => best_heads_stream.fuse(), Err(err) => { tracing::error!(target: LOG_TARGET, error = ?err, "Unable to retrieve best heads stream."); - return; + return }, }; @@ -253,12 +253,12 @@ async fn handle_new_block_imported( }; let unset_hash = if notification.header.number() < unset_best_header.number() { - return; + return } else if notification.header.number() == unset_best_header.number() { let unset_hash = unset_best_header.hash(); if unset_hash != notification.hash { - return; + return } else { unset_hash } @@ -303,7 +303,7 @@ async fn handle_new_best_parachain_head( error = ?err, "Could not decode Parachain header while following best heads.", ); - return; + return }, }; @@ -367,7 +367,7 @@ where "Skipping importing block as new best block, because there already exists a \ best block with an higher number", ); - return; + return } // Make it the new best block diff --git a/client/consensus/common/src/tests.rs b/client/consensus/common/src/tests.rs index f20cde0e5e1..23729abebb4 100644 --- a/client/consensus/common/src/tests.rs +++ b/client/consensus/common/src/tests.rs @@ -136,7 +136,7 @@ fn follow_new_best_works() { loop { Delay::new(Duration::from_millis(100)).await; if block.hash() == client.usage_info().chain.best_hash { - break; + break } } }; @@ -170,7 +170,7 @@ fn follow_finalized_works() { loop { Delay::new(Duration::from_millis(100)).await; if block.hash() == client.usage_info().chain.finalized_hash { - break; + break } } }; @@ -217,7 +217,7 @@ fn follow_finalized_does_not_stop_on_unknown_block() { loop { Delay::new(Duration::from_millis(100)).await; if block.hash() == client.usage_info().chain.finalized_hash { - break; + break } } }; @@ -262,7 +262,7 @@ fn follow_new_best_sets_best_after_it_is_imported() { loop { Delay::new(Duration::from_millis(100)).await; if block.hash() == client.usage_info().chain.best_hash { - break; + break } } @@ -287,7 +287,7 @@ fn follow_new_best_sets_best_after_it_is_imported() { loop { Delay::new(Duration::from_millis(100)).await; if unknown_block.hash() == client.usage_info().chain.best_hash { - break; + break } } }; diff --git a/client/consensus/relay-chain/src/lib.rs b/client/consensus/relay-chain/src/lib.rs index c089e4a9849..20d3b7cc757 100644 --- a/client/consensus/relay-chain/src/lib.rs +++ b/client/consensus/relay-chain/src/lib.rs @@ -210,7 +210,7 @@ where "Error importing build block.", ); - return None; + return None } Some(ParachainCandidate { block, proof }) diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs index fd0e15e6a2f..7e906da1b1d 100644 --- a/client/network/src/lib.rs +++ b/client/network/src/lib.rs @@ -96,7 +96,7 @@ impl BlockAnnounceData { h } else { tracing::debug!(target: LOG_TARGET, "`CompactStatement` isn't the candidate variant!",); - return Err(Validation::Failure { disconnect: true }); + return Err(Validation::Failure { disconnect: true }) }; if *candidate_hash != self.receipt.hash() { @@ -104,7 +104,7 @@ impl BlockAnnounceData { target: LOG_TARGET, "Receipt candidate hash doesn't match candidate hash in statement", ); - return Err(Validation::Failure { disconnect: true }); + return Err(Validation::Failure { disconnect: true }) } if HeadData(encoded_header).hash() != self.receipt.descriptor.para_head { @@ -112,7 +112,7 @@ impl BlockAnnounceData { target: LOG_TARGET, "Receipt para head hash doesn't match the hash of the header in the block announcement", ); - return Err(Validation::Failure { disconnect: true }); + return Err(Validation::Failure { disconnect: true }) } Ok(()) @@ -151,7 +151,7 @@ impl BlockAnnounceData { "Block announcement justification signer is a validator index out of bound", ); - return Ok(Validation::Failure { disconnect: true }); + return Ok(Validation::Failure { disconnect: true }) }, }; @@ -162,7 +162,7 @@ impl BlockAnnounceData { "Block announcement justification signature is invalid.", ); - return Ok(Validation::Failure { disconnect: true }); + return Ok(Validation::Failure { disconnect: true }) } Ok(Validation::Success { is_new_best: true }) @@ -176,7 +176,7 @@ impl TryFrom<&'_ CollationSecondedSignal> for BlockAnnounceData { let receipt = if let Statement::Seconded(receipt) = signal.statement.payload() { receipt.to_plain() } else { - return Err(()); + return Err(()) }; Ok(BlockAnnounceData { @@ -341,25 +341,24 @@ where .unwrap_or(false); if relay_chain_is_syncing { - return Ok(Validation::Success { is_new_best: false }); + return Ok(Validation::Success { is_new_best: false }) } if data.is_empty() { - return block_announce_validator.handle_empty_block_announce_data(header).await; + return block_announce_validator.handle_empty_block_announce_data(header).await } let block_announce_data = match BlockAnnounceData::decode_all(&mut data.as_slice()) { Ok(r) => r, - Err(err) => { + Err(err) => return Err(Box::new(BlockAnnounceError(format!( "Can not decode the `BlockAnnounceData`: {:?}", err - ))) as Box<_>) - }, + ))) as Box<_>), }; if let Err(e) = block_announce_data.validate(header_encoded) { - return Ok(e); + return Ok(e) } let relay_parent = block_announce_data.receipt.descriptor.relay_parent; @@ -440,7 +439,7 @@ async fn wait_to_announce( block = ?block_hash, "Wait to announce stopped, because sender was dropped.", ); - return; + return }, }; diff --git a/client/pov-recovery/src/active_candidate_recovery.rs b/client/pov-recovery/src/active_candidate_recovery.rs index 466931c02e8..a269a26f821 100644 --- a/client/pov-recovery/src/active_candidate_recovery.rs +++ b/client/pov-recovery/src/active_candidate_recovery.rs @@ -102,7 +102,7 @@ impl ActiveCandidateRecovery { loop { if let Some(res) = self.recoveries.next().await { self.candidates.remove(&res.0); - return res; + return res } else { futures::pending!() } diff --git a/client/pov-recovery/src/lib.rs b/client/pov-recovery/src/lib.rs index 394542f11c9..aeff69d56c5 100644 --- a/client/pov-recovery/src/lib.rs +++ b/client/pov-recovery/src/lib.rs @@ -96,9 +96,8 @@ impl RecoveryDelay { fn as_delay(self) -> Delay { match self { Self::WithMax { max } => Delay::new(max.mul_f64(thread_rng().gen())), - Self::WithMinAndMax { min, max } => { - Delay::new(min + max.saturating_sub(min).mul_f64(thread_rng().gen())) - }, + Self::WithMinAndMax { min, max } => + Delay::new(min + max.saturating_sub(min).mul_f64(thread_rng().gen())), } } } @@ -167,12 +166,12 @@ where error = ?e, "Failed to decode parachain header from pending candidate", ); - return; + return }, }; if *header.number() <= self.parachain_client.usage_info().chain.finalized_number { - return; + return } let hash = header.hash(); @@ -187,7 +186,7 @@ where block_hash = ?hash, "Failed to get block status", ); - return; + return }, } @@ -203,7 +202,7 @@ where ) .is_some() { - return; + return } // Delay the recovery by some random time to not spam the relay chain. @@ -261,7 +260,7 @@ where Some(data) => data, None => { self.clear_waiting_for_parent(block_hash); - return; + return }, }; @@ -275,7 +274,7 @@ where self.clear_waiting_for_parent(block_hash); - return; + return }, }; @@ -290,7 +289,7 @@ where self.clear_waiting_for_parent(block_hash); - return; + return }, }; @@ -309,7 +308,7 @@ where ); self.waiting_for_parent.entry(parent).or_default().push(block); - return; + return } else { tracing::debug!( target: "cumulus-consensus", @@ -320,7 +319,7 @@ where self.clear_waiting_for_parent(block_hash); - return; + return } }, Err(error) => { @@ -333,7 +332,7 @@ where self.clear_waiting_for_parent(block_hash); - return; + return }, // Any other status is fine to "ignore/accept" _ => (), @@ -386,7 +385,7 @@ where Ok(pending_candidate_stream) => pending_candidate_stream.fuse(), Err(err) => { tracing::error!(target: LOG_TARGET, error = ?err, "Unable to retrieve pending candidate stream."); - return; + return }, }; diff --git a/client/relay-chain-inprocess-interface/src/lib.rs b/client/relay-chain-inprocess-interface/src/lib.rs index e168651a2aa..d713ab9cf38 100644 --- a/client/relay-chain-inprocess-interface/src/lib.rs +++ b/client/relay-chain-inprocess-interface/src/lib.rs @@ -270,7 +270,7 @@ where let block_id = BlockId::Hash(hash); if backend.blockchain().status(block_id)? == BlockStatus::InChain { - return Ok(BlockCheckStatus::InChain); + return Ok(BlockCheckStatus::InChain) } let listener = client.import_notification_stream(); diff --git a/client/relay-chain-rpc-interface/src/lib.rs b/client/relay-chain-rpc-interface/src/lib.rs index 6f2ab73da6d..f295c693ecd 100644 --- a/client/relay-chain-rpc-interface/src/lib.rs +++ b/client/relay-chain-rpc-interface/src/lib.rs @@ -170,7 +170,7 @@ impl RelayChainInterface for RelayChainRpcInterface { let mut head_stream = self.rpc_client.get_imported_heads_stream().await?; if self.rpc_client.chain_get_header(Some(wait_for_hash)).await?.is_some() { - return Ok(()); + return Ok(()) } let mut timeout = futures_timer::Delay::new(Duration::from_secs(TIMEOUT_IN_SECONDS)).fuse(); diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 0152cc5cfbe..5ca73a530a3 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -199,7 +199,7 @@ where // relay chain if blocks are not announced on parachain. This will be enabled again once // /~https://github.com/paritytech/cumulus/issues/545 is finished. if collator_options.relay_chain_rpc_url.is_some() { - return Ok(()); + return Ok(()) } let overseer_handle = relay_chain_interface diff --git a/pallets/dmp-queue/src/lib.rs b/pallets/dmp-queue/src/lib.rs index 748c6e95b76..a811bf54054 100644 --- a/pallets/dmp-queue/src/lib.rs +++ b/pallets/dmp-queue/src/lib.rs @@ -199,7 +199,7 @@ pub mod pallet { Err(..) => { // Too much weight needed - put the remaining messages back and bail Pages::::insert(page_index.begin_used, &page[i..]); - return used; + return used }, } } @@ -241,9 +241,8 @@ pub mod pallet { Ok(Ok(x)) => { let outcome = T::XcmExecutor::execute_xcm(Parent, x, limit); match outcome { - Outcome::Error(XcmError::WeightLimitReached(required)) => { - Err((message_id, required)) - }, + Outcome::Error(XcmError::WeightLimitReached(required)) => + Err((message_id, required)), outcome => { let weight_used = outcome.weight_used(); Self::deposit_event(Event::ExecutedDownward { message_id, outcome }); @@ -301,7 +300,7 @@ pub mod pallet { page_index.overweight_count += 1; // Not needed for control flow, but only to ensure that the compiler // understands that we won't attempt to re-use `data` later. - continue; + continue } else { // not overweight. stop executing inline and enqueue normally // from here on. diff --git a/pallets/parachain-system/proc-macro/src/lib.rs b/pallets/parachain-system/proc-macro/src/lib.rs index 3168ee1fe78..855d7fed484 100644 --- a/pallets/parachain-system/proc-macro/src/lib.rs +++ b/pallets/parachain-system/proc-macro/src/lib.rs @@ -69,13 +69,13 @@ impl Parse for Input { } else if lookahead.peek(keywords::CheckInherents) { parse_inner::(input, &mut check_inherents)?; } else { - return Err(lookahead.error()); + return Err(lookahead.error()) } } let rest = input.parse::()?; if !rest.is_empty() { - return Err(Error::new(rest.span(), "Unexpected input data")); + return Err(Error::new(rest.span(), "Unexpected input data")) } Ok(Self { @@ -88,9 +88,8 @@ impl Parse for Input { fn crate_() -> Result { match crate_name("cumulus-pallet-parachain-system") { - Ok(FoundCrate::Itself) => { - Ok(syn::Ident::new("cumulus_pallet_parachain_system", Span::call_site())) - }, + Ok(FoundCrate::Itself) => + Ok(syn::Ident::new("cumulus_pallet_parachain_system", Span::call_site())), Ok(FoundCrate::Name(name)) => Ok(Ident::new(&name, Span::call_site())), Err(e) => Err(Error::new(Span::call_site(), e)), } diff --git a/pallets/parachain-system/src/lib.rs b/pallets/parachain-system/src/lib.rs index 30683d55ded..b9056d5dcad 100644 --- a/pallets/parachain-system/src/lib.rs +++ b/pallets/parachain-system/src/lib.rs @@ -200,7 +200,7 @@ pub mod pallet { false, "host configuration is promised to set until `on_finalize`; qed", ); - return; + return }, }; let relevant_messaging_state = match Self::relevant_messaging_state() { @@ -211,7 +211,7 @@ pub mod pallet { "relevant messaging state is promised to be set until `on_finalize`; \ qed", ); - return; + return }, }; @@ -693,11 +693,11 @@ pub mod pallet { provides: vec![hash.as_ref().to_vec()], longevity: TransactionLongevity::max_value(), propagate: true, - }); + }) } } if let Call::set_validation_data { .. } = call { - return Ok(Default::default()); + return Ok(Default::default()) } Err(InvalidTransaction::Call.into()) } @@ -732,7 +732,7 @@ impl GetChannelInfo for Pallet { let channels = match Self::relevant_messaging_state() { None => { log::warn!("calling `get_channel_status` with no RelevantMessagingState?!"); - return ChannelStatus::Closed; + return ChannelStatus::Closed }, Some(d) => d.egress_channels, }; @@ -749,7 +749,7 @@ impl GetChannelInfo for Pallet { let meta = &channels[index].1; if meta.msg_count + 1 > meta.max_capacity { // The channel is at its capacity. Skip it for now. - return ChannelStatus::Full; + return ChannelStatus::Full } let max_size_now = meta.max_total_size - meta.total_size; let max_size_ever = meta.max_message_size; @@ -1043,11 +1043,10 @@ impl Pallet { // // However, changing this setting is expected to be rare. match Self::host_configuration() { - Some(cfg) => { + Some(cfg) => if message.len() > cfg.max_upward_message_size as usize { - return Err(MessageSendError::TooBig); - } - }, + 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 diff --git a/pallets/parachain-system/src/relay_state_snapshot.rs b/pallets/parachain-system/src/relay_state_snapshot.rs index cd925ca09a0..5b6a1ad3df9 100644 --- a/pallets/parachain-system/src/relay_state_snapshot.rs +++ b/pallets/parachain-system/src/relay_state_snapshot.rs @@ -154,7 +154,7 @@ impl RelayChainStateProof { ) -> Result { let db = proof.into_memory_db::>(); if !db.contains(&relay_parent_storage_root, EMPTY_PREFIX) { - return Err(Error::RootMismatch); + return Err(Error::RootMismatch) } let trie_backend = TrieBackendBuilder::new(db, relay_parent_storage_root).build(); diff --git a/pallets/parachain-system/src/validate_block/implementation.rs b/pallets/parachain-system/src/validate_block/implementation.rs index 2429ddec7c1..f37622688de 100644 --- a/pallets/parachain-system/src/validate_block/implementation.rs +++ b/pallets/parachain-system/src/validate_block/implementation.rs @@ -120,9 +120,8 @@ where .iter() .filter_map(|e| e.call().is_sub_type()) .find_map(|c| match c { - crate::Call::set_validation_data { data: validation_data } => { - Some(validation_data.clone()) - }, + crate::Call::set_validation_data { data: validation_data } => + Some(validation_data.clone()), _ => None, }) .expect("Could not find `set_validation_data` inherent"); diff --git a/pallets/xcmp-queue/src/lib.rs b/pallets/xcmp-queue/src/lib.rs index bf0cacea828..2b1bdac2b8b 100644 --- a/pallets/xcmp-queue/src/lib.rs +++ b/pallets/xcmp-queue/src/lib.rs @@ -496,7 +496,7 @@ impl Pallet { let max_message_size = T::ChannelInfo::get_channel_max(recipient).ok_or(MessageSendError::NoChannel)?; if data.len() > max_message_size { - return Err(MessageSendError::TooBig); + return Err(MessageSendError::TooBig) } let mut s = >::get(); @@ -507,18 +507,18 @@ impl Pallet { s.last_mut().expect("can't be empty; a new element was just pushed; qed") }; let have_active = details.last_index > details.first_index; - let appended = have_active - && >::mutate(recipient, details.last_index - 1, |s| { - if XcmpMessageFormat::decode_with_depth_limit(MAX_XCM_DECODE_DEPTH, &mut &s[..]) - != Ok(format) + let appended = have_active && + >::mutate(recipient, details.last_index - 1, |s| { + if XcmpMessageFormat::decode_with_depth_limit(MAX_XCM_DECODE_DEPTH, &mut &s[..]) != + Ok(format) { - return false; + return false } if s.len() + data.len() > max_message_size { - return false; + return false } s.extend_from_slice(&data[..]); - return true; + return true }); if appended { Ok((details.last_index - details.first_index - 1) as u32) @@ -606,22 +606,18 @@ impl Pallet { let location = (1, Parachain(sender.into())); match T::XcmExecutor::execute_xcm(location, xcm, max_weight) { - Outcome::Error(e) => { - (Err(e), Event::Fail { message_hash: Some(hash), error: e, weight: 0 }) - }, - Outcome::Complete(w) => { - (Ok(w), Event::Success { message_hash: Some(hash), weight: w }) - }, + Outcome::Error(e) => + (Err(e), Event::Fail { message_hash: Some(hash), error: e, weight: 0 }), + Outcome::Complete(w) => + (Ok(w), Event::Success { message_hash: Some(hash), weight: w }), // As far as the caller is concerned, this was dispatched without error, so // we just report the weight used. - Outcome::Incomplete(w, e) => { - (Ok(w), Event::Fail { message_hash: Some(hash), error: e, weight: w }) - }, + Outcome::Incomplete(w, e) => + (Ok(w), Event::Fail { message_hash: Some(hash), error: e, weight: w }), } }, - Err(()) => { - (Err(XcmError::UnhandledXcmVersion), Event::BadVersion { message_hash: Some(hash) }) - }, + Err(()) => + (Err(XcmError::UnhandledXcmVersion), Event::BadVersion { message_hash: Some(hash) }), }; Self::deposit_event(event); result @@ -668,7 +664,7 @@ impl Pallet { // That message didn't get processed this time because of being // too heavy. We leave it around for next time and bail. remaining_fragments = last_remaining_fragments; - break; + break }, Err(error) => { log::error!( @@ -696,7 +692,7 @@ impl Pallet { // That message didn't get processed this time because of being // too heavy. We leave it around for next time and bail. remaining_fragments = last_remaining_fragments; - break; + break }, Err(false) => { // Message invalid; don't attempt to retry @@ -770,7 +766,7 @@ impl Pallet { let mut status = >::get(); // <- sorted. if status.is_empty() { - return 0; + return 0 } let QueueConfigData { @@ -794,8 +790,8 @@ impl Pallet { // send more, heavier messages. let mut shuffle_index = 0; - while shuffle_index < shuffled.len() - && max_weight.saturating_sub(weight_used) >= threshold_weight + while shuffle_index < shuffled.len() && + max_weight.saturating_sub(weight_used) >= threshold_weight { let index = shuffled[shuffle_index]; let sender = status[index].sender; @@ -808,7 +804,7 @@ impl Pallet { if suspended && !is_controller { shuffle_index += 1; - continue; + continue } if weight_available != max_weight { @@ -845,8 +841,8 @@ impl Pallet { }; weight_used += weight_processed; - if status[index].message_metadata.len() as u32 <= resume_threshold - && status[index].state == InboundState::Suspended + if status[index].message_metadata.len() as u32 <= resume_threshold && + status[index].state == InboundState::Suspended { // Resume let r = Self::send_signal(sender, ChannelSignal::Resume); @@ -857,12 +853,12 @@ impl Pallet { // If there are more and we're making progress, we process them after we've given the // other channels a look in. If we've still not unlocked all weight, then we set them // up for processing a second time anyway. - if !status[index].message_metadata.is_empty() - && (weight_processed > 0 || weight_available != max_weight) + if !status[index].message_metadata.is_empty() && + (weight_processed > 0 || weight_available != max_weight) { if shuffle_index + 1 == shuffled.len() { // Only this queue left. Just run around this loop once more. - continue; + continue } shuffled.push(index); } @@ -927,7 +923,7 @@ impl XcmpMessageHandler for Pallet { Ok(f) => f, Err(_) => { debug_assert!(false, "Unknown XCMP message format. Silently dropping message"); - continue; + continue }, }; if format == XcmpMessageFormat::Signals { @@ -1002,10 +998,10 @@ impl XcmpMessageSource for Pallet { if result.len() == max_message_count { // We check this condition in the beginning of the loop so that we don't include // a message where the limit is 0. - break; + break } if outbound_state == OutboundState::Suspended { - continue; + continue } let (max_size_now, max_size_ever) = match T::ChannelInfo::get_channel_status(para_id) { ChannelStatus::Closed => { @@ -1018,7 +1014,7 @@ impl XcmpMessageSource for Pallet { >::remove(para_id); } *status = OutboundChannelDetails::new(para_id); - continue; + continue }, ChannelStatus::Full => continue, ChannelStatus::Ready(n, e) => (n, e), @@ -1031,7 +1027,7 @@ impl XcmpMessageSource for Pallet { signals_exist = false; page } else { - continue; + continue } } else if last_index > first_index { let page = >::get(para_id, first_index); @@ -1040,10 +1036,10 @@ impl XcmpMessageSource for Pallet { first_index += 1; page } else { - continue; + continue } } else { - continue; + continue }; if first_index == last_index { first_index = 0; diff --git a/pallets/xcmp-queue/src/mock.rs b/pallets/xcmp-queue/src/mock.rs index 538a27a81e8..60aff179b82 100644 --- a/pallets/xcmp-queue/src/mock.rs +++ b/pallets/xcmp-queue/src/mock.rs @@ -167,8 +167,8 @@ impl ConvertOrigin for SystemParachainAsSuperuser Result { let origin = origin.into(); - if kind == OriginKind::Superuser - && matches!( + if kind == OriginKind::Superuser && + matches!( origin, MultiLocation { parents: 1, diff --git a/parachain-template/node/src/command.rs b/parachain-template/node/src/command.rs index b8994f09cb9..735af3e42ab 100644 --- a/parachain-template/node/src/command.rs +++ b/parachain-template/node/src/command.rs @@ -202,15 +202,14 @@ pub fn run() -> Result<()> { let runner = cli.create_runner(cmd)?; // Switch on the concrete benchmark sub-command- match cmd { - BenchmarkCmd::Pallet(cmd) => { + BenchmarkCmd::Pallet(cmd) => if cfg!(feature = "runtime-benchmarks") { runner.sync_run(|config| cmd.run::(config)) } else { Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." .into()) - } - }, + }, BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { let partials = new_partial::( &config, @@ -228,9 +227,8 @@ pub fn run() -> Result<()> { cmd.run(config, partials.client.clone(), db, storage) }), - BenchmarkCmd::Machine(cmd) => { - runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) - }, + BenchmarkCmd::Machine(cmd) => + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), // NOTE: this allows the Client to leniently implement // new benchmark commands without requiring a companion MR. #[allow(unreachable_patterns)] diff --git a/parachain-template/runtime/src/xcm_config.rs b/parachain-template/runtime/src/xcm_config.rs index 1ab9c27f9cc..2ec84d18871 100644 --- a/parachain-template/runtime/src/xcm_config.rs +++ b/parachain-template/runtime/src/xcm_config.rs @@ -127,20 +127,20 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { InitiateReserveWithdraw { reserve: MultiLocation { parents: 1, interior: Here }, .. - } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } - | TransferReserveAsset { + } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } | + TransferReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } ) }) { - return Err(()); // Deny + return Err(()) // Deny } // An unexpected reserve transfer has arrived from the Relay Chain. Generally, `IsReserve` // should not allow this, but we just log it here. - if matches!(origin, MultiLocation { parents: 1, interior: Here }) - && message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) + if matches!(origin, MultiLocation { parents: 1, interior: Here }) && + message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) { log::warn!( target: "xcm::barriers", diff --git a/parachains/common/src/impls.rs b/parachains/common/src/impls.rs index cdce89f15e8..4a2411c2cf3 100644 --- a/parachains/common/src/impls.rs +++ b/parachains/common/src/impls.rs @@ -103,8 +103,8 @@ pub struct AssetsFrom(PhantomData); impl> FilterAssetLocation for AssetsFrom { fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { let loc = T::get(); - &loc == origin - && matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } + &loc == origin && + matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } if asset_loc.match_and_split(&loc).is_some()) } } diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index 0a2b37a76cf..d56876d60ca 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -47,20 +47,20 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { InitiateReserveWithdraw { reserve: MultiLocation { parents: 1, interior: Here }, .. - } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } - | TransferReserveAsset { + } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } | + TransferReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } ) }) { - return Err(()); // Deny + return Err(()) // Deny } // An unexpected reserve transfer has arrived from the Relay Chain. Generally, `IsReserve` // should not allow this, but we just log it here. - if matches!(origin, MultiLocation { parents: 1, interior: Here }) - && message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) + if matches!(origin, MultiLocation { parents: 1, interior: Here }) && + message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) { log::warn!( target: "xcm::barrier", diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/statemine/src/lib.rs index 4a66f616423..9bbfabea2fa 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/statemine/src/lib.rs @@ -319,61 +319,57 @@ impl InstanceFilter for ProxyType { fn filter(&self, c: &Call) -> bool { match self { ProxyType::Any => true, - ProxyType::NonTransfer => { - !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }) - }, + ProxyType::NonTransfer => + !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }), ProxyType::CancelProxy => matches!( c, - Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) - | Call::Utility { .. } - | Call::Multisig { .. } + Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) | + Call::Utility { .. } | Call::Multisig { .. } ), ProxyType::Assets => { matches!( c, - Call::Assets { .. } - | Call::Utility { .. } | Call::Multisig { .. } - | Call::Uniques { .. } + Call::Assets { .. } | + Call::Utility { .. } | Call::Multisig { .. } | + Call::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - Call::Assets(pallet_assets::Call::create { .. }) - | Call::Assets(pallet_assets::Call::destroy { .. }) - | Call::Assets(pallet_assets::Call::transfer_ownership { .. }) - | Call::Assets(pallet_assets::Call::set_team { .. }) - | Call::Assets(pallet_assets::Call::set_metadata { .. }) - | Call::Assets(pallet_assets::Call::clear_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::create { .. }) - | Call::Uniques(pallet_uniques::Call::destroy { .. }) - | Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) - | Call::Uniques(pallet_uniques::Call::set_team { .. }) - | Call::Uniques(pallet_uniques::Call::set_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::set_attribute { .. }) - | Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) - | Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) - | Call::Utility { .. } - | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::create { .. }) | + Call::Assets(pallet_assets::Call::destroy { .. }) | + Call::Assets(pallet_assets::Call::transfer_ownership { .. }) | + Call::Assets(pallet_assets::Call::set_team { .. }) | + Call::Assets(pallet_assets::Call::set_metadata { .. }) | + Call::Assets(pallet_assets::Call::clear_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::create { .. }) | + Call::Uniques(pallet_uniques::Call::destroy { .. }) | + Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | + Call::Uniques(pallet_uniques::Call::set_team { .. }) | + Call::Uniques(pallet_uniques::Call::set_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::set_attribute { .. }) | + Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) | + Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | + Call::Utility { .. } | Call::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - Call::Assets(pallet_assets::Call::mint { .. }) - | Call::Assets(pallet_assets::Call::burn { .. }) - | Call::Assets(pallet_assets::Call::freeze { .. }) - | Call::Assets(pallet_assets::Call::thaw { .. }) - | Call::Assets(pallet_assets::Call::freeze_asset { .. }) - | Call::Assets(pallet_assets::Call::thaw_asset { .. }) - | Call::Uniques(pallet_uniques::Call::mint { .. }) - | Call::Uniques(pallet_uniques::Call::burn { .. }) - | Call::Uniques(pallet_uniques::Call::freeze { .. }) - | Call::Uniques(pallet_uniques::Call::thaw { .. }) - | Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) - | Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) - | Call::Utility { .. } - | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::mint { .. }) | + Call::Assets(pallet_assets::Call::burn { .. }) | + Call::Assets(pallet_assets::Call::freeze { .. }) | + Call::Assets(pallet_assets::Call::thaw { .. }) | + Call::Assets(pallet_assets::Call::freeze_asset { .. }) | + Call::Assets(pallet_assets::Call::thaw_asset { .. }) | + Call::Uniques(pallet_uniques::Call::mint { .. }) | + Call::Uniques(pallet_uniques::Call::burn { .. }) | + Call::Uniques(pallet_uniques::Call::freeze { .. }) | + Call::Uniques(pallet_uniques::Call::thaw { .. }) | + Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) | + Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) | + Call::Utility { .. } | Call::Multisig { .. } ), ProxyType::Collator => matches!( c, diff --git a/parachains/runtimes/assets/statemint/src/lib.rs b/parachains/runtimes/assets/statemint/src/lib.rs index 60de6cbb98d..be579e1215e 100644 --- a/parachains/runtimes/assets/statemint/src/lib.rs +++ b/parachains/runtimes/assets/statemint/src/lib.rs @@ -349,61 +349,57 @@ impl InstanceFilter for ProxyType { fn filter(&self, c: &Call) -> bool { match self { ProxyType::Any => true, - ProxyType::NonTransfer => { - !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }) - }, + ProxyType::NonTransfer => + !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }), ProxyType::CancelProxy => matches!( c, - Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) - | Call::Utility { .. } - | Call::Multisig { .. } + Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) | + Call::Utility { .. } | Call::Multisig { .. } ), ProxyType::Assets => { matches!( c, - Call::Assets { .. } - | Call::Utility { .. } | Call::Multisig { .. } - | Call::Uniques { .. } + Call::Assets { .. } | + Call::Utility { .. } | Call::Multisig { .. } | + Call::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - Call::Assets(pallet_assets::Call::create { .. }) - | Call::Assets(pallet_assets::Call::destroy { .. }) - | Call::Assets(pallet_assets::Call::transfer_ownership { .. }) - | Call::Assets(pallet_assets::Call::set_team { .. }) - | Call::Assets(pallet_assets::Call::set_metadata { .. }) - | Call::Assets(pallet_assets::Call::clear_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::create { .. }) - | Call::Uniques(pallet_uniques::Call::destroy { .. }) - | Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) - | Call::Uniques(pallet_uniques::Call::set_team { .. }) - | Call::Uniques(pallet_uniques::Call::set_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::set_attribute { .. }) - | Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) - | Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) - | Call::Utility { .. } - | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::create { .. }) | + Call::Assets(pallet_assets::Call::destroy { .. }) | + Call::Assets(pallet_assets::Call::transfer_ownership { .. }) | + Call::Assets(pallet_assets::Call::set_team { .. }) | + Call::Assets(pallet_assets::Call::set_metadata { .. }) | + Call::Assets(pallet_assets::Call::clear_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::create { .. }) | + Call::Uniques(pallet_uniques::Call::destroy { .. }) | + Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | + Call::Uniques(pallet_uniques::Call::set_team { .. }) | + Call::Uniques(pallet_uniques::Call::set_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::set_attribute { .. }) | + Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) | + Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | + Call::Utility { .. } | Call::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - Call::Assets(pallet_assets::Call::mint { .. }) - | Call::Assets(pallet_assets::Call::burn { .. }) - | Call::Assets(pallet_assets::Call::freeze { .. }) - | Call::Assets(pallet_assets::Call::thaw { .. }) - | Call::Assets(pallet_assets::Call::freeze_asset { .. }) - | Call::Assets(pallet_assets::Call::thaw_asset { .. }) - | Call::Uniques(pallet_uniques::Call::mint { .. }) - | Call::Uniques(pallet_uniques::Call::burn { .. }) - | Call::Uniques(pallet_uniques::Call::freeze { .. }) - | Call::Uniques(pallet_uniques::Call::thaw { .. }) - | Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) - | Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) - | Call::Utility { .. } - | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::mint { .. }) | + Call::Assets(pallet_assets::Call::burn { .. }) | + Call::Assets(pallet_assets::Call::freeze { .. }) | + Call::Assets(pallet_assets::Call::thaw { .. }) | + Call::Assets(pallet_assets::Call::freeze_asset { .. }) | + Call::Assets(pallet_assets::Call::thaw_asset { .. }) | + Call::Uniques(pallet_uniques::Call::mint { .. }) | + Call::Uniques(pallet_uniques::Call::burn { .. }) | + Call::Uniques(pallet_uniques::Call::freeze { .. }) | + Call::Uniques(pallet_uniques::Call::thaw { .. }) | + Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) | + Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) | + Call::Utility { .. } | Call::Multisig { .. } ), ProxyType::Collator => matches!( c, diff --git a/parachains/runtimes/assets/westmint/src/lib.rs b/parachains/runtimes/assets/westmint/src/lib.rs index f6d5a6b84d3..a67de1fc01e 100644 --- a/parachains/runtimes/assets/westmint/src/lib.rs +++ b/parachains/runtimes/assets/westmint/src/lib.rs @@ -314,61 +314,57 @@ impl InstanceFilter for ProxyType { fn filter(&self, c: &Call) -> bool { match self { ProxyType::Any => true, - ProxyType::NonTransfer => { - !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }) - }, + ProxyType::NonTransfer => + !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }), ProxyType::CancelProxy => matches!( c, - Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) - | Call::Utility { .. } - | Call::Multisig { .. } + Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) | + Call::Utility { .. } | Call::Multisig { .. } ), ProxyType::Assets => { matches!( c, - Call::Assets { .. } - | Call::Utility { .. } | Call::Multisig { .. } - | Call::Uniques { .. } + Call::Assets { .. } | + Call::Utility { .. } | Call::Multisig { .. } | + Call::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( c, - Call::Assets(pallet_assets::Call::create { .. }) - | Call::Assets(pallet_assets::Call::destroy { .. }) - | Call::Assets(pallet_assets::Call::transfer_ownership { .. }) - | Call::Assets(pallet_assets::Call::set_team { .. }) - | Call::Assets(pallet_assets::Call::set_metadata { .. }) - | Call::Assets(pallet_assets::Call::clear_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::create { .. }) - | Call::Uniques(pallet_uniques::Call::destroy { .. }) - | Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) - | Call::Uniques(pallet_uniques::Call::set_team { .. }) - | Call::Uniques(pallet_uniques::Call::set_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::set_attribute { .. }) - | Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) - | Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) - | Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) - | Call::Utility { .. } - | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::create { .. }) | + Call::Assets(pallet_assets::Call::destroy { .. }) | + Call::Assets(pallet_assets::Call::transfer_ownership { .. }) | + Call::Assets(pallet_assets::Call::set_team { .. }) | + Call::Assets(pallet_assets::Call::set_metadata { .. }) | + Call::Assets(pallet_assets::Call::clear_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::create { .. }) | + Call::Uniques(pallet_uniques::Call::destroy { .. }) | + Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | + Call::Uniques(pallet_uniques::Call::set_team { .. }) | + Call::Uniques(pallet_uniques::Call::set_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::set_attribute { .. }) | + Call::Uniques(pallet_uniques::Call::set_collection_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) | + Call::Uniques(pallet_uniques::Call::clear_collection_metadata { .. }) | + Call::Uniques(pallet_uniques::Call::set_collection_max_supply { .. }) | + Call::Utility { .. } | Call::Multisig { .. } ), ProxyType::AssetManager => matches!( c, - Call::Assets(pallet_assets::Call::mint { .. }) - | Call::Assets(pallet_assets::Call::burn { .. }) - | Call::Assets(pallet_assets::Call::freeze { .. }) - | Call::Assets(pallet_assets::Call::thaw { .. }) - | Call::Assets(pallet_assets::Call::freeze_asset { .. }) - | Call::Assets(pallet_assets::Call::thaw_asset { .. }) - | Call::Uniques(pallet_uniques::Call::mint { .. }) - | Call::Uniques(pallet_uniques::Call::burn { .. }) - | Call::Uniques(pallet_uniques::Call::freeze { .. }) - | Call::Uniques(pallet_uniques::Call::thaw { .. }) - | Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) - | Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) - | Call::Utility { .. } - | Call::Multisig { .. } + Call::Assets(pallet_assets::Call::mint { .. }) | + Call::Assets(pallet_assets::Call::burn { .. }) | + Call::Assets(pallet_assets::Call::freeze { .. }) | + Call::Assets(pallet_assets::Call::thaw { .. }) | + Call::Assets(pallet_assets::Call::freeze_asset { .. }) | + Call::Assets(pallet_assets::Call::thaw_asset { .. }) | + Call::Uniques(pallet_uniques::Call::mint { .. }) | + Call::Uniques(pallet_uniques::Call::burn { .. }) | + Call::Uniques(pallet_uniques::Call::freeze { .. }) | + Call::Uniques(pallet_uniques::Call::thaw { .. }) | + Call::Uniques(pallet_uniques::Call::freeze_collection { .. }) | + Call::Uniques(pallet_uniques::Call::thaw_collection { .. }) | + Call::Utility { .. } | Call::Multisig { .. } ), ProxyType::Collator => matches!( c, diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs index 222e1cdae73..cd947446e26 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs @@ -296,9 +296,8 @@ impl InstanceFilter for ProxyType { ProxyType::NonTransfer => !matches!(c, Call::Balances { .. }), ProxyType::CancelProxy => matches!( c, - Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) - | Call::Utility { .. } - | Call::Multisig { .. } + Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) | + Call::Utility { .. } | Call::Multisig { .. } ), ProxyType::Collator => matches!( c, @@ -306,10 +305,9 @@ impl InstanceFilter for ProxyType { ), ProxyType::Alliance => matches!( c, - Call::AllianceMotion { .. } - | Call::Alliance { .. } - | Call::Utility { .. } - | Call::Multisig { .. } + Call::AllianceMotion { .. } | + Call::Alliance { .. } | + Call::Utility { .. } | Call::Multisig { .. } ), } } diff --git a/parachains/runtimes/testing/penpal/src/xcm_config.rs b/parachains/runtimes/testing/penpal/src/xcm_config.rs index bd9933f7010..3fb2192cd7a 100644 --- a/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -188,19 +188,19 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { InitiateReserveWithdraw { reserve: MultiLocation { parents: 1, interior: Here }, .. - } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } - | TransferReserveAsset { + } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } | + TransferReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } ) }) { - return Err(()); // Deny + return Err(()) // Deny } // allow reserve transfers to arrive from relay chain - if matches!(origin, MultiLocation { parents: 1, interior: Here }) - && message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) + if matches!(origin, MultiLocation { parents: 1, interior: Here }) && + message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) { log::warn!( target: "xcm::barriers", @@ -236,8 +236,8 @@ pub struct AssetsFrom(PhantomData); impl> FilterAssetLocation for AssetsFrom { fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { let loc = T::get(); - &loc == origin - && matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } + &loc == origin && + matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } if asset_loc.match_and_split(&loc).is_some()) } } @@ -301,7 +301,7 @@ impl FilterAssetLocation for MultiNativeAsset { fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { if let Some(ref reserve) = asset.reserve() { if reserve == origin { - return true; + return true } } false diff --git a/polkadot-parachain/src/command.rs b/polkadot-parachain/src/command.rs index 78fad30d950..18050c037bf 100644 --- a/polkadot-parachain/src/command.rs +++ b/polkadot-parachain/src/command.rs @@ -117,24 +117,20 @@ fn load_spec(id: &str) -> std::result::Result, String> { let (id, _, para_id) = extract_parachain_id(id); Ok(match id { // - Defaul-like - "staging" => { - Box::new(chain_spec::rococo_parachain::staging_rococo_parachain_local_config()) - }, - "tick" => { + "staging" => + Box::new(chain_spec::rococo_parachain::staging_rococo_parachain_local_config()), + "tick" => Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/tick.json")[..], - )?) - }, - "trick" => { + )?), + "trick" => Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/trick.json")[..], - )?) - }, - "track" => { + )?), + "track" => Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/track.json")[..], - )?) - }, + )?), // -- Starters "shell" => Box::new(chain_spec::shell::get_shell_chain_spec()), @@ -171,36 +167,29 @@ fn load_spec(id: &str) -> std::result::Result, String> { )?), // -- Polkadot Collectives - "collectives-polkadot-dev" => { - Box::new(chain_spec::collectives::collectives_polkadot_development_config()) - }, - "collectives-polkadot-local" => { - Box::new(chain_spec::collectives::collectives_polkadot_local_config()) - }, - "collectives-polkadot" => { + "collectives-polkadot-dev" => + Box::new(chain_spec::collectives::collectives_polkadot_development_config()), + "collectives-polkadot-local" => + Box::new(chain_spec::collectives::collectives_polkadot_local_config()), + "collectives-polkadot" => Box::new(chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/collectives-polkadot.json")[..], - )?) - }, - "collectives-westend" => { + )?), + "collectives-westend" => Box::new(chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/collectives-westend.json")[..], - )?) - }, + )?), // -- Contracts on Rococo - "contracts-rococo-dev" => { - Box::new(chain_spec::contracts::contracts_rococo_development_config()) - }, - "contracts-rococo-local" => { - Box::new(chain_spec::contracts::contracts_rococo_local_config()) - }, + "contracts-rococo-dev" => + Box::new(chain_spec::contracts::contracts_rococo_development_config()), + "contracts-rococo-local" => + Box::new(chain_spec::contracts::contracts_rococo_local_config()), "contracts-rococo-genesis" => Box::new(chain_spec::contracts::contracts_rococo_config()), - "contracts-rococo" => { + "contracts-rococo" => Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_bytes( &include_bytes!("../../parachains/chain-specs/contracts-rococo.json")[..], - )?) - }, + )?), // -- Penpall "penpal-kusama" => Box::new(chain_spec::penpal::get_penpal_chain_spec( @@ -222,30 +211,23 @@ fn load_spec(id: &str) -> std::result::Result, String> { path => { let path: PathBuf = path.into(); match path.runtime() { - Runtime::Statemint => { - Box::new(chain_spec::statemint::StatemintChainSpec::from_json_file(path)?) - }, - Runtime::Statemine => { - Box::new(chain_spec::statemint::StatemineChainSpec::from_json_file(path)?) - }, - Runtime::Westmint => { - Box::new(chain_spec::statemint::WestmintChainSpec::from_json_file(path)?) - }, + Runtime::Statemint => + Box::new(chain_spec::statemint::StatemintChainSpec::from_json_file(path)?), + Runtime::Statemine => + Box::new(chain_spec::statemint::StatemineChainSpec::from_json_file(path)?), + Runtime::Westmint => + Box::new(chain_spec::statemint::WestmintChainSpec::from_json_file(path)?), Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => Box::new( chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_file(path)?, ), - Runtime::Shell => { - Box::new(chain_spec::shell::ShellChainSpec::from_json_file(path)?) - }, - Runtime::Seedling => { - Box::new(chain_spec::seedling::SeedlingChainSpec::from_json_file(path)?) - }, - Runtime::ContractsRococo => { - Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path)?) - }, - Runtime::Penpal(_para_id) => { - Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?) - }, + Runtime::Shell => + Box::new(chain_spec::shell::ShellChainSpec::from_json_file(path)?), + Runtime::Seedling => + Box::new(chain_spec::seedling::SeedlingChainSpec::from_json_file(path)?), + Runtime::ContractsRococo => + Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path)?), + Runtime::Penpal(_para_id) => + Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?), Runtime::Default => Box::new( chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_file(path)?, ), @@ -316,9 +298,8 @@ impl SubstrateCli for Cli { Runtime::Statemint => &statemint_runtime::VERSION, Runtime::Statemine => &statemine_runtime::VERSION, Runtime::Westmint => &westmint_runtime::VERSION, - Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => { - &collectives_polkadot_runtime::VERSION - }, + Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => + &collectives_polkadot_runtime::VERSION, Runtime::Shell => &shell_runtime::VERSION, Runtime::Seedling => &seedling_runtime::VERSION, Runtime::ContractsRococo => &contracts_rococo_runtime::VERSION, @@ -567,19 +548,16 @@ pub fn run() -> Result<()> { // Switch on the concrete benchmark sub-command- match cmd { - BenchmarkCmd::Pallet(cmd) => { + BenchmarkCmd::Pallet(cmd) => if cfg!(feature = "runtime-benchmarks") { runner.sync_run(|config| match config.chain_spec.runtime() { - Runtime::Statemine => { - cmd.run::(config) - }, + Runtime::Statemine => + cmd.run::(config), Runtime::Westmint => cmd.run::(config), - Runtime::Statemint => { - cmd.run::(config) - }, - Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => { - cmd.run::(config) - }, + Runtime::Statemint => + cmd.run::(config), + Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => + cmd.run::(config), _ => Err(format!( "Chain '{:?}' doesn't support benchmarking", config.chain_spec.runtime() @@ -590,8 +568,7 @@ pub fn run() -> Result<()> { Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." .into()) - } - }, + }, BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { construct_benchmark_partials!(config, |partials| cmd.run(partials.client)) }), @@ -603,9 +580,8 @@ pub fn run() -> Result<()> { cmd.run(config, partials.client.clone(), db, storage) }) }), - BenchmarkCmd::Machine(cmd) => { - runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) - }, + BenchmarkCmd::Machine(cmd) => + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), // NOTE: this allows the Client to leniently implement // new benchmark commands without requiring a companion MR. #[allow(unreachable_patterns)] @@ -631,14 +607,13 @@ pub fn run() -> Result<()> { Runtime::Statemint => runner.async_run(|config| { Ok((cmd.run::(config), task_manager)) }), - Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => { + Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => runner.async_run(|config| { Ok(( cmd.run::(config), task_manager, )) - }) - }, + }), Runtime::Shell => runner.async_run(|config| { Ok((cmd.run::(config), task_manager)) }), @@ -716,16 +691,15 @@ pub fn run() -> Result<()> { .await .map(|r| r.0) .map_err(Into::into), - Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => { + Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => crate::service::start_generic_aura_node::< collectives_polkadot_runtime::RuntimeApi, AuraId, >(config, polkadot_config, collator_options, id, hwbench) .await .map(|r| r.0) - .map_err(Into::into) - }, - Runtime::Shell => { + .map_err(Into::into), + Runtime::Shell => crate::service::start_shell_node::( config, polkadot_config, @@ -735,8 +709,7 @@ pub fn run() -> Result<()> { ) .await .map(|r| r.0) - .map_err(Into::into) - }, + .map_err(Into::into), Runtime::Seedling => crate::service::start_shell_node::< seedling_runtime::RuntimeApi, >(config, polkadot_config, collator_options, id, hwbench) @@ -753,7 +726,7 @@ pub fn run() -> Result<()> { .await .map(|r| r.0) .map_err(Into::into), - Runtime::Penpal(_) | Runtime::Default => { + Runtime::Penpal(_) | Runtime::Default => crate::service::start_rococo_parachain_node( config, polkadot_config, @@ -763,8 +736,7 @@ pub fn run() -> Result<()> { ) .await .map(|r| r.0) - .map_err(Into::into) - }, + .map_err(Into::into), } }) }, diff --git a/polkadot-parachain/tests/common.rs b/polkadot-parachain/tests/common.rs index 325400d97aa..7b9dffae386 100644 --- a/polkadot-parachain/tests/common.rs +++ b/polkadot-parachain/tests/common.rs @@ -43,7 +43,7 @@ pub fn wait_for(child: &mut Child, secs: u64) -> Result { let result = wait_timeout::ChildExt::wait_timeout(child, Duration::from_secs(secs - 5)) .map_err(|_| ())?; if let Some(exit_status) = result { - return Ok(exit_status); + return Ok(exit_status) } } eprintln!("Took too long to exit (> {} seconds). Killing...", secs); diff --git a/primitives/timestamp/src/lib.rs b/primitives/timestamp/src/lib.rs index 31c789b771d..5822503ac17 100644 --- a/primitives/timestamp/src/lib.rs +++ b/primitives/timestamp/src/lib.rs @@ -61,8 +61,8 @@ impl InherentDataProvider { pub fn provide_inherent_data(&self, inherent_data: &mut InherentData) -> Result<(), Error> { // As the parachain starts building at around `relay_chain_slot + 1` we use that slot to // calculate the timestamp. - let data: InherentType = ((*self.relay_chain_slot + 1) - * self.relay_chain_slot_duration.as_millis() as u64) + let data: InherentType = ((*self.relay_chain_slot + 1) * + self.relay_chain_slot_duration.as_millis() as u64) .into(); inherent_data.put_data(INHERENT_IDENTIFIER, &data) diff --git a/primitives/utility/src/lib.rs b/primitives/utility/src/lib.rs index 0a517c78bea..ea7a81f327d 100644 --- a/primitives/utility/src/lib.rs +++ b/primitives/utility/src/lib.rs @@ -112,7 +112,7 @@ impl< // Make sure we dont enter twice if self.0.is_some() { - return Err(XcmError::NotWithdrawable); + return Err(XcmError::NotWithdrawable) } // We take the very first multiasset from payment diff --git a/test/relay-validation-worker-provider/build.rs b/test/relay-validation-worker-provider/build.rs index 875955eba39..9b5247bcbe5 100644 --- a/test/relay-validation-worker-provider/build.rs +++ b/test/relay-validation-worker-provider/build.rs @@ -28,7 +28,7 @@ const SKIP_ENV: &str = "SKIP_BUILD"; fn main() { if env::var(SKIP_ENV).is_ok() { - return; + return } let out_dir = PathBuf::from(env::var("OUT_DIR").expect("`OUT_DIR` is set by cargo")); @@ -47,7 +47,7 @@ fn find_cargo_lock() -> PathBuf { loop { if path.join("Cargo.lock").exists() { - return path.join("Cargo.lock"); + return path.join("Cargo.lock") } if !path.pop() { diff --git a/test/service/src/lib.rs b/test/service/src/lib.rs index a33a4264a6a..9132983e3eb 100644 --- a/test/service/src/lib.rs +++ b/test/service/src/lib.rs @@ -183,7 +183,7 @@ async fn build_relay_chain_interface( ) -> RelayChainResult> { if let Some(relay_chain_url) = collator_options.relay_chain_rpc_url { let client = create_client_and_start_worker(relay_chain_url, task_manager).await?; - return Ok(Arc::new(RelayChainRpcInterface::new(client)) as Arc<_>); + return Ok(Arc::new(RelayChainRpcInterface::new(client)) as Arc<_>) } let relay_chain_full_node = polkadot_test_service::new_full( diff --git a/test/service/tests/runtime_upgrade.rs b/test/service/tests/runtime_upgrade.rs index da83beec294..37eb82d8e04 100644 --- a/test/service/tests/runtime_upgrade.rs +++ b/test/service/tests/runtime_upgrade.rs @@ -95,7 +95,7 @@ async fn test_runtime_upgrade() { .expect("Runtime version exists"); if expected_runtime_version == runtime_version { - break; + break } } } From 23a121483454db26e18f1bb8723d32c8ff6a3721 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Tue, 23 Aug 2022 11:08:16 +0200 Subject: [PATCH 5/5] add comment to cargo-fmt and remove fmt gha --- .github/workflows/quick-check.yml | 40 ------------------------------- .gitlab-ci.yml | 2 ++ 2 files changed, 2 insertions(+), 40 deletions(-) delete mode 100644 .github/workflows/quick-check.yml diff --git a/.github/workflows/quick-check.yml b/.github/workflows/quick-check.yml deleted file mode 100644 index 5026aeaf091..00000000000 --- a/.github/workflows/quick-check.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Quick check Formatting - -on: - push: - branches: - - "*" - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - -jobs: - quick_check: - strategy: - matrix: - os: ["ubuntu-latest"] - runs-on: ${{ matrix.os }} - steps: - - name: Install Rust nightly toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - components: clippy, rustfmt - - - name: Cache Dependencies & Build Outputs - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - uses: actions/checkout@v3 - - - name: Cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 69cb4b451fb..c4d0ad28ed4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -114,6 +114,8 @@ variables: #### stage: .pre +# checks code format and fails if formatting is required +# the code will be formatted automatically and the pipeline will be restarted cargo-fmt: stage: .pre <<: *pr-refs