Deprecate V1 Weights (#13699)

* Remove deprecated pallet calls

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

* Deprecate old weight

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

* Update Runtime API

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

* Fix tests

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

* Delete shitty code

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

* Fix doctest

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

* Update frame/alliance/src/lib.rs

Co-authored-by: Koute <koute@users.noreply.github.com>

* Add doc

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

* contracts: Use u64 as old weight type

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

* Update frame/contracts/src/lib.rs

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Koute <koute@users.noreply.github.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Oliver Tale-Yazdi
2023-04-04 20:57:21 +02:00
committed by GitHub
parent 0766072393
commit 36957d6760
10 changed files with 107 additions and 171 deletions
@@ -26,7 +26,7 @@ use jsonrpsee::{
types::error::{CallError, ErrorCode, ErrorObject},
};
use pallet_transaction_payment_rpc_runtime_api::{FeeDetails, InclusionFee, RuntimeDispatchInfo};
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_core::Bytes;
use sp_rpc::number::NumberOrHex;
@@ -81,7 +81,7 @@ impl From<Error> for i32 {
impl<C, Block, Balance>
TransactionPaymentApiServer<
<Block as BlockT>::Hash,
RuntimeDispatchInfo<Balance, sp_weights::OldWeight>,
RuntimeDispatchInfo<Balance, sp_weights::Weight>,
> for TransactionPayment<C, Block>
where
Block: BlockT,
@@ -93,7 +93,7 @@ where
&self,
encoded_xt: Bytes,
at: Option<Block::Hash>,
) -> RpcResult<RuntimeDispatchInfo<Balance, sp_weights::OldWeight>> {
) -> RpcResult<RuntimeDispatchInfo<Balance, sp_weights::Weight>> {
let api = self.client.runtime_api();
let at_hash = at.unwrap_or_else(|| self.client.info().best_hash);
@@ -115,32 +115,15 @@ where
))
}
let api_version = api
.api_version::<dyn TransactionPaymentRuntimeApi<Block, Balance>>(at_hash)
.map_err(|e| map_err(e, "Failed to get transaction payment runtime api version"))?
.ok_or_else(|| {
CallError::Custom(ErrorObject::owned(
Error::RuntimeError.into(),
"Transaction payment runtime api wasn't found in the runtime",
None::<String>,
))
})?;
let res = api
.query_info(at_hash, uxt, encoded_len)
.map_err(|e| map_err(e, "Unable to query dispatch info."))?;
if api_version < 2 {
#[allow(deprecated)]
api.query_info_before_version_2(at_hash, uxt, encoded_len)
.map_err(|e| map_err(e, "Unable to query dispatch info.").into())
} else {
let res = api
.query_info(at_hash, uxt, encoded_len)
.map_err(|e| map_err(e, "Unable to query dispatch info."))?;
Ok(RuntimeDispatchInfo {
weight: sp_weights::OldWeight(res.weight.ref_time()),
class: res.class,
partial_fee: res.partial_fee,
})
}
Ok(RuntimeDispatchInfo {
weight: res.weight,
class: res.class,
partial_fee: res.partial_fee,
})
}
fn query_fee_details(