Set CurrentCodeHash before running some dispatchable benchmarks (#4645)

* Set CurrentCodeHash before running some dispatchable benchmarks

* Use insert instead of put

* Actually hash the ValidationCode

* cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_parachains::paras --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_parachains_paras.rs

Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Keith Yeung
2022-01-02 18:05:37 -08:00
committed by GitHub
parent 575775a19f
commit 5047ef8eff
2 changed files with 18 additions and 11 deletions
@@ -81,6 +81,7 @@ benchmarks! {
let c in 1 .. MAX_CODE_SIZE;
let new_code = ValidationCode(vec![0; c as usize]);
let para_id = ParaId::from(c as u32);
<Pallet<T> as Store>::CurrentCodeHash::insert(&para_id, new_code.hash());
generate_disordered_pruning::<T>();
}: _(RawOrigin::Root, para_id, new_code)
verify {
@@ -108,6 +109,8 @@ benchmarks! {
let s in 1 .. MAX_HEAD_DATA_SIZE;
let para_id = ParaId::from(1000);
let new_head = HeadData(vec![0; s as usize]);
let old_code_hash = ValidationCode(vec![0]).hash();
<Pallet<T> as Store>::CurrentCodeHash::insert(&para_id, old_code_hash);
// schedule an expired code upgrade for this `para_id` so that force_note_new_head would use
// the worst possible code path
let expired = frame_system::Pallet::<T>::block_number().saturating_sub(One::one());