pallet_messenger/extensions/
weights.rs

1//! Weights for pallet-messenger extensions
2
3use crate::extensions::weights_from_consensus::WeightInfo as WeightsFromConsensus;
4use crate::extensions::weights_from_domains::WeightInfo as WeightsFromDomains;
5use core::marker::PhantomData;
6use frame_support::pallet_prelude::Weight;
7
8/// Weight functions needed for pallet messenger extension.
9pub trait WeightInfo: FromConsensusWeightInfo + FromDomainWeightInfo {
10    fn mmr_proof_verification_on_consensus() -> Weight;
11    fn mmr_proof_verification_on_domain() -> Weight;
12}
13
14pub trait FromConsensusWeightInfo {
15    fn from_consensus_relay_message_channel_open() -> Weight;
16    fn from_consensus_relay_message() -> Weight;
17    fn from_consensus_relay_message_response() -> Weight;
18}
19
20pub trait FromDomainWeightInfo {
21    fn from_domains_relay_message_channel_open() -> Weight;
22    fn from_domains_relay_message() -> Weight;
23    fn from_domains_relay_message_response() -> Weight;
24}
25
26/// Weight functions for `pallet_messenger_extension`.
27pub struct SubstrateWeight<T>(PhantomData<T>);
28
29impl<T: frame_system::Config> FromConsensusWeightInfo for SubstrateWeight<T> {
30    fn from_consensus_relay_message_channel_open() -> Weight {
31        WeightsFromConsensus::<T>::from_consensus_relay_message_channel_open()
32    }
33
34    fn from_consensus_relay_message() -> Weight {
35        WeightsFromConsensus::<T>::from_consensus_relay_message()
36    }
37
38    fn from_consensus_relay_message_response() -> Weight {
39        WeightsFromConsensus::<T>::from_consensus_relay_message_response()
40    }
41}
42
43impl<T: frame_system::Config> FromDomainWeightInfo for SubstrateWeight<T> {
44    fn from_domains_relay_message_channel_open() -> Weight {
45        WeightsFromDomains::<T>::from_domains_relay_message_channel_open()
46    }
47
48    fn from_domains_relay_message() -> Weight {
49        WeightsFromDomains::<T>::from_domains_relay_message()
50    }
51
52    fn from_domains_relay_message_response() -> Weight {
53        WeightsFromDomains::<T>::from_domains_relay_message_response()
54    }
55}
56
57impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
58    fn mmr_proof_verification_on_consensus() -> Weight {
59        // Execution time to verify a given MMR proof on consensus chain
60        // is around 153_000_000 pico seconds
61        Weight::from_parts(153_000_000, 0)
62    }
63
64    fn mmr_proof_verification_on_domain() -> Weight {
65        // Execution time to verify a given MMR proof on domain chain
66        // using a host function is around 595_000_000 pico seconds
67        Weight::from_parts(595_000_000, 0)
68    }
69}