contracts: Add set_code root dispatchable (#11451)

* Add `set_code` dispatchable

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Alexander Theißen
2022-05-19 01:50:22 +02:00
committed by GitHub
parent bd225c7938
commit b3b7b4ddc7
4 changed files with 918 additions and 768 deletions
@@ -391,6 +391,20 @@ benchmarks! {
assert!(<Contract<T>>::code_removed(&hash));
}
set_code {
let instance = <Contract<T>>::with_caller(
whitelisted_caller(), WasmModule::dummy(), vec![],
)?;
// we just add some bytes so that the code hash is different
let WasmModule { code, hash, .. } = <WasmModule<T>>::dummy_with_bytes(128);
<Contracts<T>>::store_code_raw(code, instance.caller.clone())?;
let callee = instance.addr.clone();
assert_ne!(instance.info()?.code_hash, hash);
}: _(RawOrigin::Root, callee, hash)
verify {
assert_eq!(instance.info()?.code_hash, hash);
}
seal_caller {
let r in 0 .. API_BENCHMARK_BATCHES;
let instance = Contract::<T>::new(WasmModule::getter(