-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Update fee calc to use system::constants::BlockWeights.per_class.normal.base_extrinsic
#388
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep in mind that this only works for non-normal transactions if they share the same base extrinsic weight.
system::constants::BlockWeights.per_class.normal.base_extrinsic
src/services/blocks/BlocksService.ts
Outdated
? (api.consts.system.extrinsicBaseWeight as AbstractInt) | ||
: // We assume all dispatch classes have the same base_extrinsic value | ||
api.consts.system.blockWeights.perClass.normal.baseExtrinsic; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the js api has the value api.consts.system.extrinsicBaseWeight
set before the weight refactor and for a chain that has it, the latter one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If ^^^ is correct it'd be good to annotate the code above with something like "Behaviour changed with substrate PR #6629 (polkadot runtime vX.Y.Z)".
Sensible to do as you said:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a poor understanding on what is going on here, apologies.
I think this change merits a test or two.
src/services/blocks/BlocksService.ts
Outdated
? (api.consts.system.extrinsicBaseWeight as AbstractInt) | ||
: // We assume all dispatch classes have the same base_extrinsic value | ||
api.consts.system.blockWeights.perClass.normal.baseExtrinsic; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If ^^^ is correct it'd be good to annotate the code above with something like "Behaviour changed with substrate PR #6629 (polkadot runtime vX.Y.Z)".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; we'll revisit this more thoroughly in subsequent releases.
@TarikGul , @dvdplm , @kianenigma - I just re-did the whole thing. I forgot that the api always uses the latests metadata. If we are doing a query in a historical runtime we need to fetch the old metadata, decorate it, and grab the constant. If we are doing a query in the latest runtime we can save the effort and just use the decorated metadata built into the api. The logic is worth another look over |
?.extrinsicBaseWeight as AbstractInt; | ||
const extrinsicBaseWeightExists = | ||
api.consts.system.extrinsicBaseWeight || | ||
api.consts.system.blockWeights.perClass.normal.baseExtrinsic; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are making an assumption here that if a runtime has one of these in the metadata currently, all past runtimes will have it. Since we only support fee calcs on a limited number of chains I think this is ok for now
Still LGTM. |
closes: #385
For review discussion
Should we take into account
DispatchClass
when usingbaseExtrinsic
? At the moment polkadot runtimes have thebaseExtrinsic
for each class is fixed: https://github.com/paritytech/polkadot/blob/cd0e9186a6620aab846a8a54969a0e5bbecbd060/runtime/common/src/lib.rs#L88From my understanding the changes would roughly require a refactor of the
calc_fee.rs
logic to do something like take in the dispatch class for eachcalc_fee()
call and pass a mapping of thebase_extrinsic
weight for each dispatch class when creatingCalcFee.from_params()
.My two cents is that we should ship this fix ASAP, and then get the more thorough fix out next week.