-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Implement batch_all and update Utility pallet for weight refunds #7188
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.
Looks good, but not sure if we need some different base weight for transactional dispatchables?
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 don't see why there would be different weights based on transactional
dispatch. Should there be?
@xlc can you confirm quickly that the base weight running batch and batch_all are the same on your local computer?
If you want to be really safe, it is probably best for each function to get its own weight function anyway, rather than sharing one. It allows more flexibility in the future for customization and for the functions to potentially diverge in logic.
Local benchmark result (with bunch browser tabs open and IDE running)
diff --git a/frame/utility/src/benchmarking.rs b/frame/utility/src/benchmarking.rs
index 8ca0e216f..8713fecae 100644
--- a/frame/utility/src/benchmarking.rs
+++ b/frame/utility/src/benchmarking.rs
@@ -49,6 +49,19 @@ benchmarks! {
assert_last_event::<T>(Event::BatchCompleted.into())
}
+ batch_all {
+ let c in 0 .. 1000;
+ let mut calls: Vec<<T as Trait>::Call> = Vec::new();
+ for i in 0 .. c {
+ let call = frame_system::Call::remark(vec![]).into();
+ calls.push(call);
+ }
+ let caller = whitelisted_caller();
+ }: _(RawOrigin::Signed(caller), calls)
+ verify {
+ assert_last_event::<T>(Event::BatchCompleted.into())
+ }
+
as_derivative {
let u in 0 .. 1000;
let caller = account("caller", u, SEED); |
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
Does this needs an audit?
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
I have added the nice to have audit tag, but it seems the only logic it is touching is weights, with no so much concern from me? @gavofyork what do you think? |
ping @gavofyork |
We are done with the review for this PR - looks good to us! |
@xlc please merge master and we can merge this! :) |
bot merge |
Trying merge. |
Fixes #6519
Also updated
#[transactional]
to make it handle returns correctly.polkadot companion: paritytech/polkadot#1775