Skip to content

Commit 6cbdf12

Browse files
happy clippy happy life
1 parent 39d3ef1 commit 6cbdf12

15 files changed

Lines changed: 95 additions & 59 deletions

File tree

ice/route-findr/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ mod tests {
342342
.chain(route.iter().map(|t| t.asset_out))
343343
.collect();
344344
let unique: alloc::collections::BTreeSet<_> = assets.iter().collect();
345-
assert_eq!(assets.len(), unique.len(), "route has cycle: {:?}", route);
345+
assert_eq!(assets.len(), unique.len(), "route has cycle: {route:?}");
346346
}
347347
}
348348

ice/solver-bench/benches/solver.rs

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@ fn bench_resolvable(c: &mut Criterion) {
4545
for n in [10, 50, 100, 200] {
4646
let intents = generate_resolvable_intents(n);
4747
group.bench_with_input(BenchmarkId::from_parameter(n), &n, |b, _| {
48-
b.iter(|| ext.execute_with(|| Solver::solve(black_box(intents.clone()), black_box(state.clone()))))
48+
b.iter(|| {
49+
ext.execute_with(|| {
50+
Solver::solve(
51+
black_box(intents.clone()),
52+
black_box(state.clone()),
53+
black_box(Permill::zero()),
54+
)
55+
})
56+
})
4957
});
5058
}
5159
group.finish();
@@ -60,7 +68,15 @@ fn bench_unresolvable(c: &mut Criterion) {
6068
for n in [10, 50, 100, 500, 1000, 5000] {
6169
let intents = generate_unresolvable_intents(n);
6270
group.bench_with_input(BenchmarkId::from_parameter(n), &n, |b, _| {
63-
b.iter(|| ext.execute_with(|| Solver::solve(black_box(intents.clone()), black_box(state.clone()))))
71+
b.iter(|| {
72+
ext.execute_with(|| {
73+
Solver::solve(
74+
black_box(intents.clone()),
75+
black_box(state.clone()),
76+
black_box(Permill::zero()),
77+
)
78+
})
79+
})
6480
});
6581
}
6682
group.finish();
@@ -74,9 +90,17 @@ fn bench_mixed(c: &mut Criterion) {
7490
let mut group = c.benchmark_group("solver_mixed");
7591
for (good, bad) in [(50, 50), (50, 500), (50, 5000), (100, 5000)] {
7692
let intents = generate_mixed_intents(good, bad);
77-
let label = format!("{}good_{}bad", good, bad);
93+
let label = format!("{good}good_{bad}bad");
7894
group.bench_with_input(BenchmarkId::new("intents", &label), &label, |b, _| {
79-
b.iter(|| ext.execute_with(|| Solver::solve(black_box(intents.clone()), black_box(state.clone()))))
95+
b.iter(|| {
96+
ext.execute_with(|| {
97+
Solver::solve(
98+
black_box(intents.clone()),
99+
black_box(state.clone()),
100+
black_box(Permill::zero()),
101+
)
102+
})
103+
})
80104
});
81105
}
82106
group.finish();
@@ -115,7 +139,15 @@ fn bench_partial(c: &mut Criterion) {
115139
for n in [1, 2, 5, 10, 20] {
116140
let intents = generate_partial_intents(n);
117141
group.bench_with_input(BenchmarkId::from_parameter(n), &n, |b, _| {
118-
b.iter(|| ext.execute_with(|| Solver::solve(black_box(intents.clone()), black_box(state.clone()))))
142+
b.iter(|| {
143+
ext.execute_with(|| {
144+
Solver::solve(
145+
black_box(intents.clone()),
146+
black_box(state.clone()),
147+
black_box(Permill::zero()),
148+
)
149+
})
150+
})
119151
});
120152
}
121153
group.finish();
@@ -130,9 +162,17 @@ fn bench_mixed_partial(c: &mut Criterion) {
130162
// (non-partial, partial)
131163
for (np, p) in [(10, 1), (10, 5), (10, 10), (50, 10), (50, 50), (100, 20)] {
132164
let intents = generate_mixed_partial_intents(np, p);
133-
let label = format!("{}np_{}p", np, p);
165+
let label = format!("{np}np_{p}p");
134166
group.bench_with_input(BenchmarkId::new("intents", &label), &label, |b, _| {
135-
b.iter(|| ext.execute_with(|| Solver::solve(black_box(intents.clone()), black_box(state.clone()))))
167+
b.iter(|| {
168+
ext.execute_with(|| {
169+
Solver::solve(
170+
black_box(intents.clone()),
171+
black_box(state.clone()),
172+
black_box(Permill::zero()),
173+
)
174+
})
175+
})
136176
});
137177
}
138178
group.finish();

pallets/ice/amm-simulator/src/aave.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl<DP: DataProvider> Simulator<DP> {
131131

132132
let (exit_reason, value) = DP::view(ctx, data, GAS_LIMIT);
133133
if exit_reason != ExitReason::Succeed(ExitSucceed::Returned) {
134-
log::error!(target: LOG_TARGET, "to get reserves list reason: {:?}, value: {:?}", exit_reason, value);
134+
log::error!(target: LOG_TARGET, "to get reserves list reason: {exit_reason:?}, value: {value:?}");
135135
return Err(SimulatorError::Other);
136136
}
137137

@@ -163,7 +163,7 @@ impl<DP: DataProvider> Simulator<DP> {
163163

164164
let (exit_reason, value) = DP::view(ctc, data, GAS_LIMIT);
165165
if exit_reason != ExitReason::Succeed(ExitSucceed::Returned) {
166-
log::error!(target: LOG_TARGET, "to get reserves data, reason: {:?}, value: {:?}", exit_reason, value);
166+
log::error!(target: LOG_TARGET, "to get reserves data, reason: {exit_reason:?}, value: {value:?}");
167167
return Err(SimulatorError::Other);
168168
}
169169

@@ -225,7 +225,7 @@ impl<DP: DataProvider> Simulator<DP> {
225225

226226
let (exit_reason, value) = DP::view(ctx, data, GAS_LIMIT);
227227
if exit_reason != ExitReason::Succeed(ExitSucceed::Returned) {
228-
log::error!(target: LOG_TARGET, "to get scaled total supply, reserve: {:?}, reason: {:?}, value: {:?}", reserve, exit_reason, value );
228+
log::error!(target: LOG_TARGET, "to get scaled total supply, reserve: {reserve:?}, reason: {exit_reason:?}, value: {value:?}");
229229
return Err(SimulatorError::Other);
230230
}
231231

@@ -258,8 +258,8 @@ impl<DP: DataProvider> AmmSimulator for Simulator<DP> {
258258
};
259259

260260
let Some(asset_id) = DP::address_to_asset(addr) else {
261-
debug_assert!(false, "Failed to map reserve address to asset, reserve: {:?}", addr);
262-
log::error!(target: LOG_TARGET, "to map reserve address to asset, reserve: {:?}", addr);
261+
debug_assert!(false, "Failed to map reserve address to asset, reserve: {addr:?}");
262+
log::error!(target: LOG_TARGET, "to map reserve address to asset, reserve: {addr:?}");
263263
snapshot.reserves.clear();
264264
break;
265265
};

pallets/ice/amm-simulator/src/stableswap.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,20 +346,20 @@ fn find_pool(
346346
snapshot: &StableswapSnapshot,
347347
) -> Result<(AssetId, &PoolSnapshot<AssetId>), SimulatorError> {
348348
if let Some(pool) = snapshot.pools.get(&asset_a) {
349-
if pool.assets.iter().any(|&a| a == asset_b) {
349+
if pool.assets.contains(&asset_b) {
350350
return Ok((asset_a, pool));
351351
}
352352
}
353353

354354
if let Some(pool) = snapshot.pools.get(&asset_b) {
355-
if pool.assets.iter().any(|&a| a == asset_a) {
355+
if pool.assets.contains(&asset_a) {
356356
return Ok((asset_b, pool));
357357
}
358358
}
359359

360360
for (pool_id, pool) in &snapshot.pools {
361-
let has_a = pool.assets.iter().any(|&a| a == asset_a);
362-
let has_b = pool.assets.iter().any(|&a| a == asset_b);
361+
let has_a = pool.assets.contains(&asset_a);
362+
let has_b = pool.assets.contains(&asset_b);
363363
if has_a && has_b {
364364
return Ok((*pool_id, pool));
365365
}

pallets/ice/src/lib.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ use sp_std::vec::Vec;
6868
pub use pallet::*;
6969
pub use weights::WeightInfo;
7070

71-
pub const UNSIGNED_TXS_PRIORITY: u64 = u64::max_value();
71+
pub const UNSIGNED_TXS_PRIORITY: u64 = u64::MAX;
7272
/// Extra gas provided to EVM calls during solution execution.
7373
const EXTRA_GAS: u64 = 1_000_000;
7474
const LOG_TARGET: &str = "ice";
@@ -331,7 +331,7 @@ pub mod pallet {
331331
let mut exec_prices: BTreeMap<(AssetId, AssetId), Price> = BTreeMap::new();
332332
for resolved_intent in &solution.resolved_intents {
333333
let ResolvedIntent { id, data: resolve } = resolved_intent;
334-
log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), resolving intent, id: {:?}", LOG_PREFIX, id);
334+
log::debug!(target: LOG_TARGET, "{LOG_PREFIX:?}: sumbit_solution(), resolving intent, id: {id:?}");
335335

336336
ensure!(processed_intents.insert(*id), Error::<T>::DuplicateIntent);
337337

@@ -356,7 +356,7 @@ pub mod pallet {
356356
let intent = pallet_intent::Pallet::<T>::get_intent(id).ok_or(Error::<T>::IntentNotFound)?;
357357
let surplus = pallet_intent::Pallet::<T>::compute_surplus(&intent, resolve)
358358
.ok_or(Error::<T>::ArithmeticOverflow)?;
359-
log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), id: {:?}, surplus: {:?}", LOG_PREFIX, id, surplus);
359+
log::debug!(target: LOG_TARGET, "{LOG_PREFIX:?}: sumbit_solution(), id: {id:?}, surplus: {surplus:?}");
360360
exec_score = exec_score.checked_add(surplus).ok_or(Error::<T>::ArithmeticOverflow)?;
361361

362362
pallet_intent::Pallet::<T>::intent_resolved(&owner, resolved_intent)?;
@@ -416,7 +416,7 @@ pub mod pallet {
416416
match Solver::<amm_simulator::HydrationSimulator<T::Simulator>>::solve(intents, state, matched_fee) {
417417
Ok(solution) => Some(solution),
418418
Err(e) => {
419-
log::error!(target: OCW_LOG_TARGET, "{:?}: solver failed, err: {:?}", LOG_PREFIX, e);
419+
log::error!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: solver failed, err: {e:?}");
420420
None
421421
}
422422
}
@@ -426,7 +426,7 @@ pub mod pallet {
426426

427427
let tx = <T as CreateBare<self::Call<T>>>::create_bare(call.into());
428428
if let Err(e) = SubmitTransaction::<T, Call<T>>::submit_transaction(tx) {
429-
log::error!(target: OCW_LOG_TARGET, "{:?}: submit_transaction failed (validate_unsigned rejected the solution), err: {:?}", LOG_PREFIX, e);
429+
log::error!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: submit_transaction failed (validate_unsigned rejected the solution), err: {e:?}");
430430
};
431431
}
432432
}
@@ -533,9 +533,9 @@ impl<T: Config> Pallet<T> {
533533
let ed = <T as Config>::RegistryHandler::existential_deposit(*asset).unwrap_or(Balance::MAX);
534534
if expected_fee >= ed && holding_pot != &fee_receiver {
535535
<T as Config>::Currency::transfer(*asset, holding_pot, &fee_receiver, expected_fee, AllowDeath)?;
536-
log::debug!(target: LOG_TARGET, "{:?}: settle_matched_fees(), swept asset: {:?}, fee: {:?} -> {:?}", LOG_PREFIX, asset, expected_fee, fee_receiver);
536+
log::debug!(target: LOG_TARGET, "{LOG_PREFIX:?}: settle_matched_fees(), swept asset: {asset:?}, fee: {expected_fee:?} -> {fee_receiver:?}");
537537
} else if expected_fee > 0 {
538-
log::debug!(target: LOG_TARGET, "{:?}: settle_matched_fees(), fee {:?} for asset {:?} below ED {:?} — retained in pot", LOG_PREFIX, expected_fee, asset, ed);
538+
log::debug!(target: LOG_TARGET, "{LOG_PREFIX:?}: settle_matched_fees(), fee {expected_fee:?} for asset {asset:?} below ED {ed:?} — retained in pot");
539539
}
540540
}
541541
Ok(())
@@ -630,35 +630,35 @@ impl<T: Config> Pallet<T> {
630630
// is enforced authoritatively in `submit_solution` via measured pool
631631
// output (see `settle_matched_fees`).
632632
for ResolvedIntent { id, data: resolve } in &solution.resolved_intents {
633-
log::debug!(target: OCW_LOG_TARGET, "{:?}: validate_unsigned_solution(), resolved intent, id: {:?}", LOG_PREFIX, id);
633+
log::debug!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: validate_unsigned_solution(), resolved intent, id: {id:?}");
634634

635635
if let Err(e) = Self::validate_intent_amounts(resolve) {
636-
log::error!(target: OCW_LOG_TARGET, "{:?}: validate_unsigned_solution(), intent {:?} failed amount validation: {:?}", LOG_PREFIX, id, e);
636+
log::error!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: validate_unsigned_solution(), intent {id:?} failed amount validation: {e:?}");
637637
return Err(e);
638638
}
639639

640640
let intent = pallet_intent::Pallet::<T>::get_intent(id).ok_or_else(|| {
641-
log::error!(target: OCW_LOG_TARGET, "{:?}: validate_unsigned_solution(), intent {:?} not found in storage", LOG_PREFIX, id);
641+
log::error!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: validate_unsigned_solution(), intent {id:?} not found in storage");
642642
Error::<T>::IntentNotFound
643643
})?;
644644

645645
let surplus =
646646
pallet_intent::Pallet::<T>::compute_surplus(&intent, resolve).ok_or(Error::<T>::ArithmeticOverflow)?;
647-
log::debug!(target: OCW_LOG_TARGET, "{:?}: validate_unsigned_solution(), id: {:?}, surplus: {:?}", LOG_PREFIX, id, surplus);
647+
log::debug!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: validate_unsigned_solution(), id: {id:?}, surplus: {surplus:?}");
648648
score = score.checked_add(surplus).ok_or(Error::<T>::ArithmeticOverflow)?;
649649

650650
if !processed_intents.insert(*id) {
651-
log::error!(target: OCW_LOG_TARGET, "{:?}: validate_unsigned_solution(), intent {:?} is duplicate", LOG_PREFIX, id);
651+
log::error!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: validate_unsigned_solution(), intent {id:?} is duplicate");
652652
return Err(Error::<T>::DuplicateIntent.into());
653653
}
654654

655655
if let Err(e) = pallet_intent::Pallet::<T>::validate_resolve(&intent, resolve) {
656-
log::error!(target: OCW_LOG_TARGET, "{:?}: validate_unsigned_solution(), intent {:?} failed resolve validation: {:?}", LOG_PREFIX, id, e);
656+
log::error!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: validate_unsigned_solution(), intent {id:?} failed resolve validation: {e:?}");
657657
return Err(e);
658658
}
659659

660660
if let Err(e) = Self::validate_price_consistency(&mut exec_prices, resolve) {
661-
log::error!(target: OCW_LOG_TARGET, "{:?}: validate_unsigned_solution(), intent {:?} failed price consistency: {:?}", LOG_PREFIX, id, e);
661+
log::error!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: validate_unsigned_solution(), intent {id:?} failed price consistency: {e:?}");
662662
return Err(e);
663663
}
664664
}
@@ -695,17 +695,17 @@ impl<T: Config> Pallet<T> {
695695
let state = <<T as Config>::Simulator as SimulatorConfig>::Simulators::initial_state();
696696

697697
let Some(solution) = solve(intents, state) else {
698-
log::debug!(target: OCW_LOG_TARGET, "{:?}: solver returned no solution, block: {:?}", LOG_PREFIX, block_no);
698+
log::debug!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: solver returned no solution, block: {block_no:?}");
699699
return None;
700700
};
701701

702702
if solution.resolved_intents.is_empty() {
703-
log::debug!(target: OCW_LOG_TARGET, "{:?}: solver returned empty solution (no resolvable intents), block: {:?}", LOG_PREFIX, block_no);
703+
log::debug!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: solver returned empty solution (no resolvable intents), block: {block_no:?}");
704704
return None;
705705
}
706706

707707
if let Err(e) = Self::validate_unsigned_solution(&solution) {
708-
log::error!(target: OCW_LOG_TARGET, "{:?}: validate solution, err: {:?}, block: {:?}", LOG_PREFIX, e, block_no);
708+
log::error!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: validate solution, err: {e:?}, block: {block_no:?}");
709709
return None;
710710
}
711711

pallets/ice/src/tests/mock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ impl ExtBuilder {
586586
self
587587
}
588588

589+
#[allow(clippy::too_many_arguments)]
589590
pub fn with_router_settlement(
590591
mut self,
591592
trade_type: SwapType,

pallets/ice/src/tests/ocw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ fn validate_unsingned_should_not_work_when_submitted_solution_score_is_not_corre
354354

355355
//Act 4
356356
let mut s4 = s.clone();
357-
s4.score = Score::max_value();
357+
s4.score = Score::MAX;
358358
let call = Call::submit_solution { solution: s4 };
359359

360360
assert_noop!(

pallets/intent/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#![recursion_limit = "256"]
2929
#![cfg_attr(not(feature = "std"), no_std)]
30+
#![allow(clippy::useless_conversion)]
3031

3132
#[cfg(test)]
3233
mod tests;
@@ -350,7 +351,7 @@ pub mod pallet {
350351
let tx = T::create_bare(call.into());
351352
if let Err(e) = SubmitTransaction::<T, Call<T>>::submit_transaction(tx) {
352353
debug_assert!(false, "laxy-executorn: failed to submit dispatch_top transaction");
353-
log::error!(target: OCW_LOG_TARGET, "{:?}: to submit cleanup_intent call, err: {:?}", LOG_PREFIX, e);
354+
log::error!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: to submit cleanup_intent call, err: {e:?}");
354355
};
355356
}
356357
}
@@ -540,8 +541,7 @@ impl<T: Config> Pallet<T> {
540541
// Period eligibility
541542
let next_eligible = dca.last_execution_block.saturating_add(dca.period);
542543
if current_block < next_eligible {
543-
log::debug!(target: OCW_LOG_TARGET, "{:?}: get_valid_intents(), DCA intent {:?} skipped: period not elapsed (current_block: {}, next_eligible: {})",
544-
LOG_PREFIX, id, current_block, next_eligible);
544+
log::debug!(target: OCW_LOG_TARGET, "{LOG_PREFIX:?}: get_valid_intents(), DCA intent {id:?} skipped: period not elapsed (current_block: {current_block}, next_eligible: {next_eligible})");
545545
return None;
546546
}
547547
// Budget sufficient for a trade

pallets/intent/src/tests/add_intent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn should_work_when_intent_is_valid() {
4242
let id = match r {
4343
Ok(id) => id,
4444
_ => {
45-
panic!("Expected Ok(_). Got {:#?}", r);
45+
panic!("Expected Ok(_). Got {r:#?}");
4646
}
4747
};
4848

@@ -245,7 +245,7 @@ fn should_work_when_intent_has_no_deadline() {
245245
let id = match r {
246246
Ok(id) => id,
247247
_ => {
248-
panic!("Expected Ok(_). Got {:#?}", r);
248+
panic!("Expected Ok(_). Got {r:#?}");
249249
}
250250
};
251251

pallets/intent/src/tests/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ pub(crate) const MIN_DCA_PERIOD: u32 = 5;
157157

158158
thread_local! {
159159
pub static QUEUD_TASKS: RefCell<Vec<(Source, AccountId)>> = RefCell::new(Vec::default());
160-
pub static ORACLE_PRICE: RefCell<Option<EmaPrice>> = RefCell::new(None);
161-
pub static BLOCK_NUMBER: RefCell<u64> = RefCell::new(1);
160+
pub static ORACLE_PRICE: RefCell<Option<EmaPrice>> = const { RefCell::new(None) };
161+
pub static BLOCK_NUMBER: RefCell<u64> = const { RefCell::new(1) };
162162
}
163163

164164
pub fn set_oracle_price(price: Option<EmaPrice>) {

0 commit comments

Comments
 (0)