Create benchmark for the system::set_code instrisic (#13373)

* Still WIP

# Conflicts:
#	frame/system/src/weights.rs

* Still WIP

* Add benchmark for system::set_code intrinsic

fixes #13192

* Fix format

* Add missing benchmark runtime

* Fix lint warning

* Consume the rest of the block and add test verification after the benchmark

* Rewrite set_code function

* Try to fix benchmarks and tests

* Remove weight tags

* Update frame/system/src/tests.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Register ReadRuntimeVersionExt for benches

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix tests

* Fix deprecations

* Fix deprecations

* ".git/.scripts/commands/bench/bench.sh" pallet dev frame_system

* Add update info and remove obsolete complexity comments.

* ".git/.scripts/commands/fmt/fmt.sh"

* Update frame/system/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update frame/system/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update frame/system/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update frame/system/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update frame/system/benchmarking/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* ".git/.scripts/commands/fmt/fmt.sh"

* Update README.md

Just trigger CI rebuild

* Update README.md

Trigger CI

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: command-bot <>
This commit is contained in:
Falco Hirschenberger
2023-05-11 18:25:50 +02:00
committed by GitHub
parent 05201c4047
commit 0eeaf7709f
11 changed files with 148 additions and 75 deletions
+6 -2
View File
@@ -170,7 +170,7 @@ impl frame_system::Config for Test {
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SystemWeightInfo = frame_system::weights::SubstrateWeight<Test>;
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
@@ -916,12 +916,16 @@ fn batch_all_works_with_council_origin() {
#[test]
fn with_weight_works() {
new_test_ext().execute_with(|| {
use frame_system::WeightInfo;
let upgrade_code_call =
Box::new(RuntimeCall::System(frame_system::Call::set_code_without_checks {
code: vec![],
}));
// Weight before is max.
assert_eq!(upgrade_code_call.get_dispatch_info().weight, Weight::MAX);
assert_eq!(
upgrade_code_call.get_dispatch_info().weight,
<Test as frame_system::Config>::SystemWeightInfo::set_code()
);
assert_eq!(
upgrade_code_call.get_dispatch_info().class,
frame_support::dispatch::DispatchClass::Operational