Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Consume the rest of the block and add test verification after the ben…
Browse files Browse the repository at this point in the history
…chmark
  • Loading branch information
hirschenberger committed Feb 14, 2023
1 parent 37d21f9 commit 911f122
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
11 changes: 2 additions & 9 deletions frame/system/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use codec::Encode;
use frame_benchmarking::v1::{benchmarks, whitelisted_caller};
use frame_support::{dispatch::DispatchClass, storage, traits::Get};
use frame_system::{Call, EventRecord, Pallet as System, Phase, RawOrigin};
use frame_system::{Call, Pallet as System, RawOrigin};
use sp_core::storage::well_known_keys;
use sp_runtime::traits::Hash;
use sp_std::{prelude::*, vec};
Expand Down Expand Up @@ -52,14 +52,7 @@ benchmarks! {
let runtime_blob = include_bytes!("../res/kitchensink_runtime.compact.compressed.wasm");
}: _(RawOrigin::Root, runtime_blob.to_vec())
verify {
assert_eq!(
System::<T>::events(),
vec![EventRecord {
phase: Phase::Initialization,
event: frame_system::Event::<T>::CodeUpdated.into(),
topics: vec![],
}],
);
System::<T>::assert_last_event(frame_system::Event::<T>::CodeUpdated.into());
}

#[extra]
Expand Down
3 changes: 2 additions & 1 deletion frame/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ pub mod pallet {
ensure_root(origin)?;
Self::can_set_code(&code)?;
T::OnSetCode::set_code(code)?;
Ok(().into())
// consume the rest of the block to prevent further transactions
Ok(Some(T::BlockWeights::get().max_block).into())
}

/// Set the new runtime code without doing any checks of the given `code`.
Expand Down

0 comments on commit 911f122

Please sign in to comment.