mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 21:01:02 +00:00
fix benchmarks before using it in Polkadot/Kusama/Rococo runtimes (#1309)
This commit is contained in:
committed by
Bastian Köcher
parent
d4e692e429
commit
43d2e4967b
@@ -860,7 +860,7 @@ impl_runtime_apis! {
|
||||
fn prepare_outbound_message(
|
||||
params: MessageParams<Self::AccountId>,
|
||||
) -> (rialto_messages::ToRialtoMessagePayload, Balance) {
|
||||
prepare_outbound_message::<WithRialtoMessageBridge>(params)
|
||||
(prepare_outbound_message::<WithRialtoMessageBridge>(params), Self::message_fee())
|
||||
}
|
||||
|
||||
fn prepare_message_proof(
|
||||
|
||||
@@ -46,7 +46,7 @@ use sp_version::RuntimeVersion;
|
||||
/// Prepare outbound message for the `send_message` call.
|
||||
pub fn prepare_outbound_message<B>(
|
||||
params: MessageParams<AccountIdOf<ThisChain<B>>>,
|
||||
) -> (FromThisChainMessagePayload<B>, BalanceOf<ThisChain<B>>)
|
||||
) -> FromThisChainMessagePayload<B>
|
||||
where
|
||||
B: MessageBridge,
|
||||
BalanceOf<ThisChain<B>>: From<u64>,
|
||||
@@ -54,14 +54,13 @@ where
|
||||
let message_payload = vec![0; params.size as usize];
|
||||
let dispatch_origin = bp_message_dispatch::CallOrigin::SourceAccount(params.sender_account);
|
||||
|
||||
let message = FromThisChainMessagePayload::<B> {
|
||||
FromThisChainMessagePayload::<B> {
|
||||
spec_version: 0,
|
||||
weight: params.size as _,
|
||||
origin: dispatch_origin,
|
||||
call: message_payload,
|
||||
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
|
||||
};
|
||||
(message, pallet_bridge_messages::benchmarking::MESSAGE_FEE.into())
|
||||
}
|
||||
}
|
||||
|
||||
/// Prepare proof of messages for the `receive_messages_proof` call.
|
||||
|
||||
@@ -32,9 +32,6 @@ use frame_support::{traits::Get, weights::Weight};
|
||||
use frame_system::RawOrigin;
|
||||
use sp_std::{collections::vec_deque::VecDeque, convert::TryInto, ops::RangeInclusive, prelude::*};
|
||||
|
||||
/// Fee paid by submitter for single message delivery.
|
||||
pub const MESSAGE_FEE: u64 = 100_000_000_000;
|
||||
|
||||
const SEED: u32 = 0;
|
||||
|
||||
/// Pallet we're benchmarking here.
|
||||
@@ -103,6 +100,10 @@ pub trait Config<I: 'static>: crate::Config<I> {
|
||||
fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee;
|
||||
/// Create given account and give it enough balance for test purposes.
|
||||
fn endow_account(account: &Self::AccountId);
|
||||
/// Fee paid by submitter for single message delivery.
|
||||
fn message_fee() -> Self::OutboundMessageFee {
|
||||
100_000_000_000_000.into()
|
||||
}
|
||||
/// Prepare message to send over lane.
|
||||
fn prepare_outbound_message(
|
||||
params: MessageParams<Self::AccountId>,
|
||||
@@ -138,8 +139,10 @@ benchmarks_instance_pallet! {
|
||||
// added.
|
||||
send_minimal_message_worst_case {
|
||||
let lane_id = T::bench_lane_id();
|
||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||
let sender = account("sender", 0, SEED);
|
||||
T::endow_account(&sender);
|
||||
T::endow_account(&relayers_fund_id);
|
||||
|
||||
// 'send' messages that are to be pruned when our message is sent
|
||||
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
||||
@@ -169,8 +172,10 @@ benchmarks_instance_pallet! {
|
||||
// `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`.
|
||||
send_1_kb_message_worst_case {
|
||||
let lane_id = T::bench_lane_id();
|
||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||
let sender = account("sender", 0, SEED);
|
||||
T::endow_account(&sender);
|
||||
T::endow_account(&relayers_fund_id);
|
||||
|
||||
// 'send' messages that are to be pruned when our message is sent
|
||||
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
||||
@@ -206,8 +211,10 @@ benchmarks_instance_pallet! {
|
||||
// `(send_16_kb_message_worst_case - send_1_kb_message_worst_case) / 15`.
|
||||
send_16_kb_message_worst_case {
|
||||
let lane_id = T::bench_lane_id();
|
||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||
let sender = account("sender", 0, SEED);
|
||||
T::endow_account(&sender);
|
||||
T::endow_account(&relayers_fund_id);
|
||||
|
||||
// 'send' messages that are to be pruned when our message is sent
|
||||
for _nonce in 1..=T::MaxMessagesToPruneAtOnce::get() {
|
||||
@@ -239,8 +246,10 @@ benchmarks_instance_pallet! {
|
||||
//
|
||||
// Result of this benchmark is directly used by weight formula of the call.
|
||||
maximal_increase_message_fee {
|
||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||
let sender = account("sender", 42, SEED);
|
||||
T::endow_account(&sender);
|
||||
T::endow_account(&relayers_fund_id);
|
||||
|
||||
let additional_fee = T::account_balance(&sender);
|
||||
let lane_id = T::bench_lane_id();
|
||||
@@ -258,8 +267,10 @@ benchmarks_instance_pallet! {
|
||||
increase_message_fee {
|
||||
let i in 0..T::maximal_message_size().try_into().unwrap_or_default();
|
||||
|
||||
let relayers_fund_id = crate::relayer_fund_account_id::<T::AccountId, T::AccountIdConverter>();
|
||||
let sender = account("sender", 42, SEED);
|
||||
T::endow_account(&sender);
|
||||
T::endow_account(&relayers_fund_id);
|
||||
|
||||
let additional_fee = T::account_balance(&sender);
|
||||
let lane_id = T::bench_lane_id();
|
||||
@@ -506,7 +517,7 @@ benchmarks_instance_pallet! {
|
||||
verify {
|
||||
assert_eq!(
|
||||
T::account_balance(&relayer_id),
|
||||
relayer_balance + MESSAGE_FEE.into(),
|
||||
relayer_balance + T::message_fee(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -600,12 +611,12 @@ benchmarks_instance_pallet! {
|
||||
|
||||
fn send_regular_message<T: Config<I>, I: 'static>() {
|
||||
let mut outbound_lane = outbound_lane::<T, I>(T::bench_lane_id());
|
||||
outbound_lane.send_message(MessageData { payload: vec![], fee: MESSAGE_FEE.into() });
|
||||
outbound_lane.send_message(MessageData { payload: vec![], fee: T::message_fee() });
|
||||
}
|
||||
|
||||
fn send_regular_message_with_payload<T: Config<I>, I: 'static>(payload: Vec<u8>) {
|
||||
let mut outbound_lane = outbound_lane::<T, I>(T::bench_lane_id());
|
||||
outbound_lane.send_message(MessageData { payload, fee: MESSAGE_FEE.into() });
|
||||
outbound_lane.send_message(MessageData { payload, fee: T::message_fee() });
|
||||
}
|
||||
|
||||
fn confirm_message_delivery<T: Config<I>, I: 'static>(nonce: MessageNonce) {
|
||||
|
||||
Reference in New Issue
Block a user