Companion for #11415 (WeightToFee) (#5525)

* Companion for https://github.com/paritytech/substrate/pull/11415

* Rename `WeightToFee::calc()` to `WeightToFee::wight_to_fee()`

* Fix typo

* Fix compile errors

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Nazar Mokrynskyi
2022-05-25 11:06:01 +03:00
committed by GitHub
parent 69aa11f680
commit c090fb4c2e
13 changed files with 208 additions and 208 deletions
@@ -103,7 +103,7 @@ pub(crate) mod tests {
// for simplicity - add extra weight for base tx fee + fee that is paid for the tx size +
// adjusted fee
let single_source_header_submit_tx_weight = single_source_header_submit_call_weight * 3 / 2;
let single_source_header_tx_cost = W::calc(&single_source_header_submit_tx_weight);
let single_source_header_tx_cost = W::weight_to_fee(&single_source_header_submit_tx_weight);
single_source_header_tx_cost * B::from(expected_source_headers_per_day)
}
@@ -493,8 +493,8 @@ fn compute_fee_multiplier<C: Chain>(
) -> FixedU128 {
let adjusted_weight_fee_difference =
larger_adjusted_weight_fee.saturating_sub(smaller_adjusted_weight_fee);
let smaller_tx_unadjusted_weight_fee = WeightToFeeOf::<C>::calc(&smaller_tx_weight);
let larger_tx_unadjusted_weight_fee = WeightToFeeOf::<C>::calc(&larger_tx_weight);
let smaller_tx_unadjusted_weight_fee = WeightToFeeOf::<C>::weight_to_fee(&smaller_tx_weight);
let larger_tx_unadjusted_weight_fee = WeightToFeeOf::<C>::weight_to_fee(&larger_tx_weight);
FixedU128::saturating_from_rational(
adjusted_weight_fee_difference,
larger_tx_unadjusted_weight_fee.saturating_sub(smaller_tx_unadjusted_weight_fee),
@@ -507,7 +507,7 @@ fn compute_prepaid_messages_refund<C: ChainWithMessages>(
total_prepaid_nonces: MessageNonce,
fee_multiplier: FixedU128,
) -> BalanceOf<C> {
fee_multiplier.saturating_mul_int(WeightToFeeOf::<C>::calc(
fee_multiplier.saturating_mul_int(WeightToFeeOf::<C>::weight_to_fee(
&C::PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN.saturating_mul(total_prepaid_nonces),
))
}
@@ -554,11 +554,11 @@ mod tests {
let smaller_weight = 1_000_000;
let smaller_adjusted_weight_fee =
multiplier.saturating_mul_int(WeightToFeeOf::<Rococo>::calc(&smaller_weight));
multiplier.saturating_mul_int(WeightToFeeOf::<Rococo>::weight_to_fee(&smaller_weight));
let larger_weight = smaller_weight + 200_000;
let larger_adjusted_weight_fee =
multiplier.saturating_mul_int(WeightToFeeOf::<Rococo>::calc(&larger_weight));
multiplier.saturating_mul_int(WeightToFeeOf::<Rococo>::weight_to_fee(&larger_weight));
assert_eq!(
compute_fee_multiplier::<Rococo>(