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

Transaction payment runtime api: query call info and fee details #11819

Merged

Conversation

muharem
Copy link
Contributor

@muharem muharem commented Jul 12, 2022

Related #11665

New rpc and runtime api calls to query weights and fee for Call.

Use case:

  • BuyExecution for XCM Transact operation, to execute Call.

Requirements:

  • provide runtime api calls to utilize api.rpc.state.call for light clients (not only RPC calls)
  • no new custom RPCs

Useful links:

@muharem muharem added A3-in_progress Pull request is in progress. No review needed at this stage. B3-apinoteworthy C3-medium PR touches the given topic and has a medium impact on builders. labels Jul 12, 2022
@github-actions github-actions bot added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Jul 12, 2022
frame/transaction-payment/rpc/runtime-api/src/lib.rs Outdated Show resolved Hide resolved
frame/transaction-payment/src/lib.rs Outdated Show resolved Hide resolved
frame/transaction-payment/rpc/runtime-api/src/lib.rs Outdated Show resolved Hide resolved
@muharem muharem changed the title Transaction payment RPC calls: query call info [inprocess] Transaction payment RPC calls: query call info Jul 12, 2022
frame/transaction-payment/rpc/src/lib.rs Outdated Show resolved Hide resolved
frame/transaction-payment/rpc/runtime-api/src/lib.rs Outdated Show resolved Hide resolved
frame/transaction-payment/rpc/runtime-api/src/lib.rs Outdated Show resolved Hide resolved
frame/transaction-payment/rpc/runtime-api/src/lib.rs Outdated Show resolved Hide resolved
frame/transaction-payment/rpc/runtime-api/src/lib.rs Outdated Show resolved Hide resolved
frame/transaction-payment/src/lib.rs Outdated Show resolved Hide resolved
@muharem muharem added A3-in_progress Pull request is in progress. No review needed at this stage. and removed A0-please_review Pull request needs code review. labels Jul 16, 2022
Copy link
Member

@athei athei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should create a follow up issue with https://github.com/polkadot-js/api so that the new API is supported there.

@muharem muharem added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Jul 18, 2022
@muharem muharem changed the title [inprocess] Transaction payment RPC calls: query call info Transaction payment RPC calls: query call info Jul 18, 2022
@athei
Copy link
Member

athei commented Aug 8, 2022

The problem here being that a runtime api should always use a "stable" api.

Why is this a problem?

@bkchr
Copy link
Member

bkchr commented Aug 8, 2022

The problem here being that a runtime api should always use a "stable" api.

Why is this a problem?

I know that I'm a little bit pedantic here.

@athei
Copy link
Member

athei commented Aug 9, 2022

The problem here being that a runtime api should always use a "stable" api.

Why is this a problem?

I know that I'm a little bit pedantic here.

It was an honest question. I want to know why you think it is better to fail later within the runtime. I don't understand why that changes anything compatibility wise. Clients still need to encode it according to whatever the runtime expects.

I think it is better to have the type defined on the runtime API so it is obvious for clients what the signature of the API is. Otherwise they need to look into the actual code that decodes it later to know what is expected. Additionally, the plan is to expose runtime APIs through metadata just like extrinsics which would be totally pointless if all types are opaque.

@bkchr
Copy link
Member

bkchr commented Aug 9, 2022

Hmm yeah good point and sorry for my useless answer.

Yeah, maybe we should treat them as some sort of special runtime api. In the future we should probably provide some way to expose these apis more easily from the runtime. Aka not requiring first to declare the api somewhere else.

@muharem muharem added A3-in_progress Pull request is in progress. No review needed at this stage. and removed A0-please_review Pull request needs code review. labels Aug 10, 2022
@athei
Copy link
Member

athei commented Aug 10, 2022

So we go back to declaring the proper type in the API? I am not sure what the implications are. i.e where does the decoding failure happen.

@muharem muharem added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Aug 10, 2022
@muharem muharem requested a review from bkchr August 10, 2022 09:21
@muharem
Copy link
Contributor Author

muharem commented Aug 10, 2022

@bkchr @athei using Call type now for api.

@athei decoding failure is upstream, somewhere within state_call.
I also tested the runtime api with Call type, by calling state_call and passing string of bytes from (Call, len).encode(). It works.

Balance: Codec + MaybeDisplay,
Call: Codec,
{
/// Query information of a dispatch class, weight, and fee of a given encoded `Call`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed panic, since the implementation itself is not supposed to panic, only upstream state_call

@muharem
Copy link
Contributor Author

muharem commented Aug 10, 2022

bot merge

@paritytech-processbot paritytech-processbot bot merged commit edeba3f into master Aug 10, 2022
@paritytech-processbot paritytech-processbot bot deleted the transaction-payment-rpc-calls-query-call-info branch August 10, 2022 10:36
DaviRain-Su pushed a commit to octopus-network/substrate that referenced this pull request Aug 23, 2022
…itytech#11819)

* Transaction payment RPC calls: query call info

* transaction payment pallet - runtime api - add query_call info and fee_details

* remove unused deps

* separate call runtime api

* undo fmt for unchanged code

* system config call bounded to GetDispatchInfo, drop Call generic for query call info/fee

* impl GetDispatchInfo for Extrinsics within runtime test-utils

* introduced runtime api methods accept encoded Call instead of Call type

* replace Bytes by Vec, docs for for new api, drop len argument, drop GetDispatchInfo bound from system_Config::Call

* clean up toml and extra impl for dropped bound

* panic if Call can not be decoded

* revert to 6d0ca79

* fmt and docs

* rustfmt
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…itytech#11819)

* Transaction payment RPC calls: query call info

* transaction payment pallet - runtime api - add query_call info and fee_details

* remove unused deps

* separate call runtime api

* undo fmt for unchanged code

* system config call bounded to GetDispatchInfo, drop Call generic for query call info/fee

* impl GetDispatchInfo for Extrinsics within runtime test-utils

* introduced runtime api methods accept encoded Call instead of Call type

* replace Bytes by Vec, docs for for new api, drop len argument, drop GetDispatchInfo bound from system_Config::Call

* clean up toml and extra impl for dropped bound

* panic if Call can not be decoded

* revert to 6d0ca79

* fmt and docs

* rustfmt
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C3-medium PR touches the given topic and has a medium impact on builders. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants