contracts: add seal_code_hash and seal_own_code_hash to API (#10933)

* `seal_origin` + tests added

* `seal_origin` benchmark added

* `seal_code_hash` + tests added

* `seal_code_hash` benchmark added

* `seal_own_code_hash` + tests added

* `seal_own_code_hash` benchmark added

* fmt lil fix

* akward accident bug fix

* Apply suggestions from code review

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* Apply suggestions from code review

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* benchmark fix

* `WasmModule::getter()` to take `module_name` arg

* test enhanced

* fixes based on review feedback

* Apply suggestions from code review

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* Hash left as const to return a ref to it from mock

* HASH test val to local const in mock

* Apply suggestions from code review

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* fixes to benchmarks according to review feedback

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --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

* removed `seal_origin` from API

Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Alexander Gryaznov
2022-03-29 17:14:49 +02:00
committed by GitHub
parent 83d4be6151
commit e4caf7388a
7 changed files with 995 additions and 658 deletions
@@ -339,12 +339,12 @@ where
/// Creates a wasm module that calls the imported function named `getter_name` `repeat`
/// times. The imported function is expected to have the "getter signature" of
/// (out_ptr: u32, len_ptr: u32) -> ().
pub fn getter(getter_name: &'static str, repeat: u32) -> Self {
pub fn getter(module_name: &'static str, getter_name: &'static str, repeat: u32) -> Self {
let pages = max_pages::<T>();
ModuleDefinition {
memory: Some(ImportedMemory::max::<T>()),
imported_functions: vec![ImportedFunction {
module: "seal0",
module: module_name,
name: getter_name,
params: vec![ValueType::I32, ValueType::I32],
return_type: None,