Skip to content

Commit a8a89fc

Browse files
committed
Extended Kusama/Polkadot BridgeHub configuration with dynamic fees support
Squashed commit of the following: commit fcb61370cd65b3579675b3a3d20c42475176756b Merge: 8e21f41ca1 a7402efd77 Author: Branislav Kontur <[email protected]> Date: Sun Sep 3 11:31:18 2023 +0200 Merge branch 'bridge-hub-kusama-polkadot' into bridge-hub-kusama-polkadot-with-dynamic-fees commit 8e21f41ca1a69a60e4a0bf6d8e2f5238e4f81a07 Merge: ca288257c8 69db677180 Author: Branislav Kontur <[email protected]> Date: Thu Aug 17 09:55:18 2023 +0200 Merge remote-tracking branch 'origin/bridge-hub-kusama-polkadot' into bridge-hub-kusama-polkadot-with-dynamic-fees commit ca288257c8edb39453945267022c789e6d343a6a Merge: 7824adb44c d701b6ad24 Author: Branislav Kontur <[email protected]> Date: Wed Aug 16 21:36:16 2023 +0200 Merge remote-tracking branch 'origin/bridge-hub-kusama-polkadot' into bridge-hub-kusama-polkadot-with-dynamic-fees commit 7824adb44c35aba4e8334496c5c1e8c7aab2d510 Author: Branislav Kontur <[email protected]> Date: Wed Aug 16 12:36:06 2023 +0200 Added consts for base fee with sanity check commit 47addc3fd6ab5518610c5a3c15a615b520def45f Author: Branislav Kontur <[email protected]> Date: Wed Aug 16 12:28:46 2023 +0200 Fix for BHRo/Wo commit ad6f236fec91b04acb16a58c9eabb32a854be57b Author: Branislav Kontur <[email protected]> Date: Wed Aug 16 11:50:06 2023 +0200 Congestion messages as Optional to turn on/off `supports_congestion_detection` commit 5931a57af12399ee400f2b31ccacfbdbf7d317b4 Author: Branislav Kontur <[email protected]> Date: Wed Aug 16 11:48:42 2023 +0200 Introduced base delivery fee constants commit 4c5e054b998e8d8d8f5df702300ad8ba84ef15fc Author: Branislav Kontur <[email protected]> Date: Tue Aug 15 17:35:24 2023 +0200 Adjusted `require_max_weight` with XcmBridgeHubRouterTransactCallMaxWeight commit a9b4637d06e88f859c7dde23566e480d74234eec Author: Branislav Kontur <[email protected]> Date: Tue Aug 15 17:26:59 2023 +0200 Added const for `XcmBridgeHubRouterTransactCallMaxWeight` commit 16ac9a1a0c38caee65c8f82531df4230158afcfe Author: Branislav Kontur <[email protected]> Date: Tue Aug 15 12:49:03 2023 +0200 Add impl for `CongestedMessage/UncongestedMessage` for BridgeHubs commit 307654e59a491eb1a28e6c650181a7df6c336811 Author: Branislav Kontur <[email protected]> Date: Tue Aug 15 12:05:40 2023 +0200 Added XcmBridgeHubRouterCall::report_bridge_status encodings for AHK/P commit 9daeb8b87ea2a404ace4f4acba716d7a9a133a6f Author: Branislav Kontur <[email protected]> Date: Mon Aug 14 22:41:38 2023 +0200 Extended script for local run BHK/P commit 983eb8d5990758857529de109282130f2db8ff13 Author: Branislav Kontur <[email protected]> Date: Mon Aug 14 16:34:02 2023 +0200 Disabled `UnpaidExecution` for system parachains commit 3a5dfe2fc154fc5e5df6ce1a51fdbe850c73a41e Author: Branislav Kontur <[email protected]> Date: Mon Aug 14 16:15:55 2023 +0200 Adjusted test `handle_export_message_from_system_parachain_to_outbound_queue_works` for Paid or Unpaid scenario commit a701215a9b0bcacb151d5c72668f7acb74962d68 Author: Branislav Kontur <[email protected]> Date: Mon Aug 14 15:26:28 2023 +0200 Test for calculating base delivery fee on BridgeHubs commit ebc0ed144699ea6c03d43aa17b90458cce15e284 Author: Branislav Kontur <[email protected]> Date: Sat Aug 12 16:39:10 2023 +0200 Update to new version with dynamic fees commit 76115f6c759a851df3c837d3c0aa6ceb91aef2c8 Author: Branislav Kontur <[email protected]> Date: Fri Aug 11 22:19:45 2023 +0200 [dynfees] Implemented `XcmChannelStatusProvider` for `XcmpQueue` commit e5ac886647f732330defc2c681502a1540e96d98 Author: Branislav Kontur <[email protected]> Date: Fri Aug 11 10:03:21 2023 +0200 [dynfees] Rococo/Wococo does not need congestion and dynamic fees (for now) commit 4d60d0992c2da0ff5c84ff899123f3c9b33c3050 Merge: e1d0001ecf 02e00e6411 Author: Branislav Kontur <[email protected]> Date: Thu Aug 10 15:58:59 2023 +0200 Merge commit '02e00e6411c56bc44497bcd05104b17cdfdc0862' into bridge-hub-kusama-polkadot-with-dynamic-fees commit 02e00e6411c56bc44497bcd05104b17cdfdc0862 Author: Branislav Kontur <[email protected]> Date: Thu Aug 10 15:58:59 2023 +0200 Squashed 'bridges/' changes from edf33a2..8f86ec78b7 8f86ec78b7 ".git/.scripts/commands/fmt/fmt.sh" ccf2f9483b Merge remote-tracking branch 'origin/polkadot-staging' into dynamic-fees-v1 f822ebc450 Dynamic fees v1: report congestion status to sending chain (#2318) add9fb1d53 added/fixed some docs 569a80f233 Rename LocalXcmChannel to XcmChannelStatusProvider (#2319) dc3618a4a5 Clippy e7cab6ab49 (Suggestion) Ability to externalize configuration for `ExporterFor` (#2313) c68467beff fmt 5d76f25311 use saturated_len where possible 7cc1470528 Update modules/xcm-bridge-hub-router/src/lib.rs 8d7a38a409 change log target for xcm bridge router pallet 773f93209f Revert "trigger CI" 48f1ba0323 trigger CI b26aa98d1e fixing spellcheck, clippy and rustdoc c467911a37 add new pallet to verify-pallets-build.sh ed72ebe62b get rid of redundant storage value 522bbc7ec4 benchmarks for pallet-xcm-bridge-hub-router 958243564d extension_reject_call_when_dispatcher_is_inactive 38cd8f3df3 fix other tests in the bridge-runtime-common b75e64fdf7 tests for new logic in the XcmBlobHaulerAdapter 4c741714cb tests for LocalXcmQueueMessageProcessor d99420e14c tests for LocalXcmQueueSuspender 084f551bb6 new tests for logic changes in messages pallet d9515f7317 use LocalXcmChannel in XcmBlobMessageDispatch d9a0c2e468 improvements and tests for palle-xcm-bridge-router c24301374a removed commented code eea610a875 pallet-xcm-bridge-hub-router 1fdac85a14 forbid mesage delivery transactions when the channel between target bridge hub and target asset hub is suspended 3c98c245ac OnMessageDelviered callback 65787da038 LocalXcmQueueManager + more adapters 74b48e2cc3 impl backpressure in the XcmBlobHaulerAdapter git-subtree-dir: bridges git-subtree-split: 8f86ec78b7747ba32807e8691f022edb4ad3040d Co-authored-by: Branislav Kontur <[email protected]> Co-authored-by: Adrian Catangiu <[email protected]> Co-authored-by: Svyatoslav Nikolsky <[email protected]> Co-authored-by: Serban Iorga <[email protected]> Signed-off-by: Branislav Kontur <[email protected]> Signed-off-by: Adrian Catangiu <[email protected]> Signed-off-by: Svyatoslav Nikolsky <[email protected]> Signed-off-by: Serban Iorga <[email protected]>
1 parent 6fec636 commit a8a89fc

File tree

15 files changed

+289
-51
lines changed

15 files changed

+289
-51
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cumulus/pallets/xcmp-queue/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ cumulus-pallet-parachain-system = { path = "../parachain-system" }
4646
[features]
4747
default = [ "std" ]
4848
std = [
49-
"bp-xcm-bridge-hub-router/std",
49+
"bp-xcm-bridge-hub-router?/std",
5050
"codec/std",
5151
"cumulus-primitives-core/std",
5252
"frame-benchmarking?/std",

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-fea
6464
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
6565
cumulus-pallet-session-benchmarking = { path = "../../../../pallets/session-benchmarking", default-features = false}
6666
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
67-
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
67+
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false, features = ["bridging"] }
6868
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
6969
cumulus-primitives-utility = { path = "../../../../primitives/utility", default-features = false }
7070
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
7171
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
7272
parachains-common = { path = "../../../common", default-features = false }
7373

7474
# Bridges
75+
bp-asset-hub-kusama = { path = "../../../../bridges/primitives/chain-asset-hub-kusama", default-features = false }
7576
bp-bridge-hub-kusama = { path = "../../../../bridges/primitives/chain-bridge-hub-kusama", default-features = false }
7677
bp-bridge-hub-polkadot = { path = "../../../../bridges/primitives/chain-bridge-hub-polkadot", default-features = false }
7778
bp-header-chain = { path = "../../../../bridges/primitives/header-chain", default-features = false }
@@ -97,6 +98,7 @@ sp-keyring = { path = "../../../../../substrate/primitives/keyring" }
9798
[features]
9899
default = [ "std" ]
99100
std = [
101+
"bp-asset-hub-kusama/std",
100102
"bp-bridge-hub-kusama/std",
101103
"bp-bridge-hub-polkadot/std",
102104
"bp-header-chain/std",

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/bridge_hub_config.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use bridge_runtime_common::{
3333
RefundableParachain,
3434
},
3535
};
36+
use codec::Encode;
3637
use frame_support::{parameter_types, traits::PalletInfoAccess};
3738
use sp_runtime::RuntimeDebug;
3839
use xcm::{latest::prelude::*, prelude::NetworkId};
@@ -55,6 +56,28 @@ parameter_types! {
5556
ParentThen(X1(Parachain(AssetHubKusamaParaId::get().into()))).into(),
5657
ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT_LANE_ID,
5758
);
59+
60+
pub CongestedMessage: Xcm<()> = sp_std::vec![Transact {
61+
origin_kind: OriginKind::Xcm,
62+
require_weight_at_most: bp_asset_hub_kusama::XcmBridgeHubRouterTransactCallMaxWeight::get(),
63+
call: bp_asset_hub_kusama::Call::ToPolkadotXcmRouter(
64+
bp_asset_hub_kusama::XcmBridgeHubRouterCall::report_bridge_status {
65+
bridge_id: Default::default(),
66+
is_congested: true,
67+
}
68+
).encode().into(),
69+
}].into();
70+
71+
pub UncongestedMessage: Xcm<()> = sp_std::vec![Transact {
72+
origin_kind: OriginKind::Xcm,
73+
require_weight_at_most: bp_asset_hub_kusama::XcmBridgeHubRouterTransactCallMaxWeight::get(),
74+
call: bp_asset_hub_kusama::Call::ToPolkadotXcmRouter(
75+
bp_asset_hub_kusama::XcmBridgeHubRouterCall::report_bridge_status {
76+
bridge_id: Default::default(),
77+
is_congested: false,
78+
}
79+
).encode().into(),
80+
}].into();
5881
}
5982

