Skip to content

Commit d04b018

Browse files
acatangiubkchr
authored andcommitted
Few typos and clippy fixes (#1362)
* fix typos * clippy fixes
1 parent 133934d commit d04b018

File tree

10 files changed

+26
-31
lines changed

10 files changed

+26
-31
lines changed

bridges/bin/runtime-common/src/messages.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,16 @@ pub mod source {
327327
frame_system::RawOrigin<AccountIdOf<ThisChain<B>>>,
328328
OriginOf<ThisChain<B>>,
329329
> = submitter.clone().into();
330-
match raw_origin_or_err {
331-
Ok(raw_origin) =>
332-
pallet_bridge_dispatch::verify_message_origin(&raw_origin, payload)
333-
.map(drop)
334-
.map_err(|_| BAD_ORIGIN)?,
335-
Err(_) => {
336-
// so what it means that we've failed to convert origin to the
337-
// `frame_system::RawOrigin`? now it means that the custom pallet origin has
338-
// been used to send the message. Do we need to verify it? The answer is no,
339-
// because pallet may craft any origin (e.g. root) && we can't verify whether it
340-
// is valid, or not.
341-
},
330+
if let Ok(raw_origin) = raw_origin_or_err {
331+
pallet_bridge_dispatch::verify_message_origin(&raw_origin, payload)
332+
.map(drop)
333+
.map_err(|_| BAD_ORIGIN)?;
334+
} else {
335+
// so what it means that we've failed to convert origin to the
336+
// `frame_system::RawOrigin`? now it means that the custom pallet origin has
337+
// been used to send the message. Do we need to verify it? The answer is no,
338+
// because pallet may craft any origin (e.g. root) && we can't verify whether it
339+
// is valid, or not.
342340
};
343341

344342
let minimal_fee_in_this_tokens = estimate_message_dispatch_and_delivery_fee::<B>(

bridges/modules/grandpa/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub mod pallet {
166166
try_enact_authority_change::<T, I>(&finality_target, set_id)?;
167167
<RequestCount<T, I>>::mutate(|count| *count += 1);
168168
insert_header::<T, I>(*finality_target, hash);
169-
log::info!(target: "runtime::bridge-grandpa", "Succesfully imported finalized header with hash {:?}!", hash);
169+
log::info!(target: "runtime::bridge-grandpa", "Successfully imported finalized header with hash {:?}!", hash);
170170

171171
// mandatory header is a header that changes authorities set. The pallet can't go
172172
// further without importing this header. So every bridge MUST import mandatory headers.

bridges/modules/messages/src/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl SenderOrigin<AccountId> for Origin {
198198
fn linked_account(&self) -> Option<AccountId> {
199199
match self.caller {
200200
OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) =>
201-
Some(submitter.clone()),
201+
Some(*submitter),
202202
_ => None,
203203
}
204204
}

bridges/modules/messages/src/outbound_lane.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub struct OutboundLane<S> {
7474
}
7575

7676
impl<S: OutboundLaneStorage> OutboundLane<S> {
77-
/// Create new inbound lane backed by given storage.
77+
/// Create new outbound lane backed by given storage.
7878
pub fn new(storage: S) -> Self {
7979
OutboundLane { storage }
8080
}

bridges/primitives/header-chain/src/justification.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@ where
113113
// check if authority has already voted in the same round.
114114
//
115115
// there's a lot of code in `validate_commit` and `import_precommit` functions inside
116-
// `finality-grandpa` crate (mostly related to reporing equivocations). But the only thing
116+
// `finality-grandpa` crate (mostly related to reporting equivocations). But the only thing
117117
// that we care about is that only first vote from the authority is accepted
118118
if !votes.insert(signed.id.clone()) {
119119
continue
120120
}
121121

122122
// everything below this line can't just `continue`, because state is already altered
123123

124-
// all precommits must be for block higher than the target
124+
// precommits aren't allowed for block lower than the target
125125
if signed.precommit.target_number < justification.commit.target_number {
126126
return Err(Error::PrecommitIsNotCommitDescendant)
127127
}
128-
// all precommits must be for target block descendents
128+
// all precommits must be descendants of target block
129129
chain = chain
130130
.ensure_descendant(&justification.commit.target_hash, &signed.precommit.target_hash)?;
131131
// since we know now that the precommit target is the descendant of the justification
@@ -193,8 +193,8 @@ impl<Header: HeaderT> AncestryChain<Header> {
193193
AncestryChain { parents, unvisited }
194194
}
195195

196-
/// Returns `Err(_)` if `precommit_target` is a descendant of the `commit_target` block and
197-
/// `Ok(_)` otherwise.
196+
/// Returns `Ok(_)` if `precommit_target` is a descendant of the `commit_target` block and
197+
/// `Err(_)` otherwise.
198198
pub fn ensure_descendant(
199199
mut self,
200200
commit_target: &Header::Hash,
@@ -213,7 +213,7 @@ impl<Header: HeaderT> AncestryChain<Header> {
213213
// `Some(parent_hash)` means that the `current_hash` is in the `parents`
214214
// container `is_visited_before` means that it has been visited before in
215215
// some of previous calls => since we assume that previous call has finished
216-
// with `true`, this also will be finished with `true`
216+
// with `true`, this also will be finished with `true`
217217
return Ok(self)
218218
}
219219

bridges/primitives/messages/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#![cfg_attr(not(feature = "std"), no_std)]
2020
// RuntimeApi generated functions
2121
#![allow(clippy::too_many_arguments)]
22-
// Generated by `DecodeLimit::decode_with_depth_limit`
23-
#![allow(clippy::unnecessary_mut_passed)]
2422

2523
use bitvec::prelude::*;
2624
use bp_runtime::messages::DispatchFeePayment;
@@ -42,7 +40,7 @@ pub use frame_support::weights::Weight;
4240
pub enum OperatingMode {
4341
/// Normal mode, when all operations are allowed.
4442
Normal,
45-
/// The pallet is not accepting outbound messages. Inbound messages and receival proofs
43+
/// The pallet is not accepting outbound messages. Inbound messages and receiving proofs
4644
/// are still accepted.
4745
///
4846
/// This mode may be used e.g. when bridged chain expects upgrade. Then to avoid dispatch
@@ -226,7 +224,7 @@ impl DeliveredMessages {
226224
/// dispatch result.
227225
pub fn new(nonce: MessageNonce, dispatch_result: bool) -> Self {
228226
let mut dispatch_results = BitVec::with_capacity(1);
229-
dispatch_results.push(if dispatch_result { true } else { false });
227+
dispatch_results.push(dispatch_result);
230228
DeliveredMessages { begin: nonce, end: nonce, dispatch_results }
231229
}
232230

bridges/primitives/runtime/src/chain.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ pub trait Chain: Send + Sync + 'static {
154154
type Balance: AtLeast32BitUnsigned
155155
+ FixedPointOperand
156156
+ Parameter
157-
+ Parameter
158157
+ Member
159158
+ MaybeSerializeDeserialize
160159
+ Clone

bridges/relays/bin-substrate/src/cli/reinit_bridge.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl ReinitBridge {
178178
(current_number + 1, target_number),
179179
)
180180
.await?;
181-
let latest_andatory_header_number = headers_to_submit.last().map(|(h, _)| h.number());
181+
let latest_mandatory_header_number = headers_to_submit.last().map(|(h, _)| h.number());
182182
log::info!(
183183
target: "bridge",
184184
"Missing {} mandatory {} headers at {}",
@@ -281,13 +281,13 @@ impl ReinitBridge {
281281
ensure_pallet_operating_mode(&finality_target, is_last_batch).await?;
282282
}
283283

284-
if let Some(latest_andatory_header_number) = latest_andatory_header_number {
284+
if let Some(latest_mandatory_header_number) = latest_mandatory_header_number {
285285
log::info!(
286286
target: "bridge",
287287
"Successfully updated best {} header at {} to {}. Pallet is now operational",
288288
Source::NAME,
289289
Target::NAME,
290-
latest_andatory_header_number,
290+
latest_mandatory_header_number,
291291
);
292292
}
293293

bridges/relays/lib-substrate-relay/src/conversion_rate_update.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ where
280280
genesis_hash,
281281
signer: transaction_params.signer,
282282
era: TransactionEra::new(best_block_id, transaction_params.mortality),
283-
unsigned: UnsignedTransaction::new(call.into(), transaction_nonce).into(),
283+
unsigned: UnsignedTransaction::new(call.into(), transaction_nonce),
284284
})?
285285
.encode(),
286286
))

bridges/relays/lib-substrate-relay/src/messages_target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ where
192192
.inbound_lane_data(id)
193193
.await?
194194
.map(|data| data.relayers)
195-
.unwrap_or_else(|| VecDeque::new());
195+
.unwrap_or_else(VecDeque::new);
196196
let unrewarded_relayers_state = bp_messages::UnrewardedRelayersState {
197197
unrewarded_relayer_entries: relayers.len() as _,
198198
messages_in_oldest_entry: relayers

0 commit comments

Comments
 (0)