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
-1
View File
@@ -220,7 +220,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
finality_proof_provider.clone(),
)));
io.extend_with(MessageLaneApi::to_delegate(MessageLaneRpcHandler::new(
client.clone(),
backend.clone(),
Arc::new(RialtoMessageLaneKeys),
)));
+13 -6
View File
@@ -706,12 +706,19 @@ impl_runtime_apis! {
// TODO: runtime should support several chains (https://github.com/paritytech/parity-bridges-common/issues/457)
impl bp_message_lane::OutboundLaneApi<Block> for Runtime {
fn messages_dispatch_weight(lane: bp_message_lane::LaneId, begin: bp_message_lane::MessageNonce, end: bp_message_lane::MessageNonce) -> Weight {
(begin..=end)
.filter_map(|nonce| BridgeMillauMessageLane::outbound_message_payload(lane, nonce))
.filter_map(|encoded_payload| millau_messages::ToMillauMessagePayload::decode(&mut &encoded_payload[..]).ok())
.map(|decoded_payload| decoded_payload.weight)
.fold(0, |sum, weight| sum.saturating_add(weight))
fn messages_dispatch_weight(
lane: bp_message_lane::LaneId,
begin: bp_message_lane::MessageNonce,
end: bp_message_lane::MessageNonce,
) -> Vec<(bp_message_lane::MessageNonce, Weight)> {
(begin..=end).filter_map(|nonce| {
let encoded_payload = BridgeMillauMessageLane::outbound_message_payload(lane, nonce)?;
let decoded_payload = millau_messages::ToMillauMessagePayload::decode(
&mut &encoded_payload[..]
).ok()?;
Some((nonce, decoded_payload.weight))
})
.collect()
}
fn latest_received_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce {