diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 2f0641907160..bee7881f26d8 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -643,7 +643,8 @@ mod tests { type Weights = pallet_message_lane::weights::RialtoWeight; pallet_message_lane::ensure_weights_are_correct::( - bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_TX_WEIGHT, + bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT, + bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT, bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT, ); diff --git a/bridges/bin/millau/runtime/src/rialto_messages.rs b/bridges/bin/millau/runtime/src/rialto_messages.rs index 59f7542d9036..9775c93d2d0c 100644 --- a/bridges/bin/millau/runtime/src/rialto_messages.rs +++ b/bridges/bin/millau/runtime/src/rialto_messages.rs @@ -126,7 +126,7 @@ impl MessageBridge for WithRialtoMessageBridge { message_payload_len.saturating_add(bp_millau::EXTRA_STORAGE_PROOF_SIZE as _), extra_bytes_in_payload .saturating_mul(bp_rialto::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT) - .saturating_add(bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_TX_WEIGHT), + .saturating_add(bp_rialto::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT), ) } diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 6e56676a531a..af1d7c6c9faf 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -1072,7 +1072,8 @@ mod tests { type Weights = pallet_message_lane::weights::RialtoWeight; pallet_message_lane::ensure_weights_are_correct::( - bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_TX_WEIGHT, + bp_rialto::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT, + bp_rialto::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT, bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT, ); diff --git a/bridges/bin/rialto/runtime/src/millau_messages.rs b/bridges/bin/rialto/runtime/src/millau_messages.rs index 3fc11f59c75f..9fb57ee861b6 100644 --- a/bridges/bin/rialto/runtime/src/millau_messages.rs +++ b/bridges/bin/rialto/runtime/src/millau_messages.rs @@ -126,7 +126,7 @@ impl MessageBridge for WithMillauMessageBridge { message_payload_len.saturating_add(bp_rialto::EXTRA_STORAGE_PROOF_SIZE as _), extra_bytes_in_payload .saturating_mul(bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT) - .saturating_add(bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_TX_WEIGHT), + .saturating_add(bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT), ) } diff --git a/bridges/modules/message-lane/src/weights_ext.rs b/bridges/modules/message-lane/src/weights_ext.rs index 18d80159a1b8..d99a20007dac 100644 --- a/bridges/modules/message-lane/src/weights_ext.rs +++ b/bridges/modules/message-lane/src/weights_ext.rs @@ -31,7 +31,8 @@ const SIGNED_EXTENSIONS_SIZE: u32 = 1024; /// Ensure that weights from `WeightInfoExt` implementation are looking correct. pub fn ensure_weights_are_correct( - expected_single_regular_message_delivery_tx_weight: Weight, + expected_default_message_delivery_tx_weight: Weight, + expected_additional_byte_delivery_weight: Weight, expected_messages_delivery_confirmation_tx_weight: Weight, ) { // verify `send_message` weight components @@ -51,10 +52,19 @@ pub fn ensure_weights_are_correct( 0, ); assert!( - actual_single_regular_message_delivery_tx_weight <= expected_single_regular_message_delivery_tx_weight, - "Single message delivery transaction weight {} is larger than expected weight {}", + actual_single_regular_message_delivery_tx_weight <= expected_default_message_delivery_tx_weight, + "Default message delivery transaction weight {} is larger than expected weight {}", actual_single_regular_message_delivery_tx_weight, - expected_single_regular_message_delivery_tx_weight, + expected_default_message_delivery_tx_weight, + ); + + // verify that hardcoded value covers additional byte length of `receive_messages_proof` weight + let actual_additional_byte_delivery_weight = W::storage_proof_size_overhead(1); + assert!( + actual_additional_byte_delivery_weight <= expected_additional_byte_delivery_weight, + "Single additional byte delivery weight {} is larger than expected weight {}", + actual_additional_byte_delivery_weight, + expected_additional_byte_delivery_weight, ); // verify `receive_messages_delivery_proof` weight components diff --git a/bridges/primitives/millau/src/lib.rs b/bridges/primitives/millau/src/lib.rs index 017aef6da72f..84096d116ef5 100644 --- a/bridges/primitives/millau/src/lib.rs +++ b/bridges/primitives/millau/src/lib.rs @@ -69,15 +69,19 @@ pub const MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE: MessageNonce = 1024; /// Maximal number of unconfirmed messages at inbound lane. pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 1024; -/// Maximal weight of single regular message delivery transaction on Millau chain. +/// Weight of single regular message delivery transaction on Millau chain. /// -/// This value is a result of `pallet_message_lane::Module::receive_messages_proof` weight formula computation -/// for the case when single message is delivered. The result then must be rounded up to account possible future -/// runtime upgrades. -pub const MAX_SINGLE_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_000_000_000; +/// This value is a result of `pallet_message_lane::Module::receive_messages_proof_weight()` call +/// for the case when single message of `pallet_message_lane::EXPECTED_DEFAULT_MESSAGE_LENGTH` bytes is delivered. +/// The message must have dispatch weight set to zero. The result then must be rounded up to account +/// possible future runtime upgrades. +pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_000_000_000; /// Increase of delivery transaction weight on Millau chain with every additional message byte. -pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 3_000; +/// +/// This value is a result of `pallet_message_lane::WeightInfoExt::storage_proof_size_overhead(1)` call. The +/// result then must be rounded up to account possible future runtime upgrades. +pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 25_000; /// Maximal weight of single message delivery confirmation transaction on Millau chain. /// diff --git a/bridges/primitives/rialto/src/lib.rs b/bridges/primitives/rialto/src/lib.rs index 9bec3b1862ba..706e2f27854d 100644 --- a/bridges/primitives/rialto/src/lib.rs +++ b/bridges/primitives/rialto/src/lib.rs @@ -60,15 +60,19 @@ pub const MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE: MessageNonce = 128; /// Maximal number of unconfirmed messages at inbound lane. pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 128; -/// Maximal weight of single regular message delivery transaction on Rialto chain. +/// Weight of single regular message delivery transaction on Rialto chain. /// -/// This value is a result of `pallet_message_lane::Module::receive_messages_proof` weight formula computation -/// for the case when single message is delivered. The result then must be rounded up to account possible future -/// runtime upgrades. -pub const MAX_SINGLE_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_000_000_000; +/// This value is a result of `pallet_message_lane::Module::receive_messages_proof_weight()` call +/// for the case when single message of `pallet_message_lane::EXPECTED_DEFAULT_MESSAGE_LENGTH` bytes is delivered. +/// The message must have dispatch weight set to zero. The result then must be rounded up to account +/// possible future runtime upgrades. +pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_000_000_000; /// Increase of delivery transaction weight on Rialto chain with every additional message byte. -pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 3_000; +/// +/// This value is a result of `pallet_message_lane::WeightInfoExt::storage_proof_size_overhead(1)` call. The +/// result then must be rounded up to account possible future runtime upgrades. +pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 25_000; /// Maximal weight of single message delivery confirmation transaction on Rialto chain. ///