mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 11:01:01 +00:00
Define method for checking message lane weights (#1766)
* Define method for checking message lane weights * Docs for public function * Renamings
This commit is contained in:
committed by
Bastian Köcher
parent
c81afc3e93
commit
add2914a5c
@@ -163,42 +163,19 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::{Runtime, WithRialtoMessagesInstance};
|
use crate::{Runtime, WithRialtoMessagesInstance};
|
||||||
|
|
||||||
use bp_runtime::Chain;
|
|
||||||
use bridge_runtime_common::{
|
use bridge_runtime_common::{
|
||||||
assert_complete_bridge_types,
|
assert_complete_bridge_types,
|
||||||
integrity::{
|
integrity::{
|
||||||
assert_complete_bridge_constants, AssertBridgeMessagesPalletConstants,
|
assert_complete_bridge_constants, check_message_lane_weights,
|
||||||
AssertBridgePalletNames, AssertChainConstants, AssertCompleteBridgeConstants,
|
AssertBridgeMessagesPalletConstants, AssertBridgePalletNames, AssertChainConstants,
|
||||||
|
AssertCompleteBridgeConstants,
|
||||||
},
|
},
|
||||||
messages,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ensure_millau_message_lane_weights_are_correct() {
|
fn ensure_millau_message_lane_weights_are_correct() {
|
||||||
type Weights = pallet_bridge_messages::weights::BridgeWeight<Runtime>;
|
check_message_lane_weights::<bp_millau::Millau, Runtime>(
|
||||||
|
bp_rialto::EXTRA_STORAGE_PROOF_SIZE,
|
||||||
pallet_bridge_messages::ensure_weights_are_correct::<Weights>();
|
|
||||||
|
|
||||||
let max_incoming_message_proof_size = bp_rialto::EXTRA_STORAGE_PROOF_SIZE.saturating_add(
|
|
||||||
messages::target::maximal_incoming_message_size(bp_millau::Millau::max_extrinsic_size()),
|
|
||||||
);
|
|
||||||
pallet_bridge_messages::ensure_able_to_receive_message::<Weights>(
|
|
||||||
bp_millau::Millau::max_extrinsic_size(),
|
|
||||||
bp_millau::Millau::max_extrinsic_weight(),
|
|
||||||
max_incoming_message_proof_size,
|
|
||||||
messages::target::maximal_incoming_message_dispatch_weight(
|
|
||||||
bp_millau::Millau::max_extrinsic_weight(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
let max_incoming_inbound_lane_data_proof_size =
|
|
||||||
bp_messages::InboundLaneData::<()>::encoded_size_hint_u32(
|
|
||||||
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX as _,
|
|
||||||
);
|
|
||||||
pallet_bridge_messages::ensure_able_to_receive_confirmation::<Weights>(
|
|
||||||
bp_millau::Millau::max_extrinsic_size(),
|
|
||||||
bp_millau::Millau::max_extrinsic_weight(),
|
|
||||||
max_incoming_inbound_lane_data_proof_size,
|
|
||||||
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
|
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
|
||||||
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
|
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -162,41 +162,19 @@ impl SourceHeaderChain for Millau {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance};
|
use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance};
|
||||||
use bp_runtime::Chain;
|
|
||||||
use bridge_runtime_common::{
|
use bridge_runtime_common::{
|
||||||
assert_complete_bridge_types,
|
assert_complete_bridge_types,
|
||||||
integrity::{
|
integrity::{
|
||||||
assert_complete_bridge_constants, AssertBridgeMessagesPalletConstants,
|
assert_complete_bridge_constants, check_message_lane_weights,
|
||||||
AssertBridgePalletNames, AssertChainConstants, AssertCompleteBridgeConstants,
|
AssertBridgeMessagesPalletConstants, AssertBridgePalletNames, AssertChainConstants,
|
||||||
|
AssertCompleteBridgeConstants,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ensure_rialto_message_lane_weights_are_correct() {
|
fn ensure_rialto_message_lane_weights_are_correct() {
|
||||||
type Weights = pallet_bridge_messages::weights::BridgeWeight<Runtime>;
|
check_message_lane_weights::<bp_rialto::Rialto, Runtime>(
|
||||||
|
bp_millau::EXTRA_STORAGE_PROOF_SIZE,
|
||||||
pallet_bridge_messages::ensure_weights_are_correct::<Weights>();
|
|
||||||
|
|
||||||
let max_incoming_message_proof_size = bp_millau::EXTRA_STORAGE_PROOF_SIZE.saturating_add(
|
|
||||||
messages::target::maximal_incoming_message_size(bp_rialto::Rialto::max_extrinsic_size()),
|
|
||||||
);
|
|
||||||
pallet_bridge_messages::ensure_able_to_receive_message::<Weights>(
|
|
||||||
bp_rialto::Rialto::max_extrinsic_size(),
|
|
||||||
bp_rialto::Rialto::max_extrinsic_weight(),
|
|
||||||
max_incoming_message_proof_size,
|
|
||||||
messages::target::maximal_incoming_message_dispatch_weight(
|
|
||||||
bp_rialto::Rialto::max_extrinsic_weight(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
let max_incoming_inbound_lane_data_proof_size =
|
|
||||||
bp_messages::InboundLaneData::<()>::encoded_size_hint_u32(
|
|
||||||
bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX as _,
|
|
||||||
);
|
|
||||||
pallet_bridge_messages::ensure_able_to_receive_confirmation::<Weights>(
|
|
||||||
bp_rialto::Rialto::max_extrinsic_size(),
|
|
||||||
bp_rialto::Rialto::max_extrinsic_weight(),
|
|
||||||
max_incoming_inbound_lane_data_proof_size,
|
|
||||||
bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
|
bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
|
||||||
bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
|
bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
//! Most of the tests in this module assume that the bridge is using standard (see `crate::messages`
|
//! Most of the tests in this module assume that the bridge is using standard (see `crate::messages`
|
||||||
//! module for details) configuration.
|
//! module for details) configuration.
|
||||||
|
|
||||||
use crate::messages::MessageBridge;
|
use crate::{messages, messages::MessageBridge};
|
||||||
|
|
||||||
use bp_messages::MessageNonce;
|
use bp_messages::{InboundLaneData, MessageNonce};
|
||||||
use bp_runtime::{Chain, ChainId};
|
use bp_runtime::{Chain, ChainId};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use frame_support::{storage::generator::StorageValue, traits::Get};
|
use frame_support::{storage::generator::StorageValue, traits::Get};
|
||||||
@@ -289,3 +289,33 @@ where
|
|||||||
assert_bridge_messages_pallet_constants::<R, MI>(params.messages_pallet_constants);
|
assert_bridge_messages_pallet_constants::<R, MI>(params.messages_pallet_constants);
|
||||||
assert_bridge_pallet_names::<B, R, GI, MI>(params.pallet_names);
|
assert_bridge_pallet_names::<B, R, GI, MI>(params.pallet_names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check that the message lane weights are correct.
|
||||||
|
pub fn check_message_lane_weights<C: Chain, T: frame_system::Config>(
|
||||||
|
bridged_chain_extra_storage_proof_size: u32,
|
||||||
|
this_chain_max_unrewarded_relayers: MessageNonce,
|
||||||
|
this_chain_max_unconfirmed_messages: MessageNonce,
|
||||||
|
) {
|
||||||
|
type Weights<T> = pallet_bridge_messages::weights::BridgeWeight<T>;
|
||||||
|
|
||||||
|
pallet_bridge_messages::ensure_weights_are_correct::<Weights<T>>();
|
||||||
|
|
||||||
|
let max_incoming_message_proof_size = bridged_chain_extra_storage_proof_size
|
||||||
|
.saturating_add(messages::target::maximal_incoming_message_size(C::max_extrinsic_size()));
|
||||||
|
pallet_bridge_messages::ensure_able_to_receive_message::<Weights<T>>(
|
||||||
|
C::max_extrinsic_size(),
|
||||||
|
C::max_extrinsic_weight(),
|
||||||
|
max_incoming_message_proof_size,
|
||||||
|
messages::target::maximal_incoming_message_dispatch_weight(C::max_extrinsic_weight()),
|
||||||
|
);
|
||||||
|
|
||||||
|
let max_incoming_inbound_lane_data_proof_size =
|
||||||
|
InboundLaneData::<()>::encoded_size_hint_u32(this_chain_max_unrewarded_relayers as _);
|
||||||
|
pallet_bridge_messages::ensure_able_to_receive_confirmation::<Weights<T>>(
|
||||||
|
C::max_extrinsic_size(),
|
||||||
|
C::max_extrinsic_weight(),
|
||||||
|
max_incoming_inbound_lane_data_proof_size,
|
||||||
|
this_chain_max_unrewarded_relayers,
|
||||||
|
this_chain_max_unconfirmed_messages,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user