Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spaces_around_ranges = false
binop_separator = "Back"
reorder_impl_items = false
match_arm_leading_pipes = "Never"
match_arm_blocks = false
match_arm_blocks = true
match_block_trailing_comma = true
trailing_comma = "Vertical"
trailing_semicolon = true
Expand Down
5 changes: 3 additions & 2 deletions bridges/modules/grandpa/src/call_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,9 @@ pub trait CallSubType<T: Config<I, RuntimeCall = Self>, I: 'static>:

let result = SubmitFinalityProofHelper::<T, I>::check_obsolete_from_extension(&call_info);
match result {
Ok(improved_by) =>
Ok(Some(VerifiedSubmitFinalityProofInfo { base: call_info, improved_by })),
Ok(improved_by) => {
Ok(Some(VerifiedSubmitFinalityProofInfo { base: call_info, improved_by }))
},
Err(Error::<T, I>::OldHeader) => Err(InvalidTransaction::Stale.into()),
Err(_) => Err(InvalidTransaction::Call.into()),
}
Expand Down
5 changes: 3 additions & 2 deletions bridges/modules/messages/src/tests/messages_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ where
for (i, nonce) in message_nonces.into_iter().enumerate() {
let message_key = MessageKey { lane_id: lane, nonce };
let message_payload = match encode_message(nonce, &generate_message(nonce)) {
Some(message_payload) =>
Some(message_payload) => {
if i == 0 {
grow_storage_value(message_payload, &proof_params)
} else {
message_payload
},
}
},
None => continue,
};
let storage_key = storage_keys::message_key(
Expand Down
5 changes: 3 additions & 2 deletions bridges/modules/parachains/src/call_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,13 @@ impl<T: Config<I>, I: 'static> SubmitParachainHeadsHelper<T, I> {
/// Check if the `SubmitParachainHeads` was successfully executed.
pub fn was_successful(update: &SubmitParachainHeadsInfo) -> bool {
match crate::ParasInfo::<T, I>::get(update.para_id) {
Some(stored_best_head) =>
Some(stored_best_head) => {
stored_best_head.best_head_hash ==
BestParaHeadHash {
at_relay_block_number: update.at_relay_block.0,
head_hash: update.para_head_hash,
},
}
},
None => false,
}
}
Expand Down
4 changes: 3 additions & 1 deletion bridges/modules/parachains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,9 @@ pub mod pallet {
if at_relay_block.0.saturating_sub(
best_head.best_head_hash.at_relay_block_number,
) >= free_headers_interval =>
true,
{
true
},
Some(_) => false,
None => true,
};
Expand Down
5 changes: 3 additions & 2 deletions bridges/modules/relayers/src/extension/grandpa_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ where
calls.next().transpose()?.and_then(|c| c.submit_finality_proof_info());

Ok(match (total_calls, relay_finality_call, msgs_call) {
(2, Some(relay_finality_call), Some(msgs_call)) =>
Some(ExtensionCallInfo::RelayFinalityAndMsgs(relay_finality_call, msgs_call)),
(2, Some(relay_finality_call), Some(msgs_call)) => {
Some(ExtensionCallInfo::RelayFinalityAndMsgs(relay_finality_call, msgs_call))
},
(1, None, Some(msgs_call)) => Some(ExtensionCallInfo::Msgs(msgs_call)),
_ => None,
})
Expand Down
5 changes: 3 additions & 2 deletions bridges/modules/relayers/src/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,12 @@ where
"Has registered reward"
);
},
RelayerAccountAction::Slash(relayer, slash_account) =>
RelayerAccountAction::Slash(relayer, slash_account) => {
RelayersPallet::<R, C::BridgeRelayersPalletInstance>::slash_and_deregister(
&relayer,
ExplicitOrAccountParams::Params(slash_account),
),
)
},
}

