-
Notifications
You must be signed in to change notification settings - Fork 798
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
set_validation_data
register weight manually, do not use refund when the pre dispatch is zero.
#7327
Conversation
/cmd prdoc --audience runtime-dev |
Command "prdoc --audience runtime-dev" has failed ❌! See logs here |
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.
Thank you. I can confirm that the try-runtime
errors are gone.
@@ -692,7 +692,12 @@ pub mod pallet { | |||
vfp.relay_parent_number, | |||
)); | |||
|
|||
Ok(PostDispatchInfo { actual_weight: Some(total_weight), pays_fee: Pays::No }) | |||
frame_system::Pallet::<T>::register_extra_weight_unchecked( | |||
total_weight, |
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 assume we don't know an upper bound for this value pre-dispatch because it is calculated ad-hoc?
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.
Yes but it's once per block and we register the weight, meaning it will be correctly accounted for in the following transactions.
If we go with the worst case weight here before dispatching, we might greatly underestimate the block space we have since those stuctures in ParachainInherentData
can grow a lot as far as I'm aware. This model works best IMO.
DispatchClass::Mandatory, | ||
); | ||
|
||
Ok(Pays::No.into()) |
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.
Nit: You can change the return type of the dispatchable to just DispatchResult
.
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.
done in e988d2b
@@ -692,7 +692,12 @@ pub mod pallet { | |||
vfp.relay_parent_number, | |||
)); | |||
|
|||
Ok(PostDispatchInfo { actual_weight: Some(total_weight), pays_fee: Pays::No }) | |||
frame_system::Pallet::<T>::register_extra_weight_unchecked( | |||
total_weight, |
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.
Yes but it's once per block and we register the weight, meaning it will be correctly accounted for in the following transactions.
If we go with the worst case weight here before dispatching, we might greatly underestimate the block space we have since those stuctures in ParachainInherentData
can grow a lot as far as I'm aware. This model works best IMO.
DispatchClass::Mandatory, | ||
); | ||
|
||
Ok(Pays::No.into()) |
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.
Does it make a difference here if we just return this vs Ok(PostDispatchInfo { actual_weight: Some(total_weight), pays_fee: Pays::No })
? It would look more correct to me
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.
That is what we were doing before (this PR removes this line) and it was incorrect. This is because you cant (or should not) return a post dispatch weight that is higher than the pre dispatch weight. It will not be charged. Hence the error that was emitted by try runtime.
This indeed gets rid of the message for
Here only the polkadot-sdk/substrate/frame/support/src/dispatch.rs Lines 313 to 320 in e5a9dab
Maybe we need to move it again so that we can differentiate between para and relaychain. |
Do you know which dispatchable is causing that? We can just give it the same treatment. Or if it is a pallet only used on the relay chain (where PoV doesn't matter) just set pre-dispatch PoV to something super high? |
Or do not print it if |
I have kept other logs in storage weight reclaim. I just added this log because it was scary to silently ignoring post dispatch excess weight.
If the pallet is only used in relay chain and we don't want to fix the benchmark or weight calculation for the call, we can also set the proof size in the post info equal to the pre-dispatch info. |
Command help:
|
Related #6772
For an extrinsic, in the post dispatch info, the actual weight is only used to reclaim unused weight. If the actual weight is more than the pre dispatch weight, then the extrinsic is using the minimum, e.g., the weight used registered in pre dispatch.
In parachain-system pallet one call is
set_validation_data
. This call is returning an actual weight, but the pre-dispatch weight is 0.This PR fix the disregard of actual weight of
set_validation_data
by registering it manually.