Skip to content

Commit

Permalink
Add MessagesPalletInstance for integrity tests (paritytech#2107)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur authored and serban300 committed Apr 9, 2024
1 parent 10b6112 commit 91425cc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bridges/bin/millau/runtime/src/rialto_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ mod tests {

#[test]
fn ensure_millau_message_lane_weights_are_correct() {
check_message_lane_weights::<bp_millau::Millau, Runtime>(
check_message_lane_weights::<bp_millau::Millau, Runtime, WithRialtoMessagesInstance>(
bp_rialto::EXTRA_STORAGE_PROOF_SIZE,
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ mod tests {

#[test]
fn ensure_millau_message_lane_weights_are_correct() {
check_message_lane_weights::<bp_millau::Millau, Runtime>(
check_message_lane_weights::<bp_millau::Millau, Runtime, WithRialtoParachainMessagesInstance>(
bp_rialto_parachain::EXTRA_STORAGE_PROOF_SIZE,
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
Expand Down
6 changes: 5 additions & 1 deletion bridges/bin/rialto-parachain/runtime/src/millau_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ mod tests {

#[test]
fn ensure_millau_message_lane_weights_are_correct() {
check_message_lane_weights::<bp_rialto_parachain::RialtoParachain, Runtime>(
check_message_lane_weights::<
bp_rialto_parachain::RialtoParachain,
Runtime,
WithMillauMessagesInstance,
>(
bp_millau::EXTRA_STORAGE_PROOF_SIZE,
bp_rialto_parachain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
bp_rialto_parachain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/rialto/runtime/src/millau_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ mod tests {

#[test]
fn ensure_millau_message_lane_weights_are_correct() {
check_message_lane_weights::<bp_rialto::Rialto, Runtime>(
check_message_lane_weights::<bp_rialto::Rialto, Runtime, WithMillauMessagesInstance>(
bp_millau::EXTRA_STORAGE_PROOF_SIZE,
bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
Expand Down
18 changes: 11 additions & 7 deletions bridges/bin/runtime-common/src/integrity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ where
/// Check that the message lane weights are correct.
pub fn check_message_lane_weights<
C: Chain,
T: frame_system::Config + pallet_bridge_messages::Config,
T: frame_system::Config + pallet_bridge_messages::Config<MessagesPalletInstance>,
MessagesPalletInstance: 'static,
>(
bridged_chain_extra_storage_proof_size: u32,
this_chain_max_unrewarded_relayers: MessageNonce,
Expand All @@ -303,15 +304,15 @@ pub fn check_message_lane_weights<
// in other words: pass true for all known production chains
runtime_includes_refund_extension: bool,
) {
type Weights<T> = <T as pallet_bridge_messages::Config>::WeightInfo;
type Weights<T, MI> = <T as pallet_bridge_messages::Config<MI>>::WeightInfo;

// check basic weight assumptions
pallet_bridge_messages::ensure_weights_are_correct::<Weights<T>>();
pallet_bridge_messages::ensure_weights_are_correct::<Weights<T, MessagesPalletInstance>>();

// check that weights allow us to receive messages
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>>(
pallet_bridge_messages::ensure_able_to_receive_message::<Weights<T, MessagesPalletInstance>>(
C::max_extrinsic_size(),
C::max_extrinsic_weight(),
max_incoming_message_proof_size,
Expand All @@ -321,7 +322,7 @@ pub fn check_message_lane_weights<
// check that weights allow us to receive delivery confirmations
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>>(
pallet_bridge_messages::ensure_able_to_receive_confirmation::<Weights<T, MessagesPalletInstance>>(
C::max_extrinsic_size(),
C::max_extrinsic_weight(),
max_incoming_inbound_lane_data_proof_size,
Expand All @@ -336,9 +337,12 @@ pub fn check_message_lane_weights<
// ensures the extension will not refund weight when it doesn't need to (i.e. if pallet
// weights do not account weights of refund extension).
if runtime_includes_refund_extension {
assert_ne!(Weights::<T>::receive_messages_proof_overhead_from_runtime(), Weight::zero());
assert_ne!(
Weights::<T>::receive_messages_delivery_proof_overhead_from_runtime(),
Weights::<T, MessagesPalletInstance>::receive_messages_proof_overhead_from_runtime(),
Weight::zero()
);
assert_ne!(
Weights::<T, MessagesPalletInstance>::receive_messages_delivery_proof_overhead_from_runtime(),
Weight::zero()
);
}
Expand Down

0 comments on commit 91425cc

Please sign in to comment.