Limit messages weight in batch (#496)

* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of #469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
This commit is contained in:
Svyatoslav Nikolsky
2020-11-17 23:27:30 +03:00
committed by Bastian Köcher
parent e515f4fb62
commit 23f5f3cdd6
21 changed files with 859 additions and 405 deletions
+12 -2
View File
@@ -23,13 +23,16 @@
#![allow(clippy::unnecessary_mut_passed)]
use codec::{Decode, Encode};
use frame_support::{weights::Weight, RuntimeDebug};
use frame_support::RuntimeDebug;
use sp_api::decl_runtime_apis;
use sp_std::{collections::vec_deque::VecDeque, prelude::*};
pub mod source_chain;
pub mod target_chain;
// Weight is reexported to avoid additional frame-support dependencies in message-lane related crates.
pub use frame_support::weights::Weight;
/// Lane identifier.
pub type LaneId = [u8; 4];
@@ -127,7 +130,14 @@ decl_runtime_apis! {
/// Outbound message lane API.
pub trait OutboundLaneApi {
/// Returns dispatch weight of all messages in given inclusive range.
fn messages_dispatch_weight(lane: LaneId, begin: MessageNonce, end: MessageNonce) -> Weight;
///
/// 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.
fn messages_dispatch_weight(
lane: LaneId,
begin: MessageNonce,
end: MessageNonce,
) -> Vec<(MessageNonce, Weight)>;
/// Returns nonce of the latest message, received by bridged chain.
fn latest_received_nonce(lane: LaneId) -> MessageNonce;
/// Returns nonce of the latest message, generated by given lane.