Skip to content

Commit

Permalink
fmt fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
smohan-dw committed Aug 17, 2024
1 parent 0de8568 commit 3461027
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 171 deletions.
20 changes: 8 additions & 12 deletions loom/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,10 @@ impl SubstrateCli for Cli {
let id = if id.is_empty() { "loom" } else { id };

Ok(match id {
"dev" | "loom-dev" => {
Box::new(cord_loom_service::chain_spec::loom_development_config()?)
},
"loom" | "loom-local" | "loom-local-testnet" => {
Box::new(cord_loom_service::chain_spec::loom_local_testnet_config()?)
},
"dev" | "loom-dev" =>
Box::new(cord_loom_service::chain_spec::loom_development_config()?),
"loom" | "loom-local" | "loom-local-testnet" =>
Box::new(cord_loom_service::chain_spec::loom_local_testnet_config()?),
path => {
let path = std::path::PathBuf::from(path);
let chain_spec =
Expand Down Expand Up @@ -318,14 +316,13 @@ pub fn run() -> Result<()> {

match cmd {
#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) => {
BenchmarkCmd::Storage(_) =>
return Err(sc_cli::Error::Input(
"Compile with --features=runtime-benchmarks \
to enable storage benchmarks."
.into(),
)
.into())
},
.into()),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|mut config| {
let (client, backend, _, _) =
Expand All @@ -341,7 +338,7 @@ pub fn run() -> Result<()> {
cmd.run(client.clone()).map_err(Error::SubstrateCli)
}),
// These commands are very similar and can be handled in nearly the same way.
BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) => {
BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) =>
runner.sync_run(|mut config| {
let (client, _, _, _) =
cord_loom_service::new_chain_ops(&mut config, None)?;
Expand Down Expand Up @@ -378,8 +375,7 @@ pub fn run() -> Result<()> {
.map_err(Error::SubstrateCli),
_ => unreachable!("Ensured by the outside match; qed"),
}
})
},
}),
BenchmarkCmd::Pallet(cmd) => {
set_default_ss58_version(chain_spec);

Expand Down
42 changes: 21 additions & 21 deletions loom/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1082,23 +1082,23 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
),
ProxyType::Governance => matches!(
c,
RuntimeCall::Treasury(..)
| RuntimeCall::Utility(..)
| RuntimeCall::ConvictionVoting(..)
| RuntimeCall::Referenda(..)
| RuntimeCall::FellowshipCollective(..)
| RuntimeCall::FellowshipReferenda(..)
| RuntimeCall::Whitelist(..)
RuntimeCall::Treasury(..) |
RuntimeCall::Utility(..) |
RuntimeCall::ConvictionVoting(..) |
RuntimeCall::Referenda(..) |
RuntimeCall::FellowshipCollective(..) |
RuntimeCall::FellowshipReferenda(..) |
RuntimeCall::Whitelist(..)
),
ProxyType::Staking => {
matches!(
c,
RuntimeCall::Staking(..)
| RuntimeCall::Session(..)
| RuntimeCall::Utility(..)
| RuntimeCall::FastUnstake(..)
| RuntimeCall::VoterList(..)
| RuntimeCall::NominationPools(..)
RuntimeCall::Staking(..) |
RuntimeCall::Session(..) |
RuntimeCall::Utility(..) |
RuntimeCall::FastUnstake(..) |
RuntimeCall::VoterList(..) |
RuntimeCall::NominationPools(..)
)
},
ProxyType::NominationPools => {
Expand All @@ -1109,10 +1109,10 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
},
ProxyType::Auction => matches!(
c,
RuntimeCall::Auctions(..)
| RuntimeCall::Crowdloan(..)
| RuntimeCall::Registrar(..)
| RuntimeCall::Slots(..)
RuntimeCall::Auctions(..) |
RuntimeCall::Crowdloan(..) |
RuntimeCall::Registrar(..) |
RuntimeCall::Slots(..)
),
}
}
Expand Down Expand Up @@ -2715,8 +2715,8 @@ mod test_fees {
};

