From 78144c8aa2cd124bd7270dbba2969d25b0084151 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 26 Jan 2023 17:35:15 +0100 Subject: [PATCH] Revert "Add WeightToFee and LengthToFee impls to transaction-payment Runtime API (#13110)" This reverts commit 2dbf62591fd35725c6e39f8ddfd27c3695dab594. --- bin/node-template/runtime/src/lib.rs | 12 ------------ bin/node/runtime/src/lib.rs | 12 ------------ frame/transaction-payment/rpc/runtime-api/src/lib.rs | 12 ++---------- frame/transaction-payment/src/lib.rs | 7 ++----- 4 files changed, 4 insertions(+), 39 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index baba5d9b05e59..f4372af525da5 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -477,12 +477,6 @@ impl_runtime_apis! { ) -> pallet_transaction_payment::FeeDetails { TransactionPayment::query_fee_details(uxt, len) } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } } impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi @@ -500,12 +494,6 @@ impl_runtime_apis! { ) -> pallet_transaction_payment::FeeDetails { TransactionPayment::query_call_fee_details(call, len) } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } } #[cfg(feature = "runtime-benchmarks")] diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 0121f1ee3a8ca..1f85d118ea534 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -2120,12 +2120,6 @@ impl_runtime_apis! { fn query_fee_details(uxt: ::Extrinsic, len: u32) -> FeeDetails { TransactionPayment::query_fee_details(uxt, len) } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } } impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi @@ -2137,12 +2131,6 @@ impl_runtime_apis! { fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails { TransactionPayment::query_call_fee_details(call, len) } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } } impl pallet_mmr::primitives::MmrApi< diff --git a/frame/transaction-payment/rpc/runtime-api/src/lib.rs b/frame/transaction-payment/rpc/runtime-api/src/lib.rs index 760f9e3693417..10fd2a9e61fc1 100644 --- a/frame/transaction-payment/rpc/runtime-api/src/lib.rs +++ b/frame/transaction-payment/rpc/runtime-api/src/lib.rs @@ -25,7 +25,7 @@ use sp_runtime::traits::MaybeDisplay; pub use pallet_transaction_payment::{FeeDetails, InclusionFee, RuntimeDispatchInfo}; sp_api::decl_runtime_apis! { - #[api_version(3)] + #[api_version(2)] pub trait TransactionPaymentApi where Balance: Codec + MaybeDisplay, { @@ -33,11 +33,9 @@ sp_api::decl_runtime_apis! { fn query_info(uxt: Block::Extrinsic, len: u32) -> RuntimeDispatchInfo; fn query_info(uxt: Block::Extrinsic, len: u32) -> RuntimeDispatchInfo; fn query_fee_details(uxt: Block::Extrinsic, len: u32) -> FeeDetails; - fn query_weight_to_fee(weight: sp_weights::Weight) -> Balance; - fn query_length_to_fee(length: u32) -> Balance; } - #[api_version(3)] + #[api_version(2)] pub trait TransactionPaymentCallApi where Balance: Codec + MaybeDisplay, @@ -48,11 +46,5 @@ sp_api::decl_runtime_apis! { /// Query fee details of a given encoded `Call`. fn query_call_fee_details(call: Call, len: u32) -> FeeDetails; - - /// Query the output of the current `WeightToFee` given some input. - fn query_weight_to_fee(weight: sp_weights::Weight) -> Balance; - - /// Query the output of the current `LengthToFee` given some input. - fn query_length_to_fee(length: u32) -> Balance; } } diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index fb4381c5242c6..13adbf89c4270 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -612,14 +612,11 @@ where } } - /// Compute the length portion of a fee by invoking the configured `LengthToFee` impl. - pub fn length_to_fee(length: u32) -> BalanceOf { + fn length_to_fee(length: u32) -> BalanceOf { T::LengthToFee::weight_to_fee(&Weight::from_ref_time(length as u64)) } - /// Compute the unadjusted portion of the weight fee by invoking the configured `WeightToFee` - /// impl. Note that the input `weight` is capped by the maximum block weight before computation. - pub fn weight_to_fee(weight: Weight) -> BalanceOf { + fn weight_to_fee(weight: Weight) -> BalanceOf { // cap the weight to the maximum defined in runtime, otherwise it will be the // `Bounded` maximum of its data type, which is not desired. let capped_weight = weight.min(T::BlockWeights::get().max_block);