Fix transaction payment runtime api (#6792)

The transaction payment runtime api used its own extrinsic generic
parameter. This is wrong, because this resulted in using always the
native extrinsic. If there was a runtime upgrade that changed the
extrinsic in some way, it would result in the api breaking. The correct
way is to use the `Extrinsic` from the `Block` parameter. This is on the
node side the opaque extrinsic and on the runtime side the real extrinsic.
This commit is contained in:
Bastian Köcher
2020-08-03 10:46:53 +02:00
committed by GitHub
parent 1365eef4c1
commit 02c879ec49
4 changed files with 8 additions and 12 deletions
@@ -69,14 +69,13 @@ impl From<Error> for i64 {
}
}
impl<C, Block, Balance, Extrinsic> TransactionPaymentApi<<Block as BlockT>::Hash, RuntimeDispatchInfo<Balance>>
for TransactionPayment<C, (Block, Extrinsic)>
impl<C, Block, Balance> TransactionPaymentApi<<Block as BlockT>::Hash, RuntimeDispatchInfo<Balance>>
for TransactionPayment<C, Block>
where
Block: BlockT,
C: Send + Sync + 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,
C::Api: TransactionPaymentRuntimeApi<Block, Balance, Extrinsic>,
C::Api: TransactionPaymentRuntimeApi<Block, Balance>,
Balance: Codec + MaybeDisplay + MaybeFromStr,
Extrinsic: Codec + Send + Sync + 'static,
{
fn query_info(
&self,
@@ -91,7 +90,7 @@ where
let encoded_len = encoded_xt.len() as u32;
let uxt: Extrinsic = Decode::decode(&mut &*encoded_xt).map_err(|e| RpcError {
let uxt: Block::Extrinsic = Decode::decode(&mut &*encoded_xt).map_err(|e| RpcError {
code: ErrorCode::ServerError(Error::DecodeError.into()),
message: "Unable to query dispatch info.".into(),
data: Some(format!("{:?}", e).into()),