let mut active = target_voters;
while weight_with(active).all_lte(OffchainSolutionWeightLimit::get())
|| active == target_voters
while weight_with(active).all_lte(OffchainSolutionWeightLimit::get()) ||
active == target_voters
{
active += 1;
}
Expand Down Expand Up @@ -2829,8 +2829,8 @@ mod multiplier_tests {
#[test]
fn multiplier_can_grow_from_zero() {
let minimum_multiplier = MinimumMultiplier::get();
let target = TargetBlockFullness::get()
* BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap();
let target = TargetBlockFullness::get() *
BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap();
// if the min is too small, then this will not change, and we are doomed forever.
// the weight is 1/100th bigger than target.
run_with_system_weight(target.saturating_mul(101) / 100, || {
Expand Down
10 changes: 4 additions & 6 deletions loom/runtime/src/weights/xcm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ pub enum AssetTypes {
impl From<&Asset> for AssetTypes {
fn from(asset: &Asset) -> Self {
match asset {
Asset { id: AssetId(Location { parents: 0, interior: Here }), .. } => {
AssetTypes::Balances
},
Asset { id: AssetId(Location { parents: 0, interior: Here }), .. } =>
AssetTypes::Balances,
_ => AssetTypes::Unknown,
}
}
Expand Down Expand Up @@ -65,9 +64,8 @@ impl WeighAssets for AssetFilter {
// We don't support any NFTs on Polkadot, so these two variants will always match
// only 1 kind of fungible asset.
Self::Wild(AllOf { .. } | AllOfCounted { .. }) => balances_weight,
Self::Wild(AllCounted(count)) => {
balances_weight.saturating_mul(MAX_ASSETS.min(*count as u64))
},
Self::Wild(AllCounted(count)) =>
balances_weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
Self::Wild(All) => balances_weight.saturating_mul(MAX_ASSETS),
}
}
Expand Down
30 changes: 12 additions & 18 deletions weave/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,15 @@ fn runtime(id: &str) -> Runtime {
fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Ok(match id {
// -- Asset Hub
"loom-asset-hub-dev" => {
Box::new(chain_spec::asset_hub::asset_hub_loom_development_config()) as Box<_>
},
"loom-asset-hub-local" => {
Box::new(chain_spec::asset_hub::asset_hub_loom_local_testnet_config())
},
"loom-asset-hub-dev" =>
Box::new(chain_spec::asset_hub::asset_hub_loom_development_config()) as Box<_>,
"loom-asset-hub-local" =>
Box::new(chain_spec::asset_hub::asset_hub_loom_local_testnet_config()),
// -- Coretime
"loom-coretime-dev" => {
Box::new(chain_spec::coretime::coretime_loom_development_config()) as Box<_>
},
"loom-coretime-local" => {
Box::new(chain_spec::coretime::coretime_loom_local_testnet_config())
},
"loom-coretime-dev" =>
Box::new(chain_spec::coretime::coretime_loom_development_config()) as Box<_>,
"loom-coretime-local" =>
Box::new(chain_spec::coretime::coretime_loom_local_testnet_config()),
// -- Loading a specific spec from disk
path => Box::new(GenericChainSpec::from_json_file(path.into())?),
})
Expand Down Expand Up @@ -203,9 +199,8 @@ fn new_node_spec(
extra_args: NodeExtraArgs,
) -> std::result::Result<Box<dyn DynNodeSpec>, sc_cli::Error> {
Ok(match config.chain_spec.runtime()? {
Runtime::AssetHub | Runtime::Coretime => {
new_aura_node_spec::<AuraRuntimeApi, AuraId>(extra_args)
},
Runtime::AssetHub | Runtime::Coretime =>
new_aura_node_spec::<AuraRuntimeApi, AuraId>(extra_args),
Runtime::Omni(consensus) => match consensus {
Consensus::Aura => new_aura_node_spec::<AuraRuntimeApi, AuraId>(extra_args),
Consensus::Relay => Box::new(ShellNode),
Expand Down Expand Up @@ -307,9 +302,8 @@ pub fn run() -> Result<()> {
let node = new_node_spec(&config, cli.node_extra_args())?;
node.run_benchmark_storage_cmd(config, cmd)
}),
BenchmarkCmd::Machine(cmd) => {
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()))
},
BenchmarkCmd::Machine(cmd) =>
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())),
#[allow(unreachable_patterns)]
_ => Err("Benchmarking sub-command unsupported or compilation feature missing. \
Make sure to compile with --features=runtime-benchmarks \
Expand Down
10 changes: 4 additions & 6 deletions weave/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,24 +1003,22 @@ where
hwbench: Option<HwBench>,
) -> Pin<Box<dyn Future<Output = sc_service::error::Result<TaskManager>>>> {
match parachain_config.network.network_backend {
sc_network::config::NetworkBackendType::Libp2p => {
sc_network::config::NetworkBackendType::Libp2p =>
<Self as NodeSpec>::start_node::<sc_network::NetworkWorker<_, _>>(
parachain_config,
polkadot_config,
collator_options,
para_id,
hwbench,
)
},
sc_network::config::NetworkBackendType::Litep2p => {
),
sc_network::config::NetworkBackendType::Litep2p =>
<Self as NodeSpec>::start_node::<sc_network::Litep2pNetworkBackend>(
parachain_config,
polkadot_config,
collator_options,
para_id,
hwbench,
)
},
),
}
}
}
4 changes: 2 additions & 2 deletions weave/runtime/asset-hub/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ pub mod tx_payment {
};
// Try to refund if the fee paid is more than the corrected fee and the account was not
// removed by the dispatched function.
let (fee, fee_in_asset) = if fee_paid.peek() > corrected_fee
&& !T::Assets::total_balance(asset_id.clone(), who).is_zero()
let (fee, fee_in_asset) = if fee_paid.peek() > corrected_fee &&
!T::Assets::total_balance(asset_id.clone(), who).is_zero()
{
let refund_amount = fee_paid.peek().saturating_sub(corrected_fee);
// Check if the refund amount can be swapped back into the asset used by `who` for
Expand Down
Loading

0 comments on commit 3461027

Please sign in to comment.