Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Feb 15, 2024
1 parent a29757d commit 38ca491
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
pub use bp_bridge_hub_cumulus::*;
use bp_messages::*;
use bp_runtime::{
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain,
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain,
};
use frame_support::{
dispatch::DispatchClass,
Expand All @@ -35,6 +35,8 @@ use sp_runtime::{FixedPointNumber, FixedU128, RuntimeDebug, Saturating};
pub struct BridgeHubKusama;

impl Chain for BridgeHubKusama {
const ID: ChainId = *b"bhks";

type BlockNumber = BlockNumber;
type Hash = Hash;
type Hasher = Hasher;
Expand All @@ -61,6 +63,15 @@ impl Parachain for BridgeHubKusama {
const PARACHAIN_ID: u32 = BRIDGE_HUB_KUSAMA_PARACHAIN_ID;
}

impl ChainWithMessages for BridgeHubKusama {
const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
WITH_BRIDGE_HUB_KUSAMA_MESSAGES_PALLET_NAME;
const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
}

/// Public key of the chain account that may be used to verify signatures.
pub type AccountSigner = MultiSigner;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::{
};
use bp_messages::LaneId;
use bp_parachains::SingleParaStoredHeaderDataBuilder;
use bp_runtime::Chain;
use bridge_runtime_common::{
messages,
messages::{
Expand Down Expand Up @@ -137,7 +138,7 @@ parameter_types! {
pub const MaxParaHeadDataSize: u32 = bp_polkadot::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE;

/// Bridge specific chain (network) identifier of the Polkadot Bridge Hub.
pub const BridgeHubPolkadotChainId: bp_runtime::ChainId = bp_runtime::BRIDGE_HUB_POLKADOT_CHAIN_ID;
pub const BridgeHubPolkadotChainId: bp_runtime::ChainId = bp_bridge_hub_polkadot::BridgeHubPolkadot::ID;
/// Name of the `paras` pallet at Polkadot that tracks all parachain heads.
pub const ParachainPalletNameAtPolkadot: &'static str = bp_polkadot::PARAS_PALLET_NAME;

Expand Down Expand Up @@ -221,7 +222,6 @@ impl pallet_bridge_messages::Config<WithBridgeHubPolkadotMessagesInstance> for R
type DeliveryPayments = ();

type TargetHeaderChain = TargetHeaderChainAdapter<WithBridgeHubPolkadotMessageBridge>;
type LaneMessageVerifier = ToBridgeHubPolkadotMessageVerifier;
type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter<
Runtime,
WithBridgeHubPolkadotMessagesInstance,
Expand Down Expand Up @@ -300,10 +300,6 @@ impl MessageBridge for WithBridgeHubPolkadotMessageBridge {
>;
}

/// Message verifier for BridgeHubPolkadot messages sent from BridgeHubKusama
pub type ToBridgeHubPolkadotMessageVerifier =
messages::source::FromThisChainMessageVerifier<WithBridgeHubPolkadotMessageBridge>;

/// Maximal outbound payload size of BridgeHubKusama -> BridgeHubPolkadot messages.
pub type ToBridgeHubPolkadotMaximalOutboundPayloadSize =
messages::source::FromThisChainMaximalOutboundPayloadSize<WithBridgeHubPolkadotMessageBridge>;
Expand Down Expand Up @@ -412,7 +408,7 @@ mod tests {
bp_bridge_hub_polkadot::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
max_unconfirmed_messages_in_bridged_confirmation_tx:
bp_bridge_hub_polkadot::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
bridged_chain_id: bp_runtime::BRIDGE_HUB_POLKADOT_CHAIN_ID,
bridged_chain_id: bp_bridge_hub_polkadot::BridgeHubPolkadot::ID,
},
pallet_names: AssertBridgePalletNames {
with_this_chain_messages_pallet_name:
Expand Down
2 changes: 1 addition & 1 deletion system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ impl_runtime_apis! {
impl BridgeMessagesConfig<bridge_to_polkadot_config::WithBridgeHubPolkadotMessagesInstance> for Runtime {
fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool {
let bench_lane_id = <Self as BridgeMessagesConfig<bridge_to_polkadot_config::WithBridgeHubPolkadotMessagesInstance>>::bench_lane_id();
let bridged_chain_id = bp_runtime::BRIDGE_HUB_POLKADOT_CHAIN_ID;
let bridged_chain_id = bridge_to_polkadot_config::BridgeHubPolkadotChainId::get();
pallet_bridge_relayers::Pallet::<Runtime>::relayer_reward(
relayer,
bp_relayers::RewardsAccountParams::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
pub use bp_bridge_hub_cumulus::*;
use bp_messages::*;
use bp_runtime::{
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain,
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain,
};
use frame_support::dispatch::DispatchClass;
use sp_runtime::{FixedPointNumber, FixedU128, RuntimeDebug, Saturating};
Expand All @@ -32,6 +32,8 @@ use sp_runtime::{FixedPointNumber, FixedU128, RuntimeDebug, Saturating};
pub struct BridgeHubPolkadot;

impl Chain for BridgeHubPolkadot {
const ID: ChainId = *b"bhpd";

type BlockNumber = BlockNumber;
type Hash = Hash;
type Hasher = Hasher;
Expand All @@ -58,6 +60,15 @@ impl Parachain for BridgeHubPolkadot {
const PARACHAIN_ID: u32 = BRIDGE_HUB_POLKADOT_PARACHAIN_ID;
}

impl ChainWithMessages for BridgeHubPolkadot {
const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
WITH_BRIDGE_HUB_POLKADOT_MESSAGES_PALLET_NAME;
const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
}

/// Identifier of BridgeHubPolkadot in the Polkadot relay chain.
pub const BRIDGE_HUB_POLKADOT_PARACHAIN_ID: u32 = 1002;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::{
};
use bp_messages::LaneId;
use bp_parachains::SingleParaStoredHeaderDataBuilder;
use bp_runtime::Chain;
use bridge_runtime_common::{
messages,
messages::{
Expand Down Expand Up @@ -137,7 +138,7 @@ parameter_types! {
pub const MaxParaHeadDataSize: u32 = bp_kusama::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE;

/// Bridge specific chain (network) identifier of the Kusama Bridge Hub.
pub const BridgeHubKusamaChainId: bp_runtime::ChainId = bp_runtime::BRIDGE_HUB_KUSAMA_CHAIN_ID;
pub const BridgeHubKusamaChainId: bp_runtime::ChainId = bp_bridge_hub_kusama::BridgeHubKusama::ID;
/// Name of the `paras` pallet at Kusama that tracks all parachain heads.
pub const ParachainPalletNameAtKusama: &'static str = bp_kusama::PARAS_PALLET_NAME;

Expand Down Expand Up @@ -221,7 +222,6 @@ impl pallet_bridge_messages::Config<WithBridgeHubKusamaMessagesInstance> for Run
type DeliveryPayments = ();

type TargetHeaderChain = TargetHeaderChainAdapter<WithBridgeHubKusamaMessageBridge>;
type LaneMessageVerifier = ToBridgeHubKusamaMessageVerifier;
type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter<
Runtime,
WithBridgeHubKusamaMessagesInstance,
Expand Down Expand Up @@ -299,10 +299,6 @@ impl MessageBridge for WithBridgeHubKusamaMessageBridge {
>;
}

/// Message verifier for BridgeHubKusama messages sent from BridgeHubPolkadot
pub type ToBridgeHubKusamaMessageVerifier =
messages::source::FromThisChainMessageVerifier<WithBridgeHubKusamaMessageBridge>;

/// Maximal outbound payload size of BridgeHubPolkadot -> BridgeHubKusama messages.
pub type ToBridgeHubKusamaMaximalOutboundPayloadSize =
messages::source::FromThisChainMaximalOutboundPayloadSize<WithBridgeHubKusamaMessageBridge>;
Expand Down Expand Up @@ -408,7 +404,7 @@ mod tests {
bp_bridge_hub_kusama::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
max_unconfirmed_messages_in_bridged_confirmation_tx:
bp_bridge_hub_kusama::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
bridged_chain_id: bp_runtime::BRIDGE_HUB_KUSAMA_CHAIN_ID,
bridged_chain_id: bp_bridge_hub_kusama::BridgeHubKusama::ID,
},
pallet_names: AssertBridgePalletNames {
with_this_chain_messages_pallet_name:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ impl_runtime_apis! {
impl BridgeMessagesConfig<bridge_to_kusama_config::WithBridgeHubKusamaMessagesInstance> for Runtime {
fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool {
let bench_lane_id = <Self as BridgeMessagesConfig<bridge_to_kusama_config::WithBridgeHubKusamaMessagesInstance>>::bench_lane_id();
let bridged_chain_id = bp_runtime::BRIDGE_HUB_KUSAMA_CHAIN_ID;
let bridged_chain_id = bridge_to_kusama_config::BridgeHubKusamaChainId::get();
pallet_bridge_relayers::Pallet::<Runtime>::relayer_reward(
relayer,
bp_relayers::RewardsAccountParams::new(
Expand Down

0 comments on commit 38ca491

Please sign in to comment.