Ok(Weight::zero())
Expand Down
10 changes: 6 additions & 4 deletions bridges/modules/relayers/src/extension/parachain_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,16 @@ where
let relay_finality_call =
calls.next().transpose()?.and_then(|c| c.submit_finality_proof_info());
Ok(match (total_calls, relay_finality_call, para_finality_call, msgs_call) {
(3, Some(relay_finality_call), Some(para_finality_call), Some(msgs_call)) =>
(3, Some(relay_finality_call), Some(para_finality_call), Some(msgs_call)) => {
Some(ExtensionCallInfo::AllFinalityAndMsgs(
relay_finality_call,
para_finality_call,
msgs_call,
)),
(2, None, Some(para_finality_call), Some(msgs_call)) =>
Some(ExtensionCallInfo::ParachainFinalityAndMsgs(para_finality_call, msgs_call)),
))
},
(2, None, Some(para_finality_call), Some(msgs_call)) => {
Some(ExtensionCallInfo::ParachainFinalityAndMsgs(para_finality_call, msgs_call))
},
(1, None, None, Some(msgs_call)) => Some(ExtensionCallInfo::Msgs(msgs_call)),
_ => None,
})
Expand Down
4 changes: 3 additions & 1 deletion bridges/modules/xcm-bridge-hub-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ impl<T: Config<I>, I: 'static> ExporterFor for Pallet<T, I> {
match T::Bridges::exporter_for(network, remote_location, message) {
Some((bridge_hub_location, maybe_payment))
if bridge_hub_location.eq(&T::SiblingBridgeHubLocation::get()) =>
(bridge_hub_location, maybe_payment),
{
(bridge_hub_location, maybe_payment)
},
_ => {
tracing::trace!(
target: LOG_TARGET,
Expand Down
15 changes: 9 additions & 6 deletions bridges/modules/xcm-bridge-hub/src/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,15 @@ where
let bridge_message = MessagesPallet::<T, I>::validate_message(bridge.lane_id, &blob)
.map_err(|e| {
match e {
Error::LanesManager(ref ei) =>
tracing::error!(target: LOG_TARGET, error=?ei, "LanesManager"),
Error::MessageRejectedByPallet(ref ei) =>
tracing::error!(target: LOG_TARGET, error=?ei, "MessageRejectedByPallet"),
Error::ReceptionConfirmation(ref ei) =>
tracing::error!(target: LOG_TARGET, error=?ei, "ReceptionConfirmation"),
Error::LanesManager(ref ei) => {
tracing::error!(target: LOG_TARGET, error=?ei, "LanesManager")
},
Error::MessageRejectedByPallet(ref ei) => {
tracing::error!(target: LOG_TARGET, error=?ei, "MessageRejectedByPallet")
},
Error::ReceptionConfirmation(ref ei) => {
tracing::error!(target: LOG_TARGET, error=?ei, "ReceptionConfirmation")
},
_ => (),
};

Expand Down
5 changes: 3 additions & 2 deletions bridges/modules/xcm-bridge-hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,9 @@ pub mod pallet {

let lane_id = match maybe_lane_id {
Some(lane_id) => *lane_id,
None =>
locations.calculate_lane_id(xcm::latest::VERSION).expect("Valid locations"),
None => {
locations.calculate_lane_id(xcm::latest::VERSION).expect("Valid locations")
},
};

Pallet::<T, I>::do_open_bridge(locations, lane_id, true)
Expand Down
5 changes: 3 additions & 2 deletions bridges/primitives/messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ impl<RelayerId> InboundLaneData<RelayerId> {
pub fn total_unrewarded_messages(&self) -> MessageNonce {
let relayers = &self.relayers;
match (relayers.front(), relayers.back()) {
(Some(front), Some(back)) =>
(front.messages.begin..=back.messages.end).saturating_len(),
(Some(front), Some(back)) => {
(front.messages.begin..=back.messages.end).saturating_len()
},
_ => 0,
}
}
Expand Down
4 changes: 3 additions & 1 deletion bridges/primitives/relayers/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ where
match call.is_sub_type() {
Some(UtilityCall::<Runtime>::batch_all { ref calls })
if calls.len() <= max_packed_calls as usize =>
calls.iter().collect(),
{
calls.iter().collect()
},
Some(_) => vec![],
None => vec![call],
}
Expand Down
5 changes: 3 additions & 2 deletions bridges/primitives/relayers/src/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ impl<AccountId: Decode + Encode, LaneId: Decode + Encode> IdentifyAccount
fn into_account(self) -> Self::AccountId {
match self {
ExplicitOrAccountParams::Explicit(account_id) => account_id,
ExplicitOrAccountParams::Params(params) =>
PayRewardFromAccount::<(), AccountId, LaneId, ()>::rewards_account(params),
ExplicitOrAccountParams::Params(params) => {
PayRewardFromAccount::<(), AccountId, LaneId, ()>::rewards_account(params)
},
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions bridges/primitives/runtime/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ impl<ChainCall: Clone + Codec> EncodedOrDecodedCall<ChainCall> {
/// Returns decoded call.
pub fn to_decoded(&self) -> Result<ChainCall, codec::Error> {
match self {
Self::Encoded(ref encoded_call) =>
ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into),
Self::Encoded(ref encoded_call) => {
ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into)
},
Self::Decoded(ref decoded_call) => Ok(decoded_call.clone()),
}
}

/// Converts self to decoded call.
pub fn into_decoded(self) -> Result<ChainCall, codec::Error> {
match self {
Self::Encoded(encoded_call) =>
ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into),
Self::Encoded(encoded_call) => {
ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into)
},
Self::Decoded(decoded_call) => Ok(decoded_call),
}
}
Expand Down
9 changes: 6 additions & 3 deletions bridges/primitives/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ impl<BlockNumber: Copy + UniqueSaturatedInto<u64>, BlockHash: Copy>
TransactionEra::Immortal => sp_runtime::generic::Era::immortal(),
// `unique_saturated_into` is fine here - mortality `u64::MAX` is not something we
// expect to see on any chain
TransactionEra::Mortal(header_id, period) =>
sp_runtime::generic::Era::mortal(period as _, header_id.0.unique_saturated_into()),
TransactionEra::Mortal(header_id, period) => {
sp_runtime::generic::Era::mortal(period as _, header_id.0.unique_saturated_into())
},
}
}

Expand Down Expand Up @@ -396,7 +397,9 @@ pub trait OwnedBridgeModule<T: frame_system::Config> {
Ok(RawOrigin::Root) => Ok(()),
Ok(RawOrigin::Signed(ref signer))
if Self::OwnerStorage::get().as_ref() == Some(signer) =>
Ok(()),
{
Ok(())
},
_ => Err(BadOrigin),
}
}
Expand Down
5 changes: 3 additions & 2 deletions bridges/relays/client-substrate/src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ impl<C: Chain> RpcClient<C> {
// same and we need to abort if actual version is > than expected
let actual = SimpleRuntimeVersion::from_runtime_version(&env.runtime_version().await?);
match actual.spec_version.cmp(&expected.spec_version) {
Ordering::Less =>
Err(Error::WaitingForRuntimeUpgrade { chain: C::NAME.into(), expected, actual }),
Ordering::Less => {
Err(Error::WaitingForRuntimeUpgrade { chain: C::NAME.into(), expected, actual })
},
Ordering::Equal => Ok(()),
Ordering::Greater => {
tracing::error!(
Expand Down
5 changes: 3 additions & 2 deletions bridges/relays/client-substrate/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,9 @@ impl MaybeConnectionError for Error {
fn is_connection_error(&self) -> bool {
match *self {
Error::ChannelError(_) => true,
Error::RpcError(ref e) =>
matches!(*e, RpcError::Transport(_) | RpcError::RestartNeeded(_),),
Error::RpcError(ref e) => {
matches!(*e, RpcError::Transport(_) | RpcError::RestartNeeded(_),)
},
Error::ClientNotSynced(_) => true,
Error::UnorderedFinalizedHeaders { .. } => true,
_ => self.nested().map(|e| e.is_connection_error()).unwrap_or(false),
Expand Down
10 changes: 6 additions & 4 deletions bridges/relays/client-substrate/src/transaction_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ impl<C: Chain, E: Environment<C>> TransactionTracker<C, E> {
(TrackedTransactionStatus::Lost, None)
},
Either::Right((invalidation_status, _)) => match invalidation_status {
InvalidationStatus::Finalized(at_block) =>
(TrackedTransactionStatus::Finalized(at_block), Some(invalidation_status)),
InvalidationStatus::Invalid =>
(TrackedTransactionStatus::Lost, Some(invalidation_status)),
InvalidationStatus::Finalized(at_block) => {
(TrackedTransactionStatus::Finalized(at_block), Some(invalidation_status))
},
InvalidationStatus::Invalid => {
(TrackedTransactionStatus::Lost, Some(invalidation_status))
},
InvalidationStatus::Lost => {
// wait for the rest of stall timeout - this way we'll be sure that the
// transaction is actually dead if it has been crafted properly
Expand Down
10 changes: 6 additions & 4 deletions bridges/relays/equivocation/src/block_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ impl<P: EquivocationDetectionPipeline> ReadSyncedHeaders<P> {
target_client: &mut TC,
) -> Result<ReadContext<P>, Self> {
match target_client.synced_headers_finality_info(self.target_block_num).await {
Ok(synced_headers) =>
Ok(ReadContext { target_block_num: self.target_block_num, synced_headers }),
Ok(synced_headers) => {
Ok(ReadContext { target_block_num: self.target_block_num, synced_headers })
},
Err(e) => {
tracing::error!(
target: "bridge",
Expand Down Expand Up @@ -127,13 +128,14 @@ impl<P: EquivocationDetectionPipeline> FindEquivocations<P> {
&synced_header.finality_proof,
finality_proofs_buf.buf().as_slice(),
) {
Ok(equivocations) =>
Ok(equivocations) => {
if !equivocations.is_empty() {
result.push(ReportEquivocations {
source_block_hash: self.context.synced_header_hash,
equivocations,
})
},
}
},
Err(e) => {
tracing::error!(
target: "bridge",
Expand Down
10 changes: 6 additions & 4 deletions bridges/relays/finality/src/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ impl<P: FinalitySyncPipeline> JustifiedHeaderSelector<P> {
) -> Option<JustifiedHeader<P>> {
let (unjustified_headers, maybe_justified_header) = match self {
JustifiedHeaderSelector::Mandatory(justified_header) => return Some(justified_header),
JustifiedHeaderSelector::Regular(unjustified_headers, justified_header) =>
(unjustified_headers, Some(justified_header)),
JustifiedHeaderSelector::Regular(unjustified_headers, justified_header) => {
(unjustified_headers, Some(justified_header))
},
JustifiedHeaderSelector::None(unjustified_headers) => (unjustified_headers, None),
};

Expand Down Expand Up @@ -194,14 +195,15 @@ fn need_to_relay<P: FinalitySyncPipeline>(
match headers_to_relay {
HeadersToRelay::All => true,
HeadersToRelay::Mandatory => header.is_mandatory(),
HeadersToRelay::Free =>
HeadersToRelay::Free => {
header.is_mandatory() ||
free_headers_interval
.map(|free_headers_interval| {
header.number().saturating_sub(info.best_number_at_target) >=
free_headers_interval
})
.unwrap_or(false),
.unwrap_or(false)
},
}
}

Expand Down
20 changes: 12 additions & 8 deletions bridges/relays/lib-substrate-relay/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,14 @@ where
let max_messages_size_in_single_batch = P::TargetChain::max_extrinsic_size() / 3;
let limits = match params.limits {
Some(limits) => limits,
None =>
None => {
select_delivery_transaction_limits_rpc(
&params,
P::TargetChain::max_extrinsic_weight(),
P::SourceChain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
)
.await?,
.await?
},
};
let (max_messages_in_single_batch, max_messages_weight_in_single_batch) =
(limits.max_messages_in_single_batch / 2, limits.max_messages_weight_in_single_batch / 2);
Expand Down Expand Up @@ -702,8 +703,9 @@ mod tests {
impl From<MockUtilityCall<RuntimeCall>> for RuntimeCall {
fn from(value: MockUtilityCall<RuntimeCall>) -> RuntimeCall {
match value {
MockUtilityCall::batch_all(calls) =>
RuntimeCall::Utility(UtilityCall::<RuntimeCall>::batch_all(calls)),
MockUtilityCall::batch_all(calls) => {
RuntimeCall::Utility(UtilityCall::<RuntimeCall>::batch_all(calls))
},
}
}
}
Expand Down Expand Up @@ -755,8 +757,9 @@ mod tests {
);
match relayer_call_builder_receive_messages_proof {
RuntimeCall::BridgeMessages(call) => match call {
call @ CodegenBridgeMessagesCall::receive_messages_proof { .. } =>
assert_eq!(pallet_receive_messages_proof.encode(), call.encode()),
call @ CodegenBridgeMessagesCall::receive_messages_proof { .. } => {
assert_eq!(pallet_receive_messages_proof.encode(), call.encode())
},
_ => panic!("Unexpected CodegenBridgeMessagesCall type"),
},
_ => panic!("Unexpected RuntimeCall type"),
Expand Down Expand Up @@ -805,8 +808,9 @@ mod tests {
);
match relayer_call_builder_receive_messages_delivery_proof {
RuntimeCall::BridgeMessages(call) => match call {
call @ CodegenBridgeMessagesCall::receive_messages_delivery_proof { .. } =>
assert_eq!(pallet_receive_messages_delivery_proof.encode(), call.encode()),
call @ CodegenBridgeMessagesCall::receive_messages_delivery_proof { .. } => {
assert_eq!(pallet_receive_messages_delivery_proof.encode(), call.encode())
},
_ => panic!("Unexpected CodegenBridgeMessagesCall type"),
},
_ => panic!("Unexpected RuntimeCall type"),
Expand Down
Loading
Loading