Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit d21399a

Browse files
authored
Companion for #11415 (WeightToFee) (#5525)
* Companion for paritytech/substrate#11415 * Rename `WeightToFee::calc()` to `WeightToFee::wight_to_fee()` * Fix typo * Fix compile errors * update lockfile for {"substrate"} Co-authored-by: parity-processbot <>
1 parent 74ae110 commit d21399a

File tree

13 files changed

+208
-208
lines changed

13 files changed

+208
-208
lines changed

Cargo.lock

Lines changed: 172 additions & 173 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bridges/bin/rialto/runtime/src/millau_messages.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ mod tests {
343343
let bridge = MILLAU_CHAIN_ID;
344344
let call: Call = SystemCall::set_heap_pages { pages: 64 }.into();
345345
let dispatch_weight = call.get_dispatch_info().weight;
346-
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(
346+
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::weight_to_fee(
347347
&dispatch_weight,
348348
);
349349
assert!(dispatch_fee > 0);
@@ -508,7 +508,7 @@ mod tests {
508508
}
509509

510510
let dispatch_weight = 500;
511-
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(
511+
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::weight_to_fee(
512512
&dispatch_weight,
513513
);
514514
assert!(dispatch_fee > 0);

bridges/bin/runtime-common/src/messages.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use bp_runtime::{
3333
use codec::{Decode, DecodeLimit, Encode};
3434
use frame_support::{
3535
traits::{Currency, ExistenceRequirement},
36-
weights::{Weight, WeightToFeePolynomial},
36+
weights::{Weight, WeightToFee},
3737
RuntimeDebug,
3838
};
3939
use hash_db::Hasher;
@@ -598,7 +598,8 @@ pub mod target {
598598
message_id,
599599
message.data.payload.map_err(drop),
600600
|dispatch_origin, dispatch_weight| {
601-
let unadjusted_weight_fee = ThisRuntime::WeightToFee::calc(&dispatch_weight);
601+
let unadjusted_weight_fee =
602+
ThisRuntime::WeightToFee::weight_to_fee(&dispatch_weight);
602603
let fee_multiplier =
603604
pallet_transaction_payment::Pallet::<ThisRuntime>::next_fee_multiplier();
604605
let adjusted_weight_fee =

bridges/relays/bin-substrate/src/chains/kusama_headers_to_polkadot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub(crate) mod tests {
103103
// for simplicity - add extra weight for base tx fee + fee that is paid for the tx size +
104104
// adjusted fee
105105
let single_source_header_submit_tx_weight = single_source_header_submit_call_weight * 3 / 2;
106-
let single_source_header_tx_cost = W::calc(&single_source_header_submit_tx_weight);
106+
let single_source_header_tx_cost = W::weight_to_fee(&single_source_header_submit_tx_weight);
107107
single_source_header_tx_cost * B::from(expected_source_headers_per_day)
108108
}
109109

bridges/relays/lib-substrate-relay/src/messages_target.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ fn compute_fee_multiplier<C: Chain>(
493493
) -> FixedU128 {
494494
let adjusted_weight_fee_difference =
495495
larger_adjusted_weight_fee.saturating_sub(smaller_adjusted_weight_fee);
496-
let smaller_tx_unadjusted_weight_fee = WeightToFeeOf::<C>::calc(&smaller_tx_weight);
497-
let larger_tx_unadjusted_weight_fee = WeightToFeeOf::<C>::calc(&larger_tx_weight);
496+
let smaller_tx_unadjusted_weight_fee = WeightToFeeOf::<C>::weight_to_fee(&smaller_tx_weight);
497+
let larger_tx_unadjusted_weight_fee = WeightToFeeOf::<C>::weight_to_fee(&larger_tx_weight);
498498
FixedU128::saturating_from_rational(
499499
adjusted_weight_fee_difference,
500500
larger_tx_unadjusted_weight_fee.saturating_sub(smaller_tx_unadjusted_weight_fee),
@@ -507,7 +507,7 @@ fn compute_prepaid_messages_refund<C: ChainWithMessages>(
507507
total_prepaid_nonces: MessageNonce,
508508
fee_multiplier: FixedU128,
509509
) -> BalanceOf<C> {
510-
fee_multiplier.saturating_mul_int(WeightToFeeOf::<C>::calc(
510+
fee_multiplier.saturating_mul_int(WeightToFeeOf::<C>::weight_to_fee(
511511
&C::PAY_INBOUND_DISPATCH_FEE_WEIGHT_AT_CHAIN.saturating_mul(total_prepaid_nonces),
512512
))
513513
}
@@ -554,11 +554,11 @@ mod tests {
554554

555555
let smaller_weight = 1_000_000;
556556
let smaller_adjusted_weight_fee =
557-
multiplier.saturating_mul_int(WeightToFeeOf::<Rococo>::calc(&smaller_weight));
557+
multiplier.saturating_mul_int(WeightToFeeOf::<Rococo>::weight_to_fee(&smaller_weight));
558558

559559
let larger_weight = smaller_weight + 200_000;
560560
let larger_adjusted_weight_fee =
561-
multiplier.saturating_mul_int(WeightToFeeOf::<Rococo>::calc(&larger_weight));
561+
multiplier.saturating_mul_int(WeightToFeeOf::<Rococo>::weight_to_fee(&larger_weight));
562562

563563
assert_eq!(
564564
compute_fee_multiplier::<Rococo>(

runtime/kusama/constants/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ mod tests {
100100
fee::WeightToFee,
101101
};
102102
use crate::weights::ExtrinsicBaseWeight;
103-
use frame_support::weights::WeightToFeePolynomial;
103+
use frame_support::weights::WeightToFee as WeightToFeeT;
104104
use runtime_common::MAXIMUM_BLOCK_WEIGHT;
105105

106106
#[test]
107107
// Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds.
108108
fn full_block_fee_is_correct() {
109109
// A full block should cost between 1,000 and 10,000 CENTS.
110-
let full_block = WeightToFee::calc(&MAXIMUM_BLOCK_WEIGHT);
110+
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
111111
assert!(full_block >= 1_000 * CENTS);
112112
assert!(full_block <= 10_000 * CENTS);
113113
}
@@ -117,7 +117,7 @@ mod tests {
117117
fn extrinsic_base_fee_is_correct() {
118118
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
119119
println!("Base: {}", ExtrinsicBaseWeight::get());
120-
let x = WeightToFee::calc(&ExtrinsicBaseWeight::get());
120+
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
121121
let y = CENTS / 10;
122122
assert!(x.max(y) - x.min(y) < MILLICENTS);
123123
}

runtime/kusama/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! Tests for the Kusama Runtime Configuration
1818
1919
use crate::*;
20-
use frame_support::weights::{GetDispatchInfo, WeightToFeePolynomial};
20+
use frame_support::weights::{GetDispatchInfo, WeightToFee as WeightToFeeT};
2121
use keyring::Sr25519Keyring::Charlie;
2222
use pallet_transaction_payment::Multiplier;
2323
use parity_scale_codec::Encode;
@@ -68,7 +68,7 @@ fn payout_weight_portion() {
6868
#[ignore]
6969
fn block_cost() {
7070
let max_block_weight = BlockWeights::get().max_block;
71-
let raw_fee = WeightToFee::calc(&max_block_weight);
71+
let raw_fee = WeightToFee::weight_to_fee(&max_block_weight);
7272

7373
println!(
7474
"Full Block weight == {} // WeightToFee(full_block) == {} plank",

runtime/polkadot/constants/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ mod tests {
102102
fee::WeightToFee,
103103
};
104104
use crate::weights::ExtrinsicBaseWeight;
105-
use frame_support::weights::WeightToFeePolynomial;
105+
use frame_support::weights::WeightToFee as WeightToFeeT;
106106
use runtime_common::MAXIMUM_BLOCK_WEIGHT;
107107

108108
#[test]
109109
// Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds.
110110
fn full_block_fee_is_correct() {
111111
// A full block should cost between 10 and 100 DOLLARS.
112-
let full_block = WeightToFee::calc(&MAXIMUM_BLOCK_WEIGHT);
112+
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
113113
assert!(full_block >= 10 * DOLLARS);
114114
assert!(full_block <= 100 * DOLLARS);
115115
}
@@ -119,7 +119,7 @@ mod tests {
119119
fn extrinsic_base_fee_is_correct() {
120120
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
121121
println!("Base: {}", ExtrinsicBaseWeight::get());
122-
let x = WeightToFee::calc(&ExtrinsicBaseWeight::get());
122+
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
123123
let y = CENTS / 10;
124124
assert!(x.max(y) - x.min(y) < MILLICENTS);
125125
}

runtime/polkadot/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,7 @@ sp_api::impl_runtime_apis! {
20092009
#[cfg(test)]
20102010
mod test_fees {
20112011
use super::*;
2012-
use frame_support::weights::{GetDispatchInfo, WeightToFeePolynomial};
2012+
use frame_support::weights::{GetDispatchInfo, WeightToFee as WeightToFeeT};
20132013
use keyring::Sr25519Keyring::Charlie;
20142014
use pallet_transaction_payment::Multiplier;
20152015
use runtime_common::MinimumMultiplier;
@@ -2038,7 +2038,7 @@ mod test_fees {
20382038
#[ignore]
20392039
fn block_cost() {
20402040
let max_block_weight = BlockWeights::get().max_block;
2041-
let raw_fee = WeightToFee::calc(&max_block_weight);
2041+
let raw_fee = WeightToFee::weight_to_fee(&max_block_weight);
20422042

20432043
println!(
20442044
"Full Block weight == {} // WeightToFee(full_block) == {} plank",

runtime/rococo/constants/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ mod tests {
100100
fee::WeightToFee,
101101
};
102102
use crate::weights::ExtrinsicBaseWeight;
103-
use frame_support::weights::WeightToFeePolynomial;
103+
use frame_support::weights::WeightToFee as WeightToFeeT;
104104
use runtime_common::MAXIMUM_BLOCK_WEIGHT;
105105

106106
#[test]
107107
// Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds.
108108
fn full_block_fee_is_correct() {
109109
// A full block should cost between 10 and 100 DOLLARS.
110-
let full_block = WeightToFee::calc(&MAXIMUM_BLOCK_WEIGHT);
110+
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
111111
assert!(full_block >= 10 * DOLLARS);
112112
assert!(full_block <= 100 * DOLLARS);
113113
}
@@ -117,7 +117,7 @@ mod tests {
117117
fn extrinsic_base_fee_is_correct() {
118118
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
119119
println!("Base: {}", ExtrinsicBaseWeight::get());
120-
let x = WeightToFee::calc(&ExtrinsicBaseWeight::get());
120+
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
121121
let y = CENTS / 10;
122122
assert!(x.max(y) - x.min(y) < MILLICENTS);
123123
}

0 commit comments

Comments
 (0)