Benchmark Polkadot Claims Pallet (#876)

* fix

* Starting to add benchmarks

* make compile

* add benchmarks

* Make work with Substrate master

* Bench validate unsigned

* back to polkadot master

* starting to add cli with feature flag

* more stuff

* Add to kusama

* Update Cargo.lock

* fix dev dep

* bump wasm builder

* Remove encode from keccak benchmark

* bump spec

* Add weight documentation

* Update Cargo.lock

* Update check_runtime.sh

* Update publish_draft_release.sh

* Update Cargo.lock

Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Shawn Tabrizi
2020-03-13 11:42:31 +02:00
committed by GitHub
parent 1736c2d576
commit 70a5bda2ce
29 changed files with 4196 additions and 4136 deletions
+4 -2
View File
@@ -18,7 +18,7 @@ babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/par
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
rstd = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
@@ -59,6 +59,7 @@ timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
utility = { package = "pallet-utility", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false, optional = true }
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
@@ -94,7 +95,7 @@ std = [
"tx-pool-api/std",
"block-builder-api/std",
"offchain-primitives/std",
"rstd/std",
"sp-std/std",
"sp-io/std",
"frame-support/std",
"authorship/std",
@@ -135,3 +136,4 @@ std = [
"randomness-collective-flip/std",
"runtime-common/std",
]
runtime-benchmarks = ["frame-benchmarking", "runtime-common/runtime-benchmarks"]
+1 -1
View File
@@ -19,7 +19,7 @@ use wasm_builder_runner::WasmBuilder;
fn main() {
WasmBuilder::new()
.with_current_project()
.with_wasm_builder_from_crates("1.0.9")
.with_wasm_builder_from_git("https://github.com/paritytech/substrate.git", "8c672e107789ed10973d937ba8cac245404377e2")
.import_memory()
.export_heap_base()
.build()
+31 -2
View File
@@ -20,7 +20,7 @@
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit="256"]
use rstd::prelude::*;
use sp_std::prelude::*;
use sp_core::u32_trait::{_1, _2, _3, _4, _5};
use codec::{Encode, Decode};
use primitives::{
@@ -39,6 +39,8 @@ use sp_runtime::{
curve::PiecewiseLinear,
traits::{BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup},
};
#[cfg(feature = "runtime-benchmarks")]
use sp_runtime::RuntimeString;
use version::RuntimeVersion;
use grandpa::{AuthorityId as GrandpaId, fg_primitives};
#[cfg(any(feature = "std", test))]
@@ -101,7 +103,7 @@ impl SignedExtension for RestrictFunctionality {
type Pre = ();
type DispatchInfo = DispatchInfo;
fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) }
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) }
fn validate(&self, _: &Self::AccountId, call: &Self::Call, _: DispatchInfo, _: usize)
-> TransactionValidity
@@ -867,4 +869,31 @@ sp_api::impl_runtime_apis! {
TransactionPayment::query_info(uxt, len)
}
}
#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn dispatch_benchmark(
module: Vec<u8>,
extrinsic: Vec<u8>,
lowest_range_values: Vec<u32>,
highest_range_values: Vec<u32>,
steps: Vec<u32>,
repeat: u32,
) -> Result<Vec<frame_benchmarking::BenchmarkResults>, RuntimeString> {
use frame_benchmarking::Benchmarking;
let result = match module.as_slice() {
b"claims" => Claims::run_benchmark(
extrinsic,
lowest_range_values,
highest_range_values,
steps,
repeat,
),
_ => Err("Benchmark not found for this pallet."),
};
result.map_err(|e| e.into())
}
}
}