diff --git a/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/genesis.rs b/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/genesis.rs index 085f8e86a7..773e2e15cd 100644 --- a/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/genesis.rs +++ b/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/genesis.rs @@ -52,6 +52,8 @@ pub fn genesis() -> Storage { ) }) .collect(), + // TODO: Any keys to add here? + non_authority_keys: vec![], }, polkadot_xcm: bridge_hub_kusama_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml b/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml index f0a8a0bb39..c2b201ff7f 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml @@ -109,6 +109,7 @@ bridge-hub-test-utils = { workspace = true } bridge-runtime-common = { features = [ "integrity-test", ], workspace = true, default-features = true } +pallet-bridge-relayers = { workspace = true, features = ["integrity-test"] } sp-keyring = { workspace = true } static_assertions = { workspace = true } parachains-runtimes-test-utils = { workspace = true } diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs index 9d7981d46b..77de69413d 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs @@ -28,7 +28,7 @@ use frame_support::{ dispatch::DispatchClass, sp_runtime::{MultiAddress, MultiSigner}, }; -use sp_runtime::{FixedPointNumber, FixedU128, RuntimeDebug, Saturating}; +use sp_runtime::{FixedPointNumber, FixedU128, RuntimeDebug, Saturating, StateVersion}; /// BridgeHubKusama parachain. #[derive(RuntimeDebug)] @@ -36,6 +36,7 @@ pub struct BridgeHubKusama; impl Chain for BridgeHubKusama { const ID: ChainId = *b"bhks"; + const STATE_VERSION: StateVersion = StateVersion::V1; type BlockNumber = BlockNumber; type Hash = Hash; @@ -93,7 +94,7 @@ pub const WITH_BRIDGE_HUB_KUSAMA_RELAYERS_PALLET_NAME: &str = "BridgeRelayers"; pub const WITH_BRIDGE_KUSAMA_TO_POLKADOT_MESSAGES_PALLET_INDEX: u8 = 53; decl_bridge_finality_runtime_apis!(bridge_hub_kusama); -decl_bridge_messages_runtime_apis!(bridge_hub_kusama); +decl_bridge_messages_runtime_apis!(bridge_hub_kusama, LegacyLaneId); frame_support::parameter_types! { /// The XCM fee that is paid for executing XCM program (with `ExportMessage` instruction) at the Kusama diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_polkadot_config.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_polkadot_config.rs index 282f995f2b..7178dd35f0 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_polkadot_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_polkadot_config.rs @@ -20,30 +20,20 @@ use crate::{ weights, xcm_config::{UniversalLocation, XcmRouter}, AccountId, Balance, Balances, BlockNumber, BridgePolkadotMessages, PolkadotXcm, Runtime, - RuntimeEvent, RuntimeHoldReason, RuntimeOrigin, XcmOverBridgeHubPolkadot, + RuntimeEvent, RuntimeHoldReason, XcmOverBridgeHubPolkadot, }; -use bp_messages::{LaneId, LegacyLaneId}; +use bp_messages::LegacyLaneId; use bp_parachains::SingleParaStoredHeaderDataBuilder; -use bp_runtime::Chain; -use bridge_runtime_common::{ - extensions::refund_relayer_extension::{ - ActualFeeRefund, RefundBridgedParachainMessages, RefundSignedExtensionAdapter, - RefundableMessagesLane, RefundableParachain, - }, - messages, - messages::{ - source::{FromBridgedChainMessagesDeliveryProof, TargetHeaderChainAdapter}, - target::{FromBridgedChainMessagesProof, SourceHeaderChainAdapter}, - MessageBridge, ThisChainWithMessages, UnderlyingChainProvider, - }, - messages_xcm_extension::{ - SenderAndLane, XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter, - XcmBlobMessageDispatch, XcmVersionOfDestAndRemoteBridge, - }, -}; +use bp_runtime::{Chain, UnderlyingChainProvider}; +use bridge_hub_common::xcm_version::XcmVersionOfDestAndRemoteBridge; use frame_support::{parameter_types, traits::PalletInfoAccess}; use frame_system::{EnsureNever, EnsureRoot}; use kusama_runtime_constants as constants; +use pallet_bridge_messages::LaneIdOf; +use pallet_bridge_relayers::extension::{ + BridgeRelayersSignedExtension, WithMessagesExtensionConfig, +}; +use pallet_xcm_bridge_hub::XcmAsPlainPayload; use parachains_common::xcm_config::{AllSiblingSystemParachains, RelayOrOtherSystemParachains}; use polkadot_parachain_primitives::primitives::Sibling; use sp_runtime::{traits::ConstU32, RuntimeDebug}; @@ -51,7 +41,8 @@ use xcm::latest::prelude::*; use xcm_builder::{BridgeBlobDispatcher, ParentIsPreset, SiblingParachainConvertsVia}; /// Lane identifier, used to connect Kusama Asset Hub and Polkadot Asset Hub. -pub const XCM_LANE_FOR_ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT: LaneId = LaneId([0, 0, 0, 1]); +pub const XCM_LANE_FOR_ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT: LegacyLaneId = + LegacyLaneId([0, 0, 0, 1]); // Parameters that may be changed by the governance. parameter_types! { @@ -96,27 +87,9 @@ parameter_types! { ].into() }; - /// A route (XCM location and bridge lane) that the Kusama Asset Hub -> Polkadot Asset Hub - /// message is following. - pub FromAssetHubKusamaToAssetHubPolkadotRoute: SenderAndLane = SenderAndLane::new( - ParentThen(Parachain(AssetHubKusamaParaId::get().into()).into()).into(), - XCM_LANE_FOR_ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT, - ); - /// Lane identifier, used to connect Kusama Asset Hub and Polkadot Asset Hub. - pub const AssetHubKusamaToAssetHubPolkadotMessagesLane: bp_messages::LaneId + pub const AssetHubKusamaToAssetHubPolkadotMessagesLane: LegacyLaneId = XCM_LANE_FOR_ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT; - /// All active lanes that the current bridge supports. - pub ActiveOutboundLanesToBridgeHubPolkadot: &'static [bp_messages::LaneId] - = &[XCM_LANE_FOR_ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT]; - - /// Lanes - pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![ - ( - FromAssetHubKusamaToAssetHubPolkadotRoute::get(), - (PolkadotGlobalConsensusNetwork::get(), Parachain(AssetHubPolkadotParaId::get().into()).into()) - ) - ]; } // Parameters, used by bridge transport code. @@ -160,11 +133,17 @@ parameter_types! { pub PriorityBoostPerParachainHeader: u64 = 920_224_664_224_664; // see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value pub PriorityBoostPerMessage: u64 = 182_044_444_444_444; - // TODO: What's the correct value? - pub storage BridgeDeposit: Balance = 10 * DOLLARS; + pub storage BridgeDeposit: Balance = constants::currency::UNITS; } +/// Dispatches received XCM messages from other bridge +pub type FromPolkadotMessageBlobDispatcher = BridgeBlobDispatcher< + XcmRouter, + UniversalLocation, + BridgeKusamaToPolkadotMessagesPalletInstance, +>; + /// Add GRANDPA bridge pallet to track Polkadot relay chain. pub type BridgeGrandpaPolkadotInstance = pallet_bridge_grandpa::Instance1; impl pallet_bridge_grandpa::Config for Runtime { @@ -193,8 +172,11 @@ impl pallet_bridge_parachains::Config for Runti impl pallet_bridge_relayers::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Reward = Balance; - type PaymentProcedure = - bp_relayers::PayRewardFromAccount, AccountId>; + type PaymentProcedure = bp_relayers::PayRewardFromAccount< + pallet_balances::Pallet, + AccountId, + Self::LaneId, + >; type StakeAndSlash = pallet_bridge_relayers::StakeAndSlashNamed< AccountId, BlockNumber, @@ -213,59 +195,26 @@ impl pallet_bridge_messages::Config for R type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::pallet_bridge_messages::WeightInfo; - type InboundPayload = XcmAsPlainPayload; - type OutboundPayload = XcmAsPlainPayload; - type DeliveryPayments = (); - - type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter< - Runtime, - WithBridgeHubPolkadotMessagesInstance, - DeliveryRewardInBalance, - >; - type MessageDispatch = XcmBlobMessageDispatch< - FromPolkadotMessageBlobDispatcher, - Self::WeightInfo, - cumulus_pallet_xcmp_queue::bridging::OutXcmpChannelStatusProvider< - AssetHubKusamaParaId, - Runtime, - >, - >; - type OnMessagesDelivered = OnMessagesDeliveredFromPolkadot; - - type ThisChain = BridgeHubKusama; - type BridgedChain = BridgeHubPolkadot; + type ThisChain = bp_bridge_hub_kusama::BridgeHubKusama; + type BridgedChain = bp_bridge_hub_polkadot::BridgeHubPolkadot; type BridgedHeaderChain = pallet_bridge_parachains::ParachainHeaders< Runtime, BridgeParachainPolkadotInstance, bp_bridge_hub_polkadot::BridgeHubPolkadot, >; - type LaneId = LegacyLaneId; -} - -/// Proof of messages, coming from Polkadot. -pub type FromPolkadotBridgeHubMessagesProof = - FromBridgedChainMessagesProof; -/// Messages delivery proof for Kusama Bridge Hub -> Polkadot Bridge Hub messages. -pub type ToPolkadotBridgeHubMessagesDeliveryProof = - FromBridgedChainMessagesDeliveryProof; -/// Dispatches received XCM messages from Polkadot BridgeHub. -type FromPolkadotMessageBlobDispatcher = BridgeBlobDispatcher< - XcmRouter, - UniversalLocation, - BridgeKusamaToPolkadotMessagesPalletInstance, ->; - -/// Export XCM messages to be relayed to the other side -pub type ToBridgeHubPolkadotHaulBlobExporter = XcmOverBridgeHubPolkadot; -pub struct ToBridgeHubPolkadotXcmBlobHauler; -impl XcmBlobHauler for ToBridgeHubPolkadotXcmBlobHauler { - type Runtime = Runtime; - type MessagesInstance = WithBridgeHubPolkadotMessagesInstance; + type OutboundPayload = XcmAsPlainPayload; + type InboundPayload = XcmAsPlainPayload; + type LaneId = LegacyLaneId; - type ToSourceChainSender = XcmRouter; - type CongestedMessage = bp_asset_hub_kusama::CongestedMessage; - type UncongestedMessage = bp_asset_hub_kusama::UncongestedMessage; + type DeliveryPayments = (); + type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter< + Runtime, + WithBridgeHubPolkadotMessagesInstance, + DeliveryRewardInBalance, + >; + type MessageDispatch = XcmOverBridgeHubPolkadot; + type OnMessagesDelivered = XcmOverBridgeHubPolkadot; } /// Add support for the export and dispatch of XCM programs. @@ -276,7 +225,9 @@ impl pallet_xcm_bridge_hub::Config for Runtime type UniversalLocation = UniversalLocation; type BridgedNetwork = PolkadotGlobalConsensusNetworkLocation; type BridgeMessagesPalletInstance = WithBridgeHubPolkadotMessagesInstance; - + // `MessageExportPrice` is simply propagated to the inner `xcm_builder::HaulBlobExporter`, and + // we do not need or want to add any additional price for exporting here, as it is already + // covered by the measured weight of the `ExportMessage` instruction. type MessageExportPrice = (); type DestinationVersion = XcmVersionOfDestAndRemoteBridge; @@ -295,34 +246,12 @@ impl pallet_xcm_bridge_hub::Config for Runtime type AllowWithoutBridgeDeposit = RelayOrOtherSystemParachains; - // TODO: (bridges-v2) - add `LocalXcmChannelManager` impl - https://github.com/paritytech/parity-bridges-common/issues/3047 + // TODO: @acatangiu (bridges-v2) - add `LocalXcmChannelManager` impl - https://github.com/paritytech/parity-bridges-common/issues/3047 // @acatangiu type LocalXcmChannelManager = (); type BlobDispatcher = FromPolkadotMessageBlobDispatcher; } -/// On messages delivered callback. -type OnMessagesDeliveredFromPolkadot = - XcmBlobHaulerAdapter; - -/// Messaging Bridge configuration for BridgeHubKusama -> BridgeHubPolkadot -pub struct WithBridgeHubPolkadotMessageBridge; -impl MessageBridge for WithBridgeHubPolkadotMessageBridge { - const BRIDGED_MESSAGES_PALLET_NAME: &'static str = - bp_bridge_hub_kusama::WITH_BRIDGE_HUB_KUSAMA_MESSAGES_PALLET_NAME; - type ThisChain = BridgeHubKusama; - type BridgedChain = BridgeHubPolkadot; - type BridgedHeaderChain = pallet_bridge_parachains::ParachainHeaders< - Runtime, - BridgeParachainPolkadotInstance, - bp_bridge_hub_polkadot::BridgeHubPolkadot, - >; -} - -/// Maximal outbound payload size of BridgeHubKusama -> BridgeHubPolkadot messages. -pub type ToBridgeHubPolkadotMaximalOutboundPayloadSize = - messages::source::FromThisChainMaximalOutboundPayloadSize; - /// BridgeHubPolkadot chain from message lane point of view. #[derive(RuntimeDebug, Clone, Copy)] pub struct BridgeHubPolkadot; @@ -331,8 +260,6 @@ impl UnderlyingChainProvider for BridgeHubPolkadot { type Chain = bp_bridge_hub_polkadot::BridgeHubPolkadot; } -impl messages::BridgedChainWithMessages for BridgeHubPolkadot {} - /// BridgeHubKusama chain from message lane point of view. #[derive(RuntimeDebug, Clone, Copy)] pub struct BridgeHubKusama; @@ -341,28 +268,21 @@ impl UnderlyingChainProvider for BridgeHubKusama { type Chain = bp_bridge_hub_kusama::BridgeHubKusama; } -impl ThisChainWithMessages for BridgeHubKusama { - type RuntimeOrigin = RuntimeOrigin; -} +pub type RelayersForLegacyLaneIdsMessagesInstance = (); /// Signed extension that refunds relayers that are delivering messages from the Polkadot parachain. -pub type RefundBridgeHubPolkadotMessages = RefundSignedExtensionAdapter< - RefundBridgedParachainMessages< +pub type OnBridgeHubPolkadotRefundBridgeHubKusamaMessages = BridgeRelayersSignedExtension< + Runtime, + WithMessagesExtensionConfig< + StrOnBridgeHubPolkadotRefundBridgeHubKusamaMessages, Runtime, - RefundableParachain< - BridgeParachainPolkadotInstance, - bp_bridge_hub_polkadot::BridgeHubPolkadot, - >, - RefundableMessagesLane< - WithBridgeHubPolkadotMessagesInstance, - AssetHubKusamaToAssetHubPolkadotMessagesLane, - >, - ActualFeeRefund, + WithBridgeHubPolkadotMessagesInstance, + RelayersForLegacyLaneIdsMessagesInstance, PriorityBoostPerMessage, - StrRefundBridgeHubPolkadotMessages, >, + LaneIdOf, >; -bp_runtime::generate_static_str_provider!(RefundBridgeHubPolkadotMessages); +bp_runtime::generate_static_str_provider!(OnBridgeHubPolkadotRefundBridgeHubKusamaMessages); #[cfg(test)] mod tests { @@ -370,9 +290,8 @@ mod tests { use bridge_runtime_common::{ assert_complete_bridge_types, integrity::{ - assert_complete_bridge_constants, check_message_lane_weights, - AssertBridgeMessagesPalletConstants, AssertBridgePalletNames, AssertChainConstants, - AssertCompleteBridgeConstants, + assert_complete_with_parachain_bridge_constants, check_message_lane_weights, + AssertChainConstants, AssertCompleteBridgeConstants, }, }; @@ -411,11 +330,11 @@ mod tests { runtime: Runtime, with_bridged_chain_grandpa_instance: BridgeGrandpaPolkadotInstance, with_bridged_chain_messages_instance: WithBridgeHubPolkadotMessagesInstance, - this_chain: bp_kusama::Kusama, - bridged_chain: bp_polkadot::Polkadot, + this_chain: bp_bridge_hub_kusama::BridgeHubKusama, + bridged_chain: bp_bridge_hub_polkadot::BridgeHubPolkadot, ); - assert_complete_bridge_constants::< + assert_complete_with_parachain_bridge_constants::< Runtime, BridgeGrandpaPolkadotInstance, WithBridgeHubPolkadotMessagesInstance, @@ -427,19 +346,19 @@ mod tests { }, }); - bridge_runtime_common::extensions::priority_calculator::per_relay_header::ensure_priority_boost_is_sane::< + pallet_bridge_relayers::extension::per_relay_header::ensure_priority_boost_is_sane::< Runtime, BridgeGrandpaPolkadotInstance, PriorityBoostPerRelayHeader, >(FEE_BOOST_PER_RELAY_HEADER); - bridge_runtime_common::extensions::priority_calculator::per_parachain_header::ensure_priority_boost_is_sane::< + pallet_bridge_relayers::extension::per_parachain_header::ensure_priority_boost_is_sane::< Runtime, RefundableParachain, PriorityBoostPerParachainHeader, >(FEE_BOOST_PER_PARACHAIN_HEADER); - bridge_runtime_common::extensions::priority_calculator::per_message::ensure_priority_boost_is_sane::< + pallet_bridge_relayers::extension::per_message::ensure_priority_boost_is_sane::< Runtime, WithBridgeHubPolkadotMessagesInstance, PriorityBoostPerMessage, diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs index d9850b62a7..5ce7e23492 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs @@ -56,6 +56,8 @@ fn bridge_hub_kusama_genesis( ) }) .collect(), + // TODO: Any keys to add here? + non_authority_keys: vec![], }, "polkadotXcm": { "safeXcmVersion": Some(SAFE_XCM_VERSION), diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs index 44574b27e6..603c54fd5c 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -116,7 +116,7 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, BridgeRejectObsoleteHeadersAndMessages, - bridge_to_polkadot_config::RefundBridgeHubPolkadotMessages, + bridge_to_polkadot_config::OnBridgeHubPolkadotRefundBridgeHubKusamaMessages, frame_metadata_hash_extension::CheckMetadataHash, ); @@ -848,7 +848,7 @@ impl_runtime_apis! { impl bp_bridge_hub_polkadot::FromBridgeHubPolkadotInboundLaneApi for Runtime { fn message_details( - lane: bp_messages::LaneId, + lane: bp_messages::LegacyLaneId, messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>, ) -> Vec { bridge_runtime_common::messages_api::inbound_message_details::< @@ -860,7 +860,7 @@ impl_runtime_apis! { impl bp_bridge_hub_polkadot::ToBridgeHubPolkadotOutboundLaneApi for Runtime { fn message_details( - lane: bp_messages::LaneId, + lane: bp_messages::LegacyLaneId, begin: bp_messages::MessageNonce, end: bp_messages::MessageNonce, ) -> Vec { diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/pallet_bridge_messages.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/pallet_bridge_messages.rs index a0e27e2497..f2a1599fcc 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/pallet_bridge_messages.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/pallet_bridge_messages.rs @@ -77,26 +77,6 @@ impl pallet_bridge_messages::WeightInfo for WeightInfo< /// Proof: `BridgePolkadotMessages::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: `489` - // Estimated: `52645` - // Minimum execution time: 70_821_000 picoseconds. - Weight::from_parts(73_401_000, 0) - .saturating_add(Weight::from_parts(0, 52645)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `BridgePolkadotMessages::PalletOperatingMode` (r:1 w:0) - /// Proof: `BridgePolkadotMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:0) - /// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`) - /// Storage: `BridgePolkadotParachains::ImportedParaHeads` (r:1 w:0) - /// Proof: `BridgePolkadotParachains::ImportedParaHeads` (`max_values`: Some(600), `max_size`: Some(196), added: 1681, mode: `MaxEncodedLen`) - /// Storage: `BridgePolkadotMessages::InboundLanes` (r:1 w:1) - /// Proof: `BridgePolkadotMessages::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: `489` @@ -109,42 +89,6 @@ impl pallet_bridge_messages::WeightInfo for WeightInfo< } /// Storage: `BridgePolkadotMessages::PalletOperatingMode` (r:1 w:0) /// Proof: `BridgePolkadotMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:0) - /// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`) - /// Storage: `BridgePolkadotParachains::ImportedParaHeads` (r:1 w:0) - /// Proof: `BridgePolkadotParachains::ImportedParaHeads` (`max_values`: Some(600), `max_size`: Some(196), added: 1681, mode: `MaxEncodedLen`) - /// Storage: `BridgePolkadotMessages::InboundLanes` (r:1 w:1) - /// Proof: `BridgePolkadotMessages::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: `457` - // Estimated: `52645` - // Minimum execution time: 52_610_000 picoseconds. - Weight::from_parts(53_671_000, 0) - .saturating_add(Weight::from_parts(0, 52645)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `BridgePolkadotMessages::PalletOperatingMode` (r:1 w:0) - /// Proof: `BridgePolkadotMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:0) - /// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`) - /// Storage: `BridgePolkadotParachains::ImportedParaHeads` (r:1 w:0) - /// Proof: `BridgePolkadotParachains::ImportedParaHeads` (`max_values`: Some(600), `max_size`: Some(196), added: 1681, mode: `MaxEncodedLen`) - /// Storage: `BridgePolkadotMessages::InboundLanes` (r:1 w:1) - /// Proof: `BridgePolkadotMessages::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: `457` - // Estimated: `52645` - // Minimum execution time: 82_911_000 picoseconds. - Weight::from_parts(83_941_000, 0) - .saturating_add(Weight::from_parts(0, 52645)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `BridgePolkadotMessages::PalletOperatingMode` (r:1 w:0) - /// Proof: `BridgePolkadotMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) /// Storage: `BridgePolkadotParachains::ImportedParaHeads` (r:1 w:0) /// Proof: `BridgePolkadotParachains::ImportedParaHeads` (`max_values`: Some(600), `max_size`: Some(196), added: 1681, mode: `MaxEncodedLen`) /// Storage: `BridgePolkadotMessages::OutboundLanes` (r:1 w:1) @@ -203,39 +147,25 @@ impl pallet_bridge_messages::WeightInfo for WeightInfo< .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: `BridgePolkadotMessages::PalletOperatingMode` (r:1 w:0) - /// Proof: `BridgePolkadotMessages::PalletOperatingMode` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - /// Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:1) - /// Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`) - /// Storage: `BridgePolkadotParachains::ImportedParaHeads` (r:1 w:0) - /// Proof: `BridgePolkadotParachains::ImportedParaHeads` (`max_values`: Some(600), `max_size`: Some(196), added: 1681, mode: `MaxEncodedLen`) - /// Storage: `BridgePolkadotMessages::InboundLanes` (r:1 w:1) - /// Proof: `BridgePolkadotMessages::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`: Some(28), added: 2503, mode: `MaxEncodedLen`) - /// 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::OutboundXcmpMessages` (r:0 w:1) - /// Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: Some(105506), added: 107981, mode: `MaxEncodedLen`) - /// The range of component `i` is `[128, 2048]`. - fn receive_single_message_proof_with_dispatch(i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `657` - // Estimated: `52645` - // Minimum execution time: 74_781_000 picoseconds. - Weight::from_parts(75_851_615, 0) - .saturating_add(Weight::from_parts(0, 52645)) - // Standard Error: 49 - .saturating_add(Weight::from_parts(7_539, 0).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(4)) + fn receive_n_messages_proof(n: u32) -> Weight { + Weight::from_parts(0, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(Weight::from_parts(0, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn receive_single_n_bytes_message_proof(n: u32) -> Weight { + Weight::from_parts(0, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(Weight::from_parts(0, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn receive_single_n_bytes_message_proof_with_dispatch(n: u32) -> Weight { + Weight::from_parts(0, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(Weight::from_parts(0, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 2a16b42aed..55871d2040 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -14,11 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . +use crate::XcmOverBridgeHubPolkadot; + use super::{ - bridge_to_polkadot_config::ToBridgeHubPolkadotHaulBlobExporter, AccountId, - AllPalletsWithSystem, Balances, CollatorSelection, ParachainInfo, ParachainSystem, PolkadotXcm, - PriceForParentDelivery, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, - XcmpQueue, + AccountId, AllPalletsWithSystem, Balances, CollatorSelection, ParachainInfo, ParachainSystem, + PolkadotXcm, PriceForParentDelivery, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, + WeightToFee, XcmpQueue, }; use frame_support::{ parameter_types, @@ -39,10 +40,10 @@ use xcm_builder::{ AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, - RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, - XcmFeeManagerFromComponents, XcmFeeToAccount, + XcmFeeManagerFromComponents, }; use xcm_executor::{traits::ConvertLocation, XcmExecutor}; @@ -203,9 +204,9 @@ impl xcm_executor::Config for XcmConfig { type AssetExchanger = (); type FeeManager = XcmFeeManagerFromComponents< WaivedLocations, - XcmFeeToAccount, + SendXcmFeeToAccount, >; - type MessageExporter = ToBridgeHubPolkadotHaulBlobExporter; + type MessageExporter = XcmOverBridgeHubPolkadot; type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_kusama_config.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_kusama_config.rs index 49c0578b03..690f5689aa 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_kusama_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_kusama_config.rs @@ -37,7 +37,7 @@ use pallet_bridge_relayers::extension::{ use pallet_xcm_bridge_hub::XcmAsPlainPayload; use parachains_common::xcm_config::{AllSiblingSystemParachains, RelayOrOtherSystemParachains}; use polkadot_parachain_primitives::primitives::Sibling; -use polkadot_runtime_constants::{self as constants, DOLLARS}; +use polkadot_runtime_constants as constants; use sp_runtime::{traits::ConstU32, RuntimeDebug}; use xcm::latest::prelude::*; use xcm_builder::{BridgeBlobDispatcher, ParentIsPreset, SiblingParachainConvertsVia}; @@ -135,7 +135,7 @@ parameter_types! { // see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value pub PriorityBoostPerMessage: u64 = 1_820_444_444_444; // TODO: @acatangiu, is there any specs about the deposit cost? - pub storage BridgeDeposit: Balance = 10 * DOLLARS; + pub storage BridgeDeposit: Balance = 10 * constants::currency::UNITS; } /// Dispatches received XCM messages from other bridge @@ -186,8 +186,8 @@ impl pallet_bridge_relayers::Config for Runtime { RequiredStakeForStakeAndSlash, RelayerStakeLease, >; - type WeightInfo = weights::pallet_bridge_relayers::WeightInfo; type LaneId = LegacyLaneId; + type WeightInfo = weights::pallet_bridge_relayers::WeightInfo; } /// Add XCM messages support for exchanging messages with BridgeHubKusama.