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 20, 2024
1 parent 72770f5 commit 55b3aea
Show file tree
Hide file tree
Showing 21 changed files with 402 additions and 945 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;
}
6 changes: 4 additions & 2 deletions bridges/modules/messages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,25 @@ std = [
"scale-info/std",
"sp-runtime/std",
"sp-std/std",
"sp-trie/std"
"sp-trie/std",
]
runtime-benchmarks = [
"bp-runtime/test-helpers",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-bridge-grandpa/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"pallet-bridge-grandpa/try-runtime",
"sp-runtime/try-runtime",
]
test-helpers = [
"bp-runtime/test-helpers",
"sp-trie",
"bp-runtime/test-helpers"
]
2 changes: 1 addition & 1 deletion bridges/primitives/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ workspace = true
bp-header-chain = { path = "../header-chain", default-features = false }
bp-parachains = { path = "../parachains", default-features = false }
bp-polkadot-core = { path = "../polkadot-core", default-features = false }
bp-runtime = { path = "../runtime", default-features = false }
bp-runtime = { path = "../runtime", default-features = false, features = ["test-helpers"] }
codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false }
ed25519-dalek = { version = "2.1", default-features = false }
finality-grandpa = { version = "0.16.2", default-features = false }
Expand Down
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
Loading

0 comments on commit 55b3aea

Please sign in to comment.