Token swap pallet benchmarks (#1174)

* token swap benchmarks

* spellcheck
This commit is contained in:
Svyatoslav Nikolsky
2021-10-08 12:35:11 +03:00
committed by Bastian Köcher
parent c0df990b90
commit 4b525f4fe1
14 changed files with 500 additions and 49 deletions
+11 -20
View File
@@ -51,7 +51,7 @@ use crate::{
use bp_messages::{
source_chain::{
LaneMessageVerifier, MessageDeliveryAndDispatchPayment, OnDeliveryConfirmed,
OnMessageAccepted, TargetHeaderChain,
OnMessageAccepted, SendMessageArtifacts, TargetHeaderChain,
},
target_chain::{
DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages, SourceHeaderChain,
@@ -281,7 +281,10 @@ pub mod pallet {
payload,
delivery_and_dispatch_fee,
)
.map(|sent_message| sent_message.post_dispatch_info)
.map(|sent_message| PostDispatchInfo {
actual_weight: Some(sent_message.weight),
pays_fee: Pays::Yes,
})
}
/// Pay additional fee for the message.
@@ -853,27 +856,21 @@ where
lane: LaneId,
message: T::OutboundPayload,
delivery_and_dispatch_fee: T::OutboundMessageFee,
) -> Result<MessageNonce, Self::Error> {
) -> Result<SendMessageArtifacts, Self::Error> {
crate::send_message::<T, I>(sender, lane, message, delivery_and_dispatch_fee)
.map(|sent_message| sent_message.nonce)
}
}
/// Message that has been sent.
struct SentMessage {
/// Nonce of the message.
pub nonce: MessageNonce,
/// Post-dispatch call info.
pub post_dispatch_info: PostDispatchInfo,
}
/// Function that actually sends message.
fn send_message<T: Config<I>, I: 'static>(
submitter: bp_messages::source_chain::Sender<T::AccountId>,
lane_id: LaneId,
payload: T::OutboundPayload,
delivery_and_dispatch_fee: T::OutboundMessageFee,
) -> sp_std::result::Result<SentMessage, sp_runtime::DispatchErrorWithPostInfo<PostDispatchInfo>> {
) -> sp_std::result::Result<
SendMessageArtifacts,
sp_runtime::DispatchErrorWithPostInfo<PostDispatchInfo>,
> {
ensure_normal_operating_mode::<T, I>()?;
// initially, actual (post-dispatch) weight is equal to pre-dispatch weight
@@ -986,13 +983,7 @@ fn send_message<T: Config<I>, I: 'static>(
Pallet::<T, I>::deposit_event(Event::MessageAccepted(lane_id, nonce));
Ok(SentMessage {
nonce,
post_dispatch_info: PostDispatchInfo {
actual_weight: Some(actual_weight),
pays_fee: Pays::Yes,
},
})
Ok(SendMessageArtifacts { nonce, weight: actual_weight })
}
/// Ensure that the origin is either root, or `PalletOwner`.
+3 -3
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for pallet_bridge_messages
//! Autogenerated weights for `pallet_bridge_messages`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
//! DATE: 2021-06-18, STEPS: [50, ], REPEAT: 20
@@ -46,7 +46,7 @@ use frame_support::{
};
use sp_std::marker::PhantomData;
/// Weight functions needed for pallet_bridge_messages.
/// Weight functions needed for `pallet_bridge_messages`.
pub trait WeightInfo {
fn send_minimal_message_worst_case() -> Weight;
fn send_1_kb_message_worst_case() -> Weight;
@@ -71,7 +71,7 @@ pub trait WeightInfo {
fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight;
}
/// Weights for pallet_bridge_messages using the Rialto node and recommended hardware.
/// Weights for `pallet_bridge_messages` using the Rialto node and recommended hardware.
pub struct RialtoWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
fn send_minimal_message_worst_case() -> Weight {