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

Make get_dispatch_info and weight_to_fee Available via state_call #11665

Closed
joepetrowski opened this issue Jun 14, 2022 · 8 comments · Fixed by paritytech/polkadot#5871 or paritytech/cumulus#1535
Assignees
Labels
J0-enhancement An additional feature request. U3-nice_to_have Issue is worth doing eventually. Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.

Comments

@joepetrowski
Copy link
Contributor

joepetrowski commented Jun 14, 2022

When constructing XCM Transact calls, it's useful to have an idea of how much weight some call will consume and how much that weight will cost in order to BuyExecution. query_info only takes a fully encoded extrinsic and returns the weight and fee, but requires some hacks, namely:

  • Users must add some bytes to represent an extrinsic (signature/signed extensions), but an XCM Transact will just have the call.
  • The return includes the length fee and the ExtrinsicBaseWeight, which are not relevant in Transact.

The addition of these two endpoints would allow submission of a Call and obtaining its weight and a fee estimate (with the user knowing that the weight to fee rate can be variable so they'll want to supply a little extra):

Related: polkadot-js/apps#7688

@joepetrowski joepetrowski added J0-enhancement An additional feature request. U3-nice_to_have Issue is worth doing eventually. Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be. labels Jun 14, 2022
@bkchr
Copy link
Member

bkchr commented Jun 14, 2022

This is already returned by payment_querInfo.

And should that not be doable with payment_queryFeeDetails?

@joepetrowski
Copy link
Contributor Author

joepetrowski commented Jun 14, 2022

This is already returned by payment_querInfo

AFAIK, no, because it expects an extrinsic, not just a call.

@joepetrowski joepetrowski changed the title Make get_dispatch_info and weight_to_fee Available via RPC Make weight_to_fee Available via RPC Jun 14, 2022
@joepetrowski joepetrowski changed the title Make weight_to_fee Available via RPC Make get_dispatch_info and weight_to_fee Available via RPC Jul 4, 2022
@athei
Copy link
Member

athei commented Jul 5, 2022

But is there any reason why you couldn't turn your call into an extrinsic and then submit it to these RPCs? It shouldn't matter with which key the extrinsic is signed.

@joepetrowski
Copy link
Contributor Author

It's possible but it's also kind of a hack IMO. @TarikGul wrote this script to do that and that's what I use now.

It also doesn't give you the weight and execution cost of the call, because it includes ExtrinsicBaseWeight and the length fee. Calls made over XCM don't have this overhead. Again, it's OK-ish as it's an overestimate, but IMO we expect an increase in para-to-para interaction with instructions that are not signed by users, so we should expose weight and fee info related to executing the instructions and not on verifying signatures.

@xlc
Copy link
Contributor

xlc commented Jul 5, 2022

One thing I would like to add is that as we want to start using light client more, which doesn't supports custom RPC, we should avoid adding more custom RPC instead. The alternative solution is add new runtime API and use state_call to call the runtime API.

@joepetrowski
Copy link
Contributor Author

Yes, that's why I linked to the runtime API source in the main body.
https://github.com/paritytech/substrate/blob/ef66142/frame/transaction-payment/rpc/runtime-api/src/lib.rs

@muharem
Copy link
Contributor

muharem commented Jul 11, 2022

Had a chat with @bkontur
Picking up the issue

@muharem muharem unpinned this issue Jul 11, 2022
@athei
Copy link
Member

athei commented Jul 11, 2022

Please keep in mind what @xlc said: Don't add a new RPC. Having a new runtime API should be enough in order to call it through state_call.

@gilescope gilescope changed the title Make get_dispatch_info and weight_to_fee Available via RPC Make get_dispatch_info and weight_to_fee Available via state_call Jul 12, 2022
@muharem muharem added D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. and removed D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. labels Jul 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request. U3-nice_to_have Issue is worth doing eventually. Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.
Projects
None yet
7 participants