-
Notifications
You must be signed in to change notification settings - Fork 744
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
Add benchmarks to transaction extensions #2726
Conversation
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Re
So the main question here is whether this weight you got through benchmarks is added to the base tx weight. If so, then please just left all as is (no additional benchmarks required for our extensions) - just return |
Regarding
This part is already done, check out the PR doing it and merging into the original PR. Feel free to create additional PRs with any fixes/improvements. |
Something I forgot to address in my original comment: in the current implementation I'm just aiming to have a weight associated with running the whole |
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
That is what worries me. As I said, for non-bridge transactions, our extensions are just (almost) noops in term of weight. So if we'll have non-zero weights for that tx and it'll be added by default to the tx base weight (like |
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
This reverts commit 809b2e2.
@svyatonik at least for now, I reverted the benches for the bridge extensions altogether here. |
cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/frame_system_extensions.rs
Show resolved
Hide resolved
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.
Code looks good.
Just about the design: why did you opt to create a new SystemExtensionsWeightInfo
instead of just making it part of the WeightInfo
of frame-system
?
It causes a lot of changes (also breaking) and i dont really see the advantage.
//! Autogenerated weights for `pallet_transaction_payment` | ||
//! | ||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev | ||
//! DATE: 2023-12-21, STEPS: `2`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]` |
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.
Will need to re-generate those with the bench bot.
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.
There are a bunch of weight files which were just copied, some of them are outdated as well. Everything will need to be benched again before a release.
use frame_support::traits::fungibles::Inspect as FnInspect; | ||
|
||
#[cfg(feature = "runtime-benchmarks")] | ||
impl pallet_asset_conversion_tx_payment::ExtConfig for Runtime { |
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 wonder if we can get around copy&pasting this everywhere.
Maybe you can pull both functions into a shared crate?
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 tried really hard to make it generic but I found the setup is just too specific. One improvement here would be to move this to a BenchmarkHelper
kind of thing in the regular config.
@@ -1521,6 +1548,11 @@ mod benchmarking { | |||
} | |||
|
|||
benchmarks! { | |||
where_clause { where <T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>>, | |||
T: Config + Send + Sync + ExtConfig, |
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 understand that a TE itself should be Send + Sync
, but i dont get why we need this on the Config
as well.
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 need it for extensions holding a PhantomData
, but not for the other ones. I removed it where applicable.
substrate/frame/transaction-payment/asset-tx-payment/src/benchmarking.rs
Outdated
Show resolved
Hide resolved
substrate/frame/transaction-payment/asset-tx-payment/src/benchmarking.rs
Outdated
Show resolved
Hide resolved
@@ -22,7 +22,11 @@ use core::marker::PhantomData; | |||
|
|||
/// Weight functions for `{{pallet}}`. | |||
pub struct WeightInfo<T>(PhantomData<T>); | |||
{{#if (eq pallet "frame_system_extensions")}} |
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.
Looks a bit hacky, see my review comment
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.
It doesn't feel hacky to me, it's basically the same as the model for the frame_system
weights in the other templates. They also get special treatment because of the name, like in substrate/.maintain/frame-weight-template.hbs
.
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.
Yea but its not neccecary here since you can move the TE benchmarks to a new frame-system-ext-benchmarking
crate.
PS: But then it will need to use the weight trait from a different crate in frame-system
, that is also not so nice...
I actually think it's cleaner having them separate since the code being benchmarked in extensions does very different things compared to the system pallet, even though they both depend on |
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Removing some bounds as it came up in #2726 while still keeping `Send + Sync` capabilities. --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
Follow up effort on top of #2280
This PR implements benchmarking code for transaction extensions:
Extensions which still don't have benchmarks but could probably continue to use the default impl of
Weight::zero()
or call some existing weight function in the case of wrappers:Each extension's
TransactionExtensionBase::weight
impl needs to use the resulting weight function and adapt existing runtimes' benchmarking configuration to these changes. So far, this has been done for:RefundTransactionExtensionAdapter