6083
/// Proof of messages, coming from BridgeHubPolkadot.
@@ -81,10 +104,13 @@ impl XcmBlobHauler for ToBridgeHubPolkadotXcmBlobHauler {
81104
type SenderAndLane = FromAssetHubKusamaToAssetHubPolkadotRoute;
82105

83106
type ToSourceChainSender = crate::XcmRouter;
84-
type CongestedMessage = ();
85-
type UncongestedMessage = ();
107+
type CongestedMessage = CongestedMessage;
108+
type UncongestedMessage = UncongestedMessage;
86109
}
87110

111+
/// On messages delivered callback.
112+
pub type OnMessagesDelivered = XcmBlobHaulerAdapter<ToBridgeHubPolkadotXcmBlobHauler>;
113+
88114
/// Messaging Bridge configuration for ThisChain -> BridgeHubPolkadot
89115
pub struct WithBridgeHubPolkadotMessageBridge;
90116
impl MessageBridge for WithBridgeHubPolkadotMessageBridge {

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,15 @@ impl pallet_bridge_messages::Config<WithBridgeHubPolkadotMessagesInstance> for R
493493
DeliveryRewardInBalance,
494494
>;
495495
type SourceHeaderChain = SourceHeaderChainAdapter<WithBridgeHubPolkadotMessageBridge>;
496-
type MessageDispatch =
497-
XcmBlobMessageDispatch<OnThisChainBlobDispatcher<UniversalLocation>, Self::WeightInfo, ()>;
498-
type OnMessagesDelivered = ();
496+
type MessageDispatch = XcmBlobMessageDispatch<
497+
OnThisChainBlobDispatcher<UniversalLocation>,
498+
Self::WeightInfo,
499+
cumulus_pallet_xcmp_queue::bridging::OutboundXcmpChannelCongestionStatusProvider<
500+
bridge_hub_config::AssetHubKusamaParaId,
501+
Runtime,
502+
>,
503+
>;
504+
type OnMessagesDelivered = bridge_hub_config::OnMessagesDelivered;
499505
}
500506

