Skip to content

Commit

Permalink
Adjusted BH runtimes to the latest vogue
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Jun 14, 2024
1 parent 9b5f266 commit f0f50af
Show file tree
Hide file tree
Showing 17 changed files with 389 additions and 894 deletions.
8 changes: 4 additions & 4 deletions bridges/chains/chain-bridge-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ frame_support::parameter_types! {
pub const BridgeHubRococoBaseXcmFeeInRocs: u128 = 59_034_266;

/// Transaction fee that is paid at the Rococo BridgeHub for delivering single inbound message.
/// (initially was calculated by test `BridgeHubRococo::can_calculate_fee_for_complex_message_delivery_transaction` + `33%`)
pub const BridgeHubRococoBaseDeliveryFeeInRocs: u128 = 314_037_860;
/// (initially was calculated by test `BridgeHubRococo::can_calculate_fee_for_standalone_message_delivery_transaction` + `33%`)
pub const BridgeHubRococoBaseDeliveryFeeInRocs: u128 = 82_023_783;

/// Transaction fee that is paid at the Rococo BridgeHub for delivering single outbound message confirmation.
/// (initially was calculated by test `BridgeHubRococo::can_calculate_fee_for_complex_message_confirmation_transaction` + `33%`)
pub const BridgeHubRococoBaseConfirmationFeeInRocs: u128 = 57_414_813;
/// (initially was calculated by test `BridgeHubRococo::can_calculate_fee_for_standalone_message_confirmation_transaction` + `33%`)
pub const BridgeHubRococoBaseConfirmationFeeInRocs: u128 = 58_434_469;
}
4 changes: 2 additions & 2 deletions bridges/chains/chain-bridge-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ frame_support::parameter_types! {

/// Transaction fee that is paid at the Westend BridgeHub for delivering single inbound message.
/// (initially was calculated by test `BridgeHubWestend::can_calculate_fee_for_standalone_message_delivery_transaction` + `33%`)
pub const BridgeHubWestendBaseDeliveryFeeInWnds: u128 = 94_211_536_452;
pub const BridgeHubWestendBaseDeliveryFeeInWnds: u128 = 94_661_076_452;

/// Transaction fee that is paid at the Westend BridgeHub for delivering single outbound message confirmation.
/// (initially was calculated by test `BridgeHubWestend::can_calculate_fee_for_standalone_message_confirmation_transaction` + `33%`)
pub const BridgeHubWestendBaseConfirmationFeeInWnds: u128 = 17_224_486_452;
pub const BridgeHubWestendBaseConfirmationFeeInWnds: u128 = 17_530_386_452;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@
//! 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, RuntimeOrigin,
};
use super::{weights, AccountId, Balance, Balances, BlockNumber, Runtime, RuntimeEvent};
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;
Expand Down Expand Up @@ -103,15 +98,3 @@ impl pallet_bridge_grandpa::Config<BridgeGrandpaRococoBulletinInstance> for Runt
// 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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,34 @@
//! are reusing Polkadot Bulletin chain primitives everywhere here.
use crate::{
bridge_common_config::BridgeHubRococo, weights, xcm_config::UniversalLocation, AccountId,
BridgeRococoBulletinGrandpa, BridgeRococoBulletinMessages, PolkadotXcm, Runtime, RuntimeEvent,
XcmOverRococoBulletin, XcmRouter,
weights, xcm_config::UniversalLocation, BridgeRococoBulletinGrandpa,
BridgeRococoBulletinMessages, PolkadotXcm, Runtime, RuntimeEvent, XcmOverRococoBulletin,
XcmRouter,
};
use bp_messages::{
source_chain::FromBridgedChainMessagesDeliveryProof,
target_chain::FromBridgedChainMessagesProof, LaneId,
};
use bp_messages::LaneId;
use bp_runtime::Chain;
use bridge_runtime_common::{
extensions::refund_relayer_extension::{
ActualFeeRefund, RefundBridgedMessages, RefundSignedExtensionAdapter,
RefundableMessagesLane,
},
messages,
messages::{
source::{FromBridgedChainMessagesDeliveryProof, TargetHeaderChainAdapter},
target::{FromBridgedChainMessagesProof, SourceHeaderChainAdapter},
MessageBridge, UnderlyingChainProvider,
},
messages_xcm_extension::{
SenderAndLane, XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter,
XcmBlobMessageDispatch, XcmVersionOfDestAndRemoteBridge,
},
};

