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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitlab/pipeline/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cargo-clippy:
RUSTFLAGS: "-D warnings"
script:
- SKIP_WASM_BUILD=1 cargo clippy --all-targets --locked --workspace
- SKIP_WASM_BUILD=1 cargo clippy --all-targets --all-features --locked --workspace
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a different step for this? Or modify the one we already have?
Or does clippy do some magic and not re-do the work after the first command?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I'd add it here to hijack the previous job since it has already downloaded the packages and only has to recompile workspace packages which have other features (no other deps). You can actually see it in the clippy job that has run on this PR. Happy to make it a separate step if the CI folks are happy with the extra cost (if there is any - I don't know the ins and outs of forklift).
The features are not purely additive, and can actually remove code from the main build so I don't think we should replace the previous step.


check-try-runtime:
stage: check
Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -482,20 +482,21 @@ suspicious_double_ref_op = { level = "allow", priority = 2 }

[workspace.lints.clippy]
all = { level = "allow", priority = 0 }
correctness = { level = "deny", priority = 1 }
correctness = { level = "warn", priority = 1 }
complexity = { level = "warn", priority = 1 }
if-same-then-else = { level = "allow", priority = 2 }
complexity = { level = "deny", priority = 1 }
zero-prefixed-literal = { level = "allow", priority = 2 } # 00_1000_000
type_complexity = { level = "allow", priority = 2 } # raison d'etre
nonminimal-bool = { level = "allow", priority = 2 } # maybe
borrowed-box = { level = "allow", priority = 2 } # Reasonable to fix this one
too-many-arguments = { level = "allow", priority = 2 } # (Turning this on would lead to)
needless-lifetimes = { level = "allow", priority = 2 } # generated code
unnecessary_cast = { level = "allow", priority = 2 } # Types may change
identity-op = { level = "allow", priority = 2 } # One case where we do 0 +
useless_conversion = { level = "allow", priority = 2 } # Types may change
unit_arg = { level = "allow", priority = 2 } # styalistic.
option-map-unit-fn = { level = "allow", priority = 2 } # styalistic
bind_instead_of_map = { level = "allow", priority = 2 } # styalistic
unit_arg = { level = "allow", priority = 2 } # stylistic
option-map-unit-fn = { level = "allow", priority = 2 } # stylistic
bind_instead_of_map = { level = "allow", priority = 2 } # stylistic
erasing_op = { level = "allow", priority = 2 } # E.g. 0 * DOLLARS
eq_op = { level = "allow", priority = 2 } # In tests we test equality.
while_immutable_condition = { level = "allow", priority = 2 } # false positives
Expand Down
4 changes: 2 additions & 2 deletions bridges/modules/relayers/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ benchmarks! {
// create slash destination account
let lane = LaneId([0, 0, 0, 0]);
let slash_destination = RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain);
T::prepare_rewards_account(slash_destination.clone(), Zero::zero());
T::prepare_rewards_account(slash_destination, Zero::zero());
}: {
crate::Pallet::<T>::slash_and_deregister(&relayer, slash_destination)
}
Expand All @@ -121,7 +121,7 @@ benchmarks! {
let account_params =
RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain);
}: {
crate::Pallet::<T>::register_relayer_reward(account_params.clone(), &relayer, One::one());
crate::Pallet::<T>::register_relayer_reward(account_params, &relayer, One::one());
}
verify {
assert_eq!(RelayerRewards::<T>::get(relayer, &account_params), Some(One::one()));
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/xcmp-queue/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ mod benchmarks {
}

assert!(
OutboundXcmpStatus::<T>::get().iter().find(|p| p.recipient == para).is_none(),
OutboundXcmpStatus::<T>::get().iter().all(|p| p.recipient != para),
"No messages in the channel; therefore removed."
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mod benchmarks {
.map_err(|_| BenchmarkError::Weightless)?;

#[extrinsic_call]
_(origin as T::RuntimeOrigin, cid.clone(), Some(expire_at.clone()));
_(origin as T::RuntimeOrigin, cid.clone(), Some(expire_at));

assert_eq!(<Announcements<T, I>>::count(), 1);
assert_last_event::<T, I>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ benchmarks! {
// Ensure that the votes are for the correct session
assert_eq!(vote.session, scenario._session);
// Ensure that there are an expected number of candidates
let header = BenchBuilder::<T>::header(scenario._block_number.clone());
let header = BenchBuilder::<T>::header(scenario._block_number);
// Traverse candidates and assert descriptors are as expected
for (para_id, backing_validators) in vote.backing_validators_per_candidate.iter().enumerate() {
let descriptor = backing_validators.0.descriptor();
Expand Down Expand Up @@ -189,7 +189,7 @@ benchmarks! {
// Ensure that the votes are for the correct session
assert_eq!(vote.session, scenario._session);
// Ensure that there are an expected number of candidates
let header = BenchBuilder::<T>::header(scenario._block_number.clone());
let header = BenchBuilder::<T>::header(scenario._block_number);
// Traverse candidates and assert descriptors are as expected
for (para_id, backing_validators)
in vote.backing_validators_per_candidate.iter().enumerate() {
Expand Down
26 changes: 13 additions & 13 deletions polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ benchmarks! {
descend_origin {
let mut executor = new_executor::<T>(Default::default());
let who = X2(OnlyChild, OnlyChild);
let instruction = Instruction::DescendOrigin(who.clone());
let instruction = Instruction::DescendOrigin(who);
let xcm = Xcm(vec![instruction]);
} : {
executor.bench_process(xcm)?;
Expand Down Expand Up @@ -242,7 +242,7 @@ benchmarks! {
&origin,
assets.clone().into(),
&XcmContext {
origin: Some(origin.clone()),
origin: Some(origin),
message_id: [0; 32],
topic: None,
},
Expand Down Expand Up @@ -279,7 +279,7 @@ benchmarks! {
let origin = T::subscribe_origin()?;
let query_id = Default::default();
let max_response_weight = Default::default();
let mut executor = new_executor::<T>(origin.clone());
let mut executor = new_executor::<T>(origin);
let instruction = Instruction::SubscribeVersion { query_id, max_response_weight };
let xcm = Xcm(vec![instruction]);
} : {
Expand All @@ -299,14 +299,14 @@ benchmarks! {
query_id,
max_response_weight,
&XcmContext {
origin: Some(origin.clone()),
origin: Some(origin),
message_id: [0; 32],
topic: None,
},
).map_err(|_| "Could not start subscription")?;
assert!(<T::XcmConfig as xcm_executor::Config>::SubscriptionService::is_subscribed(&origin));

let mut executor = new_executor::<T>(origin.clone());
let mut executor = new_executor::<T>(origin);
let instruction = Instruction::UnsubscribeVersion;
let xcm = Xcm(vec![instruction]);
} : {
Expand Down Expand Up @@ -538,7 +538,7 @@ benchmarks! {

let mut executor = new_executor::<T>(origin);

let instruction = Instruction::UniversalOrigin(alias.clone());
let instruction = Instruction::UniversalOrigin(alias);
let xcm = Xcm(vec![instruction]);
}: {
executor.bench_process(xcm)?;
Expand Down Expand Up @@ -632,13 +632,13 @@ benchmarks! {

let (unlocker, owner, asset) = T::unlockable_asset()?;

let mut executor = new_executor::<T>(unlocker.clone());
let mut executor = new_executor::<T>(unlocker);

// We first place the asset in lock first...
<T::XcmConfig as xcm_executor::Config>::AssetLocker::prepare_lock(
unlocker,
asset.clone(),
owner.clone(),
owner,
)
.map_err(|_| BenchmarkError::Skip)?
.enact()
Expand All @@ -658,13 +658,13 @@ benchmarks! {

let (unlocker, owner, asset) = T::unlockable_asset()?;

let mut executor = new_executor::<T>(unlocker.clone());
let mut executor = new_executor::<T>(unlocker);

// We first place the asset in lock first...
<T::XcmConfig as xcm_executor::Config>::AssetLocker::prepare_lock(
unlocker,
asset.clone(),
owner.clone(),
owner,
)
.map_err(|_| BenchmarkError::Skip)?
.enact()
Expand All @@ -686,9 +686,9 @@ benchmarks! {

// We first place the asset in lock first...
<T::XcmConfig as xcm_executor::Config>::AssetLocker::prepare_lock(
locker.clone(),
locker,
asset.clone(),
owner.clone(),
owner,
)
.map_err(|_| BenchmarkError::Skip)?
.enact()
Expand Down Expand Up @@ -739,7 +739,7 @@ benchmarks! {

let mut executor = new_executor::<T>(origin);

let instruction = Instruction::AliasOrigin(target.clone());
let instruction = Instruction::AliasOrigin(target);
let xcm = Xcm(vec![instruction]);
}: {
executor.bench_process(xcm)?;
Expand Down
2 changes: 1 addition & 1 deletion polkadot/xcm/xcm-simulator/example/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl EnsureOriginWithArg<RuntimeOrigin, MultiLocation> for ForeignCreators {

#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin(a: &MultiLocation) -> Result<RuntimeOrigin, ()> {
Ok(pallet_xcm::Origin::Xcm(a.clone()).into())
Ok(pallet_xcm::Origin::Xcm(*a).into())
}
}

Expand Down
57 changes: 18 additions & 39 deletions substrate/frame/alliance/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,15 @@ mod benchmarks {
let voter = &members[j as usize];
Alliance::<T, I>::vote(
SystemOrigin::Signed(voter.clone()).into(),
last_hash.clone(),
last_hash,
index,
true,
)?;
}

let voter = members[m as usize - 3].clone();
// Voter votes aye without resolving the vote.
Alliance::<T, I>::vote(
SystemOrigin::Signed(voter.clone()).into(),
last_hash.clone(),
index,
true,
)?;
Alliance::<T, I>::vote(SystemOrigin::Signed(voter.clone()).into(), last_hash, index, true)?;

// Voter switches vote to nay, but does not kill the vote, just updates + inserts
let approve = false;
Expand All @@ -206,7 +201,7 @@ mod benchmarks {
frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into());

#[extrinsic_call]
_(SystemOrigin::Signed(voter), last_hash.clone(), index, approve);
_(SystemOrigin::Signed(voter), last_hash, index, approve);

//nothing to verify
Ok(())
Expand Down Expand Up @@ -255,24 +250,19 @@ mod benchmarks {
let voter = &members[j as usize];
Alliance::<T, I>::vote(
SystemOrigin::Signed(voter.clone()).into(),
last_hash.clone(),
last_hash,
index,
true,
)?;
}

// Voter votes aye without resolving the vote.
Alliance::<T, I>::vote(
SystemOrigin::Signed(voter.clone()).into(),
last_hash.clone(),
index,
true,
)?;
Alliance::<T, I>::vote(SystemOrigin::Signed(voter.clone()).into(), last_hash, index, true)?;

// Voter switches vote to nay, which kills the vote
Alliance::<T, I>::vote(
SystemOrigin::Signed(voter.clone()).into(),
last_hash.clone(),
last_hash,
index,
false,
)?;
Expand All @@ -282,7 +272,7 @@ mod benchmarks {
frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into());

#[extrinsic_call]
close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage);
close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage);

assert_eq!(T::ProposalProvider::proposal_of(last_hash), None);
Ok(())
Expand Down Expand Up @@ -330,7 +320,7 @@ mod benchmarks {
// approval vote
Alliance::<T, I>::vote(
SystemOrigin::Signed(proposer.clone()).into(),
last_hash.clone(),
last_hash,
index,
false,
)?;
Expand All @@ -340,7 +330,7 @@ mod benchmarks {
let voter = &members[j as usize];
Alliance::<T, I>::vote(
SystemOrigin::Signed(voter.clone()).into(),
last_hash.clone(),
last_hash,
index,
false,
)?;
Expand All @@ -349,22 +339,17 @@ mod benchmarks {
// Member zero is the first aye
Alliance::<T, I>::vote(
SystemOrigin::Signed(members[0].clone()).into(),
last_hash.clone(),
last_hash,
index,
true,
)?;

let voter = members[1].clone();
// Caller switches vote to aye, which passes the vote
Alliance::<T, I>::vote(
SystemOrigin::Signed(voter.clone()).into(),
last_hash.clone(),
index,
true,
)?;
Alliance::<T, I>::vote(SystemOrigin::Signed(voter.clone()).into(), last_hash, index, true)?;

#[extrinsic_call]
close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage);
close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage);

assert_eq!(T::ProposalProvider::proposal_of(last_hash), None);
Ok(())
Expand Down Expand Up @@ -414,23 +399,23 @@ mod benchmarks {
let voter = &members[j as usize];
Alliance::<T, I>::vote(
SystemOrigin::Signed(voter.clone()).into(),
last_hash.clone(),
last_hash,
index,
true,
)?;
}

Alliance::<T, I>::vote(
SystemOrigin::Signed(voter.clone()).into(),
last_hash.clone(),
last_hash,
index,
false,
)?;

System::<T>::set_block_number(BlockNumberFor::<T>::max_value());

#[extrinsic_call]
close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage);
close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage);

// The last proposal is removed.
assert_eq!(T::ProposalProvider::proposal_of(last_hash), None);
Expand Down Expand Up @@ -477,7 +462,7 @@ mod benchmarks {
// The prime member votes aye, so abstentions default to aye.
Alliance::<T, I>::vote(
SystemOrigin::Signed(proposer.clone()).into(),
last_hash.clone(),
last_hash,
p - 1,
true, // Vote aye.
)?;
Expand All @@ -489,7 +474,7 @@ mod benchmarks {
let voter = &members[j as usize];
Alliance::<T, I>::vote(
SystemOrigin::Signed(voter.clone()).into(),
last_hash.clone(),
last_hash,
index,
false,
)?;
Expand All @@ -499,13 +484,7 @@ mod benchmarks {
System::<T>::set_block_number(BlockNumberFor::<T>::max_value());

#[extrinsic_call]
close(
SystemOrigin::Signed(proposer),
last_hash.clone(),
index,
Weight::MAX,
bytes_in_storage,
);
close(SystemOrigin::Signed(proposer), last_hash, index, Weight::MAX, bytes_in_storage);

assert_eq!(T::ProposalProvider::proposal_of(last_hash), None);
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/bounties/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ benchmarks_instance_pallet! {
);
}
verify {
ensure!(missed_any == false, "Missed some");
ensure!(!missed_any, "Missed some");
if b > 0 {
ensure!(budget_remaining < BalanceOf::<T, I>::max_value(), "Budget not used");
assert_last_event::<T, I>(Event::BountyBecameActive { index: b - 1 }.into())
Expand Down
Loading