501507
/// Allows collect and claim rewards for relayers
@@ -972,7 +978,7 @@ impl_runtime_apis! {
972978
Runtime,
973979
BridgeGrandpaPolkadotInstance,
974980
bridge_hub_config::WithBridgeHubPolkadotMessageBridge,
975-
>(params, X2(GlobalConsensus(xcm_config::RelayNetwork::get().unwrap()), Parachain(42)))
981+
>(params, generate_xcm_builder_bridge_message_sample(X2(GlobalConsensus(xcm_config::RelayNetwork::get().unwrap()), Parachain(42))))
976982
}
977983
fn prepare_message_delivery_proof(
978984
params: MessageDeliveryProofParams<AccountId>,

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ match_types! {
112112
MultiLocation { parents: 1, interior: Here } |
113113
MultiLocation { parents: 1, interior: X1(_) }
114114
};
115-
// TODO:check-parameter - (https://github.com/paritytech/parity-bridges-common/issues/2084)
116-
// remove this and extend `AllowExplicitUnpaidExecutionFrom` with "or SystemParachains" once merged https://github.com/paritytech/polkadot/pull/7005
117-
pub type SystemParachains: impl Contains<MultiLocation> = {
118-
// Statemine
119-
MultiLocation { parents: 1, interior: X1(Parachain(1000)) }
120-
};
121115
}
122116

