Skip to content

Commit 097308e

Browse files
svyatonikacatangiudependabot[bot]sandreimEgorPopelyaev
authored
Add Rococo People <> Rococo Bulletin bridge support to Rococo Bridge Hub (#2540)
This PR adds [Rococo People](#2281) <> [Rococo Bulletin](https://github.com/zdave-parity/polkadot-bulletin-chain) to the Rococo Bridge Hub code. There's a couple of things left to do here: - [x] add remaining tests - it'd need some refactoring in the `bridge-hub-test-utils` - will do in a separate PR; - [x] actually run benchmarks for new messaging pallet (do we have bot nowadays?). The reason why I'm opening it before this ^^^ is ready, is that I'd like to hear others opinion on how to deal with hacks with that bridge. Initially I was assuming that Rococo Bulletin will be the 1:1 copy of the Polkadot Bulletin (to avoid maintaining multiple runtimes/releases/...), so you can see many `PolkadotBulletin` mentions in this PR, even though we are going to bridge with the parallel chain (`RococoBulletin`). That's because e.g. pallet names from `construct_runtime` are affecting runtime storage keys and bridges are using runtime storage proofs => it is important to use names that the Bulletin chain expects. But in the end, this hack won't work - we can't use Polkadot Bulletin runtime to bridge with Rococo Bridge Hub, because Polkadot Bulletin expects Polkadot Bridge hub to use `1002` parachain id and Rococo Bridge Hub seats on the `1013`. This also affects storage keys using in bridging, so I had to add the [`rococo` feature](https://github.com/svyatonik/polkadot-bulletin-chain/blob/add-bridge-pallets/runtime/Cargo.toml#L198) to the Bulletin chain. So now we can actually alter its runtime and adapt it for Rococo. So the question here is - what's better for us here - to leave everything as is (seems hacky and non-trivial); - change Bulletin chain runtime when `rococo` feature is used - e.g. use proper names there (`WithPolkadotGrandpa` -> `WithRococoGrandpa`, ...) - add another set of pallets to the Bulletin chain runtime to bridge with Rococo and never use them in production. Similar to hack that we had in Rococo/Wococo cc @acatangiu @bkontur @serban300 also cc @joepetrowski as the main "client" of this bridge --- A couple words on how this bridge is different from the Rococo <> Westend bridge: - it is a bridge with a chain that uses GRANDPA finality, not the parachain finality (hence the tests needs to be changed); - it is a fee-free bridge. So `AllowExplicitUnpaidExecutionFrom<Equals<SiblingPeople>>` + we are not paying any rewards to relayers (apart from compensating transaction costs). --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Andrei Sandu <[email protected]> Co-authored-by: Adrian Catangiu <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrei Sandu <[email protected]> Co-authored-by: Egor_P <[email protected]> Co-authored-by: command-bot <>
1 parent 10a91f8 commit 097308e

14 files changed

Lines changed: 1000 additions & 122 deletions

File tree

Cargo.lock

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

bridges/modules/messages/src/weights_ext.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ pub fn ensure_weights_are_correct<W: WeightInfoExt>() {
6060
// W::receive_messages_delivery_proof_messages_overhead(1).ref_time() may be zero because:
6161
// there's no code that iterates over confirmed messages in confirmation transaction
6262
assert_eq!(W::receive_messages_delivery_proof_messages_overhead(1).proof_size(), 0);
63-
assert_ne!(W::receive_messages_delivery_proof_relayers_overhead(1).ref_time(), 0);
63+
// W::receive_messages_delivery_proof_relayers_overhead(1).ref_time() may be zero because:
64+
// runtime **can** choose not to pay any rewards to relayers
6465
// W::receive_messages_delivery_proof_relayers_overhead(1).proof_size() is an exception
6566
// it may or may not cause additional db reads, so proof size may vary
6667
assert_ne!(W::storage_proof_size_overhead(1).ref_time(), 0);

bridges/primitives/chain-bridge-hub-rococo/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ pub const WITH_BRIDGE_HUB_ROCOCO_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
7676

7777
/// Pallet index of `BridgeWestendMessages: pallet_bridge_messages::<Instance3>`.
7878
pub const WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX: u8 = 51;
79+
/// Pallet index of `BridgePolkadotBulletinMessages: pallet_bridge_messages::<Instance4>`.
80+
pub const WITH_BRIDGE_ROCOCO_TO_BULLETIN_MESSAGES_PALLET_INDEX: u8 = 61;
7981

8082
decl_bridge_finality_runtime_apis!(bridge_hub_rococo);
8183
decl_bridge_messages_runtime_apis!(bridge_hub_rococo);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ parachains-common = { path = "../../../common", default-features = false }
8787
# Bridges
8888
bp-asset-hub-rococo = { path = "../../../../../bridges/primitives/chain-asset-hub-rococo", default-features = false }
8989
bp-asset-hub-westend = { path = "../../../../../bridges/primitives/chain-asset-hub-westend", default-features = false }
90+
bp-bridge-hub-polkadot = { path = "../../../../../bridges/primitives/chain-bridge-hub-polkadot", default-features = false }
9091
bp-bridge-hub-rococo = { path = "../../../../../bridges/primitives/chain-bridge-hub-rococo", default-features = false }
9192
bp-bridge-hub-westend = { path = "../../../../../bridges/primitives/chain-bridge-hub-westend", default-features = false }
9293
bp-header-chain = { path = "../../../../../bridges/primitives/header-chain", default-features = false }
9394
bp-messages = { path = "../../../../../bridges/primitives/messages", default-features = false }
9495
bp-parachains = { path = "../../../../../bridges/primitives/parachains", default-features = false }
96+
bp-polkadot-bulletin = { path = "../../../../../bridges/primitives/chain-polkadot-bulletin", default-features = false }
9597
bp-polkadot-core = { path = "../../../../../bridges/primitives/polkadot-core", default-features = false }
9698
bp-relayers = { path = "../../../../../bridges/primitives/relayers", default-features = false }
9799
bp-runtime = { path = "../../../../../bridges/primitives/runtime", default-features = false }
@@ -117,11 +119,13 @@ default = ["std"]
117119
std = [
118120
"bp-asset-hub-rococo/std",
119121
"bp-asset-hub-westend/std",
122+
"bp-bridge-hub-polkadot/std",
120123
"bp-bridge-hub-rococo/std",
121124
"bp-bridge-hub-westend/std",
122125
"bp-header-chain/std",
123126
"bp-messages/std",
124127
"bp-parachains/std",
128+
"bp-polkadot-bulletin/std",
125129
"bp-polkadot-core/std",
126130
"bp-relayers/std",
127131
"bp-rococo/std",

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_common_config.rs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@
2121
//! For example, the messaging pallet needs to know the sending and receiving chains, but the
2222
//! GRANDPA tracking pallet only needs to be aware of one chain.
2323
24-
use super::{weights, AccountId, Balance, Balances, BlockNumber, Runtime, RuntimeEvent};
24+
use super::{
25+
weights, AccountId, Balance, Balances, BlockNumber, Runtime, RuntimeEvent, RuntimeOrigin,
26+
};
2527
use bp_parachains::SingleParaStoredHeaderDataBuilder;
28+
use bp_runtime::UnderlyingChainProvider;
29+
use bridge_runtime_common::messages::ThisChainWithMessages;
2630
use frame_support::{parameter_types, traits::ConstU32};
31+
use sp_runtime::RuntimeDebug;
2732

2833
parameter_types! {
2934
pub const RelayChainHeadersToKeep: u32 = 1024;
3035
pub const ParachainHeadsToKeep: u32 = 64;
3136

32-
pub const WestendBridgeParachainPalletName: &'static str = "Paras";
37+
pub const WestendBridgeParachainPalletName: &'static str = bp_westend::PARAS_PALLET_NAME;
3338
pub const MaxWestendParaHeadDataSize: u32 = bp_westend::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE;
3439

3540
pub storage RequiredStakeForStakeAndSlash: Balance = 1_000_000;
@@ -78,3 +83,33 @@ impl pallet_bridge_relayers::Config for Runtime {
7883
>;
7984
type WeightInfo = weights::pallet_bridge_relayers::WeightInfo<Runtime>;
8085
}
86+
87+
/// Add GRANDPA bridge pallet to track Rococo Bulletin chain.
88+
pub type BridgeGrandpaRococoBulletinInstance = pallet_bridge_grandpa::Instance4;
89+
impl pallet_bridge_grandpa::Config<BridgeGrandpaRococoBulletinInstance> for Runtime {
90+
type RuntimeEvent = RuntimeEvent;
91+
type BridgedChain = bp_polkadot_bulletin::PolkadotBulletin;
92+
type MaxFreeMandatoryHeadersPerBlock = ConstU32<4>;
93+
type HeadersToKeep = RelayChainHeadersToKeep;
94+
// Technically this is incorrect - we have two pallet instances and ideally we shall
95+
// benchmark every instance separately. But the benchmarking engine has a flaw - it
96+
// messes with components. E.g. in Kusama maximal validators count is 1024 and in
97+
// Bulletin chain it is 100. But benchmarking engine runs Bulletin benchmarks using
98+
// components range, computed for Kusama => it causes an error.
99+
//
100+
// In practice, however, GRANDPA pallet works the same way for all bridged chains, so
101+
// weights are also the same for both bridges.
102+
type WeightInfo = weights::pallet_bridge_grandpa::WeightInfo<Runtime>;
103+
}
104+
105+
/// BridgeHubRococo chain from message lane point of view.
106+
#[derive(RuntimeDebug, Clone, Copy)]
107+
pub struct BridgeHubRococo;
108+
109+
impl UnderlyingChainProvider for BridgeHubRococo {
110+
type Chain = bp_bridge_hub_rococo::BridgeHubRococo;
111+
}
112+
113+
impl ThisChainWithMessages for BridgeHubRococo {
114+
type RuntimeOrigin = RuntimeOrigin;
115+
}

0 commit comments

Comments
 (0)