Skip to content

Commit

Permalink
cargo +nightly fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ndkazu committed Sep 5, 2024
1 parent a52c9d4 commit 73860e6
Show file tree
Hide file tree
Showing 60 changed files with 257 additions and 178 deletions.
37 changes: 19 additions & 18 deletions bridges/modules/xcm-bridge-hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,25 +1474,26 @@ mod tests {
let lane_id = LaneId::from_inner(Either::Left(H256::default()));
let lane_id_mismatch = LaneId::from_inner(Either::Left(H256::from([1u8; 32])));

let test_bridge_state = |id,
bridge,
(lane_id, bridge_id),
(inbound_lane_id, outbound_lane_id),
expected_error: Option<TryRuntimeError>| {
Bridges::<TestRuntime, ()>::insert(id, bridge);
LaneToBridge::<TestRuntime, ()>::insert(lane_id, bridge_id);
let test_bridge_state =
|id,
bridge,
(lane_id, bridge_id),
(inbound_lane_id, outbound_lane_id),
expected_error: Option<TryRuntimeError>| {
Bridges::<TestRuntime, ()>::insert(id, bridge);
LaneToBridge::<TestRuntime, ()>::insert(lane_id, bridge_id);

let lanes_manager = LanesManagerOf::<TestRuntime, ()>::new();
lanes_manager.create_inbound_lane(inbound_lane_id).unwrap();
lanes_manager.create_outbound_lane(outbound_lane_id).unwrap();

let result = XcmOverBridge::do_try_state();
if let Some(e) = expected_error {
assert_err!(result, e);
} else {
assert_ok!(result);
}
};
let lanes_manager = LanesManagerOf::<TestRuntime, ()>::new();
lanes_manager.create_inbound_lane(inbound_lane_id).unwrap();
lanes_manager.create_outbound_lane(outbound_lane_id).unwrap();

let result = XcmOverBridge::do_try_state();
if let Some(e) = expected_error {
assert_err!(result, e);
} else {
assert_ok!(result);
}
};
let cleanup = |bridge_id, lane_ids| {
Bridges::<TestRuntime, ()>::remove(bridge_id);
for lane_id in lane_ids {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ impl<'a, P: SubstrateParachainsPipeline, SourceRelayClnt, TargetClnt>
for (
&'a OnDemandParachainsRelay<P, SourceRelayClnt, TargetClnt>,
&'a ParachainsSource<P, SourceRelayClnt>,
) where
)
where
SourceRelayClnt: Client<P::SourceRelayChain>,
TargetClnt: Client<P::TargetChain>,
{
Expand Down
6 changes: 4 additions & 2 deletions bridges/relays/messages/src/message_race_strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ impl<
TargetHeaderHash,
SourceNoncesRange,
Proof,
> where
>
where
SourceHeaderHash: Clone,
SourceHeaderNumber: Clone + Ord,
SourceNoncesRange: NoncesRange,
Expand Down Expand Up @@ -189,7 +190,8 @@ impl<
TargetHeaderHash,
SourceNoncesRange,
Proof,
> where
>
where
SourceHeaderHash: Clone + Debug + Send + Sync,
SourceHeaderNumber: Clone + Ord + Debug + Send + Sync,
SourceNoncesRange: NoncesRange + Debug + Send + Sync,
Expand Down
3 changes: 2 additions & 1 deletion bridges/snowbridge/primitives/router/src/inbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ impl<CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, AccountId,
InboundQueuePalletInstance,
AccountId,
Balance,
> where
>
where
CreateAssetCall: Get<CallIndex>,
CreateAssetDeposit: Get<u128>,
InboundQueuePalletInstance: Get<u8>,
Expand Down
3 changes: 2 additions & 1 deletion bridges/snowbridge/runtime/runtime-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ impl<Balance, AccountId, FeeAssetLocation, EthereumNetwork, AssetTransactor, Fee
EthereumNetwork,
AssetTransactor,
FeeProvider,
> where
>
where
Balance: BaseArithmetic + Unsigned + Copy + From<u128> + Into<u128> + Debug,
AccountId: Clone + FullCodec,
FeeAssetLocation: Get<Location>,
Expand Down
3 changes: 2 additions & 1 deletion cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ pub mod pallet {

let maximum_channels = host_config
.hrmp_max_message_num_per_candidate
.min(<AnnouncedHrmpMessagesPerCandidate<T>>::take()) as usize;
.min(<AnnouncedHrmpMessagesPerCandidate<T>>::take())
as usize;

// Note: this internally calls the `GetChannelInfo` implementation for this
// pallet, which draws on the `RelevantMessagingState`. That in turn has
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() {
let delivery_fees = AssetHubRococo::execute_with(|| {
xcm_helpers::teleport_assets_delivery_fees::<
<AssetHubRococoXcmConfig as xcm_executor::Config>::XcmSender,
>(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest)
>(
test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest
)
});

// Sender's balance is reduced
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() {
let delivery_fees = AssetHubWestend::execute_with(|| {
xcm_helpers::teleport_assets_delivery_fees::<
<AssetHubWestendXcmConfig as xcm_executor::Config>::XcmSender,
>(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest)
>(
test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest
)
});

// Sender's balance is reduced
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() {
let delivery_fees = PeopleRococo::execute_with(|| {
xcm_helpers::teleport_assets_delivery_fees::<
<PeopleRococoXcmConfig as xcm_executor::Config>::XcmSender,
>(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest)
>(
test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest
)
});

// Sender's balance is reduced
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ fn limited_teleport_native_assets_from_system_para_to_relay_fails() {
let delivery_fees = PeopleWestend::execute_with(|| {
xcm_helpers::teleport_assets_delivery_fees::<
<PeopleWestendXcmConfig as xcm_executor::Config>::XcmSender,
>(test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest)
>(
test.args.assets.clone(), 0, test.args.weight_limit, test.args.beneficiary, test.args.dest
)
});

// Sender's balance is reduced
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,8 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. } |
RuntimeCall::NftFractionalization { .. } |
RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. }
RuntimeCall::Nfts { .. } |
RuntimeCall::Uniques { .. }
)
},
ProxyType::AssetOwner => matches!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,8 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. } |
RuntimeCall::NftFractionalization { .. } |
RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. }
RuntimeCall::Nfts { .. } |
RuntimeCall::Uniques { .. }
)
},
ProxyType::AssetOwner => matches!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,8 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
.with_balances(vec![(
foreign_creator_as_account_id.clone(),
existential_deposit +
asset_deposit + metadata_deposit_base +
asset_deposit +
metadata_deposit_base +
metadata_deposit_per_byte_eta +
buy_execution_fee_amount.into() +
buy_execution_fee_amount.into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,12 @@ pub fn message_dispatch_routing_works<

// 2. this message is sent from other global consensus with destination of this Runtime
// sibling parachain (HRMP)
let bridging_message = test_data::simulate_message_exporter_on_bridged_chain::<
BridgedNetwork,
NetworkWithParentCount<RuntimeNetwork, NetworkDistanceAsParentCount>,
AlwaysLatest,
>((RuntimeNetwork::get(), [Parachain(sibling_parachain_id)].into()));
let bridging_message =
test_data::simulate_message_exporter_on_bridged_chain::<
BridgedNetwork,
NetworkWithParentCount<RuntimeNetwork, NetworkDistanceAsParentCount>,
AlwaysLatest,
>((RuntimeNetwork::get(), [Parachain(sibling_parachain_id)].into()));

// 2.1. WITHOUT opened hrmp channel -> RoutingError
let result =
Expand Down
6 changes: 4 additions & 2 deletions cumulus/primitives/utility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ impl<
FungiblesAssetMatcher,
OnUnbalanced,
AccountId,
> where
>
where
Fungibles::Balance: Into<u128>,
{
fn new() -> Self {
Expand Down Expand Up @@ -541,7 +542,8 @@ impl<
FungiblesAssetMatcher,
OnUnbalanced,
AccountId,
> where
>
where
Fungibles::Balance: Into<u128>,
{
fn drop(&mut self) {
Expand Down
7 changes: 6 additions & 1 deletion polkadot/node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2415,7 +2415,12 @@ fn schedule_wakeup_action(
last_assignment_tick.map(|l| l + APPROVAL_DELAY).filter(|t| t > &tick_now),
next_no_show,
)
.map(|tick| Action::ScheduleWakeup { block_hash, block_number, candidate_hash, tick })
.map(|tick| Action::ScheduleWakeup {
block_hash,
block_number,
candidate_hash,
tick,
})
},
RequiredTranches::Pending { considered, next_no_show, clock_drift, .. } => {
// select the minimum of `next_no_show`, or the tick of the next non-empty tranche
Expand Down
3 changes: 2 additions & 1 deletion polkadot/node/core/approval-voting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ where
_relay_vrf_story: polkadot_node_primitives::approval::v1::RelayVRFStory,
_assignment: &polkadot_node_primitives::approval::v2::AssignmentCertV2,
_backing_groups: Vec<polkadot_primitives::GroupIndex>,
) -> Result<polkadot_node_primitives::approval::v1::DelayTranche, criteria::InvalidAssignment> {
) -> Result<polkadot_node_primitives::approval::v1::DelayTranche, criteria::InvalidAssignment>
{
self.1(validator_index)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ fn try_restrict(worker_info: &WorkerInfo) -> Result<()> {
libc::MS_BIND |
libc::MS_REC | libc::MS_NOEXEC |
libc::MS_NODEV | libc::MS_NOSUID |
libc::MS_NOATIME | additional_flags,
libc::MS_NOATIME |
additional_flags,
ptr::null(), // ignored when MS_BIND is used
) < 0
{
Expand Down
3 changes: 2 additions & 1 deletion polkadot/node/network/approval-distribution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,8 @@ impl AssignmentCriteria for MockAssignmentCriteria {
_relay_vrf_story: polkadot_node_primitives::approval::v1::RelayVRFStory,
_assignment: &polkadot_node_primitives::approval::v2::AssignmentCertV2,
_backing_groups: Vec<polkadot_primitives::GroupIndex>,
) -> Result<polkadot_node_primitives::approval::v1::DelayTranche, criteria::InvalidAssignment> {
) -> Result<polkadot_node_primitives::approval::v1::DelayTranche, criteria::InvalidAssignment>
{
self.tranche
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ impl FetchChunks {
state: &mut State,
common_params: &RecoveryParams,
) -> Result<AvailableData, RecoveryError> {
let recovery_duration = common_params
.metrics
.time_erasure_recovery(RecoveryStrategy::<Sender>::strategy_type(self));
let recovery_duration =
common_params
.metrics
.time_erasure_recovery(RecoveryStrategy::<Sender>::strategy_type(self));

// Send request to reconstruct available data from chunks.
let (avilable_data_tx, available_data_rx) = oneshot::channel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ use crate::{
ErasureTask, PostRecoveryCheck, LOG_TARGET,
};

use futures::{channel::oneshot, SinkExt};
use polkadot_node_network_protocol::request_response::{
self as req_res, outgoing::RequestError, OutgoingRequest, Recipient, Requests,
};
use polkadot_node_primitives::AvailableData;
use polkadot_node_subsystem::{messages::NetworkBridgeTxMessage, overseer, RecoveryError};
use polkadot_primitives::ValidatorIndex;
use sc_network::{IfDisconnected, OutboundFailure, RequestFailure};
use sc_network::request_responses::CustomOutboundFailure;
use futures::{channel::oneshot, SinkExt};
use rand::seq::SliceRandom;
use sc_network::{
request_responses::CustomOutboundFailure, IfDisconnected, OutboundFailure, RequestFailure,
};

/// Parameters specific to the `FetchFull` strategy.
pub struct FetchFullParams {
Expand Down Expand Up @@ -153,7 +154,9 @@ impl<Sender: overseer::AvailabilityRecoverySenderTrait> RecoveryStrategy<Sender>
RequestError::InvalidResponse(_) =>
common_params.metrics.on_full_request_invalid(),
RequestError::NetworkError(req_failure) => {
if let RequestFailure::Network(CustomOutboundFailure::Timeout) = req_failure {
if let RequestFailure::Network(CustomOutboundFailure::Timeout) =
req_failure
{
common_params.metrics.on_full_request_timeout();
} else {
common_params.metrics.on_full_request_error();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use crate::{
};

use codec::Decode;
use sc_network::request_responses::CustomOutboundFailure;
use futures::{channel::oneshot, SinkExt};
use polkadot_erasure_coding::branch_hash;
#[cfg(not(test))]
Expand All @@ -44,7 +43,10 @@ use polkadot_node_subsystem::{
overseer, RecoveryError,
};
use polkadot_primitives::{AuthorityDiscoveryId, BlakeTwo256, ChunkIndex, HashT, ValidatorIndex};
use sc_network::{IfDisconnected, OutboundFailure, ProtocolName, RequestFailure};
use sc_network::{
request_responses::CustomOutboundFailure, IfDisconnected, OutboundFailure, ProtocolName,
RequestFailure,
};
use std::{
collections::{BTreeMap, HashMap, VecDeque},
time::Duration,
Expand Down
16 changes: 8 additions & 8 deletions polkadot/node/subsystem-bench/src/lib/statement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ fn build_overseer(
state.pvd.clone(),
state.own_backing_group.clone(),
);
let (statement_req_receiver, statement_req_cfg) = IncomingRequest::get_config_receiver::<
Block,
sc_network::NetworkWorker<Block, Hash>,
>(&ReqProtocolNames::new(GENESIS_HASH, None));
let (candidate_req_receiver, candidate_req_cfg) = IncomingRequest::get_config_receiver::<
Block,
sc_network::NetworkWorker<Block, Hash>,
>(&ReqProtocolNames::new(GENESIS_HASH, None));
let (statement_req_receiver, statement_req_cfg) =
IncomingRequest::get_config_receiver::<Block, sc_network::NetworkWorker<Block, Hash>>(
&ReqProtocolNames::new(GENESIS_HASH, None),
);
let (candidate_req_receiver, candidate_req_cfg) =
IncomingRequest::get_config_receiver::<Block, sc_network::NetworkWorker<Block, Hash>>(
&ReqProtocolNames::new(GENESIS_HASH, None),
);
let keystore = make_keystore();
let subsystem = StatementDistributionSubsystem::new(
keystore.clone(),
Expand Down
3 changes: 2 additions & 1 deletion polkadot/node/subsystem-types/src/runtime_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ where
fn number(
&self,
hash: Block::Hash,
) -> sc_client_api::blockchain::Result<Option<<<Block as BlockT>::Header as HeaderT>::Number>> {
) -> sc_client_api::blockchain::Result<Option<<<Block as BlockT>::Header as HeaderT>::Number>>
{
self.client.number(hash)
}

Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/parachains/src/hrmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ impl<T: Config> Pallet<T> {
outgoing_paras.len() as u32
))
.saturating_add(<T as Config>::WeightInfo::force_process_hrmp_close(
outgoing_paras.len() as u32
outgoing_paras.len() as u32,
))
}

Expand Down
Loading

0 comments on commit 73860e6

Please sign in to comment.