use frame_support::{parameter_types, traits::PalletInfoAccess};
use sp_runtime::RuntimeDebug;
use xcm::{
latest::prelude::*,
prelude::{InteriorLocation, 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_polkadot_bulletin::PolkadotBulletin::ID;
/// Interior location (relative to this runtime) of the with-RococoBulletin messages pallet.
Expand Down Expand Up @@ -142,31 +129,6 @@ impl XcmBlobHauler for ToRococoBulletinXcmBlobHauler {
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;
}

/// 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<
Expand All @@ -189,22 +151,20 @@ impl pallet_bridge_messages::Config<WithRococoBulletinMessagesInstance> for Runt
type RuntimeEvent = RuntimeEvent;
type WeightInfo =
weights::pallet_bridge_messages_rococo_to_rococo_bulletin::WeightInfo<Runtime>;
type BridgedChainId = RococoBulletinChainId;

type ThisChain = bp_bridge_hub_rococo::BridgeHubRococo;
type BridgedChain = bp_polkadot_bulletin::PolkadotBulletin;
type BridgedHeaderChain = BridgeRococoBulletinGrandpa;

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 DeliveryConfirmationPayments = ();

type SourceHeaderChain = SourceHeaderChainAdapter<WithRococoBulletinMessageBridge>;
type MessageDispatch =
XcmBlobMessageDispatch<FromRococoBulletinMessageBlobDispatcher, Self::WeightInfo, ()>;
type OnMessagesDelivered = OnMessagesDeliveredFromRococoBulletin;
Expand Down Expand Up @@ -267,8 +227,7 @@ mod tests {
runtime: Runtime,
with_bridged_chain_grandpa_instance: BridgeGrandpaRococoBulletinInstance,
with_bridged_chain_messages_instance: WithRococoBulletinMessagesInstance,
bridge: WithRococoBulletinMessageBridge,
this_chain: bp_rococo::Rococo,
this_chain: bp_bridge_hub_rococo::BridgeHubRococo,
bridged_chain: bp_polkadot_bulletin::PolkadotBulletin,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,21 @@
//! Bridge definitions used on BridgeHubRococo for bridging to BridgeHubWestend.
use crate::{
bridge_common_config::{
BridgeHubRococo, BridgeParachainWestendInstance, DeliveryRewardInBalance,
},
bridge_common_config::{BridgeParachainWestendInstance, DeliveryRewardInBalance},
weights,
xcm_config::UniversalLocation,
AccountId, BridgeWestendMessages, PolkadotXcm, Runtime, RuntimeEvent, XcmOverBridgeHubWestend,
XcmRouter,
BridgeWestendMessages, PolkadotXcm, Runtime, RuntimeEvent, XcmOverBridgeHubWestend, XcmRouter,
};
use bp_messages::{
source_chain::FromBridgedChainMessagesDeliveryProof,
target_chain::FromBridgedChainMessagesProof, LaneId,
};
use bp_messages::LaneId;
use bp_runtime::Chain;
use bridge_runtime_common::{
extensions::refund_relayer_extension::{
ActualFeeRefund, RefundBridgedMessages, RefundSignedExtensionAdapter,
RefundableMessagesLane,
},
messages,
messages::{
source::{FromBridgedChainMessagesDeliveryProof, TargetHeaderChainAdapter},
target::{FromBridgedChainMessagesProof, SourceHeaderChainAdapter},
MessageBridge, UnderlyingChainProvider,
},
messages_xcm_extension::{
SenderAndLane, XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter,
XcmBlobMessageDispatch, XcmVersionOfDestAndRemoteBridge,
Expand All @@ -46,19 +40,14 @@ use bridge_runtime_common::{

use codec::Encode;
use frame_support::{parameter_types, traits::PalletInfoAccess};
use sp_runtime::RuntimeDebug;
use xcm::{
latest::prelude::*,
prelude::{InteriorLocation, NetworkId},
};
use xcm_builder::BridgeBlobDispatcher;

parameter_types! {
pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce =
bp_bridge_hub_rococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
bp_bridge_hub_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
pub const BridgeHubWestendChainId: bp_runtime::ChainId = BridgeHubWestend::ID;
pub const BridgeHubWestendChainId: bp_runtime::ChainId = bp_bridge_hub_westend::BridgeHubWestend::ID;
pub BridgeRococoToWestendMessagesPalletInstance: InteriorLocation = [PalletInstance(<BridgeWestendMessages as PalletInfoAccess>::index() as u8)].into();
pub WestendGlobalConsensusNetwork: NetworkId = NetworkId::Westend;
pub WestendGlobalConsensusNetworkLocation: Location = Location::new(
Expand All @@ -70,7 +59,7 @@ parameter_types! {
// see the `FEE_BOOST_PER_PARACHAIN_HEADER` constant get the meaning of this value
pub PriorityBoostPerParachainHeader: u64 = 1_396_340_903_540_903;
// see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value
pub PriorityBoostPerMessage: u64 = 182_044_444_444_444;
pub PriorityBoostPerMessage: u64 = 2_222_542_612_942_613;

pub AssetHubRococoParaId: cumulus_primitives_core::ParaId = bp_asset_hub_rococo::ASSET_HUB_ROCOCO_PARACHAIN_ID.into();
pub AssetHubWestendParaId: cumulus_primitives_core::ParaId = bp_asset_hub_westend::ASSET_HUB_WESTEND_PARACHAIN_ID.into();
Expand Down Expand Up @@ -148,34 +137,6 @@ impl XcmBlobHauler for ToBridgeHubWestendXcmBlobHauler {
type OnMessagesDeliveredFromWestend =
XcmBlobHaulerAdapter<ToBridgeHubWestendXcmBlobHauler, ActiveLanes>;

/// Messaging Bridge configuration for BridgeHubRococo -> BridgeHubWestend
pub struct WithBridgeHubWestendMessageBridge;
impl MessageBridge for WithBridgeHubWestendMessageBridge {
const BRIDGED_MESSAGES_PALLET_NAME: &'static str =
bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME;
type ThisChain = BridgeHubRococo;
type BridgedChain = BridgeHubWestend;
type BridgedHeaderChain = pallet_bridge_parachains::ParachainHeaders<
Runtime,
BridgeParachainWestendInstance,
bp_bridge_hub_westend::BridgeHubWestend,
>;
}

/// Maximal outbound payload size of BridgeHubRococo -> BridgeHubWestend messages.
pub type ToBridgeHubWestendMaximalOutboundPayloadSize =
messages::source::FromThisChainMaximalOutboundPayloadSize<WithBridgeHubWestendMessageBridge>;

/// BridgeHubWestend chain from message lane point of view.
#[derive(RuntimeDebug, Clone, Copy)]
pub struct BridgeHubWestend;

impl UnderlyingChainProvider for BridgeHubWestend {
type Chain = bp_bridge_hub_westend::BridgeHubWestend;
}

impl messages::BridgedChainWithMessages for BridgeHubWestend {}

/// Signed extension that refunds relayers that are delivering messages from the Westend parachain.
pub type OnBridgeHubRococoRefundBridgeHubWestendMessages = RefundSignedExtensionAdapter<
RefundBridgedMessages<
Expand All @@ -196,26 +157,28 @@ pub type WithBridgeHubWestendMessagesInstance = pallet_bridge_messages::Instance
impl pallet_bridge_messages::Config<WithBridgeHubWestendMessagesInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_bridge_messages_rococo_to_westend::WeightInfo<Runtime>;
type BridgedChainId = BridgeHubWestendChainId;

type ThisChain = bp_bridge_hub_rococo::BridgeHubRococo;
type BridgedChain = bp_bridge_hub_westend::BridgeHubWestend;
type BridgedHeaderChain = pallet_bridge_parachains::ParachainHeaders<
Runtime,
BridgeParachainWestendInstance,
bp_bridge_hub_westend::BridgeHubWestend,
>;

type ActiveOutboundLanes = ActiveOutboundLanesToBridgeHubWestend;
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane;

type MaximalOutboundPayloadSize = ToBridgeHubWestendMaximalOutboundPayloadSize;
type OutboundPayload = XcmAsPlainPayload;

type InboundPayload = XcmAsPlainPayload;
type InboundRelayer = AccountId;
type DeliveryPayments = ();

type TargetHeaderChain = TargetHeaderChainAdapter<WithBridgeHubWestendMessageBridge>;
type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter<
Runtime,
WithBridgeHubWestendMessagesInstance,
DeliveryRewardInBalance,
>;

type SourceHeaderChain = SourceHeaderChainAdapter<WithBridgeHubWestendMessageBridge>;
type MessageDispatch = XcmBlobMessageDispatch<
FromWestendMessageBlobDispatcher,
Self::WeightInfo,
Expand Down Expand Up @@ -248,9 +211,8 @@ mod tests {
assert_complete_bridge_types,
extensions::refund_relayer_extension::RefundableParachain,
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,
},
};
use parachains_common::Balance;
Expand Down Expand Up @@ -292,36 +254,20 @@ mod tests {
runtime: Runtime,
with_bridged_chain_grandpa_instance: BridgeGrandpaWestendInstance,
with_bridged_chain_messages_instance: WithBridgeHubWestendMessagesInstance,
bridge: WithBridgeHubWestendMessageBridge,
this_chain: bp_rococo::Rococo,
bridged_chain: bp_westend::Westend,
this_chain: bp_bridge_hub_rococo::BridgeHubRococo,
bridged_chain: bp_bridge_hub_westend::BridgeHubWestend,
);

assert_complete_bridge_constants::<
assert_complete_with_parachain_bridge_constants::<
Runtime,
BridgeGrandpaWestendInstance,
WithBridgeHubWestendMessagesInstance,
WithBridgeHubWestendMessageBridge,
bp_westend::Westend,
>(AssertCompleteBridgeConstants {
this_chain_constants: AssertChainConstants {
block_length: bp_bridge_hub_rococo::BlockLength::get(),
block_weights: bp_bridge_hub_rococo::BlockWeightsForAsyncBacking::get(),
},
messages_pallet_constants: AssertBridgeMessagesPalletConstants {
max_unrewarded_relayers_in_bridged_confirmation_tx:
bp_bridge_hub_westend::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
max_unconfirmed_messages_in_bridged_confirmation_tx:
bp_bridge_hub_westend::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
bridged_chain_id: BridgeHubWestend::ID,
},
pallet_names: AssertBridgePalletNames {
with_this_chain_messages_pallet_name:
bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME,
with_bridged_chain_grandpa_pallet_name:
bp_westend::WITH_WESTEND_GRANDPA_PALLET_NAME,
with_bridged_chain_messages_pallet_name:
bp_bridge_hub_westend::WITH_BRIDGE_HUB_WESTEND_MESSAGES_PALLET_NAME,
},
});

bridge_runtime_common::extensions::priority_calculator::per_relay_header::ensure_priority_boost_is_sane::<
Expand All @@ -332,7 +278,7 @@ mod tests {

bridge_runtime_common::extensions::priority_calculator::per_parachain_header::ensure_priority_boost_is_sane::<
Runtime,
RefundableParachain<WithBridgeHubWestendMessagesInstance, BridgeHubWestend>,
RefundableParachain<WithBridgeHubWestendMessagesInstance, bp_bridge_hub_westend::BridgeHubWestend>,
PriorityBoostPerParachainHeader,
>(FEE_BOOST_PER_PARACHAIN_HEADER);

Expand Down
Loading

0 comments on commit f0f50af

Please sign in to comment.