mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-08 22:58:00 +00:00
* 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:
Generated
+172
-173
File diff suppressed because it is too large
Load Diff
@@ -343,7 +343,7 @@ mod tests {
|
||||
let bridge = MILLAU_CHAIN_ID;
|
||||
let call: Call = SystemCall::set_heap_pages { pages: 64 }.into();
|
||||
let dispatch_weight = call.get_dispatch_info().weight;
|
||||
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(
|
||||
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::weight_to_fee(
|
||||
&dispatch_weight,
|
||||
);
|
||||
assert!(dispatch_fee > 0);
|
||||
@@ -508,7 +508,7 @@ mod tests {
|
||||
}
|
||||
|
||||
let dispatch_weight = 500;
|
||||
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(
|
||||
let dispatch_fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::weight_to_fee(
|
||||
&dispatch_weight,
|
||||
);
|
||||
assert!(dispatch_fee > 0);
|
||||
|
||||
@@ -33,7 +33,7 @@ use bp_runtime::{
|
||||
use codec::{Decode, DecodeLimit, Encode};
|
||||
use frame_support::{
|
||||
traits::{Currency, ExistenceRequirement},
|
||||
weights::{Weight, WeightToFeePolynomial},
|
||||
weights::{Weight, WeightToFee},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use hash_db::Hasher;
|
||||
@@ -598,7 +598,8 @@ pub mod target {
|
||||
message_id,
|
||||
message.data.payload.map_err(drop),
|
||||
|dispatch_origin, dispatch_weight| {
|
||||
let unadjusted_weight_fee = ThisRuntime::WeightToFee::calc(&dispatch_weight);
|
||||
let unadjusted_weight_fee =
|
||||
ThisRuntime::WeightToFee::weight_to_fee(&dispatch_weight);
|
||||
let fee_multiplier =
|
||||
pallet_transaction_payment::Pallet::<ThisRuntime>::next_fee_multiplier();
|
||||
let adjusted_weight_fee =
|
||||
|
||||
@@ -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>(
|
||||
|
||||
@@ -100,14 +100,14 @@ mod tests {
|
||||
fee::WeightToFee,
|
||||
};
|
||||
use crate::weights::ExtrinsicBaseWeight;
|
||||
use frame_support::weights::WeightToFeePolynomial;
|
||||
use frame_support::weights::WeightToFee as WeightToFeeT;
|
||||
use runtime_common::MAXIMUM_BLOCK_WEIGHT;
|
||||
|
||||
#[test]
|
||||
// Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds.
|
||||
fn full_block_fee_is_correct() {
|
||||
// A full block should cost between 1,000 and 10,000 CENTS.
|
||||
let full_block = WeightToFee::calc(&MAXIMUM_BLOCK_WEIGHT);
|
||||
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
|
||||
assert!(full_block >= 1_000 * CENTS);
|
||||
assert!(full_block <= 10_000 * CENTS);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ mod tests {
|
||||
fn extrinsic_base_fee_is_correct() {
|
||||
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
|
||||
println!("Base: {}", ExtrinsicBaseWeight::get());
|
||||
let x = WeightToFee::calc(&ExtrinsicBaseWeight::get());
|
||||
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
|
||||
let y = CENTS / 10;
|
||||
assert!(x.max(y) - x.min(y) < MILLICENTS);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Tests for the Kusama Runtime Configuration
|
||||
|
||||
use crate::*;
|
||||
use frame_support::weights::{GetDispatchInfo, WeightToFeePolynomial};
|
||||
use frame_support::weights::{GetDispatchInfo, WeightToFee as WeightToFeeT};
|
||||
use keyring::Sr25519Keyring::Charlie;
|
||||
use pallet_transaction_payment::Multiplier;
|
||||
use parity_scale_codec::Encode;
|
||||
@@ -68,7 +68,7 @@ fn payout_weight_portion() {
|
||||
#[ignore]
|
||||
fn block_cost() {
|
||||
let max_block_weight = BlockWeights::get().max_block;
|
||||
let raw_fee = WeightToFee::calc(&max_block_weight);
|
||||
let raw_fee = WeightToFee::weight_to_fee(&max_block_weight);
|
||||
|
||||
println!(
|
||||
"Full Block weight == {} // WeightToFee(full_block) == {} plank",
|
||||
|
||||
@@ -102,14 +102,14 @@ mod tests {
|
||||
fee::WeightToFee,
|
||||
};
|
||||
use crate::weights::ExtrinsicBaseWeight;
|
||||
use frame_support::weights::WeightToFeePolynomial;
|
||||
use frame_support::weights::WeightToFee as WeightToFeeT;
|
||||
use runtime_common::MAXIMUM_BLOCK_WEIGHT;
|
||||
|
||||
#[test]
|
||||
// Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds.
|
||||
fn full_block_fee_is_correct() {
|
||||
// A full block should cost between 10 and 100 DOLLARS.
|
||||
let full_block = WeightToFee::calc(&MAXIMUM_BLOCK_WEIGHT);
|
||||
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
|
||||
assert!(full_block >= 10 * DOLLARS);
|
||||
assert!(full_block <= 100 * DOLLARS);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ mod tests {
|
||||
fn extrinsic_base_fee_is_correct() {
|
||||
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
|
||||
println!("Base: {}", ExtrinsicBaseWeight::get());
|
||||
let x = WeightToFee::calc(&ExtrinsicBaseWeight::get());
|
||||
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
|
||||
let y = CENTS / 10;
|
||||
assert!(x.max(y) - x.min(y) < MILLICENTS);
|
||||
}
|
||||
|
||||
@@ -2009,7 +2009,7 @@ sp_api::impl_runtime_apis! {
|
||||
#[cfg(test)]
|
||||
mod test_fees {
|
||||
use super::*;
|
||||
use frame_support::weights::{GetDispatchInfo, WeightToFeePolynomial};
|
||||
use frame_support::weights::{GetDispatchInfo, WeightToFee as WeightToFeeT};
|
||||
use keyring::Sr25519Keyring::Charlie;
|
||||
use pallet_transaction_payment::Multiplier;
|
||||
use runtime_common::MinimumMultiplier;
|
||||
@@ -2038,7 +2038,7 @@ mod test_fees {
|
||||
#[ignore]
|
||||
fn block_cost() {
|
||||
let max_block_weight = BlockWeights::get().max_block;
|
||||
let raw_fee = WeightToFee::calc(&max_block_weight);
|
||||
let raw_fee = WeightToFee::weight_to_fee(&max_block_weight);
|
||||
|
||||
println!(
|
||||
"Full Block weight == {} // WeightToFee(full_block) == {} plank",
|
||||
|
||||
@@ -100,14 +100,14 @@ mod tests {
|
||||
fee::WeightToFee,
|
||||
};
|
||||
use crate::weights::ExtrinsicBaseWeight;
|
||||
use frame_support::weights::WeightToFeePolynomial;
|
||||
use frame_support::weights::WeightToFee as WeightToFeeT;
|
||||
use runtime_common::MAXIMUM_BLOCK_WEIGHT;
|
||||
|
||||
#[test]
|
||||
// Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds.
|
||||
fn full_block_fee_is_correct() {
|
||||
// A full block should cost between 10 and 100 DOLLARS.
|
||||
let full_block = WeightToFee::calc(&MAXIMUM_BLOCK_WEIGHT);
|
||||
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
|
||||
assert!(full_block >= 10 * DOLLARS);
|
||||
assert!(full_block <= 100 * DOLLARS);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ mod tests {
|
||||
fn extrinsic_base_fee_is_correct() {
|
||||
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
|
||||
println!("Base: {}", ExtrinsicBaseWeight::get());
|
||||
let x = WeightToFee::calc(&ExtrinsicBaseWeight::get());
|
||||
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
|
||||
let y = CENTS / 10;
|
||||
assert!(x.max(y) - x.min(y) < MILLICENTS);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ use bridge_runtime_common::messages::{
|
||||
};
|
||||
use frame_support::{
|
||||
traits::Get,
|
||||
weights::{Weight, WeightToFeePolynomial},
|
||||
weights::{Weight, WeightToFee as WeightToFeeT},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use rococo_runtime_constants::fee::WeightToFee;
|
||||
@@ -141,7 +141,7 @@ impl<B, GI> ThisChainWithMessages for RococoLikeChain<B, GI> {
|
||||
.base_extrinsic,
|
||||
crate::TransactionByteFee::get(),
|
||||
pallet_transaction_payment::Pallet::<Runtime>::next_fee_multiplier(),
|
||||
|weight| WeightToFee::calc(&weight),
|
||||
|weight| WeightToFee::weight_to_fee(&weight),
|
||||
transaction,
|
||||
)
|
||||
}
|
||||
@@ -199,7 +199,7 @@ impl<B, GI> BridgedChainWithMessages for RococoLikeChain<B, GI> {
|
||||
.base_extrinsic,
|
||||
crate::TransactionByteFee::get(),
|
||||
pallet_transaction_payment::Pallet::<Runtime>::next_fee_multiplier(),
|
||||
|weight| WeightToFee::calc(&weight),
|
||||
|weight| WeightToFee::weight_to_fee(&weight),
|
||||
transaction,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -100,14 +100,14 @@ mod tests {
|
||||
fee::WeightToFee,
|
||||
};
|
||||
use crate::weights::ExtrinsicBaseWeight;
|
||||
use frame_support::weights::WeightToFeePolynomial;
|
||||
use frame_support::weights::WeightToFee as WeightToFeeT;
|
||||
use runtime_common::MAXIMUM_BLOCK_WEIGHT;
|
||||
|
||||
#[test]
|
||||
// Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds.
|
||||
fn full_block_fee_is_correct() {
|
||||
// A full block should cost between 10 and 100 UNITS.
|
||||
let full_block = WeightToFee::calc(&MAXIMUM_BLOCK_WEIGHT);
|
||||
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
|
||||
assert!(full_block >= 10 * UNITS);
|
||||
assert!(full_block <= 100 * UNITS);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ mod tests {
|
||||
fn extrinsic_base_fee_is_correct() {
|
||||
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
|
||||
println!("Base: {}", ExtrinsicBaseWeight::get());
|
||||
let x = WeightToFee::calc(&ExtrinsicBaseWeight::get());
|
||||
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
|
||||
let y = CENTS / 10;
|
||||
assert!(x.max(y) - x.min(y) < MILLICENTS);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use frame_support::{
|
||||
traits::{tokens::currency::Currency as CurrencyT, Get, OnUnbalanced as OnUnbalancedT},
|
||||
weights::{constants::WEIGHT_PER_SECOND, GetDispatchInfo, Weight, WeightToFeePolynomial},
|
||||
weights::{constants::WEIGHT_PER_SECOND, GetDispatchInfo, Weight, WeightToFee as WeightToFeeT},
|
||||
};
|
||||
use parity_scale_codec::Decode;
|
||||
use sp_runtime::traits::{SaturatedConversion, Saturating, Zero};
|
||||
@@ -241,7 +241,7 @@ impl<T: Get<(AssetId, u128)>, R: TakeRevenue> Drop for FixedRateOfFungible<T, R>
|
||||
/// Weight trader which uses the `TransactionPayment` pallet to set the right price for weight and then
|
||||
/// places any weight bought into the right account.
|
||||
pub struct UsingComponents<
|
||||
WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
|
||||
WeightToFee: WeightToFeeT<Balance = Currency::Balance>,
|
||||
AssetId: Get<MultiLocation>,
|
||||
AccountId,
|
||||
Currency: CurrencyT<AccountId>,
|
||||
@@ -252,7 +252,7 @@ pub struct UsingComponents<
|
||||
PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,
|
||||
);
|
||||
impl<
|
||||
WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
|
||||
WeightToFee: WeightToFeeT<Balance = Currency::Balance>,
|
||||
AssetId: Get<MultiLocation>,
|
||||
AccountId,
|
||||
Currency: CurrencyT<AccountId>,
|
||||
@@ -265,7 +265,7 @@ impl<
|
||||
|
||||
fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {
|
||||
log::trace!(target: "xcm::weight", "UsingComponents::buy_weight weight: {:?}, payment: {:?}", weight, payment);
|
||||
let amount = WeightToFee::calc(&weight);
|
||||
let amount = WeightToFee::weight_to_fee(&weight);
|
||||
let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;
|
||||
let required = (Concrete(AssetId::get()), u128_amount).into();
|
||||
let unused = payment.checked_sub(required).map_err(|_| XcmError::TooExpensive)?;
|
||||
@@ -277,7 +277,7 @@ impl<
|
||||
fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {
|
||||
log::trace!(target: "xcm::weight", "UsingComponents::refund_weight weight: {:?}", weight);
|
||||
let weight = weight.min(self.0);
|
||||
let amount = WeightToFee::calc(&weight);
|
||||
let amount = WeightToFee::weight_to_fee(&weight);
|
||||
self.0 -= weight;
|
||||
self.1 = self.1.saturating_sub(amount);
|
||||
let amount: u128 = amount.saturated_into();
|
||||
@@ -289,7 +289,7 @@ impl<
|
||||
}
|
||||
}
|
||||
impl<
|
||||
WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,
|
||||
WeightToFee: WeightToFeeT<Balance = Currency::Balance>,
|
||||
AssetId: Get<MultiLocation>,
|
||||
AccountId,
|
||||
Currency: CurrencyT<AccountId>,
|
||||
|
||||
Reference in New Issue
Block a user