123117
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
@@ -191,9 +185,8 @@ pub type Barrier = TrailingSetTopicAsId<
191185
// If the message is one that immediately attemps to pay for execution, then
192186
// allow it.
193187
AllowTopLevelPaidExecutionFrom<Everything>,
194-
// Parent, its pluralities (i.e. governance bodies) and system parachains get
195-
// free execution.
196-
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, SystemParachains)>,
188+
// Parent and its pluralities (i.e. governance bodies) get free execution.
189+
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality,)>,
197190
// Subscriptions for version tracking are OK.
198191
AllowSubscriptionsFrom<ParentOrSiblings>,
199192
),

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/tests/tests.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use bp_polkadot_core::Signature;
1818
pub use bridge_hub_kusama_runtime::{
1919
bridge_hub_config,
2020
constants::fee::WeightToFee,
21-
xcm_config::{RelayNetwork, XcmConfig},
21+
xcm_config::{KsmRelayLocation, RelayNetwork, XcmConfig},
2222
AllPalletsWithoutSystem, Balances, BridgeGrandpaPolkadotInstance,
2323
BridgeRejectObsoleteHeadersAndMessages, ExistentialDeposit, ParachainSystem, PolkadotXcm,
2424
Runtime, RuntimeCall, RuntimeEvent, SessionKeys, WithBridgeHubPolkadotMessagesInstance,
@@ -184,7 +184,10 @@ fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() {
184184
}
185185
}),
186186
|| ExportMessage { network: Polkadot, destination: X1(Parachain(1234)), xcm: Xcm(vec![]) },
187-
bridge_hub_config::ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT_LANE_ID
187+
bridge_hub_config::ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT_LANE_ID,
188+
Some((KsmRelayLocation::get(), ExistentialDeposit::get()).into()),
189+
// value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
190+
Some((KsmRelayLocation::get(), bp_asset_hub_kusama::BridgeHubKusamaBaseFeeInDots::get()).into()),
188191
)
189192
}
190193

