Skip to content

Commit

Permalink
Backport latest changes from polkadot staging (#2732)
Browse files Browse the repository at this point in the history
* separate constants for average and worst case relay headers (#2728)

* separate constants for average and worst case relay headers

* fix compilation

* Select header that will be fully refunded in on-demand batch finality relay (#2729)

* select header that will be fully refunded for submission in on-demand **batch** finality relay

* added the only possible test

* spelling

* nl

* updated comment

* backport some nits from #2727

* NotApplicable instead of Unroutable

* Grafana update stuff (#2733)

---------

Co-authored-by: Branislav Kontur <bkontur@gmail.com>
  • Loading branch information
svyatonik and bkontur committed May 7, 2024
1 parent d942471 commit f9b420c
Show file tree
Hide file tree
Showing 21 changed files with 286 additions and 145 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 128,
"version": 130,
"uid": "r41otJp4k",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -186,9 +186,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 126,
"version": 128,
"uid": "wqmPtJpVz",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -284,9 +284,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 122,
"version": 124,
"uid": "z4h3pJtVz",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -382,9 +382,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 121,
"version": 123,
"uid": "Kj_z21t4k",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -480,9 +480,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 116,
"version": 118,
"uid": "hw_a21pVk",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -578,9 +578,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 115,
"version": 117,
"uid": "daN62Jt4z",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -676,9 +676,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 112,
"version": 114,
"uid": "BzBDb1pVz",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -774,9 +774,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 111,
"version": 113,
"uid": "1W6lb1p4z",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -872,9 +872,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 110,
"version": 112,
"uid": "Y5Dm-1tVz",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -970,9 +970,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 109,
"version": 111,
"uid": "yUl4a1tVz",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -1111,9 +1111,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 78,
"version": 80,
"uid": "R6GKwNA4z",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -1252,9 +1252,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 76,
"version": 78,
"uid": "rAM1QHAVk",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -1283,24 +1283,24 @@
"data": [
{
"refId": "B",
"queryType": "range",
"queryType": "instant",
"relativeTimeRange": {
"from": 600,
"to": 0
},
"datasourceUid": "P03E52D76DFE188C3",
"datasourceUid": "P3572579027B246FE",
"model": {
"datasource": {
"type": "loki",
"uid": "P03E52D76DFE188C3"
"uid": "P3572579027B246FE"
},
"editorMode": "code",
"expr": "count_over_time({container=\"bridges-common-relay\"} |= `Aborting relay` [1m])",
"hide": false,
"intervalMs": 1000,
"legendFormat": "Aborts per minute",
"maxDataPoints": 43200,
"queryType": "range",
"queryType": "instant",
"refId": "B"
}
},
Expand Down Expand Up @@ -1392,9 +1392,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 75,
"version": 77,
"uid": "TwWPeN04z",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -1533,9 +1533,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 70,
"version": 72,
"uid": "08-5gv04k",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -1674,9 +1674,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 69,
"version": 71,
"uid": "Esj2gD0Vk",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -1717,7 +1717,7 @@
"uid": "PC96415006F908B67"
},
"editorMode": "code",
"expr": "increase(BridgeHubRococo_to_BridgeHubWestend_MessageLane_00000002_lane_state_nonces{domain=\"parity-testnet\", type=~\"source_latest_generated\"}[24h])",
"expr": "max by(container) (increase(BridgeHubRococo_to_BridgeHubWestend_MessageLane_00000002_lane_state_nonces{domain=\"parity-testnet\", type=~\"source_latest_generated\"}[24h]))",
"hide": true,
"instant": false,
"interval": "",
Expand Down Expand Up @@ -1816,9 +1816,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 41,
"version": 43,
"uid": "ry1K5SB4k",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down Expand Up @@ -1958,9 +1958,9 @@
}
}
],
"updated": "2023-11-22T09:28:26Z",
"updated": "2023-12-08T06:04:42Z",
"intervalSeconds": 60,
"version": 39,
"version": 41,
"uid": "9YAdEUB4z",
"namespace_uid": "eblDiw17z",
"namespace_id": 140,
Expand Down
27 changes: 14 additions & 13 deletions modules/grandpa/src/call_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

use crate::{weights::WeightInfo, BridgedBlockNumber, BridgedHeader, Config, Error, Pallet};
use bp_header_chain::{
justification::GrandpaJustification, ChainWithGrandpa, SubmitFinalityProofInfo,
justification::GrandpaJustification, max_expected_submit_finality_proof_arguments_size,
ChainWithGrandpa, GrandpaConsensusLogReader, SubmitFinalityProofInfo,
};
use bp_runtime::{BlockNumberOf, OwnedBridgeModule};
use codec::Encode;
Expand Down Expand Up @@ -145,28 +146,28 @@ pub(crate) fn submit_finality_proof_info_from_args<T: Config<I>, I: 'static>(
Weight::zero()
};

