diff --git a/bridges/bin/millau/node/src/chain_spec.rs b/bridges/bin/millau/node/src/chain_spec.rs index 5c11f07df2..846dfa6930 100644 --- a/bridges/bin/millau/node/src/chain_spec.rs +++ b/bridges/bin/millau/node/src/chain_spec.rs @@ -70,10 +70,7 @@ impl Alternative { let properties = Some( serde_json::json!({ "tokenDecimals": 9, - "tokenSymbol": "MLAU", - "bridgeIds": { - "Rialto": bp_runtime::RIALTO_CHAIN_ID, - } + "tokenSymbol": "MLAU" }) .as_object() .expect("Map given; qed") diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 8d9f5edcf1..cc004b8629 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -362,6 +362,7 @@ parameter_types! { pub const GetDeliveryConfirmationTransactionFee: Balance = bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT as _; pub const RootAccountForPayments: Option = None; + pub const BridgedChainId: bp_runtime::ChainId = bp_runtime::RIALTO_CHAIN_ID; } /// Instance of the messages pallet used to relay messages to/from Rialto chain. @@ -397,6 +398,7 @@ impl pallet_bridge_messages::Config for Runtime { type SourceHeaderChain = crate::rialto_messages::Rialto; type MessageDispatch = crate::rialto_messages::FromRialtoMessageDispatch; + type BridgedChainId = BridgedChainId; } construct_runtime!( diff --git a/bridges/bin/rialto/node/src/chain_spec.rs b/bridges/bin/rialto/node/src/chain_spec.rs index a0d9a89ce1..99645e14cb 100644 --- a/bridges/bin/rialto/node/src/chain_spec.rs +++ b/bridges/bin/rialto/node/src/chain_spec.rs @@ -71,10 +71,7 @@ impl Alternative { let properties = Some( json!({ "tokenDecimals": 9, - "tokenSymbol": "RLT", - "bridgeIds": { - "Millau": bp_runtime::MILLAU_CHAIN_ID, - } + "tokenSymbol": "RLT" }) .as_object() .expect("Map given; qed") diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 3a40139d6d..a1b36dd059 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -490,6 +490,7 @@ parameter_types! { pub const GetDeliveryConfirmationTransactionFee: Balance = bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT as _; pub const RootAccountForPayments: Option = None; + pub const BridgedChainId: bp_runtime::ChainId = bp_runtime::MILLAU_CHAIN_ID; } /// Instance of the messages pallet used to relay messages to/from Millau chain. @@ -524,6 +525,7 @@ impl pallet_bridge_messages::Config for Runtime { type SourceHeaderChain = crate::millau_messages::Millau; type MessageDispatch = crate::millau_messages::FromMillauMessageDispatch; + type BridgedChainId = BridgedChainId; } construct_runtime!( diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs index 842c28bd4b..8f7a6c8b71 100644 --- a/bridges/modules/messages/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -54,7 +54,7 @@ use bp_messages::{ total_unrewarded_messages, DeliveredMessages, InboundLaneData, LaneId, MessageData, MessageKey, MessageNonce, OperatingMode, OutboundLaneData, Parameter as MessagesParameter, UnrewardedRelayersState, }; -use bp_runtime::Size; +use bp_runtime::{ChainId, Size}; use codec::{Decode, Encode}; use frame_support::{ decl_error, decl_event, decl_module, decl_storage, @@ -161,6 +161,9 @@ pub trait Config: frame_system::Config { Self::InboundMessageFee, DispatchPayload = Self::InboundPayload, >; + + /// Chain Id for the bridged chain. + type BridgedChainId: Get; } /// Shortcut to messages proof type for Config. @@ -255,6 +258,9 @@ decl_module! { /// Deposit one of this module's events by using the default implementation. fn deposit_event() = default; + /// Gets the chain id value from the instance. + const BridgedChainId: ChainId = T::BridgedChainId::get(); + /// Ensure runtime invariants. fn on_runtime_upgrade() -> Weight { let reads = T::MessageDeliveryAndDispatchPayment::initialize( diff --git a/bridges/modules/messages/src/mock.rs b/bridges/modules/messages/src/mock.rs index f2a42ab55e..77a421b341 100644 --- a/bridges/modules/messages/src/mock.rs +++ b/bridges/modules/messages/src/mock.rs @@ -142,6 +142,7 @@ parameter_types! { pub const MaxUnrewardedRelayerEntriesAtInboundLane: u64 = 16; pub const MaxUnconfirmedMessagesAtInboundLane: u64 = 32; pub storage TokenConversionRate: FixedU128 = 1.into(); + pub const TestBridgedChainId: bp_runtime::ChainId = *b"test"; } #[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)] @@ -181,6 +182,7 @@ impl Config for TestRuntime { type SourceHeaderChain = TestSourceHeaderChain; type MessageDispatch = TestMessageDispatch; + type BridgedChainId = TestBridgedChainId; } impl Size for TestPayload {