@@ -263,3 +266,21 @@ pub fn complex_relay_extrinsic_works() {
263266
construct_and_apply_extrinsic,
264267
);
265268
}
269+
270+
#[test]
271+
pub fn can_calculate_weight_for_paid_export_message_with_reserve_transfer() {
272+
let estimated = bridge_hub_test_utils::test_cases::can_calculate_weight_for_paid_export_message_with_reserve_transfer::<
273+
Runtime,
274+
XcmConfig,
275+
WeightToFee,
276+
>();
277+
278+
// check if estimated value is sane
279+
let max_expected = bp_asset_hub_kusama::BridgeHubKusamaBaseFeeInDots::get();
280+
assert!(
281+
estimated <= max_expected,
282+
"calculated: {:?}, max_expected: {:?}, please adjust `bp_asset_hub_kusama::BridgeHubKusamaBaseFeeInDots` value",
283+
estimated,
284+
max_expected
285+
);
286+
}

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-fea
6464
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
6565
cumulus-pallet-session-benchmarking = { path = "../../../../pallets/session-benchmarking", default-features = false}
6666
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
67-
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
67+
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false, features = ["bridging"] }
6868
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
6969
cumulus-primitives-utility = { path = "../../../../primitives/utility", default-features = false }
7070
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
7171
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
7272
parachains-common = { path = "../../../common", default-features = false }
7373

7474
# Bridges
75+
bp-asset-hub-polkadot = { path = "../../../../bridges/primitives/chain-asset-hub-polkadot", default-features = false }
7576
bp-bridge-hub-kusama = { path = "../../../../bridges/primitives/chain-bridge-hub-kusama", default-features = false }
7677
bp-bridge-hub-polkadot = { path = "../../../../bridges/primitives/chain-bridge-hub-polkadot", default-features = false }
7778
bp-header-chain = { path = "../../../../bridges/primitives/header-chain", default-features = false }
@@ -97,6 +98,7 @@ sp-keyring = { path = "../../../../../substrate/primitives/keyring" }
9798
[features]
9899
default = [ "std" ]
99100
std = [
101+
"bp-asset-hub-polkadot/std",
100102
"bp-bridge-hub-kusama/std",
101103
"bp-bridge-hub-polkadot/std",
102104
"bp-header-chain/std",

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/bridge_hub_config.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use bridge_runtime_common::{
3333
RefundableParachain,
3434
},
3535
};
36+
use codec::Encode;
3637
use frame_support::{parameter_types, traits::PalletInfoAccess};
3738
use sp_runtime::RuntimeDebug;
3839
use xcm::{latest::prelude::*, prelude::NetworkId};
@@ -55,6 +56,28 @@ parameter_types! {
5556
ParentThen(X1(Parachain(AssetHubPolkadotParaId::get().into()))).into(),
5657
ASSET_HUB_POLKADOT_TO_ASSET_HUB_KUSAMA_LANE_ID,
5758
);
59+
60+
pub CongestedMessage: Xcm<()> = sp_std::vec![Transact {
61+
origin_kind: OriginKind::Xcm,
62+
require_weight_at_most: bp_asset_hub_polkadot::XcmBridgeHubRouterTransactCallMaxWeight::get(),
63+
call: bp_asset_hub_polkadot::Call::ToKusamaXcmRouter(
64+
bp_asset_hub_polkadot::XcmBridgeHubRouterCall::report_bridge_status {
65+
bridge_id: Default::default(),
66+
is_congested: true,
67+
}
68+
).encode().into(),
69+
}].into();
70+
71+
pub UncongestedMessage: Xcm<()> = sp_std::vec![Transact {
72+
origin_kind: OriginKind::Xcm,
73+
require_weight_at_most: bp_asset_hub_polkadot::XcmBridgeHubRouterTransactCallMaxWeight::get(),
74+
call: bp_asset_hub_polkadot::Call::ToKusamaXcmRouter(
75+
bp_asset_hub_polkadot::XcmBridgeHubRouterCall::report_bridge_status {
76+
bridge_id: Default::default(),
77+
is_congested: false,
78+
}
79+
).encode().into(),
80+
}].into();
5881
}
5982

6083
/// Proof of messages, coming from BridgeHubKusama.
@@ -81,10 +104,13 @@ impl XcmBlobHauler for ToBridgeHubKusamaXcmBlobHauler {
81104
type SenderAndLane = FromAssetHubPolkadotToAssetHubKusamaRoute;
82105

83106
type ToSourceChainSender = crate::XcmRouter;
84-
type CongestedMessage = ();
85-
type UncongestedMessage = ();
107+
type CongestedMessage = CongestedMessage;
108+
type UncongestedMessage = UncongestedMessage;
86109
}
87110

111+
/// On messages delivered callback.
112+
pub type OnMessagesDelivered = XcmBlobHaulerAdapter<ToBridgeHubKusamaXcmBlobHauler>;
113+
88114
/// Messaging Bridge configuration for ThisChain -> BridgeHubKusama
89115
pub struct WithBridgeHubKusamaMessageBridge;
90116
impl MessageBridge for WithBridgeHubKusamaMessageBridge {

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,15 @@ impl pallet_bridge_messages::Config<WithBridgeHubKusamaMessagesInstance> for Run
494494
DeliveryRewardInBalance,
495495
>;
496496
type SourceHeaderChain = SourceHeaderChainAdapter<WithBridgeHubKusamaMessageBridge>;
497-
type MessageDispatch =
498-
XcmBlobMessageDispatch<OnThisChainBlobDispatcher<UniversalLocation>, Self::WeightInfo, ()>;
499-
type OnMessagesDelivered = ();
497+
type MessageDispatch = XcmBlobMessageDispatch<
498+
OnThisChainBlobDispatcher<UniversalLocation>,
499+
Self::WeightInfo,
500+
cumulus_pallet_xcmp_queue::bridging::OutboundXcmpChannelCongestionStatusProvider<
501+
bridge_hub_config::AssetHubPolkadotParaId,
502+
Runtime,
503+
>,
504+
>;
505+
type OnMessagesDelivered = bridge_hub_config::OnMessagesDelivered;
500506
}
501507

