Skip to content
Snippets Groups Projects
Commit 2c0993d0 authored by Oliver Tale-Yazdi's avatar Oliver Tale-Yazdi Committed by GitHub
Browse files

pallet nis: remove benchmarking hack (#13759)


* pallet nis: remove benchmark hack

Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* NearestPrefDown -> Down

Tested on the kitchensink and in case that
n = 10000000000000000 and d = 12000100600000000000000 it rounds the
Perquintill up (correctly) since 833326347280+47318160/60000503 should round up.
That triggers the path 'amount <= on_hold' in L736.

Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

---------

Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
parent 29ea9e0a
No related merge requests found
......@@ -164,9 +164,6 @@ benchmarks! {
Nis::<T>::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?;
Nis::<T>::process_queues(Perquintill::one(), 1, 2, &mut WeightCounter::unlimited());
frame_system::Pallet::<T>::set_block_number(Receipts::<T>::get(0).unwrap().expiry);
// FIXME: Ensure that the pallet has enough funding. This should already be the case, but
// a rounding error can cause it to fail.
T::Currency::set_balance(&Nis::<T>::account_id(), BalanceOf::<T>::max_value() / 10u32.into());
}: _(RawOrigin::Signed(caller.clone()), 0, None)
verify {
assert!(Receipts::<T>::get(0).is_none());
......@@ -185,9 +182,6 @@ benchmarks! {
Nis::<T>::process_queues(Perquintill::one(), 1, 2, &mut WeightCounter::unlimited());
frame_system::Pallet::<T>::set_block_number(Receipts::<T>::get(0).unwrap().expiry);
Nis::<T>::communify(RawOrigin::Signed(caller.clone()).into(), 0)?;
// FIXME: Ensure that the pallet has enough funding. This should already be the case, but
// a rounding error can cause it to fail.
T::Currency::set_balance(&Nis::<T>::account_id(), BalanceOf::<T>::max_value() / 10u32.into());
}: _(RawOrigin::Signed(caller.clone()), 0)
verify {
assert!(Receipts::<T>::get(0).is_none());
......
......@@ -1139,9 +1139,8 @@ pub mod pallet {
// Now to activate the bid...
let n = amount;
let d = issuance.effective;
let proportion =
Perquintill::from_rational_with_rounding(n, d, Rounding::NearestPrefDown)
.defensive_unwrap_or_default();
let proportion = Perquintill::from_rational_with_rounding(n, d, Rounding::Down)
.defensive_unwrap_or_default();
let who = bid.who;
let index = summary.index;
summary.proportion_owed.defensive_saturating_accrue(proportion);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment