Few typos and clippy fixes (#1362)

* fix typos

* clippy fixes
This commit is contained in:
Adrian Catangiu
2022-03-22 14:59:58 +02:00
committed by Bastian Köcher
parent 133934df7c
commit d04b018630
10 changed files with 26 additions and 31 deletions
+10 -12
View File
@@ -327,18 +327,16 @@ pub mod source {
frame_system::RawOrigin<AccountIdOf<ThisChain<B>>>, frame_system::RawOrigin<AccountIdOf<ThisChain<B>>>,
OriginOf<ThisChain<B>>, OriginOf<ThisChain<B>>,
> = submitter.clone().into(); > = submitter.clone().into();
match raw_origin_or_err { if let Ok(raw_origin) = raw_origin_or_err {
Ok(raw_origin) => pallet_bridge_dispatch::verify_message_origin(&raw_origin, payload)
pallet_bridge_dispatch::verify_message_origin(&raw_origin, payload) .map(drop)
.map(drop) .map_err(|_| BAD_ORIGIN)?;
.map_err(|_| BAD_ORIGIN)?, } else {
Err(_) => { // so what it means that we've failed to convert origin to the
// 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
// `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,
// 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
// because pallet may craft any origin (e.g. root) && we can't verify whether it // is valid, or not.
// is valid, or not.
},
}; };
let minimal_fee_in_this_tokens = estimate_message_dispatch_and_delivery_fee::<B>( let minimal_fee_in_this_tokens = estimate_message_dispatch_and_delivery_fee::<B>(
+1 -1
View File
@@ -166,7 +166,7 @@ pub mod pallet {
try_enact_authority_change::<T, I>(&finality_target, set_id)?; try_enact_authority_change::<T, I>(&finality_target, set_id)?;
<RequestCount<T, I>>::mutate(|count| *count += 1); <RequestCount<T, I>>::mutate(|count| *count += 1);
insert_header::<T, I>(*finality_target, hash); insert_header::<T, I>(*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 // 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. // further without importing this header. So every bridge MUST import mandatory headers.
+1 -1
View File
@@ -198,7 +198,7 @@ impl SenderOrigin<AccountId> for Origin {
fn linked_account(&self) -> Option<AccountId> { fn linked_account(&self) -> Option<AccountId> {
match self.caller { match self.caller {
OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) => OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) =>
Some(submitter.clone()), Some(*submitter),
_ => None, _ => None,
} }
} }
@@ -74,7 +74,7 @@ pub struct OutboundLane<S> {
} }
impl<S: OutboundLaneStorage> OutboundLane<S> { impl<S: OutboundLaneStorage> OutboundLane<S> {
/// Create new inbound lane backed by given storage. /// Create new outbound lane backed by given storage.
pub fn new(storage: S) -> Self { pub fn new(storage: S) -> Self {
OutboundLane { storage } OutboundLane { storage }
} }
@@ -113,7 +113,7 @@ where
// check if authority has already voted in the same round. // check if authority has already voted in the same round.
// //
// there's a lot of code in `validate_commit` and `import_precommit` functions inside // 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 // that we care about is that only first vote from the authority is accepted
if !votes.insert(signed.id.clone()) { if !votes.insert(signed.id.clone()) {
continue continue
@@ -121,11 +121,11 @@ where
// everything below this line can't just `continue`, because state is already altered // 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 { if signed.precommit.target_number < justification.commit.target_number {
return Err(Error::PrecommitIsNotCommitDescendant) return Err(Error::PrecommitIsNotCommitDescendant)
} }
// all precommits must be for target block descendents // all precommits must be descendants of target block
chain = chain chain = chain
.ensure_descendant(&justification.commit.target_hash, &signed.precommit.target_hash)?; .ensure_descendant(&justification.commit.target_hash, &signed.precommit.target_hash)?;
// since we know now that the precommit target is the descendant of the justification // since we know now that the precommit target is the descendant of the justification
@@ -193,8 +193,8 @@ impl<Header: HeaderT> AncestryChain<Header> {
AncestryChain { parents, unvisited } AncestryChain { parents, unvisited }
} }
/// Returns `Err(_)` if `precommit_target` is a descendant of the `commit_target` block and /// Returns `Ok(_)` if `precommit_target` is a descendant of the `commit_target` block and
/// `Ok(_)` otherwise. /// `Err(_)` otherwise.
pub fn ensure_descendant( pub fn ensure_descendant(
mut self, mut self,
commit_target: &Header::Hash, commit_target: &Header::Hash,
@@ -213,7 +213,7 @@ impl<Header: HeaderT> AncestryChain<Header> {
// `Some(parent_hash)` means that the `current_hash` is in the `parents` // `Some(parent_hash)` means that the `current_hash` is in the `parents`
// container `is_visited_before` means that it has been visited before in // container `is_visited_before` means that it has been visited before in
// some of previous calls => since we assume that previous call has finished // 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) return Ok(self)
} }
+2 -4
View File
@@ -19,8 +19,6 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// RuntimeApi generated functions // RuntimeApi generated functions
#![allow(clippy::too_many_arguments)] #![allow(clippy::too_many_arguments)]
// Generated by `DecodeLimit::decode_with_depth_limit`
#![allow(clippy::unnecessary_mut_passed)]
use bitvec::prelude::*; use bitvec::prelude::*;
use bp_runtime::messages::DispatchFeePayment; use bp_runtime::messages::DispatchFeePayment;
@@ -42,7 +40,7 @@ pub use frame_support::weights::Weight;
pub enum OperatingMode { pub enum OperatingMode {
/// Normal mode, when all operations are allowed. /// Normal mode, when all operations are allowed.
Normal, 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. /// are still accepted.
/// ///
/// This mode may be used e.g. when bridged chain expects upgrade. Then to avoid dispatch /// This mode may be used e.g. when bridged chain expects upgrade. Then to avoid dispatch
@@ -226,7 +224,7 @@ impl DeliveredMessages {
/// dispatch result. /// dispatch result.
pub fn new(nonce: MessageNonce, dispatch_result: bool) -> Self { pub fn new(nonce: MessageNonce, dispatch_result: bool) -> Self {
let mut dispatch_results = BitVec::with_capacity(1); 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 } DeliveredMessages { begin: nonce, end: nonce, dispatch_results }
} }
-1
View File
@@ -154,7 +154,6 @@ pub trait Chain: Send + Sync + 'static {
type Balance: AtLeast32BitUnsigned type Balance: AtLeast32BitUnsigned
+ FixedPointOperand + FixedPointOperand
+ Parameter + Parameter
+ Parameter
+ Member + Member
+ MaybeSerializeDeserialize + MaybeSerializeDeserialize
+ Clone + Clone
@@ -178,7 +178,7 @@ impl ReinitBridge {
(current_number + 1, target_number), (current_number + 1, target_number),
) )
.await?; .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!( log::info!(
target: "bridge", target: "bridge",
"Missing {} mandatory {} headers at {}", "Missing {} mandatory {} headers at {}",
@@ -281,13 +281,13 @@ impl ReinitBridge {
ensure_pallet_operating_mode(&finality_target, is_last_batch).await?; 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!( log::info!(
target: "bridge", target: "bridge",
"Successfully updated best {} header at {} to {}. Pallet is now operational", "Successfully updated best {} header at {} to {}. Pallet is now operational",
Source::NAME, Source::NAME,
Target::NAME, Target::NAME,
latest_andatory_header_number, latest_mandatory_header_number,
); );
} }
@@ -280,7 +280,7 @@ where
genesis_hash, genesis_hash,
signer: transaction_params.signer, signer: transaction_params.signer,
era: TransactionEra::new(best_block_id, transaction_params.mortality), 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(), .encode(),
)) ))
@@ -192,7 +192,7 @@ where
.inbound_lane_data(id) .inbound_lane_data(id)
.await? .await?
.map(|data| data.relayers) .map(|data| data.relayers)
.unwrap_or_else(|| VecDeque::new()); .unwrap_or_else(VecDeque::new);
let unrewarded_relayers_state = bp_messages::UnrewardedRelayersState { let unrewarded_relayers_state = bp_messages::UnrewardedRelayersState {
unrewarded_relayer_entries: relayers.len() as _, unrewarded_relayer_entries: relayers.len() as _,
messages_in_oldest_entry: relayers messages_in_oldest_entry: relayers