502508
/// Allows collect and claim rewards for relayers
@@ -973,7 +979,7 @@ impl_runtime_apis! {
973979
Runtime,
974980
BridgeGrandpaKusamaInstance,
975981
bridge_hub_config::WithBridgeHubKusamaMessageBridge,
976-
>(params, X2(GlobalConsensus(xcm_config::RelayNetwork::get().unwrap()), Parachain(42)))
982+
>(params, generate_xcm_builder_bridge_message_sample(X2(GlobalConsensus(xcm_config::RelayNetwork::get().unwrap()), Parachain(42))))
977983
}
978984
fn prepare_message_delivery_proof(
979985
params: MessageDeliveryProofParams<AccountId>,

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,6 @@ match_types! {
115115
pub type FellowsPlurality: impl Contains<MultiLocation> = {
116116
MultiLocation { parents: 1, interior: X2(Parachain(1001), Plurality { id: BodyId::Technical, ..}) }
117117
};
118-
// TODO:check-parameter - (https://github.com/paritytech/parity-bridges-common/issues/2084)
119-
// remove this and extend `AllowExplicitUnpaidExecutionFrom` with "or SystemParachains" once merged https://github.com/paritytech/polkadot/pull/7005
120-
pub type SystemParachains: impl Contains<MultiLocation> = {
121-
// Statemint
122-
MultiLocation { parents: 1, interior: X1(Parachain(1000)) } |
123-
// Collectives
124-
MultiLocation { parents: 1, interior: X1(Parachain(1001)) }
125-
};
126118
}
127119

128120
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
@@ -196,13 +188,9 @@ pub type Barrier = TrailingSetTopicAsId<
196188
// If the message is one that immediately attemps to pay for execution, then
197189
// allow it.
198190
AllowTopLevelPaidExecutionFrom<Everything>,
199-
// Parent, its pluralities (i.e. governance bodies), the Fellows plurality
200-
// and system parachains get free execution.
201-
AllowExplicitUnpaidExecutionFrom<(
202-
ParentOrParentsPlurality,
203-
FellowsPlurality,
204-
SystemParachains,
205-
)>,
191+
// Parent, its pluralities (i.e. governance bodies) and the Fellows plurality
192+
// get free execution.
193+
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>,
206194
// Subscriptions for version tracking are OK.
207195
AllowSubscriptionsFrom<ParentOrSiblings>,
208196
),

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/tests/tests.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use bp_polkadot_core::Signature;
1818
pub use bridge_hub_polkadot_runtime::{
1919
bridge_hub_config,
2020
constants::fee::WeightToFee,
21-
xcm_config::{RelayNetwork, XcmConfig},
21+
xcm_config::{DotRelayLocation, RelayNetwork, XcmConfig},
2222
AllPalletsWithoutSystem, Balances, BridgeGrandpaKusamaInstance,
2323
BridgeRejectObsoleteHeadersAndMessages, ExistentialDeposit, ParachainSystem, PolkadotXcm,
2424
Runtime, RuntimeCall, RuntimeEvent, SessionKeys, WithBridgeHubKusamaMessagesInstance,
@@ -184,7 +184,10 @@ fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() {
184184
}
185185
}),
186186
|| ExportMessage { network: Kusama, destination: X1(Parachain(1234)), xcm: Xcm(vec![]) },
187-
bridge_hub_config::ASSET_HUB_POLKADOT_TO_ASSET_HUB_KUSAMA_LANE_ID
187+
bridge_hub_config::ASSET_HUB_POLKADOT_TO_ASSET_HUB_KUSAMA_LANE_ID,
188+
Some((DotRelayLocation::get(), ExistentialDeposit::get()).into()),
189+
// value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
190+
Some((DotRelayLocation::get(), bp_asset_hub_polkadot::BridgeHubPolkadotBaseFeeInDots::get()).into()),
188191
)
189192
}
190193

@@ -263,3 +266,21 @@ pub fn complex_relay_extrinsic_works() {
263266
construct_and_apply_extrinsic,
264267
);
265268
}
269+
270+
#[test]
271+
pub fn can_calculate_weight_for_paid_export_message_with_reserve_transfer() {
272+
let estimated = bridge_hub_test_utils::test_cases::can_calculate_weight_for_paid_export_message_with_reserve_transfer::<
273+
Runtime,
274+
XcmConfig,
275+
WeightToFee,
276+
>();
277+
278+
// check if estimated value is sane
279+
let max_expected = bp_asset_hub_polkadot::BridgeHubPolkadotBaseFeeInDots::get();
280+
assert!(
281+
estimated <= max_expected,
282+
"calculated: {:?}, max_expected: {:?}, please adjust `bp_asset_hub_polkadot::BridgeHubPolkadotBaseFeeInDots` value",
283+
estimated,
284+
max_expected
285+
);
286+
}

0 commit comments

Comments
 (0)