// check if the `finality_target` is a mandatory header. If so, we are ready to refund larger
// size
let is_mandatory_finality_target =
GrandpaConsensusLogReader::<BridgedBlockNumber<T, I>>::find_scheduled_change(
finality_target.digest(),
)
.is_some();

// we can estimate extra call size easily, without any additional significant overhead
let actual_call_size: u32 = finality_target
.encoded_size()
.saturating_add(justification.encoded_size())
.saturated_into();
let max_expected_call_size = max_expected_call_size::<T, I>(required_precommits);
let max_expected_call_size = max_expected_submit_finality_proof_arguments_size::<T::BridgedChain>(
is_mandatory_finality_target,
required_precommits,
);
let extra_size = actual_call_size.saturating_sub(max_expected_call_size);

SubmitFinalityProofInfo { block_number, extra_weight, extra_size }
}

/// Returns maximal expected size of `submit_finality_proof` call arguments.
fn max_expected_call_size<T: Config<I>, I: 'static>(required_precommits: u32) -> u32 {
let max_expected_justification_size =
GrandpaJustification::<BridgedHeader<T, I>>::max_reasonable_size::<T::BridgedChain>(
required_precommits,
);

// call arguments are header and justification
T::BridgedChain::MAX_HEADER_SIZE.saturating_add(max_expected_justification_size)
}

#[cfg(test)]
mod tests {
use crate::{
Expand Down
4 changes: 2 additions & 2 deletions modules/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ impl ChainWithGrandpa for TestBridgedChain {
const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = "";
const MAX_AUTHORITIES_COUNT: u32 = MAX_BRIDGED_AUTHORITIES;
const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 8;
const MAX_HEADER_SIZE: u32 = 256;
const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 64;
const MAX_MANDATORY_HEADER_SIZE: u32 = 256;
const AVERAGE_HEADER_SIZE: u32 = 64;
}

/// Return test externalities to use in tests.
Expand Down
4 changes: 2 additions & 2 deletions modules/messages/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ impl ChainWithGrandpa for BridgedChain {
const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = "WithBridgedChainBridgeGrandpa";
const MAX_AUTHORITIES_COUNT: u32 = 16;
const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 4;
const MAX_HEADER_SIZE: u32 = 4096;
const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 4096;
const AVERAGE_HEADER_SIZE: u32 = 4096;
const MAX_MANDATORY_HEADER_SIZE: u32 = 8192;
}

impl ChainWithMessages for BridgedChain {
Expand Down
8 changes: 4 additions & 4 deletions modules/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ impl ChainWithGrandpa for TestBridgedChain {
const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = "";
const MAX_AUTHORITIES_COUNT: u32 = 16;
const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 8;
const MAX_HEADER_SIZE: u32 = 256;
const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 64;
const MAX_MANDATORY_HEADER_SIZE: u32 = 256;
const AVERAGE_HEADER_SIZE: u32 = 64;
}

#[derive(Debug)]
Expand Down Expand Up @@ -307,8 +307,8 @@ impl ChainWithGrandpa for OtherBridgedChain {
const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = "";
const MAX_AUTHORITIES_COUNT: u32 = 16;
const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 8;
const MAX_HEADER_SIZE: u32 = 256;
const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 64;
const MAX_MANDATORY_HEADER_SIZE: u32 = 256;
const AVERAGE_HEADER_SIZE: u32 = 64;
}

/// Return test externalities to use in tests.
Expand Down
4 changes: 2 additions & 2 deletions modules/relayers/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ impl ChainWithGrandpa for BridgedUnderlyingChain {
const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = "";
const MAX_AUTHORITIES_COUNT: u32 = 16;
const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 8;
const MAX_HEADER_SIZE: u32 = 256;
const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 64;
const AVERAGE_HEADER_SIZE: u32 = 64;
const MAX_MANDATORY_HEADER_SIZE: u32 = 128;
}

impl ChainWithMessages for BridgedUnderlyingChain {
Expand Down
5 changes: 2 additions & 3 deletions modules/xcm-bridge-hub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
name = "pallet-xcm-bridge-hub"
description = "Module that adds dynamic bridges/lanes support to XCM infrastucture at the bridge hub."
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
authors.workspace = true
edition.workspace = true

[dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
Expand Down
Loading

0 comments on commit f9b420c

Please sign in to comment.