[contracts] Add per local weight for function call (#12806)

* Add per local weight for function call

* ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts

* Update frame/contracts/src/benchmarking/mod.rs

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

* apply suggestions from code review

* ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts

* Update frame/contracts/src/benchmarking/mod.rs

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

* tune the benchmark

* ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts

* fix benches

* ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts

Co-authored-by: command-bot <>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
Sasha Gryaznov
2022-12-06 11:52:12 +02:00
committed by GitHub
parent e1f38d95ec
commit c336eae64a
7 changed files with 1383 additions and 1267 deletions
@@ -29,11 +29,14 @@ use frame_support::traits::Get;
use sp_core::crypto::UncheckedFrom;
use sp_runtime::traits::Hash;
use sp_std::{borrow::ToOwned, prelude::*};
use wasm_instrument::parity_wasm::{
builder,
elements::{
self, BlockType, CustomSection, External, FuncBody, Instruction, Instructions, Module,
Section, ValueType,
use wasm_instrument::{
gas_metering,
parity_wasm::{
builder,
elements::{
self, BlockType, CustomSection, External, FuncBody, Instruction, Instructions, Module,
Section, ValueType,
},
},
};
@@ -541,7 +544,8 @@ where
fn inject_gas_metering<T: Config>(module: Module) -> Module {
let schedule = T::Schedule::get();
let gas_rules = schedule.rules(&module, Determinism::Deterministic);
wasm_instrument::gas_metering::inject(module, &gas_rules, "seal0").unwrap()
let backend = gas_metering::host_function::Injector::new("seal0", "gas");
gas_metering::inject(module, backend, &gas_rules).unwrap()
}
fn inject_stack_metering<T: Config>(module: Module) -> Module {