mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
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: Parity Bot <admin@parity.io>
This commit is contained in:
committed by
GitHub
parent
57125623ed
commit
4b9fc6460e
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user