Unverified Commit 6da1cf62 authored by Falco Hirschenberger's avatar Falco Hirschenberger Committed by GitHub
Browse files

Add call-decoding weight to benchmarks (#3866)

* Add add call-decoding weight to benchmarks

fixes #3864

* Change order as suggested by @thiolliere

* More reordering as @KiChjang

 suggested

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

* cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=polkadot-dev --steps=50 --repeat=20 --pallet=runtime_common::claims --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/polkadot/src/weights/runtime_common_claims.rs
Co-authored-by: default avatarParity Bot <admin@parity.io>
parent 1f850b0c
Pipeline #160818 passed with stages
in 40 minutes and 38 seconds
......@@ -1388,6 +1388,7 @@ mod benchmarking {
use super::*;
use crate::claims::Call;
use frame_benchmarking::{account, benchmarks};
use frame_support::dispatch::UnfilteredDispatchable;
use frame_system::RawOrigin;
use secp_utils::*;
use sp_runtime::{traits::ValidateUnsigned, DispatchResult};
......@@ -1443,10 +1444,15 @@ mod benchmarking {
super::Pallet::<T>::mint_claim(RawOrigin::Root.into(), eth_address, VALUE.into(), vesting, None)?;
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
let source = sp_runtime::transaction_validity::TransactionSource::External;
let call = Call::<T>::claim { dest: account.clone(), ethereum_signature: signature.clone() };
let call_enc = Call::<T>::claim {
dest: account.clone(),
ethereum_signature: signature.clone()
}.encode();
}: {
let call = <Call<T> as Decode>::decode(&mut &*call_enc)
.expect("call is encoded above, encoding must be correct");
super::Pallet::<T>::validate_unsigned(source, &call).map_err(|e| -> &'static str { e.into() })?;
super::Pallet::<T>::claim(RawOrigin::None.into(), account, signature)?;
call.dispatch_bypass_filter(RawOrigin::None.into())?;
}
verify {
assert_eq!(Claims::<T>::get(eth_address), None);
......@@ -1488,11 +1494,17 @@ mod benchmarking {
let signature = sig::<T>(&secret_key, &account.encode(), statement.to_text());
super::Pallet::<T>::mint_claim(RawOrigin::Root.into(), eth_address, VALUE.into(), vesting, Some(statement))?;
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
let call = Call::<T>::claim_attest { dest: account.clone(), ethereum_signature: signature.clone(), statement: StatementKind::Regular.to_text().to_vec() };
let call_enc = Call::<T>::claim_attest {
dest: account.clone(),
ethereum_signature: signature.clone(),
statement: StatementKind::Regular.to_text().to_vec()
}.encode();
let source = sp_runtime::transaction_validity::TransactionSource::External;
}: {
let call = <Call<T> as Decode>::decode(&mut &*call_enc)
.expect("call is encoded above, encoding must be correct");
super::Pallet::<T>::validate_unsigned(source, &call).map_err(|e| -> &'static str { e.into() })?;
super::Pallet::<T>::claim_attest(RawOrigin::None.into(), account, signature, statement.to_text().to_vec())?;
call.dispatch_bypass_filter(RawOrigin::None.into())?;
}
verify {
assert_eq!(Claims::<T>::get(eth_address), None);
......@@ -1518,7 +1530,7 @@ mod benchmarking {
Preclaims::<T>::insert(&account, eth_address);
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
let call = super::Call::attest { statement: StatementKind::Regular.to_text().to_vec() };
let call = super::Call::<T>::attest { statement: StatementKind::Regular.to_text().to_vec() };
// We have to copy the validate statement here because of trait issues... :(
let validate = |who: &T::AccountId, call: &super::Call<T>| -> DispatchResult {
if let Call::attest{ statement: attested_statement } = call {
......@@ -1529,9 +1541,12 @@ mod benchmarking {
}
Ok(())
};
let call_enc = call.encode();
}: {
let call = <Call<T> as Decode>::decode(&mut &*call_enc)
.expect("call is encoded above, encoding must be correct");
validate(&account, &call)?;
super::Pallet::<T>::attest(RawOrigin::Signed(account).into(), statement.to_text().to_vec())?;
call.dispatch_bypass_filter(RawOrigin::Signed(account).into())?;
}
verify {
assert_eq!(Claims::<T>::get(eth_address), None);
......
// Copyright 2017-2020 Parity Technologies (UK) Ltd.
// Copyright 2017-2021 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
......@@ -15,8 +15,8 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `runtime_common::claims`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
//! DATE: 2021-07-01, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-10-06, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128
// Executed Command:
......@@ -31,8 +31,10 @@
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --output=./runtime/kusama/src/weights/
// --output=./runtime/kusama/src/weights/runtime_common_claims.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
......@@ -42,28 +44,58 @@ use sp_std::marker::PhantomData;
/// Weight functions for `runtime_common::claims`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> runtime_common::claims::WeightInfo for WeightInfo<T> {
// Storage: Claims Claims (r:1 w:1)
// Storage: Claims Signing (r:1 w:1)
// Storage: Claims Total (r:1 w:1)
// Storage: Claims Vesting (r:1 w:1)
// Storage: Vesting Vesting (r:1 w:1)
// Storage: System Account (r:1 w:0)
// Storage: Balances Locks (r:1 w:1)
fn claim() -> Weight {
(438_457_000 as Weight)
(442_992_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
// Storage: Claims Total (r:1 w:1)
// Storage: Claims Vesting (r:0 w:1)
// Storage: Claims Claims (r:0 w:1)
// Storage: Claims Signing (r:0 w:1)
fn mint_claim() -> Weight {
(13_035_000 as Weight)
(12_098_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
// Storage: Claims Claims (r:1 w:1)
// Storage: Claims Signing (r:1 w:1)
// Storage: Claims Total (r:1 w:1)
// Storage: Claims Vesting (r:1 w:1)
// Storage: Vesting Vesting (r:1 w:1)
// Storage: System Account (r:1 w:0)
// Storage: Balances Locks (r:1 w:1)
fn claim_attest() -> Weight {
(439_894_000 as Weight)
(442_328_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
// Storage: Claims Preclaims (r:1 w:1)
// Storage: Claims Signing (r:1 w:1)
// Storage: Claims Claims (r:1 w:1)
// Storage: Claims Total (r:1 w:1)
// Storage: Claims Vesting (r:1 w:1)
// Storage: Vesting Vesting (r:1 w:1)
// Storage: System Account (r:1 w:0)
// Storage: Balances Locks (r:1 w:1)
fn attest() -> Weight {
(132_760_000 as Weight)
(126_506_000 as Weight)
.saturating_add(T::DbWeight::get().reads(8 as Weight))
.saturating_add(T::DbWeight::get().writes(7 as Weight))
}
// Storage: Claims Claims (r:1 w:2)
// Storage: Claims Vesting (r:1 w:2)
// Storage: Claims Signing (r:1 w:2)
// Storage: Claims Preclaims (r:1 w:1)
fn move_claim() -> Weight {
(28_459_000 as Weight)
(26_618_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(7 as Weight))
}
......
// Copyright 2017-2020 Parity Technologies (UK) Ltd.
// Copyright 2017-2021 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
......@@ -15,8 +15,8 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `runtime_common::claims`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
//! DATE: 2021-07-01, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-10-06, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 128
// Executed Command:
......@@ -31,8 +31,10 @@
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --output=./runtime/polkadot/src/weights/
// --output=./runtime/polkadot/src/weights/runtime_common_claims.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
......@@ -42,28 +44,58 @@ use sp_std::marker::PhantomData;
/// Weight functions for `runtime_common::claims`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> runtime_common::claims::WeightInfo for WeightInfo<T> {
// Storage: Claims Claims (r:1 w:1)
// Storage: Claims Signing (r:1 w:1)
// Storage: Claims Total (r:1 w:1)
// Storage: Claims Vesting (r:1 w:1)
// Storage: Vesting Vesting (r:1 w:1)
// Storage: System Account (r:1 w:0)
// Storage: Balances Locks (r:1 w:1)
fn claim() -> Weight {
(447_705_000 as Weight)
(440_159_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
// Storage: Claims Total (r:1 w:1)
// Storage: Claims Vesting (r:0 w:1)
// Storage: Claims Claims (r:0 w:1)
// Storage: Claims Signing (r:0 w:1)
fn mint_claim() -> Weight {
(11_995_000 as Weight)
(11_988_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
// Storage: Claims Claims (r:1 w:1)
// Storage: Claims Signing (r:1 w:1)
// Storage: Claims Total (r:1 w:1)
// Storage: Claims Vesting (r:1 w:1)
// Storage: Vesting Vesting (r:1 w:1)
// Storage: System Account (r:1 w:0)
// Storage: Balances Locks (r:1 w:1)
fn claim_attest() -> Weight {
(439_703_000 as Weight)
(443_037_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
// Storage: Claims Preclaims (r:1 w:1)
// Storage: Claims Signing (r:1 w:1)
// Storage: Claims Claims (r:1 w:1)
// Storage: Claims Total (r:1 w:1)
// Storage: Claims Vesting (r:1 w:1)
// Storage: Vesting Vesting (r:1 w:1)
// Storage: System Account (r:1 w:0)
// Storage: Balances Locks (r:1 w:1)
fn attest() -> Weight {
(128_588_000 as Weight)
(125_350_000 as Weight)
.saturating_add(T::DbWeight::get().reads(8 as Weight))
.saturating_add(T::DbWeight::get().writes(7 as Weight))
}
// Storage: Claims Claims (r:1 w:2)
// Storage: Claims Vesting (r:1 w:2)
// Storage: Claims Signing (r:1 w:2)
// Storage: Claims Preclaims (r:1 w:1)
fn move_claim() -> Weight {
(26_297_000 as Weight)
(26_261_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(7 as Weight))
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment