Skip to content

Commit

Permalink
fix: clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Grigoriy Simonov committed Oct 12, 2023
1 parent 5f71c37 commit 3db37f4
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 55 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ macro_rules! testnet_genesis {
vesting: VestingConfig { vesting: vec![] },
parachain_info: ParachainInfoConfig {
parachain_id: $id.into(),
Default::default()
..Default::default()
},
aura: AuraConfig {
authorities: $initial_invulnerables
Expand Down
1 change: 1 addition & 0 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ pub fn run() -> Result<()> {
Some(Subcommand::TryRuntime(cmd)) => {
use std::{future::Future, pin::Pin};

use polkadot_cli::Block;
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
use try_runtime_cli::block_building_info::timestamp_with_aura_info;

Expand Down
4 changes: 2 additions & 2 deletions node/cli/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub struct FullDeps<C, P, SC> {
}

/// Instantiate all Full RPC extensions.
pub fn create_full<C, P, SC, R, A, B>(
pub fn create_full<C, P, SC, R, B>(
io: &mut RpcModule<()>,
deps: FullDeps<C, P, SC>,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>>
Expand Down Expand Up @@ -244,7 +244,7 @@ where
EthFilter::new(
client.clone(),
eth_backend,
graph.clone(),
graph,
filter_pool,
500_usize, // max stored filters
max_past_logs,
Expand Down
66 changes: 43 additions & 23 deletions node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ where
select_chain,
};

create_full::<_, _, _, Runtime, RuntimeApi, _>(&mut rpc_handle, full_deps)?;
create_full::<_, _, _, Runtime, _>(&mut rpc_handle, full_deps)?;

let eth_deps = EthDeps {
client,
Expand Down Expand Up @@ -547,7 +547,7 @@ where
config: parachain_config,
keystore: params.keystore_container.keystore(),
backend: backend.clone(),
network: network.clone(),
network,
sync_service: sync_service.clone(),
system_rpc_tx,
telemetry: telemetry.as_mut(),
Expand Down Expand Up @@ -600,19 +600,21 @@ where
if validator {
start_consensus(
client.clone(),
backend.clone(),
prometheus_registry.as_ref(),
telemetry.as_ref().map(|t| t.handle()),
&task_manager,
relay_chain_interface.clone(),
transaction_pool,
sync_service.clone(),
params.keystore_container.keystore(),
overseer_handle,
relay_chain_slot_duration,
para_id,
collator_key.expect("cli args do not allow this"),
announce_block,
StartConsensusParameters {
backend: backend.clone(),
prometheus_registry: prometheus_registry.as_ref(),
telemetry: telemetry.as_ref().map(|t| t.handle()),
task_manager: &task_manager,
relay_chain_interface: relay_chain_interface.clone(),
sync_oracle: sync_service,
keystore: params.keystore_container.keystore(),
overseer_handle,
relay_chain_slot_duration,
para_id,
collator_key: collator_key.expect("cli args do not allow this"),
announce_block,
}
)?;
}

Expand Down Expand Up @@ -670,23 +672,27 @@ where
.map_err(Into::into)
}

pub fn start_consensus<ExecutorDispatch, RuntimeApi, Runtime>(
client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
pub struct StartConsensusParameters<'a> {
backend: Arc<FullBackend>,
prometheus_registry: Option<&Registry>,
prometheus_registry: Option<&'a Registry>,
telemetry: Option<TelemetryHandle>,
task_manager: &TaskManager,
task_manager: &'a TaskManager,
relay_chain_interface: Arc<dyn RelayChainInterface>,
transaction_pool: Arc<
sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
>,
sync_oracle: Arc<SyncingService<Block>>,
keystore: KeystorePtr,
overseer_handle: OverseerHandle,
relay_chain_slot_duration: Duration,
para_id: ParaId,
collator_key: CollatorPair,
announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
}

pub fn start_consensus<ExecutorDispatch, RuntimeApi, Runtime>(
client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,
transaction_pool: Arc<
sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,
>,
parameters: StartConsensusParameters<'_>,
) -> Result<(), sc_service::Error>
where
ExecutorDispatch: NativeExecutionDispatch + 'static,
Expand All @@ -697,14 +703,28 @@ where
RuntimeApi::RuntimeApi: RuntimeApiDep<Runtime> + 'static,
Runtime: RuntimeInstance,
{
let StartConsensusParameters {
backend,
prometheus_registry,
telemetry,
task_manager,
relay_chain_interface,
sync_oracle,
keystore,
overseer_handle,
relay_chain_slot_duration,
para_id,
collator_key,
announce_block,
} = parameters;
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;

let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
task_manager.spawn_handle(),
client.clone(),
transaction_pool,
prometheus_registry,
telemetry.clone(),
telemetry,
);
let proposer = Proposer::new(proposer_factory);

Expand Down Expand Up @@ -1043,7 +1063,7 @@ where
select_chain,
};

create_full::<_, _, _, Runtime, RuntimeApi, _>(&mut rpc_module, full_deps)?;
create_full::<_, _, _, Runtime, _>(&mut rpc_module, full_deps)?;

let eth_deps = EthDeps {
client,
Expand Down
16 changes: 8 additions & 8 deletions pallets/app-promotion/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ mod benchmarks {
T::RelayBlockNumberProvider::set_block_number(30_000.into());

#[extrinsic_call]
_(RawOrigin::Signed(pallet_admin.clone()), Some(b as u8));
_(RawOrigin::Signed(pallet_admin), Some(b as u8));

Ok(())
}
Expand All @@ -178,7 +178,7 @@ mod benchmarks {

#[extrinsic_call]
_(
RawOrigin::Signed(caller.clone()),
RawOrigin::Signed(caller),
share * <T as Config>::Currency::total_balance(&caller),
);

Expand Down Expand Up @@ -211,7 +211,7 @@ mod benchmarks {
.collect::<Result<Vec<_>, _>>()?;

#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()));
_(RawOrigin::Signed(caller));

Ok(())
}
Expand Down Expand Up @@ -242,7 +242,7 @@ mod benchmarks {

#[extrinsic_call]
_(
RawOrigin::Signed(caller.clone()),
RawOrigin::Signed(caller),
Into::<BalanceOf<T>>::into(1000u128) * T::Nominal::get(),
);

Expand All @@ -268,7 +268,7 @@ mod benchmarks {
let collection = create_nft_collection::<T>(caller)?;

#[extrinsic_call]
_(RawOrigin::Signed(pallet_admin.clone()), collection);
_(RawOrigin::Signed(pallet_admin), collection);

Ok(())
}
Expand Down Expand Up @@ -296,7 +296,7 @@ mod benchmarks {
)?;

#[extrinsic_call]
_(RawOrigin::Signed(pallet_admin.clone()), collection);
_(RawOrigin::Signed(pallet_admin), collection);

Ok(())
}
Expand All @@ -319,7 +319,7 @@ mod benchmarks {
<EvmMigrationPallet<T>>::finish(RawOrigin::Root.into(), address, data)?;

#[extrinsic_call]
_(RawOrigin::Signed(pallet_admin.clone()), address);
_(RawOrigin::Signed(pallet_admin), address);

Ok(())
}
Expand All @@ -346,7 +346,7 @@ mod benchmarks {
)?;

#[extrinsic_call]
_(RawOrigin::Signed(pallet_admin.clone()), address);
_(RawOrigin::Signed(pallet_admin), address);

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion pallets/nonfungible/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mod benchmarks {

#[block]
{
create_max_item(&collection, &sender, to.clone())?;
create_max_item(&collection, &sender, to)?;
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion pallets/refungible/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mod benchmarks {

#[block]
{
create_max_item(&collection, &sender, [(to.clone(), 200)])?;
create_max_item(&collection, &sender, [(to, 200)])?;
}

Ok(())
Expand Down
26 changes: 11 additions & 15 deletions pallets/unique/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ mod benchmarks {
let collection = create_nft_collection::<T>(caller.clone())?;

#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), collection);
_(RawOrigin::Signed(caller), collection);

Ok(())
}
Expand All @@ -120,7 +120,7 @@ mod benchmarks {

#[extrinsic_call]
_(
RawOrigin::Signed(caller.clone()),
RawOrigin::Signed(caller),
collection,
T::CrossAccountId::from_sub(allowlist_account),
);
Expand All @@ -141,7 +141,7 @@ mod benchmarks {

#[extrinsic_call]
_(
RawOrigin::Signed(caller.clone()),
RawOrigin::Signed(caller),
collection,
T::CrossAccountId::from_sub(allowlist_account),
);
Expand All @@ -156,7 +156,7 @@ mod benchmarks {
let new_owner: T::AccountId = account("admin", 0, SEED);

#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), collection, new_owner);
_(RawOrigin::Signed(caller), collection, new_owner);

Ok(())
}
Expand All @@ -169,7 +169,7 @@ mod benchmarks {

#[extrinsic_call]
_(
RawOrigin::Signed(caller.clone()),
RawOrigin::Signed(caller),
collection,
T::CrossAccountId::from_sub(new_admin),
);
Expand All @@ -190,7 +190,7 @@ mod benchmarks {

#[extrinsic_call]
_(
RawOrigin::Signed(caller.clone()),
RawOrigin::Signed(caller),
collection,
T::CrossAccountId::from_sub(new_admin),
);
Expand All @@ -204,11 +204,7 @@ mod benchmarks {
let collection = create_nft_collection::<T>(caller.clone())?;

#[extrinsic_call]
_(
RawOrigin::Signed(caller.clone()),
collection,
caller.clone(),
);
_(RawOrigin::Signed(caller), collection, caller.clone());

Ok(())
}
Expand All @@ -224,7 +220,7 @@ mod benchmarks {
)?;

#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), collection);
_(RawOrigin::Signed(caller), collection);

Ok(())
}
Expand All @@ -241,7 +237,7 @@ mod benchmarks {
<Pallet<T>>::confirm_sponsorship(RawOrigin::Signed(caller.clone()).into(), collection)?;

#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), collection);
_(RawOrigin::Signed(caller), collection);

Ok(())
}
Expand All @@ -252,7 +248,7 @@ mod benchmarks {
let collection = create_nft_collection::<T>(caller.clone())?;

#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), collection, false);
_(RawOrigin::Signed(caller), collection, false);

Ok(())
}
Expand All @@ -275,7 +271,7 @@ mod benchmarks {
};

#[extrinsic_call]
set_collection_limits(RawOrigin::Signed(caller.clone()), collection, cl);
set_collection_limits(RawOrigin::Signed(caller), collection, cl);

Ok(())
}
Expand Down
7 changes: 3 additions & 4 deletions runtime/common/config/xcm/foreignassets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,18 @@ impl<ConvertAssetId: MaybeEquivalence<AssetId, AssetId>> MaybeEquivalence<MultiL
let here_id =
ConvertAssetId::convert(&AssetId::NativeAssetId(NativeCurrency::Here)).unwrap();

if asset_id.clone() == parent_id {
if *asset_id == parent_id {
return Some(MultiLocation::parent());
}

if asset_id.clone() == here_id {
if *asset_id == here_id {
return Some(MultiLocation::new(
1,
X1(Parachain(ParachainInfo::get().into())),
));
}

let fid =
<AssetId as TryAsForeign<AssetId, ForeignAssetId>>::try_as_foreign(asset_id.clone())?;
let fid = <AssetId as TryAsForeign<AssetId, ForeignAssetId>>::try_as_foreign(*asset_id)?;
XcmForeignAssetIdMapping::<Runtime>::get_multi_location(fid)
}
}
Expand Down
Loading

0 comments on commit 3db37f4

Please sign in to comment.