This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Benchmark pallet sudo #13880
Merged
Merged
Benchmark pallet sudo #13880
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
086d363
set_key
Doordashcon 0319a2f
v2
Doordashcon 6e16a8c
Merge branch 'master' into ddc-OG
Doordashcon 6cccbfe
update runtime
Doordashcon 7b5817b
Merge branch 'ddc-OG' of https://github.com/Doordashcon/substrate int…
Doordashcon fd71be3
cargo fmt
Doordashcon 823d98b
remove commenting
Doordashcon e082fec
Merge branch 'master' of https://github.com/paritytech/substrate into…
5078939
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_sudo
01a597a
impl weights
Doordashcon 811d52d
Merge branch 'paritytech:master' into ddc-OG
Doordashcon fe6e0a4
Merge branch 'paritytech:master' into ddc-OG
Doordashcon 1890456
sudo & sudo_as
Doordashcon 885b7b0
Merge branch 'paritytech:master' into ddc-OG
Doordashcon 28878cf
where
Doordashcon 6d9d079
Merge branch 'paritytech:master' into ddc-OG
Doordashcon f931e7b
Merge branch 'paritytech:master' into ddc-OG
Doordashcon e38b8a9
Merge branch 'master' of https://github.com/paritytech/substrate into…
891a949
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_sudo
8ffafdf
update weights
Doordashcon ff180b3
cargo fmt
Doordashcon ff4405c
Merge branch 'paritytech:master' into ddc-OG
Doordashcon fc1d8af
Merge branch 'paritytech:master' into ddc-OG
Doordashcon 6c3acef
Update Cargo.lock
ggwpez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! Benchmarks for Sudo Pallet | ||
|
|
||
| use super::*; | ||
| use crate::Pallet; | ||
| use frame_benchmarking::v2::*; | ||
| use frame_system::RawOrigin; | ||
|
|
||
| const SEED: u32 = 0; | ||
|
|
||
| fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) { | ||
| frame_system::Pallet::<T>::assert_last_event(generic_event.into()); | ||
| } | ||
|
|
||
| #[benchmarks( where <T as Config>::RuntimeCall: From<frame_system::Call<T>>)] | ||
| mod benchmarks { | ||
| use super::*; | ||
|
|
||
| #[benchmark] | ||
| fn set_key() { | ||
| let caller: T::AccountId = whitelisted_caller(); | ||
| Key::<T>::put(caller.clone()); | ||
|
|
||
| let new_sudoer: T::AccountId = account("sudoer", 0, SEED); | ||
| let new_sudoer_lookup = T::Lookup::unlookup(new_sudoer.clone()); | ||
|
|
||
| #[extrinsic_call] | ||
| _(RawOrigin::Signed(caller.clone()), new_sudoer_lookup); | ||
|
|
||
| assert_last_event::<T>(Event::KeyChanged { old_sudoer: Some(caller) }.into()); | ||
| } | ||
|
|
||
| #[benchmark] | ||
| fn sudo() { | ||
| let caller: T::AccountId = whitelisted_caller(); | ||
| Key::<T>::put(caller.clone()); | ||
|
|
||
| let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); | ||
|
|
||
| #[extrinsic_call] | ||
| _(RawOrigin::Signed(caller.clone()), Box::new(call.clone())); | ||
|
|
||
| assert_last_event::<T>(Event::Sudid { sudo_result: Ok(()) }.into()) | ||
| } | ||
|
|
||
| #[benchmark] | ||
| fn sudo_as() { | ||
| let caller: T::AccountId = whitelisted_caller(); | ||
| Key::<T>::put(caller.clone()); | ||
|
|
||
| let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); | ||
|
|
||
| let who: T::AccountId = account("as", 0, SEED); | ||
| let who_lookup = T::Lookup::unlookup(who.clone()); | ||
|
|
||
| #[extrinsic_call] | ||
| _(RawOrigin::Signed(caller), who_lookup, Box::new(call.clone())); | ||
|
|
||
| assert_last_event::<T>(Event::SudoAsDone { sudo_result: Ok(()) }.into()) | ||
| } | ||
|
|
||
| impl_benchmark_test_suite!(Pallet, crate::mock::new_bench_ext(), crate::mock::Test); | ||
| } |
Doordashcon marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.