Add Rococo People <> Rococo Bulletin bridge support to Rococo Bridge Hub (#2540)

This PR adds [Rococo
People](https://github.com/paritytech/polkadot-sdk/pull/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] <support@github.com>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
Co-authored-by: Egor_P <egor@parity.io>
Co-authored-by: command-bot <>
This commit is contained in:
Svyatoslav Nikolsky
2023-12-14 17:54:26 +03:00
committed by GitHub
parent 10a91f821e
commit 097308e385
14 changed files with 1002 additions and 124 deletions
Generated
+2
View File
@@ -1894,11 +1894,13 @@ version = "0.1.0"
dependencies = [
"bp-asset-hub-rococo",
"bp-asset-hub-westend",
"bp-bridge-hub-polkadot",
"bp-bridge-hub-rococo",
"bp-bridge-hub-westend",
"bp-header-chain",
"bp-messages",
"bp-parachains",
"bp-polkadot-bulletin",
"bp-polkadot-core",
"bp-relayers",
"bp-rococo",
+2 -1
View File
@@ -60,7 +60,8 @@ pub fn ensure_weights_are_correct<W: WeightInfoExt>() {
// W::receive_messages_delivery_proof_messages_overhead(1).ref_time() may be zero because:
// there's no code that iterates over confirmed messages in confirmation transaction
assert_eq!(W::receive_messages_delivery_proof_messages_overhead(1).proof_size(), 0);
assert_ne!(W::receive_messages_delivery_proof_relayers_overhead(1).ref_time(), 0);
// W::receive_messages_delivery_proof_relayers_overhead(1).ref_time() may be zero because:
// runtime **can** choose not to pay any rewards to relayers
// W::receive_messages_delivery_proof_relayers_overhead(1).proof_size() is an exception
// it may or may not cause additional db reads, so proof size may vary
assert_ne!(W::storage_proof_size_overhead(1).ref_time(), 0);
@@ -76,6 +76,8 @@ pub const WITH_BRIDGE_HUB_ROCOCO_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";
/// Pallet index of `BridgeWestendMessages: pallet_bridge_messages::<Instance3>`.
pub const WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX: u8 = 51;
/// Pallet index of `BridgePolkadotBulletinMessages: pallet_bridge_messages::<Instance4>`.
pub const WITH_BRIDGE_ROCOCO_TO_BULLETIN_MESSAGES_PALLET_INDEX: u8 = 61;
decl_bridge_finality_runtime_apis!(bridge_hub_rococo);
decl_bridge_messages_runtime_apis!(bridge_hub_rococo);
@@ -87,11 +87,13 @@ parachains-common = { path = "../../../common", default-features = false }
# Bridges
bp-asset-hub-rococo = { path = "../../../../../bridges/primitives/chain-asset-hub-rococo", default-features = false }
bp-asset-hub-westend = { path = "../../../../../bridges/primitives/chain-asset-hub-westend", default-features = false }
bp-bridge-hub-polkadot = { path = "../../../../../bridges/primitives/chain-bridge-hub-polkadot", default-features = false }
bp-bridge-hub-rococo = { path = "../../../../../bridges/primitives/chain-bridge-hub-rococo", default-features = false }
bp-bridge-hub-westend = { path = "../../../../../bridges/primitives/chain-bridge-hub-westend", default-features = false }
bp-header-chain = { path = "../../../../../bridges/primitives/header-chain", default-features = false }
bp-messages = { path = "../../../../../bridges/primitives/messages", default-features = false }
bp-parachains = { path = "../../../../../bridges/primitives/parachains", default-features = false }
bp-polkadot-bulletin = { path = "../../../../../bridges/primitives/chain-polkadot-bulletin", default-features = false }
bp-polkadot-core = { path = "../../../../../bridges/primitives/polkadot-core", default-features = false }
bp-relayers = { path = "../../../../../bridges/primitives/relayers", default-features = false }
bp-runtime = { path = "../../../../../bridges/primitives/runtime", default-features = false }
@@ -117,11 +119,13 @@ default = ["std"]
std = [
"bp-asset-hub-rococo/std",
"bp-asset-hub-westend/std",
"bp-bridge-hub-polkadot/std",
"bp-bridge-hub-rococo/std",
"bp-bridge-hub-westend/std",
"bp-header-chain/std",
"bp-messages/std",
"bp-parachains/std",
"bp-polkadot-bulletin/std",
"bp-polkadot-core/std",
"bp-relayers/std",
"bp-rococo/std",
@@ -21,15 +21,20 @@
//! For example, the messaging pallet needs to know the sending and receiving chains, but the
//! GRANDPA tracking pallet only needs to be aware of one chain.
use super::{weights, AccountId, Balance, Balances, BlockNumber, Runtime, RuntimeEvent};
use super::{
weights, AccountId, Balance, Balances, BlockNumber, Runtime, RuntimeEvent, RuntimeOrigin,
};
use bp_parachains::SingleParaStoredHeaderDataBuilder;
use bp_runtime::UnderlyingChainProvider;
use bridge_runtime_common::messages::ThisChainWithMessages;
use frame_support::{parameter_types, traits::ConstU32};
use sp_runtime::RuntimeDebug;
parameter_types! {
pub const RelayChainHeadersToKeep: u32 = 1024;
pub const ParachainHeadsToKeep: u32 = 64;
pub const WestendBridgeParachainPalletName: &'static str = "Paras";
pub const WestendBridgeParachainPalletName: &'static str = bp_westend::PARAS_PALLET_NAME;
pub const MaxWestendParaHeadDataSize: u32 = bp_westend::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE;
pub storage RequiredStakeForStakeAndSlash: Balance = 1_000_000;
@@ -78,3 +83,33 @@ impl pallet_bridge_relayers::Config for Runtime {
>;
type WeightInfo = weights::pallet_bridge_relayers::WeightInfo<Runtime>;
}
/// Add GRANDPA bridge pallet to track Rococo Bulletin chain.
pub type BridgeGrandpaRococoBulletinInstance = pallet_bridge_grandpa::Instance4;
impl pallet_bridge_grandpa::Config<BridgeGrandpaRococoBulletinInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type BridgedChain = bp_polkadot_bulletin::PolkadotBulletin;
type MaxFreeMandatoryHeadersPerBlock = ConstU32<4>;
type HeadersToKeep = RelayChainHeadersToKeep;
// Technically this is incorrect - we have two pallet instances and ideally we shall
// benchmark every instance separately. But the benchmarking engine has a flaw - it
// messes with components. E.g. in Kusama maximal validators count is 1024 and in
// Bulletin chain it is 100. But benchmarking engine runs Bulletin benchmarks using
// components range, computed for Kusama => it causes an error.
//
// In practice, however, GRANDPA pallet works the same way for all bridged chains, so
// weights are also the same for both bridges.
type WeightInfo = weights::pallet_bridge_grandpa::WeightInfo<Runtime>;
}
/// BridgeHubRococo chain from message lane point of view.
#[derive(RuntimeDebug, Clone, Copy)]
pub struct BridgeHubRococo;
impl UnderlyingChainProvider for BridgeHubRococo {
type Chain = bp_bridge_hub_rococo::BridgeHubRococo;
}
impl ThisChainWithMessages for BridgeHubRococo {
type RuntimeOrigin = RuntimeOrigin;
}
@@ -0,0 +1,292 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
//! Bridge definitions used on BridgeHubRococo for bridging to Rococo Bulletin.
//!
//! Rococo Bulletin chain will be the 1:1 copy of the Polkadot Bulletin, so we
//! are reusing Polkadot Bulletin chain primitives everywhere here.
use crate::{
bridge_common_config::{BridgeGrandpaRococoBulletinInstance, BridgeHubRococo},
weights,
xcm_config::UniversalLocation,
AccountId, BridgeRococoBulletinGrandpa, BridgeRococoBulletinMessages, PolkadotXcm, Runtime,
RuntimeEvent, XcmOverRococoBulletin, XcmRouter,
};
use bp_messages::LaneId;
use bridge_runtime_common::{
messages,
messages::{
source::{FromBridgedChainMessagesDeliveryProof, TargetHeaderChainAdapter},
target::{FromBridgedChainMessagesProof, SourceHeaderChainAdapter},
MessageBridge, UnderlyingChainProvider,
},
messages_xcm_extension::{
SenderAndLane, XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter,
XcmBlobMessageDispatch, XcmVersionOfDestAndRemoteBridge,
},
refund_relayer_extension::{
ActualFeeRefund, RefundBridgedGrandpaMessages, RefundSignedExtensionAdapter,
RefundableMessagesLane,
},
};
use frame_support::{parameter_types, traits::PalletInfoAccess};
use sp_runtime::RuntimeDebug;
use xcm::{
latest::prelude::*,
prelude::{InteriorMultiLocation, NetworkId},
};
use xcm_builder::BridgeBlobDispatcher;
parameter_types! {
/// Maximal number of entries in the unrewarded relayers vector at the Rococo Bridge Hub. It matches the
/// maximal number of unrewarded relayers that the single confirmation transaction at Rococo Bulletin Chain
/// may process.
pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce =
bp_polkadot_bulletin::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
/// Maximal number of unconfirmed messages at the Rococo Bridge Hub. It matches the maximal number of
/// unconfirmed messages that the single confirmation transaction at Rococo Bulletin Chain may process.
pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
bp_polkadot_bulletin::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
/// Bridge specific chain (network) identifier of the Rococo Bulletin Chain.
pub const RococoBulletinChainId: bp_runtime::ChainId = bp_runtime::POLKADOT_BULLETIN_CHAIN_ID;
/// Interior location (relative to this runtime) of the with-RococoBulletin messages pallet.
pub BridgeRococoToRococoBulletinMessagesPalletInstance: InteriorMultiLocation = X1(
PalletInstance(<BridgeRococoBulletinMessages as PalletInfoAccess>::index() as u8)
);
/// Rococo Bulletin Network identifier.
pub RococoBulletinGlobalConsensusNetwork: NetworkId = NetworkId::PolkadotBulletin;
/// Relative location of the Rococo Bulletin chain.
pub RococoBulletinGlobalConsensusNetworkLocation: MultiLocation = MultiLocation {
parents: 2,
interior: X1(GlobalConsensus(RococoBulletinGlobalConsensusNetwork::get()))
};
/// All active lanes that the current bridge supports.
pub ActiveOutboundLanesToRococoBulletin: &'static [bp_messages::LaneId]
= &[XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN];
/// Lane identifier, used to connect Rococo People and Rococo Bulletin chain.
pub const RococoPeopleToRococoBulletinMessagesLane: bp_messages::LaneId
= XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN;
/// Priority boost that the registered relayer receives for every additional message in the message
/// delivery transaction.
///
/// It is determined semi-automatically - see `FEE_BOOST_PER_MESSAGE` constant to get the
/// meaning of this value.
pub PriorityBoostPerMessage: u64 = 182_044_444_444_444;
/// Identifier of the sibling Rococo People parachain.
pub RococoPeopleParaId: cumulus_primitives_core::ParaId = rococo_runtime_constants::system_parachain::PEOPLE_ID.into();
/// A route (XCM location and bridge lane) that the Rococo People Chain -> Rococo Bulletin Chain
/// message is following.
pub FromRococoPeopleToRococoBulletinRoute: SenderAndLane = SenderAndLane::new(
ParentThen(X1(Parachain(RococoPeopleParaId::get().into()))).into(),
XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN,
);
/// All active routes and their destinations.
pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorMultiLocation))> = sp_std::vec![
(
FromRococoPeopleToRococoBulletinRoute::get(),
(RococoBulletinGlobalConsensusNetwork::get(), Here)
)
];
/// XCM message that is never sent.
pub NeverSentMessage: Option<Xcm<()>> = None;
}
pub const XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN: LaneId = LaneId([0, 0, 0, 0]);
/// Proof of messages, coming from Rococo Bulletin chain.
pub type FromRococoBulletinMessagesProof =
FromBridgedChainMessagesProof<bp_polkadot_bulletin::Hash>;
/// Messages delivery proof for Rococo Bridge Hub -> Rococo Bulletin messages.
pub type ToRococoBulletinMessagesDeliveryProof =
FromBridgedChainMessagesDeliveryProof<bp_polkadot_bulletin::Hash>;
/// Dispatches received XCM messages from other bridge.
type FromRococoBulletinMessageBlobDispatcher = BridgeBlobDispatcher<
XcmRouter,
UniversalLocation,
BridgeRococoToRococoBulletinMessagesPalletInstance,
>;
/// Export XCM messages to be relayed to the other side
pub type ToRococoBulletinHaulBlobExporter = XcmOverRococoBulletin;
pub struct ToRococoBulletinXcmBlobHauler;
impl XcmBlobHauler for ToRococoBulletinXcmBlobHauler {
type Runtime = Runtime;
type MessagesInstance = WithRococoBulletinMessagesInstance;
type ToSourceChainSender = XcmRouter;
type CongestedMessage = NeverSentMessage;
type UncongestedMessage = NeverSentMessage;
}
/// On messages delivered callback.
type OnMessagesDeliveredFromRococoBulletin =
XcmBlobHaulerAdapter<ToRococoBulletinXcmBlobHauler, ActiveLanes>;
/// Messaging Bridge configuration for BridgeHubRococo -> Rococo Bulletin.
pub struct WithRococoBulletinMessageBridge;
impl MessageBridge for WithRococoBulletinMessageBridge {
// Bulletin chain assumes it is bridged with Polkadot Bridge Hub
const BRIDGED_MESSAGES_PALLET_NAME: &'static str =
bp_bridge_hub_polkadot::WITH_BRIDGE_HUB_POLKADOT_MESSAGES_PALLET_NAME;
type ThisChain = BridgeHubRococo;
type BridgedChain = RococoBulletin;
type BridgedHeaderChain = BridgeRococoBulletinGrandpa;
}
/// Message verifier for RococoBulletin messages sent from BridgeHubRococo.
pub type ToRococoBulletinMessageVerifier =
messages::source::FromThisChainMessageVerifier<WithRococoBulletinMessageBridge>;
/// Maximal outbound payload size of BridgeHubRococo -> RococoBulletin messages.
pub type ToRococoBulletinMaximalOutboundPayloadSize =
messages::source::FromThisChainMaximalOutboundPayloadSize<WithRococoBulletinMessageBridge>;
/// RococoBulletin chain from message lane point of view.
#[derive(RuntimeDebug, Clone, Copy)]
pub struct RococoBulletin;
impl UnderlyingChainProvider for RococoBulletin {
type Chain = bp_polkadot_bulletin::PolkadotBulletin;
}
impl messages::BridgedChainWithMessages for RococoBulletin {}
/// Signed extension that refunds relayers that are delivering messages from the Rococo Bulletin
/// chain.
pub type OnBridgeHubRococoRefundRococoBulletinMessages = RefundSignedExtensionAdapter<
RefundBridgedGrandpaMessages<
Runtime,
BridgeGrandpaRococoBulletinInstance,
RefundableMessagesLane<
WithRococoBulletinMessagesInstance,
RococoPeopleToRococoBulletinMessagesLane,
>,
ActualFeeRefund<Runtime>,
PriorityBoostPerMessage,
StrOnBridgeHubRococoRefundRococoBulletinMessages,
>,
>;
bp_runtime::generate_static_str_provider!(OnBridgeHubRococoRefundRococoBulletinMessages);
/// Add XCM messages support for BridgeHubRococo to support Rococo->Rococo Bulletin XCM messages.
pub type WithRococoBulletinMessagesInstance = pallet_bridge_messages::Instance4;
impl pallet_bridge_messages::Config<WithRococoBulletinMessagesInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo =
weights::pallet_bridge_messages_rococo_to_rococo_bulletin::WeightInfo<Runtime>;
type BridgedChainId = RococoBulletinChainId;
type ActiveOutboundLanes = ActiveOutboundLanesToRococoBulletin;
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane;
type MaximalOutboundPayloadSize = ToRococoBulletinMaximalOutboundPayloadSize;
type OutboundPayload = XcmAsPlainPayload;
type InboundPayload = XcmAsPlainPayload;
type InboundRelayer = AccountId;
type DeliveryPayments = ();
type TargetHeaderChain = TargetHeaderChainAdapter<WithRococoBulletinMessageBridge>;
type LaneMessageVerifier = ToRococoBulletinMessageVerifier;
type DeliveryConfirmationPayments = ();
type SourceHeaderChain = SourceHeaderChainAdapter<WithRococoBulletinMessageBridge>;
type MessageDispatch =
XcmBlobMessageDispatch<FromRococoBulletinMessageBlobDispatcher, Self::WeightInfo, ()>;
type OnMessagesDelivered = OnMessagesDeliveredFromRococoBulletin;
}
/// Add support for the export and dispatch of XCM programs.
pub type XcmOverPolkadotBulletinInstance = pallet_xcm_bridge_hub::Instance2;
impl pallet_xcm_bridge_hub::Config<XcmOverPolkadotBulletinInstance> for Runtime {
type UniversalLocation = UniversalLocation;
type BridgedNetwork = RococoBulletinGlobalConsensusNetworkLocation;
type BridgeMessagesPalletInstance = WithRococoBulletinMessagesInstance;
type MessageExportPrice = ();
type DestinationVersion =
XcmVersionOfDestAndRemoteBridge<PolkadotXcm, RococoBulletinGlobalConsensusNetworkLocation>;
type Lanes = ActiveLanes;
type LanesSupport = ToRococoBulletinXcmBlobHauler;
}
#[cfg(test)]
mod tests {
use super::*;
use crate::bridge_common_config::BridgeGrandpaRococoBulletinInstance;
use bridge_runtime_common::{
assert_complete_bridge_types, integrity::check_message_lane_weights,
};
use parachains_common::{rococo, Balance};
/// Every additional message in the message delivery transaction boosts its priority.
/// So the priority of transaction with `N+1` messages is larger than priority of
/// transaction with `N` messages by the `PriorityBoostPerMessage`.
///
/// Economically, it is an equivalent of adding tip to the transaction with `N` messages.
/// The `FEE_BOOST_PER_MESSAGE` constant is the value of this tip.
///
/// We want this tip to be large enough (delivery transactions with more messages = less
/// operational costs and a faster bridge), so this value should be significant.
const FEE_BOOST_PER_MESSAGE: Balance = 2 * rococo::currency::UNITS;
#[test]
fn ensure_bridge_hub_rococo_message_lane_weights_are_correct() {
check_message_lane_weights::<
bp_bridge_hub_rococo::BridgeHubRococo,
Runtime,
WithRococoBulletinMessagesInstance,
>(
bp_polkadot_bulletin::EXTRA_STORAGE_PROOF_SIZE,
bp_bridge_hub_rococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
bp_bridge_hub_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
true,
);
}
#[test]
fn ensure_bridge_integrity() {
assert_complete_bridge_types!(
runtime: Runtime,
with_bridged_chain_grandpa_instance: BridgeGrandpaRococoBulletinInstance,
with_bridged_chain_messages_instance: WithRococoBulletinMessagesInstance,
bridge: WithRococoBulletinMessageBridge,
this_chain: bp_rococo::Rococo,
bridged_chain: bp_polkadot_bulletin::PolkadotBulletin,
);
// we can't use `assert_complete_bridge_constants` here, because there's a trick with
// Bulletin chain - it has the same (almost) runtime for Polkadot Bulletin and Rococo
// Bulletin, so we have to adhere Polkadot names here
bridge_runtime_common::priority_calculator::ensure_priority_boost_is_sane::<
Runtime,
WithRococoBulletinMessagesInstance,
PriorityBoostPerMessage,
>(FEE_BOOST_PER_MESSAGE);
assert_eq!(
BridgeRococoToRococoBulletinMessagesPalletInstance::get(),
X1(PalletInstance(
bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_BULLETIN_MESSAGES_PALLET_INDEX
))
);
}
}
@@ -14,14 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
//! Bridge definitions used on BridgeHub with the Rococo flavor for bridging to BridgeHubWestend.
//! Bridge definitions used on BridgeHubRococo for bridging to BridgeHubWestend.
use crate::{
bridge_common_config::{BridgeParachainWestendInstance, DeliveryRewardInBalance},
bridge_common_config::{
BridgeHubRococo, BridgeParachainWestendInstance, DeliveryRewardInBalance,
},
weights,
xcm_config::UniversalLocation,
AccountId, BridgeWestendMessages, PolkadotXcm, Runtime, RuntimeEvent, RuntimeOrigin,
XcmOverBridgeHubWestend, XcmRouter,
AccountId, BridgeWestendMessages, PolkadotXcm, Runtime, RuntimeEvent, XcmOverBridgeHubWestend,
XcmRouter,
};
use bp_messages::LaneId;
use bridge_runtime_common::{
@@ -29,7 +31,7 @@ use bridge_runtime_common::{
messages::{
source::{FromBridgedChainMessagesDeliveryProof, TargetHeaderChainAdapter},
target::{FromBridgedChainMessagesProof, SourceHeaderChainAdapter},
MessageBridge, ThisChainWithMessages, UnderlyingChainProvider,
MessageBridge, UnderlyingChainProvider,
},
messages_xcm_extension::{
SenderAndLane, XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter,
@@ -173,18 +175,6 @@ impl UnderlyingChainProvider for BridgeHubWestend {
impl messages::BridgedChainWithMessages for BridgeHubWestend {}
/// BridgeHubRococo chain from message lane point of view.
#[derive(RuntimeDebug, Clone, Copy)]
pub struct BridgeHubRococo;
impl UnderlyingChainProvider for BridgeHubRococo {
type Chain = bp_bridge_hub_rococo::BridgeHubRococo;
}
impl ThisChainWithMessages for BridgeHubRococo {
type RuntimeOrigin = RuntimeOrigin;
}
/// Signed extension that refunds relayers that are delivering messages from the Westend parachain.
pub type OnBridgeHubRococoRefundBridgeHubWestendMessages = RefundSignedExtensionAdapter<
RefundBridgedParachainMessages<
@@ -208,7 +198,7 @@ bp_runtime::generate_static_str_provider!(OnBridgeHubRococoRefundBridgeHubWesten
pub type WithBridgeHubWestendMessagesInstance = pallet_bridge_messages::Instance3;
impl pallet_bridge_messages::Config<WithBridgeHubWestendMessagesInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_bridge_messages::WeightInfo<Runtime>;
type WeightInfo = weights::pallet_bridge_messages_rococo_to_westend::WeightInfo<Runtime>;
type BridgedChainId = BridgeHubWestendChainId;
type ActiveOutboundLanes = ActiveOutboundLanesToBridgeHubWestend;
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
@@ -18,6 +18,7 @@
//!
//! This runtime currently supports bridging between:
//! - Rococo <> Westend
//! - Rococo <> Rococo Bulletin
#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
@@ -28,6 +29,7 @@
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
pub mod bridge_common_config;
pub mod bridge_to_bulletin_config;
pub mod bridge_to_westend_config;
mod weights;
pub mod xcm_config;
@@ -106,7 +108,10 @@ pub type SignedExtra = (
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
BridgeRejectObsoleteHeadersAndMessages,
(bridge_to_westend_config::OnBridgeHubRococoRefundBridgeHubWestendMessages,),
(
bridge_to_westend_config::OnBridgeHubRococoRefundBridgeHubWestendMessages,
bridge_to_bulletin_config::OnBridgeHubRococoRefundRococoBulletinMessages,
),
);
/// Unchecked extrinsic type as expected by this runtime.
@@ -483,39 +488,56 @@ construct_runtime!(
Utility: pallet_utility::{Pallet, Call, Event} = 40,
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 36,
// BridgeHubRococo uses:
// - BridgeWestendGrandpa
// - BridgeWestendParachains
// - BridgeWestendMessages
// - BridgeRelayers
// GRANDPA bridge modules.
BridgeWestendGrandpa: pallet_bridge_grandpa::<Instance3>::{Pallet, Call, Storage, Event<T>, Config<T>} = 48,
// Parachain bridge modules.
BridgeWestendParachains: pallet_bridge_parachains::<Instance3>::{Pallet, Call, Storage, Event<T>} = 49,
// Messaging bridge modules.
BridgeWestendMessages: pallet_bridge_messages::<Instance3>::{Pallet, Call, Storage, Event<T>, Config<T>} = 51,
// Bridge relayers pallet, used by several bridges here.
BridgeRelayers: pallet_bridge_relayers::{Pallet, Call, Storage, Event<T>} = 47,
// With-Westend GRANDPA bridge module.
BridgeWestendGrandpa: pallet_bridge_grandpa::<Instance3>::{Pallet, Call, Storage, Event<T>, Config<T>} = 48,
// With-Westend parachain bridge module.
BridgeWestendParachains: pallet_bridge_parachains::<Instance3>::{Pallet, Call, Storage, Event<T>} = 49,
// With-Westend messaging bridge module.
BridgeWestendMessages: pallet_bridge_messages::<Instance3>::{Pallet, Call, Storage, Event<T>, Config<T>} = 51,
// With-Westend bridge hub pallet.
XcmOverBridgeHubWestend: pallet_xcm_bridge_hub::<Instance1>::{Pallet} = 52,
// With-Rococo Bulletin GRANDPA bridge module.
//
// we can't use `BridgeRococoBulletinGrandpa` name here, because the same Bulletin runtime will be
// used for both Rococo and Polkadot Bulletin chains AND this name affects runtime storage keys, used
// by the relayer process
BridgePolkadotBulletinGrandpa: pallet_bridge_grandpa::<Instance4>::{Pallet, Call, Storage, Event<T>, Config<T>} = 60,
// With-Rococo Bulletin messaging bridge module.
//
// we can't use `BridgeRococoBulletinMessages` name here, because the same Bulletin runtime will be
// used for both Rococo and Polkadot Bulletin chains AND this name affects runtime storage keys, used
// by this runtime and the relayer process
BridgePolkadotBulletinMessages: pallet_bridge_messages::<Instance4>::{Pallet, Call, Storage, Event<T>, Config<T>} = 61,
// With-Rococo Bulletin bridge hub pallet.
XcmOverPolkadotBulletin: pallet_xcm_bridge_hub::<Instance2>::{Pallet} = 62,
// Message Queue. Importantly, is registered last so that messages are processed after
// the `on_initialize` hooks of bridging pallets.
MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event<T>} = 250,
}
);
/// Proper alias for bridge GRANDPA pallet used to bridge with the bulletin chain.
pub type BridgeRococoBulletinGrandpa = BridgePolkadotBulletinGrandpa;
/// Proper alias for bridge messages pallet used to bridge with the bulletin chain.
pub type BridgeRococoBulletinMessages = BridgePolkadotBulletinMessages;
/// Proper alias for bridge messages pallet used to bridge with the bulletin chain.
pub type XcmOverRococoBulletin = XcmOverPolkadotBulletin;
bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! {
RuntimeCall, AccountId,
// Grandpa
BridgeWestendGrandpa,
BridgeRococoBulletinGrandpa,
// Parachains
BridgeWestendParachains,
// Messages
BridgeWestendMessages
BridgeWestendMessages,
BridgeRococoBulletinMessages
}
#[cfg(feature = "runtime-benchmarks")]
@@ -540,6 +562,7 @@ mod benches {
[pallet_bridge_grandpa, WestendFinality]
[pallet_bridge_parachains, WithinWestend]
[pallet_bridge_messages, RococoToWestend]
[pallet_bridge_messages, RococoToRococoBulletin]
[pallet_bridge_relayers, BridgeRelayersBench::<Runtime>]
);
}
@@ -733,6 +756,42 @@ impl_runtime_apis! {
}
}
impl bp_polkadot_bulletin::PolkadotBulletinFinalityApi<Block> for Runtime {
fn best_finalized() -> Option<bp_runtime::HeaderId<bp_polkadot_bulletin::Hash, bp_polkadot_bulletin::BlockNumber>> {
BridgePolkadotBulletinGrandpa::best_finalized()
}
fn synced_headers_grandpa_info(
) -> Vec<bp_header_chain::StoredHeaderGrandpaInfo<bp_polkadot_bulletin::Header>> {
BridgePolkadotBulletinGrandpa::synced_headers_grandpa_info()
}
}
impl bp_polkadot_bulletin::FromPolkadotBulletinInboundLaneApi<Block> for Runtime {
fn message_details(
lane: bp_messages::LaneId,
messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>,
) -> Vec<bp_messages::InboundMessageDetails> {
bridge_runtime_common::messages_api::inbound_message_details::<
Runtime,
bridge_to_bulletin_config::WithRococoBulletinMessagesInstance,
>(lane, messages)
}
}
impl bp_polkadot_bulletin::ToPolkadotBulletinOutboundLaneApi<Block> for Runtime {
fn message_details(
lane: bp_messages::LaneId,
begin: bp_messages::MessageNonce,
end: bp_messages::MessageNonce,
) -> Vec<bp_messages::OutboundMessageDetails> {
bridge_runtime_common::messages_api::outbound_message_details::<
Runtime,
bridge_to_bulletin_config::WithRococoBulletinMessagesInstance,
>(lane, begin, end)
}
}
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
@@ -775,6 +834,7 @@ impl_runtime_apis! {
type WestendFinality = BridgeWestendGrandpa;
type WithinWestend = pallet_bridge_parachains::benchmarking::Pallet::<Runtime, bridge_common_config::BridgeParachainWestendInstance>;
type RococoToWestend = pallet_bridge_messages::benchmarking::Pallet ::<Runtime, bridge_to_westend_config::WithBridgeHubWestendMessagesInstance>;
type RococoToRococoBulletin = pallet_bridge_messages::benchmarking::Pallet ::<Runtime, bridge_to_bulletin_config::WithRococoBulletinMessagesInstance>;
let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);
@@ -968,9 +1028,12 @@ impl_runtime_apis! {
type WestendFinality = BridgeWestendGrandpa;
type WithinWestend = pallet_bridge_parachains::benchmarking::Pallet::<Runtime, bridge_common_config::BridgeParachainWestendInstance>;
type RococoToWestend = pallet_bridge_messages::benchmarking::Pallet ::<Runtime, bridge_to_westend_config::WithBridgeHubWestendMessagesInstance>;
type RococoToRococoBulletin = pallet_bridge_messages::benchmarking::Pallet ::<Runtime, bridge_to_bulletin_config::WithRococoBulletinMessagesInstance>;
use bridge_runtime_common::messages_benchmarking::{
prepare_message_delivery_proof_from_grandpa_chain,
prepare_message_delivery_proof_from_parachain,
prepare_message_proof_from_grandpa_chain,
prepare_message_proof_from_parachain,
generate_xcm_builder_bridge_message_sample,
};
@@ -1023,6 +1086,41 @@ impl_runtime_apis! {
}
}
impl BridgeMessagesConfig<bridge_to_bulletin_config::WithRococoBulletinMessagesInstance> for Runtime {
fn is_relayer_rewarded(_relayer: &Self::AccountId) -> bool {
// we do not pay any rewards in this bridge
true
}
fn prepare_message_proof(
params: MessageProofParams,
) -> (bridge_to_bulletin_config::FromRococoBulletinMessagesProof, Weight) {
use cumulus_primitives_core::XcmpMessageSource;
assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(42.into());
prepare_message_proof_from_grandpa_chain::<
Runtime,
bridge_common_config::BridgeGrandpaRococoBulletinInstance,
bridge_to_bulletin_config::WithRococoBulletinMessageBridge,
>(params, generate_xcm_builder_bridge_message_sample(X2(GlobalConsensus(Rococo), Parachain(42))))
}
fn prepare_message_delivery_proof(
params: MessageDeliveryProofParams<AccountId>,
) -> bridge_to_bulletin_config::ToRococoBulletinMessagesDeliveryProof {
prepare_message_delivery_proof_from_grandpa_chain::<
Runtime,
bridge_common_config::BridgeGrandpaRococoBulletinInstance,
bridge_to_bulletin_config::WithRococoBulletinMessageBridge,
>(params)
}
fn is_message_successfully_dispatched(_nonce: bp_messages::MessageNonce) -> bool {
use cumulus_primitives_core::XcmpMessageSource;
!XcmpQueue::take_outbound_messages(usize::MAX).is_empty()
}
}
use bridge_runtime_common::parachains_benchmarking::prepare_parachain_heads_proof;
use pallet_bridge_parachains::benchmarking::Config as BridgeParachainsConfig;
use pallet_bridge_relayers::benchmarking::{
@@ -1134,7 +1232,10 @@ mod tests {
frame_system::CheckWeight::new(),
pallet_transaction_payment::ChargeTransactionPayment::from(10),
BridgeRejectObsoleteHeadersAndMessages,
(bridge_to_westend_config::OnBridgeHubRococoRefundBridgeHubWestendMessages::default(),)
(
bridge_to_westend_config::OnBridgeHubRococoRefundBridgeHubWestendMessages::default(),
bridge_to_bulletin_config::OnBridgeHubRococoRefundRococoBulletinMessages::default(),
)
);
// for BridgeHubRococo
@@ -27,7 +27,8 @@ pub mod extrinsic_weights;
pub mod frame_system;
pub mod pallet_balances;
pub mod pallet_bridge_grandpa;
pub mod pallet_bridge_messages;
pub mod pallet_bridge_messages_rococo_to_rococo_bulletin;
pub mod pallet_bridge_messages_rococo_to_westend;
pub mod pallet_bridge_parachains;
pub mod pallet_bridge_relayers;
pub mod pallet_collator_selection;
@@ -52,7 +53,26 @@ use frame_support::weights::Weight;
// import trait from dependency module
use ::pallet_bridge_relayers::WeightInfoExt as _;
impl MessagesWeightInfoExt for pallet_bridge_messages::WeightInfo<crate::Runtime> {
impl MessagesWeightInfoExt
for pallet_bridge_messages_rococo_to_rococo_bulletin::WeightInfo<crate::Runtime>
{
fn expected_extra_storage_proof_size() -> u32 {
bp_polkadot_bulletin::EXTRA_STORAGE_PROOF_SIZE
}
fn receive_messages_proof_overhead_from_runtime() -> Weight {
pallet_bridge_relayers::WeightInfo::<Runtime>::receive_messages_proof_overhead_from_runtime(
)
}
fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight {
pallet_bridge_relayers::WeightInfo::<Runtime>::receive_messages_delivery_proof_overhead_from_runtime()
}
}
impl MessagesWeightInfoExt
for pallet_bridge_messages_rococo_to_westend::WeightInfo<crate::Runtime>
{
fn expected_extra_storage_proof_size() -> u32 {
bp_bridge_hub_westend::EXTRA_STORAGE_PROOF_SIZE
}
@@ -0,0 +1,221 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_bridge_messages`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-12-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-itmxxexx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("bridge-hub-rococo-dev")`, DB CACHE: 1024
// Executed Command:
// target/production/polkadot-parachain
// benchmark
// pallet
// --steps=50
// --repeat=20
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
// --pallet=pallet_bridge_messages
// --chain=bridge-hub-rococo-dev
// --header=./cumulus/file_header.txt
// --output=./cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_bridge_messages`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_bridge_messages::WeightInfo for WeightInfo<T> {
/// Storage: `BridgePolkadotBulletinMessages::PalletOperatingMode` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (`max_values`: Some(1024), `max_size`: Some(68), added: 1553, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinMessages::InboundLanes` (r:1 w:1)
/// Proof: `BridgePolkadotBulletinMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
/// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
/// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn receive_single_message_proof() -> Weight {
// Proof Size summary in bytes:
// Measured: `621`
// Estimated: `52645`
// Minimum execution time: 36_661_000 picoseconds.
Weight::from_parts(38_106_000, 0)
.saturating_add(Weight::from_parts(0, 52645))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `BridgePolkadotBulletinMessages::PalletOperatingMode` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (`max_values`: Some(1024), `max_size`: Some(68), added: 1553, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinMessages::InboundLanes` (r:1 w:1)
/// Proof: `BridgePolkadotBulletinMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
/// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
/// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn receive_two_messages_proof() -> Weight {
// Proof Size summary in bytes:
// Measured: `621`
// Estimated: `52645`
// Minimum execution time: 47_599_000 picoseconds.
Weight::from_parts(49_731_000, 0)
.saturating_add(Weight::from_parts(0, 52645))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `BridgePolkadotBulletinMessages::PalletOperatingMode` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (`max_values`: Some(1024), `max_size`: Some(68), added: 1553, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinMessages::InboundLanes` (r:1 w:1)
/// Proof: `BridgePolkadotBulletinMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
/// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
/// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
// Proof Size summary in bytes:
// Measured: `621`
// Estimated: `52645`
// Minimum execution time: 42_211_000 picoseconds.
Weight::from_parts(43_454_000, 0)
.saturating_add(Weight::from_parts(0, 52645))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `BridgePolkadotBulletinMessages::PalletOperatingMode` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (`max_values`: Some(1024), `max_size`: Some(68), added: 1553, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinMessages::InboundLanes` (r:1 w:1)
/// Proof: `BridgePolkadotBulletinMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
fn receive_single_message_proof_1_kb() -> Weight {
// Proof Size summary in bytes:
// Measured: `589`
// Estimated: `52645`
// Minimum execution time: 36_072_000 picoseconds.
Weight::from_parts(37_260_000, 0)
.saturating_add(Weight::from_parts(0, 52645))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `BridgePolkadotBulletinMessages::PalletOperatingMode` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (`max_values`: Some(1024), `max_size`: Some(68), added: 1553, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinMessages::InboundLanes` (r:1 w:1)
/// Proof: `BridgePolkadotBulletinMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
fn receive_single_message_proof_16_kb() -> Weight {
// Proof Size summary in bytes:
// Measured: `589`
// Estimated: `52645`
// Minimum execution time: 66_995_000 picoseconds.
Weight::from_parts(68_661_000, 0)
.saturating_add(Weight::from_parts(0, 52645))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `BridgePolkadotBulletinMessages::PalletOperatingMode` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (`max_values`: Some(1024), `max_size`: Some(68), added: 1553, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinMessages::OutboundLanes` (r:1 w:1)
/// Proof: `BridgePolkadotBulletinMessages::OutboundLanes` (`max_values`: Some(1), `max_size`: Some(44), added: 539, mode: `MaxEncodedLen`)
fn receive_delivery_proof_for_single_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `588`
// Estimated: `2543`
// Minimum execution time: 25_553_000 picoseconds.
Weight::from_parts(26_205_000, 0)
.saturating_add(Weight::from_parts(0, 2543))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `BridgePolkadotBulletinMessages::PalletOperatingMode` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (`max_values`: Some(1024), `max_size`: Some(68), added: 1553, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinMessages::OutboundLanes` (r:1 w:1)
/// Proof: `BridgePolkadotBulletinMessages::OutboundLanes` (`max_values`: Some(1), `max_size`: Some(44), added: 539, mode: `MaxEncodedLen`)
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
// Proof Size summary in bytes:
// Measured: `588`
// Estimated: `2543`
// Minimum execution time: 25_610_000 picoseconds.
Weight::from_parts(26_273_000, 0)
.saturating_add(Weight::from_parts(0, 2543))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `BridgePolkadotBulletinMessages::PalletOperatingMode` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (`max_values`: Some(1024), `max_size`: Some(68), added: 1553, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinMessages::OutboundLanes` (r:1 w:1)
/// Proof: `BridgePolkadotBulletinMessages::OutboundLanes` (`max_values`: Some(1), `max_size`: Some(44), added: 539, mode: `MaxEncodedLen`)
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
// Proof Size summary in bytes:
// Measured: `588`
// Estimated: `2543`
// Minimum execution time: 25_651_000 picoseconds.
Weight::from_parts(26_172_000, 0)
.saturating_add(Weight::from_parts(0, 2543))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `BridgePolkadotBulletinMessages::PalletOperatingMode` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (r:1 w:0)
/// Proof: `BridgePolkadotBulletinGrandpa::ImportedHeaders` (`max_values`: Some(1024), `max_size`: Some(68), added: 1553, mode: `MaxEncodedLen`)
/// Storage: `BridgePolkadotBulletinMessages::InboundLanes` (r:1 w:1)
/// Proof: `BridgePolkadotBulletinMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
/// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
/// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `XcmpQueue::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `XcmpQueue::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0)
/// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1)
/// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0)
/// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParachainSystem::RelevantMessagingState` (r:1 w:0)
/// Proof: `ParachainSystem::RelevantMessagingState` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:1)
/// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmpQueue::OutboundXcmpMessages` (r:0 w:1)
/// Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `i` is `[128, 2048]`.
/// The range of component `i` is `[128, 2048]`.
fn receive_single_message_proof_with_dispatch(i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `780`
// Estimated: `52645`
// Minimum execution time: 64_219_000 picoseconds.
Weight::from_parts(65_848_290, 0)
.saturating_add(Weight::from_parts(0, 52645))
// Standard Error: 43
.saturating_add(Weight::from_parts(7_577, 0).saturating_mul(i.into()))
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(4))
}
}
@@ -17,7 +17,7 @@
//! Autogenerated weights for `pallet_bridge_messages`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-12-12, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-12-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-itmxxexx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("bridge-hub-rococo-dev")`, DB CACHE: 1024
@@ -60,10 +60,10 @@ impl<T: frame_system::Config> pallet_bridge_messages::WeightInfo for WeightInfo<
/// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn receive_single_message_proof() -> Weight {
// Proof Size summary in bytes:
// Measured: `538`
// Measured: `605`
// Estimated: `52645`
// Minimum execution time: 39_918_000 picoseconds.
Weight::from_parts(40_996_000, 0)
// Minimum execution time: 40_349_000 picoseconds.
Weight::from_parts(41_856_000, 0)
.saturating_add(Weight::from_parts(0, 52645))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(1))
@@ -80,10 +80,10 @@ impl<T: frame_system::Config> pallet_bridge_messages::WeightInfo for WeightInfo<
/// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn receive_two_messages_proof() -> Weight {
// Proof Size summary in bytes:
// Measured: `538`
// Measured: `605`
// Estimated: `52645`
// Minimum execution time: 50_245_000 picoseconds.
Weight::from_parts(51_441_000, 0)
// Minimum execution time: 50_514_000 picoseconds.
Weight::from_parts(52_254_000, 0)
.saturating_add(Weight::from_parts(0, 52645))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(1))
@@ -100,10 +100,10 @@ impl<T: frame_system::Config> pallet_bridge_messages::WeightInfo for WeightInfo<
/// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
// Proof Size summary in bytes:
// Measured: `538`
// Measured: `605`
// Estimated: `52645`
// Minimum execution time: 44_572_000 picoseconds.
Weight::from_parts(45_629_000, 0)
// Minimum execution time: 45_761_000 picoseconds.
Weight::from_parts(47_075_000, 0)
.saturating_add(Weight::from_parts(0, 52645))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(1))
@@ -118,10 +118,10 @@ impl<T: frame_system::Config> pallet_bridge_messages::WeightInfo for WeightInfo<
/// Proof: `BridgeWestendMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
fn receive_single_message_proof_1_kb() -> Weight {
// Proof Size summary in bytes:
// Measured: `506`
// Measured: `573`
// Estimated: `52645`
// Minimum execution time: 38_804_000 picoseconds.
Weight::from_parts(39_516_000, 0)
// Minimum execution time: 39_098_000 picoseconds.
Weight::from_parts(40_577_000, 0)
.saturating_add(Weight::from_parts(0, 52645))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(1))
@@ -136,10 +136,10 @@ impl<T: frame_system::Config> pallet_bridge_messages::WeightInfo for WeightInfo<
/// Proof: `BridgeWestendMessages::InboundLanes` (`max_values`: None, `max_size`: Some(49180), added: 51655, mode: `MaxEncodedLen`)
fn receive_single_message_proof_16_kb() -> Weight {
// Proof Size summary in bytes:
// Measured: `506`
// Measured: `573`
// Estimated: `52645`
// Minimum execution time: 68_674_000 picoseconds.
Weight::from_parts(72_690_000, 0)
// Minimum execution time: 69_120_000 picoseconds.
Weight::from_parts(71_810_000, 0)
.saturating_add(Weight::from_parts(0, 52645))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(1))
@@ -156,11 +156,11 @@ impl<T: frame_system::Config> pallet_bridge_messages::WeightInfo for WeightInfo<
/// Proof: `BridgeRelayers::RelayerRewards` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
fn receive_delivery_proof_for_single_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `413`
// Estimated: `3878`
// Minimum execution time: 32_833_000 picoseconds.
Weight::from_parts(33_442_000, 0)
.saturating_add(Weight::from_parts(0, 3878))
// Measured: `447`
// Estimated: `3912`
// Minimum execution time: 32_325_000 picoseconds.
Weight::from_parts(33_070_000, 0)
.saturating_add(Weight::from_parts(0, 3912))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -176,11 +176,11 @@ impl<T: frame_system::Config> pallet_bridge_messages::WeightInfo for WeightInfo<
/// Proof: `BridgeRelayers::RelayerRewards` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
// Proof Size summary in bytes:
// Measured: `413`
// Estimated: `3878`
// Minimum execution time: 32_528_000 picoseconds.
Weight::from_parts(33_627_000, 0)
.saturating_add(Weight::from_parts(0, 3878))
// Measured: `447`
// Estimated: `3912`
// Minimum execution time: 32_180_000 picoseconds.
Weight::from_parts(33_202_000, 0)
.saturating_add(Weight::from_parts(0, 3912))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -196,10 +196,10 @@ impl<T: frame_system::Config> pallet_bridge_messages::WeightInfo for WeightInfo<
/// Proof: `BridgeRelayers::RelayerRewards` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`)
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
// Proof Size summary in bytes:
// Measured: `413`
// Measured: `447`
// Estimated: `6086`
// Minimum execution time: 37_493_000 picoseconds.
Weight::from_parts(38_324_000, 0)
// Minimum execution time: 36_774_000 picoseconds.
Weight::from_parts(37_774_000, 0)
.saturating_add(Weight::from_parts(0, 6086))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(3))
@@ -227,15 +227,16 @@ impl<T: frame_system::Config> pallet_bridge_messages::WeightInfo for WeightInfo<
/// Storage: `XcmpQueue::OutboundXcmpMessages` (r:0 w:1)
/// Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `i` is `[128, 2048]`.
/// The range of component `i` is `[128, 2048]`.
fn receive_single_message_proof_with_dispatch(i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `669`
// Measured: `736`
// Estimated: `52645`
// Minimum execution time: 64_104_000 picoseconds.
Weight::from_parts(66_006_268, 0)
// Minimum execution time: 65_934_000 picoseconds.
Weight::from_parts(67_915_916, 0)
.saturating_add(Weight::from_parts(0, 52645))
// Standard Error: 91
.saturating_add(Weight::from_parts(7_932, 0).saturating_mul(i.into()))
// Standard Error: 65
.saturating_add(Weight::from_parts(7_190, 0).saturating_mul(i.into()))
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -20,7 +20,8 @@ use super::{
TransactionByteFee, WeightToFee, XcmpQueue,
};
use crate::bridge_common_config::{
BridgeGrandpaWestendInstance, DeliveryRewardInBalance, RequiredStakeForStakeAndSlash,
BridgeGrandpaRococoBulletinInstance, BridgeGrandpaWestendInstance, DeliveryRewardInBalance,
RequiredStakeForStakeAndSlash,
};
use bp_messages::LaneId;
use bp_relayers::{PayRewardFromAccount, RewardsAccountOwner, RewardsAccountParams};
@@ -72,6 +73,7 @@ parameter_types! {
pub const MaxAssetsIntoHolding: u32 = 64;
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
pub SiblingPeople: MultiLocation = (Parent, Parachain(rococo_runtime_constants::system_parachain::PEOPLE_ID)).into();
}
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
@@ -187,6 +189,10 @@ impl Contains<RuntimeCall> for SafeCallFilter {
RuntimeCall::BridgeWestendGrandpa(pallet_bridge_grandpa::Call::<
Runtime,
BridgeGrandpaWestendInstance,
>::initialize { .. }) |
RuntimeCall::BridgePolkadotBulletinGrandpa(pallet_bridge_grandpa::Call::<
Runtime,
BridgeGrandpaRococoBulletinInstance,
>::initialize { .. })
)
}
@@ -205,11 +211,12 @@ pub type Barrier = TrailingSetTopicAsId<
// If the message is one that immediately attempts to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent, its pluralities (i.e. governance bodies) and relay treasury pallet
// get free execution.
// Parent, its pluralities (i.e. governance bodies), relay treasury pallet
// and sibling People get free execution.
AllowExplicitUnpaidExecutionFrom<(
ParentOrParentsPlurality,
Equals<RelayTreasuryLocation>,
Equals<SiblingPeople>,
)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
@@ -273,7 +280,10 @@ impl xcm_executor::Config for XcmConfig {
XcmFeeToAccount<Self::AssetTransactor, AccountId, TreasuryAccount>,
),
>;
type MessageExporter = (crate::bridge_to_westend_config::ToBridgeHubWestendHaulBlobExporter,);
type MessageExporter = (
crate::bridge_to_westend_config::ToBridgeHubWestendHaulBlobExporter,
crate::bridge_to_bulletin_config::ToRococoBulletinHaulBlobExporter,
);
type UniversalAliases = Nothing;
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
type SafeCallFilter = SafeCallFilter;
@@ -18,7 +18,7 @@
use bp_polkadot_core::Signature;
use bridge_hub_rococo_runtime::{
bridge_common_config, bridge_to_westend_config,
bridge_common_config, bridge_to_bulletin_config, bridge_to_westend_config,
xcm_config::{RelayNetwork, TokenLocation, XcmConfig},
AllPalletsWithoutSystem, BridgeRejectObsoleteHeadersAndMessages, Executive, ExistentialDeposit,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, SessionKeys,
@@ -34,9 +34,6 @@ use sp_runtime::{
};
use xcm::latest::prelude::*;
// Para id of sibling chain used in tests.
pub const SIBLING_PARACHAIN_ID: u32 = 1000;
parameter_types! {
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
}
@@ -58,7 +55,10 @@ fn construct_extrinsic(
frame_system::CheckWeight::<Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
BridgeRejectObsoleteHeadersAndMessages::default(),
(bridge_to_westend_config::OnBridgeHubRococoRefundBridgeHubWestendMessages::default(),),
(
bridge_to_westend_config::OnBridgeHubRococoRefundBridgeHubWestendMessages::default(),
bridge_to_bulletin_config::OnBridgeHubRococoRefundRococoBulletinMessages::default(),
),
);
let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
let signature = payload.using_encoded(|e| sender.sign(e));
@@ -94,11 +94,48 @@ fn collator_session_keys() -> bridge_hub_test_utils::CollatorSessionKeys<Runtime
)
}
mod bridge_hub_rococo_tests {
bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
Runtime,
AllPalletsWithoutSystem,
XcmConfig,
CheckingAccount,
WeightToFee,
ParachainSystem,
collator_session_keys(),
ExistentialDeposit::get(),
Box::new(|runtime_event_encoded: Vec<u8>| {
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event),
_ => None,
}
}),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID
);
#[test]
fn change_required_stake_by_governance_works() {
bridge_hub_test_utils::test_cases::change_storage_constant_by_governance_works::<
Runtime,
bridge_common_config::RequiredStakeForStakeAndSlash,
Balance,
>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
Box::new(|call| RuntimeCall::System(call).encode()),
|| {
(
bridge_common_config::RequiredStakeForStakeAndSlash::key().to_vec(),
bridge_common_config::RequiredStakeForStakeAndSlash::get(),
)
},
|old_value| old_value.checked_mul(2).unwrap(),
)
}
mod bridge_hub_westend_tests {
use super::*;
use bridge_common_config::{
BridgeGrandpaWestendInstance, BridgeParachainWestendInstance, DeliveryRewardInBalance,
RequiredStakeForStakeAndSlash,
};
use bridge_to_westend_config::{
BridgeHubWestendChainId, BridgeHubWestendLocation, WestendGlobalConsensusNetwork,
@@ -106,27 +143,12 @@ mod bridge_hub_rococo_tests {
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
};
bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
Runtime,
AllPalletsWithoutSystem,
XcmConfig,
CheckingAccount,
WeightToFee,
ParachainSystem,
collator_session_keys(),
ExistentialDeposit::get(),
Box::new(|runtime_event_encoded: Vec<u8>| {
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event),
_ => None,
}
}),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID
);
// Para id of sibling chain used in tests.
pub const SIBLING_PARACHAIN_ID: u32 = 1000;
#[test]
fn initialize_bridge_by_governance_works() {
// for Westend finality
// for RococoBulletin finality
bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::<
Runtime,
BridgeGrandpaWestendInstance,
@@ -152,26 +174,6 @@ mod bridge_hub_rococo_tests {
)
}
#[test]
fn change_required_stake_by_governance_works() {
bridge_hub_test_utils::test_cases::change_storage_constant_by_governance_works::<
Runtime,
RequiredStakeForStakeAndSlash,
Balance,
>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
Box::new(|call| RuntimeCall::System(call).encode()),
|| {
(
RequiredStakeForStakeAndSlash::key().to_vec(),
RequiredStakeForStakeAndSlash::get(),
)
},
|old_value| old_value.checked_mul(2).unwrap(),
)
}
#[test]
fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() {
// for Westend
@@ -344,3 +346,198 @@ mod bridge_hub_rococo_tests {
);
}
}
mod bridge_hub_bulletin_tests {
use super::*;
use bridge_common_config::BridgeGrandpaRococoBulletinInstance;
use bridge_to_bulletin_config::{
RococoBulletinChainId, RococoBulletinGlobalConsensusNetwork,
RococoBulletinGlobalConsensusNetworkLocation, WithRococoBulletinMessageBridge,
WithRococoBulletinMessagesInstance, XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN,
};
// Para id of sibling chain used in tests.
pub const SIBLING_PARACHAIN_ID: u32 = rococo_runtime_constants::system_parachain::PEOPLE_ID;
#[test]
fn initialize_bridge_by_governance_works() {
// for Bulletin finality
bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::<
Runtime,
BridgeGrandpaRococoBulletinInstance,
>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
Box::new(|call| RuntimeCall::BridgePolkadotBulletinGrandpa(call).encode()),
)
}
#[test]
fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() {
// for Bulletin
bridge_hub_test_utils::test_cases::handle_export_message_from_system_parachain_to_outbound_queue_works::<
Runtime,
XcmConfig,
WithRococoBulletinMessagesInstance,
>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
SIBLING_PARACHAIN_ID,
Box::new(|runtime_event_encoded: Vec<u8>| {
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
Ok(RuntimeEvent::BridgePolkadotBulletinMessages(event)) => Some(event),
_ => None,
}
}),
|| ExportMessage {
network: RococoBulletinGlobalConsensusNetwork::get(),
destination: Here,
xcm: Xcm(vec![]),
},
XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN,
Some((TokenLocation::get(), ExistentialDeposit::get()).into()),
None,
|| PolkadotXcm::force_xcm_version(RuntimeOrigin::root(), Box::new(RococoBulletinGlobalConsensusNetworkLocation::get()), XCM_VERSION).expect("version saved!"),
)
}
#[test]
fn message_dispatch_routing_works() {
// from Bulletin
bridge_hub_test_utils::test_cases::message_dispatch_routing_works::<
Runtime,
AllPalletsWithoutSystem,
XcmConfig,
ParachainSystem,
WithRococoBulletinMessagesInstance,
RelayNetwork,
RococoBulletinGlobalConsensusNetwork,
ConstU8<2>,
>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
SIBLING_PARACHAIN_ID,
Box::new(|runtime_event_encoded: Vec<u8>| {
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
Ok(RuntimeEvent::ParachainSystem(event)) => Some(event),
_ => None,
}
}),
Box::new(|runtime_event_encoded: Vec<u8>| {
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
Ok(RuntimeEvent::XcmpQueue(event)) => Some(event),
_ => None,
}
}),
XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN,
|| (),
)
}
#[test]
fn relayed_incoming_message_works() {
// from Bulletin
bridge_hub_test_utils::test_cases::from_grandpa_chain::relayed_incoming_message_works::<
Runtime,
AllPalletsWithoutSystem,
ParachainSystem,
BridgeGrandpaRococoBulletinInstance,
WithRococoBulletinMessagesInstance,
WithRococoBulletinMessageBridge,
>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
RococoBulletinChainId::get(),
SIBLING_PARACHAIN_ID,
Rococo,
XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN,
|| (),
construct_and_apply_extrinsic,
)
}
#[test]
pub fn complex_relay_extrinsic_works() {
// for Bulletin
bridge_hub_test_utils::test_cases::from_grandpa_chain::complex_relay_extrinsic_works::<
Runtime,
AllPalletsWithoutSystem,
XcmConfig,
ParachainSystem,
BridgeGrandpaRococoBulletinInstance,
WithRococoBulletinMessagesInstance,
WithRococoBulletinMessageBridge,
>(
collator_session_keys(),
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
SIBLING_PARACHAIN_ID,
RococoBulletinChainId::get(),
Rococo,
XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN,
|| (),
construct_and_apply_extrinsic,
);
}
#[test]
pub fn can_calculate_weight_for_paid_export_message_with_reserve_transfer() {
let estimated = bridge_hub_test_utils::test_cases::can_calculate_weight_for_paid_export_message_with_reserve_transfer::<
Runtime,
XcmConfig,
WeightToFee,
>();
// check if estimated value is sane
let max_expected = bp_bridge_hub_rococo::BridgeHubRococoBaseXcmFeeInRocs::get();
assert!(
estimated <= max_expected,
"calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_rococo::BridgeHubRococoBaseXcmFeeInRocs` value",
estimated,
max_expected
);
}
#[test]
pub fn can_calculate_fee_for_complex_message_delivery_transaction() {
let estimated = bridge_hub_test_utils::test_cases::from_grandpa_chain::can_calculate_fee_for_complex_message_delivery_transaction::<
Runtime,
BridgeGrandpaRococoBulletinInstance,
WithRococoBulletinMessagesInstance,
WithRococoBulletinMessageBridge,
>(
collator_session_keys(),
construct_and_estimate_extrinsic_fee
);
// check if estimated value is sane
let max_expected = bp_bridge_hub_rococo::BridgeHubRococoBaseDeliveryFeeInRocs::get();
assert!(
estimated <= max_expected,
"calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_rococo::BridgeHubRococoBaseDeliveryFeeInRocs` value",
estimated,
max_expected
);
}
#[test]
pub fn can_calculate_fee_for_complex_message_confirmation_transaction() {
let estimated = bridge_hub_test_utils::test_cases::from_grandpa_chain::can_calculate_fee_for_complex_message_confirmation_transaction::<
Runtime,
BridgeGrandpaRococoBulletinInstance,
WithRococoBulletinMessagesInstance,
WithRococoBulletinMessageBridge,
>(
collator_session_keys(),
construct_and_estimate_extrinsic_fee
);
// check if estimated value is sane
let max_expected = bp_bridge_hub_rococo::BridgeHubRococoBaseConfirmationFeeInRocs::get();
assert!(
estimated <= max_expected,
"calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_rococo::BridgeHubRococoBaseConfirmationFeeInRocs` value",
estimated,
max_expected
);
}
}
@@ -112,6 +112,8 @@ pub mod system_parachain {
pub const CONTRACTS_ID: u32 = 1002;
/// Encointer parachain ID.
pub const ENCOINTER_ID: u32 = 1003;
/// People parachain ID.
pub const PEOPLE_ID: u32 = 1004;
/// BridgeHub parachain ID.
pub const BRIDGE_HUB_ID: u32 = 1013;