mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 14:01:02 +00:00
rename messages_dispatch_weight -> message_details (#996)
Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
954137eada
commit
ec8412b6d0
@@ -601,17 +601,23 @@ impl_runtime_apis! {
|
|||||||
).ok()
|
).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn messages_dispatch_weight(
|
fn message_details(
|
||||||
lane: bp_messages::LaneId,
|
lane: bp_messages::LaneId,
|
||||||
begin: bp_messages::MessageNonce,
|
begin: bp_messages::MessageNonce,
|
||||||
end: bp_messages::MessageNonce,
|
end: bp_messages::MessageNonce,
|
||||||
) -> Vec<(bp_messages::MessageNonce, Weight, u32)> {
|
) -> Vec<bp_messages::MessageDetails<Balance>> {
|
||||||
(begin..=end).filter_map(|nonce| {
|
(begin..=end).filter_map(|nonce| {
|
||||||
let encoded_payload = BridgeRialtoMessages::outbound_message_payload(lane, nonce)?;
|
let message_data = BridgeRialtoMessages::outbound_message_data(lane, nonce)?;
|
||||||
let decoded_payload = rialto_messages::ToRialtoMessagePayload::decode(
|
let decoded_payload = rialto_messages::ToRialtoMessagePayload::decode(
|
||||||
&mut &encoded_payload[..]
|
&mut &message_data.payload[..]
|
||||||
).ok()?;
|
).ok()?;
|
||||||
Some((nonce, decoded_payload.weight, encoded_payload.len() as _))
|
Some(bp_messages::MessageDetails {
|
||||||
|
nonce,
|
||||||
|
dispatch_weight: decoded_payload.weight,
|
||||||
|
size: message_data.payload.len() as _,
|
||||||
|
delivery_and_dispatch_fee: message_data.fee,
|
||||||
|
// TODO: include dispatch fee type (https://github.com/paritytech/parity-bridges-common/pull/911)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -752,17 +752,23 @@ impl_runtime_apis! {
|
|||||||
).ok()
|
).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn messages_dispatch_weight(
|
fn message_details(
|
||||||
lane: bp_messages::LaneId,
|
lane: bp_messages::LaneId,
|
||||||
begin: bp_messages::MessageNonce,
|
begin: bp_messages::MessageNonce,
|
||||||
end: bp_messages::MessageNonce,
|
end: bp_messages::MessageNonce,
|
||||||
) -> Vec<(bp_messages::MessageNonce, Weight, u32)> {
|
) -> Vec<bp_messages::MessageDetails<Balance>> {
|
||||||
(begin..=end).filter_map(|nonce| {
|
(begin..=end).filter_map(|nonce| {
|
||||||
let encoded_payload = BridgeMillauMessages::outbound_message_payload(lane, nonce)?;
|
let message_data = BridgeMillauMessages::outbound_message_data(lane, nonce)?;
|
||||||
let decoded_payload = millau_messages::ToMillauMessagePayload::decode(
|
let decoded_payload = millau_messages::ToMillauMessagePayload::decode(
|
||||||
&mut &encoded_payload[..]
|
&mut &message_data.payload[..]
|
||||||
).ok()?;
|
).ok()?;
|
||||||
Some((nonce, decoded_payload.weight, encoded_payload.len() as _))
|
Some(bp_messages::MessageDetails {
|
||||||
|
nonce,
|
||||||
|
dispatch_weight: decoded_payload.weight,
|
||||||
|
size: message_data.payload.len() as _,
|
||||||
|
delivery_and_dispatch_fee: message_data.fee,
|
||||||
|
// TODO: include dispatch fee type (https://github.com/paritytech/parity-bridges-common/pull/911)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ use crate::weights::WeightInfo;
|
|||||||
use bp_messages::{
|
use bp_messages::{
|
||||||
source_chain::{LaneMessageVerifier, MessageDeliveryAndDispatchPayment, RelayersRewards, TargetHeaderChain},
|
source_chain::{LaneMessageVerifier, MessageDeliveryAndDispatchPayment, RelayersRewards, TargetHeaderChain},
|
||||||
target_chain::{DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages, SourceHeaderChain},
|
target_chain::{DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages, SourceHeaderChain},
|
||||||
total_unrewarded_messages, InboundLaneData, LaneId, MessageData, MessageKey, MessageNonce, MessagePayload,
|
total_unrewarded_messages, InboundLaneData, LaneId, MessageData, MessageKey, MessageNonce, OperatingMode,
|
||||||
OperatingMode, OutboundLaneData, Parameter as MessagesParameter, UnrewardedRelayersState,
|
OutboundLaneData, Parameter as MessagesParameter, UnrewardedRelayersState,
|
||||||
};
|
};
|
||||||
use bp_runtime::Size;
|
use bp_runtime::Size;
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
@@ -607,9 +607,9 @@ decl_module! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Config<I>, I: Instance> Pallet<T, I> {
|
impl<T: Config<I>, I: Instance> Pallet<T, I> {
|
||||||
/// Get payload of given outbound message.
|
/// Get stored data of the outbound message with given nonce.
|
||||||
pub fn outbound_message_payload(lane: LaneId, nonce: MessageNonce) -> Option<MessagePayload> {
|
pub fn outbound_message_data(lane: LaneId, nonce: MessageNonce) -> Option<MessageData<T::OutboundMessageFee>> {
|
||||||
OutboundMessages::<T, I>::get(MessageKey { lane_id: lane, nonce }).map(|message_data| message_data.payload)
|
OutboundMessages::<T, I>::get(MessageKey { lane_id: lane, nonce })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get nonce of latest generated message at given outbound lane.
|
/// Get nonce of latest generated message at given outbound lane.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
// Runtime-generated DecodeLimit::decode_all_with_depth_limit
|
// Runtime-generated DecodeLimit::decode_all_with_depth_limit
|
||||||
#![allow(clippy::unnecessary_mut_passed)]
|
#![allow(clippy::unnecessary_mut_passed)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState, Weight};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
pub use bp_polkadot_core::*;
|
pub use bp_polkadot_core::*;
|
||||||
@@ -43,8 +43,8 @@ pub const IS_KNOWN_KUSAMA_HEADER_METHOD: &str = "KusamaFinalityApi_is_known_head
|
|||||||
/// Name of the `ToKusamaOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
/// Name of the `ToKusamaOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
||||||
pub const TO_KUSAMA_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
pub const TO_KUSAMA_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||||
"ToKusamaOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToKusamaOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToKusamaOutboundLaneApi::messages_dispatch_weight` runtime method.
|
/// Name of the `ToKusamaOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_KUSAMA_MESSAGES_DISPATCH_WEIGHT_METHOD: &str = "ToKusamaOutboundLaneApi_messages_dispatch_weight";
|
pub const TO_KUSAMA_MESSAGE_DETAILS_METHOD: &str = "ToKusamaOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToKusamaOutboundLaneApi::latest_generated_nonce` runtime method.
|
/// Name of the `ToKusamaOutboundLaneApi::latest_generated_nonce` runtime method.
|
||||||
pub const TO_KUSAMA_LATEST_GENERATED_NONCE_METHOD: &str = "ToKusamaOutboundLaneApi_latest_generated_nonce";
|
pub const TO_KUSAMA_LATEST_GENERATED_NONCE_METHOD: &str = "ToKusamaOutboundLaneApi_latest_generated_nonce";
|
||||||
/// Name of the `ToKusamaOutboundLaneApi::latest_received_nonce` runtime method.
|
/// Name of the `ToKusamaOutboundLaneApi::latest_received_nonce` runtime method.
|
||||||
@@ -87,15 +87,16 @@ sp_api::decl_runtime_apis! {
|
|||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns total dispatch weight and encoded payload size of all messages in given inclusive range.
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
|
/// messages in given inclusive range.
|
||||||
///
|
///
|
||||||
/// If some (or all) messages are missing from the storage, they'll also will
|
/// If some (or all) messages are missing from the storage, they'll also will
|
||||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||||
fn messages_dispatch_weight(
|
fn message_details(
|
||||||
lane: LaneId,
|
lane: LaneId,
|
||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<(MessageNonce, Weight, u32)>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
/// Returns nonce of the latest message, received by bridged chain.
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
/// Returns nonce of the latest message, generated by given lane.
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
mod millau_hash;
|
mod millau_hash;
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
||||||
use bp_runtime::Chain;
|
use bp_runtime::Chain;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, Weight},
|
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, Weight},
|
||||||
@@ -244,8 +244,8 @@ pub const BEST_FINALIZED_MILLAU_HEADER_METHOD: &str = "MillauFinalityApi_best_fi
|
|||||||
/// Name of the `ToMillauOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
/// Name of the `ToMillauOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
||||||
pub const TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
pub const TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||||
"ToMillauOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToMillauOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToMillauOutboundLaneApi::messages_dispatch_weight` runtime method.
|
/// Name of the `ToMillauOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_MILLAU_MESSAGES_DISPATCH_WEIGHT_METHOD: &str = "ToMillauOutboundLaneApi_messages_dispatch_weight";
|
pub const TO_MILLAU_MESSAGE_DETAILS_METHOD: &str = "ToMillauOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToMillauOutboundLaneApi::latest_received_nonce` runtime method.
|
/// Name of the `ToMillauOutboundLaneApi::latest_received_nonce` runtime method.
|
||||||
pub const TO_MILLAU_LATEST_RECEIVED_NONCE_METHOD: &str = "ToMillauOutboundLaneApi_latest_received_nonce";
|
pub const TO_MILLAU_LATEST_RECEIVED_NONCE_METHOD: &str = "ToMillauOutboundLaneApi_latest_received_nonce";
|
||||||
/// Name of the `ToMillauOutboundLaneApi::latest_generated_nonce` runtime method.
|
/// Name of the `ToMillauOutboundLaneApi::latest_generated_nonce` runtime method.
|
||||||
@@ -288,15 +288,16 @@ sp_api::decl_runtime_apis! {
|
|||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns total dispatch weight and encoded payload size of all messages in given inclusive range.
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
|
/// messages in given inclusive range.
|
||||||
///
|
///
|
||||||
/// If some (or all) messages are missing from the storage, they'll also will
|
/// If some (or all) messages are missing from the storage, they'll also will
|
||||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||||
fn messages_dispatch_weight(
|
fn message_details(
|
||||||
lane: LaneId,
|
lane: LaneId,
|
||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<(MessageNonce, Weight, u32)>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
/// Returns nonce of the latest message, received by bridged chain.
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
/// Returns nonce of the latest message, generated by given lane.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
// Runtime-generated DecodeLimit::decode_all_with_depth_limit
|
// Runtime-generated DecodeLimit::decode_all_with_depth_limit
|
||||||
#![allow(clippy::unnecessary_mut_passed)]
|
#![allow(clippy::unnecessary_mut_passed)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState, Weight};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
pub use bp_polkadot_core::*;
|
pub use bp_polkadot_core::*;
|
||||||
@@ -43,8 +43,8 @@ pub const IS_KNOWN_POLKADOT_HEADER_METHOD: &str = "PolkadotFinalityApi_is_known_
|
|||||||
/// Name of the `ToPolkadotOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
/// Name of the `ToPolkadotOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
||||||
pub const TO_POLKADOT_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
pub const TO_POLKADOT_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||||
"ToPolkadotOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToPolkadotOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToPolkadotOutboundLaneApi::messages_dispatch_weight` runtime method.
|
/// Name of the `ToPolkadotOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_POLKADOT_MESSAGES_DISPATCH_WEIGHT_METHOD: &str = "ToPolkadotOutboundLaneApi_messages_dispatch_weight";
|
pub const TO_POLKADOT_MESSAGE_DETAILS_METHOD: &str = "ToPolkadotOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToPolkadotOutboundLaneApi::latest_generated_nonce` runtime method.
|
/// Name of the `ToPolkadotOutboundLaneApi::latest_generated_nonce` runtime method.
|
||||||
pub const TO_POLKADOT_LATEST_GENERATED_NONCE_METHOD: &str = "ToPolkadotOutboundLaneApi_latest_generated_nonce";
|
pub const TO_POLKADOT_LATEST_GENERATED_NONCE_METHOD: &str = "ToPolkadotOutboundLaneApi_latest_generated_nonce";
|
||||||
/// Name of the `ToPolkadotOutboundLaneApi::latest_received_nonce` runtime method.
|
/// Name of the `ToPolkadotOutboundLaneApi::latest_received_nonce` runtime method.
|
||||||
@@ -87,15 +87,16 @@ sp_api::decl_runtime_apis! {
|
|||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns total dispatch weight and encoded payload size of all messages in given inclusive range.
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
|
/// messages in given inclusive range.
|
||||||
///
|
///
|
||||||
/// If some (or all) messages are missing from the storage, they'll also will
|
/// If some (or all) messages are missing from the storage, they'll also will
|
||||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||||
fn messages_dispatch_weight(
|
fn message_details(
|
||||||
lane: LaneId,
|
lane: LaneId,
|
||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<(MessageNonce, Weight, u32)>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
/// Returns nonce of the latest message, received by bridged chain.
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
/// Returns nonce of the latest message, generated by given lane.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
// Runtime-generated DecodeLimit::decode_all_With_depth_limit
|
// Runtime-generated DecodeLimit::decode_all_With_depth_limit
|
||||||
#![allow(clippy::unnecessary_mut_passed)]
|
#![allow(clippy::unnecessary_mut_passed)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
||||||
use bp_runtime::Chain;
|
use bp_runtime::Chain;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, Weight},
|
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, Weight},
|
||||||
@@ -205,8 +205,8 @@ pub const BEST_FINALIZED_RIALTO_HEADER_METHOD: &str = "RialtoFinalityApi_best_fi
|
|||||||
/// Name of the `ToRialtoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
/// Name of the `ToRialtoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
||||||
pub const TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
pub const TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||||
"ToRialtoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToRialtoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToRialtoOutboundLaneApi::messages_dispatch_weight` runtime method.
|
/// Name of the `ToRialtoOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_RIALTO_MESSAGES_DISPATCH_WEIGHT_METHOD: &str = "ToRialtoOutboundLaneApi_messages_dispatch_weight";
|
pub const TO_RIALTO_MESSAGE_DETAILS_METHOD: &str = "ToRialtoOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToRialtoOutboundLaneApi::latest_generated_nonce` runtime method.
|
/// Name of the `ToRialtoOutboundLaneApi::latest_generated_nonce` runtime method.
|
||||||
pub const TO_RIALTO_LATEST_GENERATED_NONCE_METHOD: &str = "ToRialtoOutboundLaneApi_latest_generated_nonce";
|
pub const TO_RIALTO_LATEST_GENERATED_NONCE_METHOD: &str = "ToRialtoOutboundLaneApi_latest_generated_nonce";
|
||||||
/// Name of the `ToRialtoOutboundLaneApi::latest_received_nonce` runtime method.
|
/// Name of the `ToRialtoOutboundLaneApi::latest_received_nonce` runtime method.
|
||||||
@@ -249,15 +249,16 @@ sp_api::decl_runtime_apis! {
|
|||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns total dispatch weight and encoded payload size of all messages in given inclusive range.
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
|
/// messages in given inclusive range.
|
||||||
///
|
///
|
||||||
/// If some (or all) messages are missing from the storage, they'll also will
|
/// If some (or all) messages are missing from the storage, they'll also will
|
||||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||||
fn messages_dispatch_weight(
|
fn message_details(
|
||||||
lane: LaneId,
|
lane: LaneId,
|
||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<(MessageNonce, Weight, u32)>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
/// Returns nonce of the latest message, received by bridged chain.
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
/// Returns nonce of the latest message, generated by given lane.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
// Runtime-generated DecodeLimit::decode_all_with_depth_limit
|
// Runtime-generated DecodeLimit::decode_all_with_depth_limit
|
||||||
#![allow(clippy::unnecessary_mut_passed)]
|
#![allow(clippy::unnecessary_mut_passed)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState, Weight};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
||||||
use bp_runtime::Chain;
|
use bp_runtime::Chain;
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
@@ -91,8 +91,8 @@ pub const IS_KNOWN_ROCOCO_HEADER_METHOD: &str = "RococoFinalityApi_is_known_head
|
|||||||
/// Name of the `ToRococoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
/// Name of the `ToRococoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
||||||
pub const TO_ROCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
pub const TO_ROCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||||
"ToRococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToRococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToRococoOutboundLaneApi::messages_dispatch_weight` runtime method.
|
/// Name of the `ToRococoOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_ROCOCO_MESSAGES_DISPATCH_WEIGHT_METHOD: &str = "ToRococoOutboundLaneApi_messages_dispatch_weight";
|
pub const TO_ROCOCO_MESSAGE_DETAILS_METHOD: &str = "ToRococoOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToRococoOutboundLaneApi::latest_generated_nonce` runtime method.
|
/// Name of the `ToRococoOutboundLaneApi::latest_generated_nonce` runtime method.
|
||||||
pub const TO_ROCOCO_LATEST_GENERATED_NONCE_METHOD: &str = "ToRococoOutboundLaneApi_latest_generated_nonce";
|
pub const TO_ROCOCO_LATEST_GENERATED_NONCE_METHOD: &str = "ToRococoOutboundLaneApi_latest_generated_nonce";
|
||||||
/// Name of the `ToRococoOutboundLaneApi::latest_received_nonce` runtime method.
|
/// Name of the `ToRococoOutboundLaneApi::latest_received_nonce` runtime method.
|
||||||
@@ -135,15 +135,16 @@ sp_api::decl_runtime_apis! {
|
|||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns total dispatch weight and encoded payload size of all messages in given inclusive range.
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
|
/// messages in given inclusive range.
|
||||||
///
|
///
|
||||||
/// If some (or all) messages are missing from the storage, they'll also will
|
/// If some (or all) messages are missing from the storage, they'll also will
|
||||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||||
fn messages_dispatch_weight(
|
fn message_details(
|
||||||
lane: LaneId,
|
lane: LaneId,
|
||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<(MessageNonce, Weight, u32)>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
/// Returns nonce of the latest message, received by bridged chain.
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
/// Returns nonce of the latest message, generated by given lane.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
// Runtime-generated DecodeLimit::decode_all_with_depth_limit
|
// Runtime-generated DecodeLimit::decode_all_with_depth_limit
|
||||||
#![allow(clippy::unnecessary_mut_passed)]
|
#![allow(clippy::unnecessary_mut_passed)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState, Weight};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
||||||
use bp_runtime::Chain;
|
use bp_runtime::Chain;
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
@@ -98,8 +98,8 @@ pub const IS_KNOWN_WESTEND_HEADER_METHOD: &str = "WestendFinalityApi_is_known_he
|
|||||||
/// Name of the `ToWestendOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
/// Name of the `ToWestendOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
||||||
pub const TO_WESTEND_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
pub const TO_WESTEND_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||||
"ToWestendOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToWestendOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToWestendOutboundLaneApi::messages_dispatch_weight` runtime method.
|
/// Name of the `ToWestendOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_WESTEND_MESSAGES_DISPATCH_WEIGHT_METHOD: &str = "ToWestendOutboundLaneApi_messages_dispatch_weight";
|
pub const TO_WESTEND_MESSAGE_DETAILS_METHOD: &str = "ToWestendOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToWestendOutboundLaneApi::latest_generated_nonce` runtime method.
|
/// Name of the `ToWestendOutboundLaneApi::latest_generated_nonce` runtime method.
|
||||||
pub const TO_WESTEND_LATEST_GENERATED_NONCE_METHOD: &str = "ToWestendOutboundLaneApi_latest_generated_nonce";
|
pub const TO_WESTEND_LATEST_GENERATED_NONCE_METHOD: &str = "ToWestendOutboundLaneApi_latest_generated_nonce";
|
||||||
/// Name of the `ToWestendOutboundLaneApi::latest_received_nonce` runtime method.
|
/// Name of the `ToWestendOutboundLaneApi::latest_received_nonce` runtime method.
|
||||||
@@ -149,15 +149,16 @@ sp_api::decl_runtime_apis! {
|
|||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns total dispatch weight and encoded payload size of all messages in given inclusive range.
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
|
/// messages in given inclusive range.
|
||||||
///
|
///
|
||||||
/// If some (or all) messages are missing from the storage, they'll also will
|
/// If some (or all) messages are missing from the storage, they'll also will
|
||||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||||
fn messages_dispatch_weight(
|
fn message_details(
|
||||||
lane: LaneId,
|
lane: LaneId,
|
||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<(MessageNonce, Weight, u32)>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
/// Returns nonce of the latest message, received by bridged chain.
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
/// Returns nonce of the latest message, generated by given lane.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
// Runtime-generated DecodeLimit::decode_all_with_depth_limit
|
// Runtime-generated DecodeLimit::decode_all_with_depth_limit
|
||||||
#![allow(clippy::unnecessary_mut_passed)]
|
#![allow(clippy::unnecessary_mut_passed)]
|
||||||
|
|
||||||
use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState, Weight};
|
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
||||||
use bp_runtime::Chain;
|
use bp_runtime::Chain;
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
@@ -98,8 +98,8 @@ pub const IS_KNOWN_WOCOCO_HEADER_METHOD: &str = "WococoFinalityApi_is_known_head
|
|||||||
/// Name of the `ToWococoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
/// Name of the `ToWococoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
||||||
pub const TO_WOCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
pub const TO_WOCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||||
"ToWococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
"ToWococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||||
/// Name of the `ToWococoOutboundLaneApi::messages_dispatch_weight` runtime method.
|
/// Name of the `ToWococoOutboundLaneApi::message_details` runtime method.
|
||||||
pub const TO_WOCOCO_MESSAGES_DISPATCH_WEIGHT_METHOD: &str = "ToWococoOutboundLaneApi_messages_dispatch_weight";
|
pub const TO_WOCOCO_MESSAGE_DETAILS_METHOD: &str = "ToWococoOutboundLaneApi_message_details";
|
||||||
/// Name of the `ToWococoOutboundLaneApi::latest_generated_nonce` runtime method.
|
/// Name of the `ToWococoOutboundLaneApi::latest_generated_nonce` runtime method.
|
||||||
pub const TO_WOCOCO_LATEST_GENERATED_NONCE_METHOD: &str = "ToWococoOutboundLaneApi_latest_generated_nonce";
|
pub const TO_WOCOCO_LATEST_GENERATED_NONCE_METHOD: &str = "ToWococoOutboundLaneApi_latest_generated_nonce";
|
||||||
/// Name of the `ToWococoOutboundLaneApi::latest_received_nonce` runtime method.
|
/// Name of the `ToWococoOutboundLaneApi::latest_received_nonce` runtime method.
|
||||||
@@ -142,15 +142,16 @@ sp_api::decl_runtime_apis! {
|
|||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
payload: OutboundPayload,
|
payload: OutboundPayload,
|
||||||
) -> Option<OutboundMessageFee>;
|
) -> Option<OutboundMessageFee>;
|
||||||
/// Returns total dispatch weight and encoded payload size of all messages in given inclusive range.
|
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||||
|
/// messages in given inclusive range.
|
||||||
///
|
///
|
||||||
/// If some (or all) messages are missing from the storage, they'll also will
|
/// If some (or all) messages are missing from the storage, they'll also will
|
||||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||||
fn messages_dispatch_weight(
|
fn message_details(
|
||||||
lane: LaneId,
|
lane: LaneId,
|
||||||
begin: MessageNonce,
|
begin: MessageNonce,
|
||||||
end: MessageNonce,
|
end: MessageNonce,
|
||||||
) -> Vec<(MessageNonce, Weight, u32)>;
|
) -> Vec<MessageDetails<OutboundMessageFee>>;
|
||||||
/// Returns nonce of the latest message, received by bridged chain.
|
/// Returns nonce of the latest message, received by bridged chain.
|
||||||
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
|
||||||
/// Returns nonce of the latest message, generated by given lane.
|
/// Returns nonce of the latest message, generated by given lane.
|
||||||
|
|||||||
@@ -163,6 +163,19 @@ impl<RelayerId> InboundLaneData<RelayerId> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Message details, returned by runtime APIs.
|
||||||
|
#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq)]
|
||||||
|
pub struct MessageDetails<OutboundMessageFee> {
|
||||||
|
/// Nonce assigned to the message.
|
||||||
|
pub nonce: MessageNonce,
|
||||||
|
/// Message dispatch weight, declared by the submitter.
|
||||||
|
pub dispatch_weight: Weight,
|
||||||
|
/// Size of the encoded message.
|
||||||
|
pub size: u32,
|
||||||
|
/// Delivery+dispatch fee paid by the message submitter at the source chain.
|
||||||
|
pub delivery_and_dispatch_fee: OutboundMessageFee,
|
||||||
|
}
|
||||||
|
|
||||||
/// Gist of `InboundLaneData::relayers` field used by runtime APIs.
|
/// Gist of `InboundLaneData::relayers` field used by runtime APIs.
|
||||||
#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq)]
|
#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq)]
|
||||||
pub struct UnrewardedRelayersState {
|
pub struct UnrewardedRelayersState {
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ pub type MillauMessagesToRialto =
|
|||||||
SubstrateMessageLaneToSubstrate<Millau, MillauSigningParams, Rialto, RialtoSigningParams>;
|
SubstrateMessageLaneToSubstrate<Millau, MillauSigningParams, Rialto, RialtoSigningParams>;
|
||||||
|
|
||||||
impl SubstrateMessageLane for MillauMessagesToRialto {
|
impl SubstrateMessageLane for MillauMessagesToRialto {
|
||||||
const OUTBOUND_LANE_MESSAGES_DISPATCH_WEIGHT_METHOD: &'static str =
|
const OUTBOUND_LANE_MESSAGE_DETAILS_METHOD: &'static str = bp_rialto::TO_RIALTO_MESSAGE_DETAILS_METHOD;
|
||||||
bp_rialto::TO_RIALTO_MESSAGES_DISPATCH_WEIGHT_METHOD;
|
|
||||||
const OUTBOUND_LANE_LATEST_GENERATED_NONCE_METHOD: &'static str =
|
const OUTBOUND_LANE_LATEST_GENERATED_NONCE_METHOD: &'static str =
|
||||||
bp_rialto::TO_RIALTO_LATEST_GENERATED_NONCE_METHOD;
|
bp_rialto::TO_RIALTO_LATEST_GENERATED_NONCE_METHOD;
|
||||||
const OUTBOUND_LANE_LATEST_RECEIVED_NONCE_METHOD: &'static str = bp_rialto::TO_RIALTO_LATEST_RECEIVED_NONCE_METHOD;
|
const OUTBOUND_LANE_LATEST_RECEIVED_NONCE_METHOD: &'static str = bp_rialto::TO_RIALTO_LATEST_RECEIVED_NONCE_METHOD;
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ pub type RialtoMessagesToMillau =
|
|||||||
SubstrateMessageLaneToSubstrate<Rialto, RialtoSigningParams, Millau, MillauSigningParams>;
|
SubstrateMessageLaneToSubstrate<Rialto, RialtoSigningParams, Millau, MillauSigningParams>;
|
||||||
|
|
||||||
impl SubstrateMessageLane for RialtoMessagesToMillau {
|
impl SubstrateMessageLane for RialtoMessagesToMillau {
|
||||||
const OUTBOUND_LANE_MESSAGES_DISPATCH_WEIGHT_METHOD: &'static str =
|
const OUTBOUND_LANE_MESSAGE_DETAILS_METHOD: &'static str = bp_millau::TO_MILLAU_MESSAGE_DETAILS_METHOD;
|
||||||
bp_millau::TO_MILLAU_MESSAGES_DISPATCH_WEIGHT_METHOD;
|
|
||||||
const OUTBOUND_LANE_LATEST_GENERATED_NONCE_METHOD: &'static str =
|
const OUTBOUND_LANE_LATEST_GENERATED_NONCE_METHOD: &'static str =
|
||||||
bp_millau::TO_MILLAU_LATEST_GENERATED_NONCE_METHOD;
|
bp_millau::TO_MILLAU_LATEST_GENERATED_NONCE_METHOD;
|
||||||
const OUTBOUND_LANE_LATEST_RECEIVED_NONCE_METHOD: &'static str = bp_millau::TO_MILLAU_LATEST_RECEIVED_NONCE_METHOD;
|
const OUTBOUND_LANE_LATEST_RECEIVED_NONCE_METHOD: &'static str = bp_millau::TO_MILLAU_LATEST_RECEIVED_NONCE_METHOD;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ pub struct MessagesRelayParams<SC: Chain, SS, TC: Chain, TS> {
|
|||||||
/// Message sync pipeline for Substrate <-> Substrate relays.
|
/// Message sync pipeline for Substrate <-> Substrate relays.
|
||||||
pub trait SubstrateMessageLane: MessageLane {
|
pub trait SubstrateMessageLane: MessageLane {
|
||||||
/// Name of the runtime method that returns dispatch weight of outbound messages at the source chain.
|
/// Name of the runtime method that returns dispatch weight of outbound messages at the source chain.
|
||||||
const OUTBOUND_LANE_MESSAGES_DISPATCH_WEIGHT_METHOD: &'static str;
|
const OUTBOUND_LANE_MESSAGE_DETAILS_METHOD: &'static str;
|
||||||
/// Name of the runtime method that returns latest generated nonce at the source chain.
|
/// Name of the runtime method that returns latest generated nonce at the source chain.
|
||||||
const OUTBOUND_LANE_LATEST_GENERATED_NONCE_METHOD: &'static str;
|
const OUTBOUND_LANE_LATEST_GENERATED_NONCE_METHOD: &'static str;
|
||||||
/// Name of the runtime method that returns latest received (confirmed) nonce at the the source chain.
|
/// Name of the runtime method that returns latest received (confirmed) nonce at the the source chain.
|
||||||
|
|||||||
@@ -176,13 +176,13 @@ where
|
|||||||
let encoded_response = self
|
let encoded_response = self
|
||||||
.client
|
.client
|
||||||
.state_call(
|
.state_call(
|
||||||
P::OUTBOUND_LANE_MESSAGES_DISPATCH_WEIGHT_METHOD.into(),
|
P::OUTBOUND_LANE_MESSAGE_DETAILS_METHOD.into(),
|
||||||
Bytes((self.lane_id, nonces.start(), nonces.end()).encode()),
|
Bytes((self.lane_id, nonces.start(), nonces.end()).encode()),
|
||||||
Some(id.1),
|
Some(id.1),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
make_message_weights_map::<C>(
|
make_message_details_map::<C>(
|
||||||
Decode::decode(&mut &encoded_response.0[..]).map_err(SubstrateError::ResponseParseFailed)?,
|
Decode::decode(&mut &encoded_response.0[..]).map_err(SubstrateError::ResponseParseFailed)?,
|
||||||
nonces,
|
nonces,
|
||||||
)
|
)
|
||||||
@@ -287,8 +287,8 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_message_weights_map<C: Chain>(
|
fn make_message_details_map<C: Chain>(
|
||||||
weights: Vec<(MessageNonce, Weight, u32)>,
|
weights: Vec<bp_messages::MessageDetails<C::Balance>>,
|
||||||
nonces: RangeInclusive<MessageNonce>,
|
nonces: RangeInclusive<MessageNonce>,
|
||||||
) -> Result<MessageWeightsMap, SubstrateError> {
|
) -> Result<MessageWeightsMap, SubstrateError> {
|
||||||
let make_missing_nonce_error = |expected_nonce| {
|
let make_missing_nonce_error = |expected_nonce| {
|
||||||
@@ -308,7 +308,7 @@ fn make_message_weights_map<C: Chain>(
|
|||||||
// check if last nonce is missing - loop below is not checking this
|
// check if last nonce is missing - loop below is not checking this
|
||||||
let last_nonce_is_missing = weights
|
let last_nonce_is_missing = weights
|
||||||
.last()
|
.last()
|
||||||
.map(|(last_nonce, _, _)| last_nonce != nonces.end())
|
.map(|details| details.nonce != *nonces.end())
|
||||||
.unwrap_or(true);
|
.unwrap_or(true);
|
||||||
if last_nonce_is_missing {
|
if last_nonce_is_missing {
|
||||||
return make_missing_nonce_error(*nonces.end());
|
return make_missing_nonce_error(*nonces.end());
|
||||||
@@ -317,8 +317,8 @@ fn make_message_weights_map<C: Chain>(
|
|||||||
let mut expected_nonce = *nonces.start();
|
let mut expected_nonce = *nonces.start();
|
||||||
let mut is_at_head = true;
|
let mut is_at_head = true;
|
||||||
|
|
||||||
for (nonce, weight, size) in weights {
|
for details in weights {
|
||||||
match (nonce == expected_nonce, is_at_head) {
|
match (details.nonce == expected_nonce, is_at_head) {
|
||||||
(true, _) => (),
|
(true, _) => (),
|
||||||
(false, true) => {
|
(false, true) => {
|
||||||
// this may happen if some messages were already pruned from the source node
|
// this may happen if some messages were already pruned from the source node
|
||||||
@@ -328,7 +328,7 @@ fn make_message_weights_map<C: Chain>(
|
|||||||
target: "bridge",
|
target: "bridge",
|
||||||
"Some messages are missing from the {} node: {:?}. Target node may be out of sync?",
|
"Some messages are missing from the {} node: {:?}. Target node may be out of sync?",
|
||||||
C::NAME,
|
C::NAME,
|
||||||
expected_nonce..nonce,
|
expected_nonce..details.nonce,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
(false, false) => {
|
(false, false) => {
|
||||||
@@ -340,13 +340,13 @@ fn make_message_weights_map<C: Chain>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
weights_map.insert(
|
weights_map.insert(
|
||||||
nonce,
|
details.nonce,
|
||||||
MessageWeights {
|
MessageWeights {
|
||||||
weight,
|
weight: details.dispatch_weight,
|
||||||
size: size as _,
|
size: details.size as _,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expected_nonce = nonce + 1;
|
expected_nonce = details.nonce + 1;
|
||||||
is_at_head = false;
|
is_at_head = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,11 +357,24 @@ fn make_message_weights_map<C: Chain>(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
fn message_details_from_rpc(
|
||||||
|
nonces: RangeInclusive<MessageNonce>,
|
||||||
|
) -> Vec<bp_messages::MessageDetails<bp_rialto::Balance>> {
|
||||||
|
nonces
|
||||||
|
.into_iter()
|
||||||
|
.map(|nonce| bp_messages::MessageDetails {
|
||||||
|
nonce,
|
||||||
|
dispatch_weight: 0,
|
||||||
|
size: 0,
|
||||||
|
delivery_and_dispatch_fee: 0,
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn make_message_weights_map_succeeds_if_no_messages_are_missing() {
|
fn make_message_details_map_succeeds_if_no_messages_are_missing() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
make_message_weights_map::<relay_rialto_client::Rialto>(vec![(1, 0, 0), (2, 0, 0), (3, 0, 0)], 1..=3,)
|
make_message_details_map::<relay_rialto_client::Rialto>(message_details_from_rpc(1..=3), 1..=3,).unwrap(),
|
||||||
.unwrap(),
|
|
||||||
vec![
|
vec![
|
||||||
(1, MessageWeights { weight: 0, size: 0 }),
|
(1, MessageWeights { weight: 0, size: 0 }),
|
||||||
(2, MessageWeights { weight: 0, size: 0 }),
|
(2, MessageWeights { weight: 0, size: 0 }),
|
||||||
@@ -373,9 +386,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn make_message_weights_map_succeeds_if_head_messages_are_missing() {
|
fn make_message_details_map_succeeds_if_head_messages_are_missing() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
make_message_weights_map::<relay_rialto_client::Rialto>(vec![(2, 0, 0), (3, 0, 0)], 1..=3,).unwrap(),
|
make_message_details_map::<relay_rialto_client::Rialto>(message_details_from_rpc(2..=3), 1..=3,).unwrap(),
|
||||||
vec![
|
vec![
|
||||||
(2, MessageWeights { weight: 0, size: 0 }),
|
(2, MessageWeights { weight: 0, size: 0 }),
|
||||||
(3, MessageWeights { weight: 0, size: 0 }),
|
(3, MessageWeights { weight: 0, size: 0 }),
|
||||||
@@ -386,25 +399,27 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn make_message_weights_map_fails_if_mid_messages_are_missing() {
|
fn make_message_details_map_fails_if_mid_messages_are_missing() {
|
||||||
|
let mut message_details_from_rpc = message_details_from_rpc(1..=3);
|
||||||
|
message_details_from_rpc.remove(1);
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
make_message_weights_map::<relay_rialto_client::Rialto>(vec![(1, 0, 0), (3, 0, 0)], 1..=3,),
|
make_message_details_map::<relay_rialto_client::Rialto>(message_details_from_rpc, 1..=3,),
|
||||||
Err(SubstrateError::Custom(_))
|
Err(SubstrateError::Custom(_))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn make_message_weights_map_fails_if_tail_messages_are_missing() {
|
fn make_message_details_map_fails_if_tail_messages_are_missing() {
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
make_message_weights_map::<relay_rialto_client::Rialto>(vec![(1, 0, 0), (2, 0, 0)], 1..=3,),
|
make_message_details_map::<relay_rialto_client::Rialto>(message_details_from_rpc(1..=2), 1..=3,),
|
||||||
Err(SubstrateError::Custom(_))
|
Err(SubstrateError::Custom(_))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn make_message_weights_map_fails_if_all_messages_are_missing() {
|
fn make_message_details_map_fails_if_all_messages_are_missing() {
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
make_message_weights_map::<relay_rialto_client::Rialto>(vec![], 1..=3),
|
make_message_details_map::<relay_rialto_client::Rialto>(vec![], 1..=3),
|
||||||
Err(SubstrateError::Custom(_))
|
Err(SubstrateError::Custom(_))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user