diff --git a/bridges/bin/runtime-common/src/messages.rs b/bridges/bin/runtime-common/src/messages.rs index 250b68ceffe2f..6bcaae4d36577 100644 --- a/bridges/bin/runtime-common/src/messages.rs +++ b/bridges/bin/runtime-common/src/messages.rs @@ -327,18 +327,16 @@ pub mod source { frame_system::RawOrigin>>, OriginOf>, > = submitter.clone().into(); - match raw_origin_or_err { - Ok(raw_origin) => - pallet_bridge_dispatch::verify_message_origin(&raw_origin, payload) - .map(drop) - .map_err(|_| BAD_ORIGIN)?, - Err(_) => { - // so what it means that we've failed to convert origin to the - // `frame_system::RawOrigin`? now it means that the custom pallet origin has - // been used to send the message. Do we need to verify it? The answer is no, - // because pallet may craft any origin (e.g. root) && we can't verify whether it - // is valid, or not. - }, + if let Ok(raw_origin) = raw_origin_or_err { + pallet_bridge_dispatch::verify_message_origin(&raw_origin, payload) + .map(drop) + .map_err(|_| BAD_ORIGIN)?; + } else { + // so what it means that we've failed to convert origin to the + // `frame_system::RawOrigin`? now it means that the custom pallet origin has + // been used to send the message. Do we need to verify it? The answer is no, + // because pallet may craft any origin (e.g. root) && we can't verify whether it + // is valid, or not. }; let minimal_fee_in_this_tokens = estimate_message_dispatch_and_delivery_fee::( diff --git a/bridges/modules/grandpa/src/lib.rs b/bridges/modules/grandpa/src/lib.rs index 947bfdc7f634c..ed5841d75107a 100644 --- a/bridges/modules/grandpa/src/lib.rs +++ b/bridges/modules/grandpa/src/lib.rs @@ -166,7 +166,7 @@ pub mod pallet { try_enact_authority_change::(&finality_target, set_id)?; >::mutate(|count| *count += 1); insert_header::(*finality_target, hash); - log::info!(target: "runtime::bridge-grandpa", "Succesfully imported finalized header with hash {:?}!", hash); + log::info!(target: "runtime::bridge-grandpa", "Successfully imported finalized header with hash {:?}!", hash); // mandatory header is a header that changes authorities set. The pallet can't go // further without importing this header. So every bridge MUST import mandatory headers. diff --git a/bridges/modules/messages/src/mock.rs b/bridges/modules/messages/src/mock.rs index 75dcce8df0449..5bf36f6809cc0 100644 --- a/bridges/modules/messages/src/mock.rs +++ b/bridges/modules/messages/src/mock.rs @@ -198,7 +198,7 @@ impl SenderOrigin for Origin { fn linked_account(&self) -> Option { match self.caller { OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) => - Some(submitter.clone()), + Some(*submitter), _ => None, } } diff --git a/bridges/modules/messages/src/outbound_lane.rs b/bridges/modules/messages/src/outbound_lane.rs index cfdc81acc315b..e4566b8895fa4 100644 --- a/bridges/modules/messages/src/outbound_lane.rs +++ b/bridges/modules/messages/src/outbound_lane.rs @@ -74,7 +74,7 @@ pub struct OutboundLane { } impl OutboundLane { - /// Create new inbound lane backed by given storage. + /// Create new outbound lane backed by given storage. pub fn new(storage: S) -> Self { OutboundLane { storage } } diff --git a/bridges/primitives/header-chain/src/justification.rs b/bridges/primitives/header-chain/src/justification.rs index 9f8e9662ea0f0..ff841d70f9bb3 100644 --- a/bridges/primitives/header-chain/src/justification.rs +++ b/bridges/primitives/header-chain/src/justification.rs @@ -113,7 +113,7 @@ where // check if authority has already voted in the same round. // // there's a lot of code in `validate_commit` and `import_precommit` functions inside - // `finality-grandpa` crate (mostly related to reporing equivocations). But the only thing + // `finality-grandpa` crate (mostly related to reporting equivocations). But the only thing // that we care about is that only first vote from the authority is accepted if !votes.insert(signed.id.clone()) { continue @@ -121,11 +121,11 @@ where // everything below this line can't just `continue`, because state is already altered - // all precommits must be for block higher than the target + // precommits aren't allowed for block lower than the target if signed.precommit.target_number < justification.commit.target_number { return Err(Error::PrecommitIsNotCommitDescendant) } - // all precommits must be for target block descendents + // all precommits must be descendants of target block chain = chain .ensure_descendant(&justification.commit.target_hash, &signed.precommit.target_hash)?; // since we know now that the precommit target is the descendant of the justification @@ -193,8 +193,8 @@ impl AncestryChain
{ AncestryChain { parents, unvisited } } - /// Returns `Err(_)` if `precommit_target` is a descendant of the `commit_target` block and - /// `Ok(_)` otherwise. + /// Returns `Ok(_)` if `precommit_target` is a descendant of the `commit_target` block and + /// `Err(_)` otherwise. pub fn ensure_descendant( mut self, commit_target: &Header::Hash, @@ -213,7 +213,7 @@ impl AncestryChain
{ // `Some(parent_hash)` means that the `current_hash` is in the `parents` // container `is_visited_before` means that it has been visited before in // some of previous calls => since we assume that previous call has finished - // with `true`, this also will be finished with `true` + // with `true`, this also will be finished with `true` return Ok(self) } diff --git a/bridges/primitives/messages/src/lib.rs b/bridges/primitives/messages/src/lib.rs index a4f204d238f7d..cef28ecb3679c 100644 --- a/bridges/primitives/messages/src/lib.rs +++ b/bridges/primitives/messages/src/lib.rs @@ -19,8 +19,6 @@ #![cfg_attr(not(feature = "std"), no_std)] // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -// Generated by `DecodeLimit::decode_with_depth_limit` -#![allow(clippy::unnecessary_mut_passed)] use bitvec::prelude::*; use bp_runtime::messages::DispatchFeePayment; @@ -42,7 +40,7 @@ pub use frame_support::weights::Weight; pub enum OperatingMode { /// Normal mode, when all operations are allowed. Normal, - /// The pallet is not accepting outbound messages. Inbound messages and receival proofs + /// The pallet is not accepting outbound messages. Inbound messages and receiving proofs /// are still accepted. /// /// This mode may be used e.g. when bridged chain expects upgrade. Then to avoid dispatch @@ -226,7 +224,7 @@ impl DeliveredMessages { /// dispatch result. pub fn new(nonce: MessageNonce, dispatch_result: bool) -> Self { let mut dispatch_results = BitVec::with_capacity(1); - dispatch_results.push(if dispatch_result { true } else { false }); + dispatch_results.push(dispatch_result); DeliveredMessages { begin: nonce, end: nonce, dispatch_results } } diff --git a/bridges/primitives/runtime/src/chain.rs b/bridges/primitives/runtime/src/chain.rs index 5a7fafe9f67c0..4f88e701fb1ba 100644 --- a/bridges/primitives/runtime/src/chain.rs +++ b/bridges/primitives/runtime/src/chain.rs @@ -154,7 +154,6 @@ pub trait Chain: Send + Sync + 'static { type Balance: AtLeast32BitUnsigned + FixedPointOperand + Parameter - + Parameter + Member + MaybeSerializeDeserialize + Clone diff --git a/bridges/relays/bin-substrate/src/cli/reinit_bridge.rs b/bridges/relays/bin-substrate/src/cli/reinit_bridge.rs index 89470872cb2ee..a6897aaf0ab1e 100644 --- a/bridges/relays/bin-substrate/src/cli/reinit_bridge.rs +++ b/bridges/relays/bin-substrate/src/cli/reinit_bridge.rs @@ -178,7 +178,7 @@ impl ReinitBridge { (current_number + 1, target_number), ) .await?; - let latest_andatory_header_number = headers_to_submit.last().map(|(h, _)| h.number()); + let latest_mandatory_header_number = headers_to_submit.last().map(|(h, _)| h.number()); log::info!( target: "bridge", "Missing {} mandatory {} headers at {}", @@ -281,13 +281,13 @@ impl ReinitBridge { ensure_pallet_operating_mode(&finality_target, is_last_batch).await?; } - if let Some(latest_andatory_header_number) = latest_andatory_header_number { + if let Some(latest_mandatory_header_number) = latest_mandatory_header_number { log::info!( target: "bridge", "Successfully updated best {} header at {} to {}. Pallet is now operational", Source::NAME, Target::NAME, - latest_andatory_header_number, + latest_mandatory_header_number, ); } diff --git a/bridges/relays/lib-substrate-relay/src/conversion_rate_update.rs b/bridges/relays/lib-substrate-relay/src/conversion_rate_update.rs index 469bc5589932b..c7e241626945d 100644 --- a/bridges/relays/lib-substrate-relay/src/conversion_rate_update.rs +++ b/bridges/relays/lib-substrate-relay/src/conversion_rate_update.rs @@ -280,7 +280,7 @@ where genesis_hash, signer: transaction_params.signer, era: TransactionEra::new(best_block_id, transaction_params.mortality), - unsigned: UnsignedTransaction::new(call.into(), transaction_nonce).into(), + unsigned: UnsignedTransaction::new(call.into(), transaction_nonce), })? .encode(), )) diff --git a/bridges/relays/lib-substrate-relay/src/messages_target.rs b/bridges/relays/lib-substrate-relay/src/messages_target.rs index 869a1d280282b..687d5163cb20d 100644 --- a/bridges/relays/lib-substrate-relay/src/messages_target.rs +++ b/bridges/relays/lib-substrate-relay/src/messages_target.rs @@ -192,7 +192,7 @@ where .inbound_lane_data(id) .await? .map(|data| data.relayers) - .unwrap_or_else(|| VecDeque::new()); + .unwrap_or_else(VecDeque::new); let unrewarded_relayers_state = bp_messages::UnrewardedRelayersState { unrewarded_relayer_entries: relayers.len() as _, messages_in_oldest_entry: relayers