Skip to content

Commit

Permalink
Few typos and clippy fixes (paritytech#1362)
Browse files Browse the repository at this point in the history
* fix typos

* clippy fixes
  • Loading branch information
acatangiu authored and serban300 committed Apr 9, 2024
1 parent 37b8119 commit 49b8485
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 31 deletions.
22 changes: 10 additions & 12 deletions bridges/bin/runtime-common/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,16 @@ pub mod source {
frame_system::RawOrigin<AccountIdOf<ThisChain<B>>>,
OriginOf<ThisChain<B>>,
> = 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::<B>(
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub mod pallet {
try_enact_authority_change::<T, I>(&finality_target, set_id)?;
<RequestCount<T, I>>::mutate(|count| *count += 1);
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
// further without importing this header. So every bridge MUST import mandatory headers.
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/messages/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl SenderOrigin<AccountId> for Origin {
fn linked_account(&self) -> Option<AccountId> {
match self.caller {
OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) =>
Some(submitter.clone()),
Some(*submitter),
_ => None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/modules/messages/src/outbound_lane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub struct 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 {
OutboundLane { storage }
}
Expand Down
12 changes: 6 additions & 6 deletions bridges/primitives/header-chain/src/justification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ 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
}

// 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
Expand Down Expand Up @@ -193,8 +193,8 @@ impl<Header: HeaderT> AncestryChain<Header> {
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,
Expand All @@ -213,7 +213,7 @@ impl<Header: HeaderT> AncestryChain<Header> {
// `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)
}

Expand Down
6 changes: 2 additions & 4 deletions bridges/primitives/messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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 }
}

Expand Down
1 change: 0 additions & 1 deletion bridges/primitives/runtime/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ pub trait Chain: Send + Sync + 'static {
type Balance: AtLeast32BitUnsigned
+ FixedPointOperand
+ Parameter
+ Parameter
+ Member
+ MaybeSerializeDeserialize
+ Clone
Expand Down
6 changes: 3 additions & 3 deletions bridges/relays/bin-substrate/src/cli/reinit_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}",
Expand Down Expand Up @@ -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,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
))
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/lib-substrate-relay/src/messages_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 49b8485

Please sign in to comment.