22
33use crate :: {
44 xcm_config:: { decode_bridge_message, XcmConfig } ,
5- AccountId , BridgePolkadotGrandpa , ConstU32 , Runtime , RuntimeEvent , RuntimeOrigin ,
5+ ConstU32 , Runtime , RuntimeEvent ,
66} ;
77use bp_messages:: {
88 source_chain:: MessagesBridge ,
99 target_chain:: { DispatchMessage , MessageDispatch } ,
10- LegacyLaneId , MessageNonce ,
10+ LegacyLaneId ,
1111} ;
1212use bp_parachains:: SingleParaStoredHeaderDataBuilder ;
13- use bp_runtime:: { messages:: MessageDispatchResult , ChainId , UnderlyingChainProvider } ;
13+ use bp_runtime:: messages:: MessageDispatchResult ;
1414use codec:: { Decode , Encode } ;
15- // use bridge_runtime_common::{
16- // messages::{
17- // source::{
18- // FromThisChainMaximalOutboundPayloadSize, FromThisChainMessageVerifier,
19- // TargetHeaderChainAdapter,
20- // },
21- // target::SourceHeaderChainAdapter,
22- // BridgedChainWithMessages, MessageBridge, ThisChainWithMessages,
23- // },
24- // messages_xcm_extension::{
25- // SenderAndLane, XcmBlobHauler, XcmBlobHaulerAdapter, XcmBlobMessageDispatch,
26- // },
27- // };
2815use frame_support:: { parameter_types, CloneNoBound , EqNoBound , PartialEqNoBound } ;
2916use pallet_xcm_bridge_hub:: XcmAsPlainPayload ;
3017use scale_info:: TypeInfo ;
31- use sp_runtime:: {
32- transaction_validity:: { InvalidTransaction , TransactionValidity } ,
33- RuntimeDebug , SaturatedConversion ,
34- } ;
35- use sp_std:: { marker:: PhantomData , vec:: Vec } ;
36- use xcm:: prelude:: * ;
18+ use sp_runtime:: SaturatedConversion ;
19+ use sp_std:: marker:: PhantomData ;
20+ use xcm:: { latest:: ROCOCO_GENESIS_HASH , prelude:: * } ;
3721use xcm_builder:: { DispatchBlob , DispatchBlobError , HaulBlob , HaulBlobError , HaulBlobExporter } ;
3822use xcm_executor:: XcmExecutor ;
3923
4024/// Lane that we are using to send and receive messages.
4125pub const XCM_LANE : LegacyLaneId = LegacyLaneId ( [ 0 , 0 , 0 , 0 ] ) ;
4226
4327parameter_types ! {
44- pub PolkadotGlobalConsensusNetwork : NetworkId = NetworkId :: Polkadot ;
45- pub PolkadotGlobalConsensusNetworkLocation : Location = Location :: new(
28+ pub RococoGlobalConsensusNetwork : NetworkId = NetworkId :: ByGenesis ( ROCOCO_GENESIS_HASH ) ;
29+ pub BridgedNetwork : NetworkId = RococoGlobalConsensusNetwork :: get( ) ;
30+ pub RococoGlobalConsensusNetworkLocation : Location = Location :: new(
4631 1 ,
47- [ GlobalConsensus ( PolkadotGlobalConsensusNetwork :: get( ) ) ]
32+ [ GlobalConsensus ( RococoGlobalConsensusNetwork :: get( ) ) ]
4833 ) ;
34+
4935 /// A number of Polkadot mandatory headers that are accepted for free at every
5036 /// **this chain** block.
51- pub const MaxFreePolkadotHeadersPerBlock : u32 = 4 ;
37+ pub const MaxFreeRococoHeadersPerBlock : u32 = 4 ;
5238 /// A number of Polkadot header digests that we keep in the storage.
53- pub const PolkadotHeadersToKeep : u32 = 1024 ;
39+ pub const RococoHeadersToKeep : u32 = 1024 ;
5440 /// A name of parachains pallet at Pokadot.
55- pub const AtPolkadotParasPalletName : & ' static str = bp_polkadot :: PARAS_PALLET_NAME ;
41+ pub const AtRococoParasPalletName : & ' static str = bp_rococo :: PARAS_PALLET_NAME ;
5642
5743// /// Chain identifier of Polkadot Bridge Hub.
5844// pub const BridgeHubPolkadotChainId: ChainId = bp_runtime::BRIDGE_HUB_POLKADOT_CHAIN_ID;
5945 /// A number of Polkadot Bridge Hub head digests that we keep in the storage.
60- pub const BridgeHubPolkadotHeadsToKeep : u32 = 1024 ;
46+ pub const BridgeHubRococoHeadsToKeep : u32 = 1024 ;
6147 /// A maximal size of Polkadot Bridge Hub head digest.
62- pub const MaxPolkadotBridgeHubHeadSize : u32 = bp_polkadot :: MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE ;
48+ pub const MaxBridgeHubRococoHeadSize : u32 = bp_rococo :: MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE ;
6349
6450// /// All active outbound lanes.
6551// pub const ActiveOutboundLanes: &'static [LaneId] = &[XCM_LANE];
@@ -80,21 +66,6 @@ parameter_types! {
8066// pub NeverSentMessage: Option<Xcm<()>> = None;
8167}
8268
83- /// Bridged chain global consensus network.
84- pub struct BridgedNetwork ;
85-
86- impl sp_runtime:: traits:: Get < NetworkId > for BridgedNetwork {
87- #[ cfg( not( feature = "rococo" ) ) ]
88- fn get ( ) -> NetworkId {
89- Polkadot
90- }
91-
92- #[ cfg( feature = "rococo" ) ]
93- fn get ( ) -> NetworkId {
94- Rococo
95- }
96- }
97-
9869// impl bp_runtime::Parachain for BridgeHubPolkadotOrRococo {
9970// #[cfg(not(feature = "rococo"))]
10071// const PARACHAIN_ID: u32 = bp_bridge_hub_polkadot::BridgeHubPolkadot::PARACHAIN_ID;
@@ -103,29 +74,29 @@ impl sp_runtime::traits::Get<NetworkId> for BridgedNetwork {
10374// }
10475//
10576/// An instance of `pallet_bridge_grandpa` used to bridge with Polkadot.
106- pub type WithPolkadotBridgeGrandpaInstance = ( ) ;
107- impl pallet_bridge_grandpa:: Config < WithPolkadotBridgeGrandpaInstance > for Runtime {
77+ pub type WithRococoBridgeGrandpaInstance = ( ) ;
78+ impl pallet_bridge_grandpa:: Config < WithRococoBridgeGrandpaInstance > for Runtime {
10879 type RuntimeEvent = RuntimeEvent ;
10980 type WeightInfo = crate :: weights:: bridge_polkadot_grandpa:: WeightInfo < Runtime > ;
11081
111- type BridgedChain = bp_polkadot :: Polkadot ;
112- type MaxFreeHeadersPerBlock = MaxFreePolkadotHeadersPerBlock ;
82+ type BridgedChain = bp_rococo :: Rococo ;
83+ type MaxFreeHeadersPerBlock = MaxFreeRococoHeadersPerBlock ;
11384 type FreeHeadersInterval = ConstU32 < 5 > ;
114- type HeadersToKeep = PolkadotHeadersToKeep ;
85+ type HeadersToKeep = RococoHeadersToKeep ;
11586}
11687
11788/// An instance of `pallet_bridge_parachains` used to bridge with Polkadot.
118- pub type WithPolkadotBridgeParachainsInstance = ( ) ;
119- impl pallet_bridge_parachains:: Config < WithPolkadotBridgeParachainsInstance > for Runtime {
89+ pub type WithRococoBridgeParachainsInstance = ( ) ;
90+ impl pallet_bridge_parachains:: Config < WithRococoBridgeParachainsInstance > for Runtime {
12091 type RuntimeEvent = RuntimeEvent ;
12192 type WeightInfo = crate :: weights:: bridge_polkadot_parachains:: WeightInfo < Runtime > ;
12293
123- type BridgesGrandpaPalletInstance = WithPolkadotBridgeGrandpaInstance ;
124- type ParasPalletName = AtPolkadotParasPalletName ;
94+ type BridgesGrandpaPalletInstance = WithRococoBridgeGrandpaInstance ;
95+ type ParasPalletName = AtRococoParasPalletName ;
12596 type ParaStoredHeaderDataBuilder =
126- SingleParaStoredHeaderDataBuilder < bp_bridge_hub_polkadot :: BridgeHubPolkadot > ;
127- type HeadsToKeep = BridgeHubPolkadotHeadsToKeep ;
128- type MaxParaHeadDataSize = MaxPolkadotBridgeHubHeadSize ;
97+ SingleParaStoredHeaderDataBuilder < bp_bridge_hub_rococo :: BridgeHubRococo > ;
98+ type HeadsToKeep = BridgeHubRococoHeadsToKeep ;
99+ type MaxParaHeadDataSize = MaxBridgeHubRococoHeadSize ;
129100}
130101
131102const LOG_TARGET_BRIDGE_DISPATCH : & str = "runtime::bridge-dispatch" ;
@@ -211,17 +182,17 @@ impl<BlobDispatcher: DispatchBlob, Weights: pallet_bridge_messages::WeightInfoEx
211182}
212183
213184/// An instance of `pallet_bridge_messages` used to bridge with Polkadot Bridge Hub.
214- pub type WithBridgeHubPolkadotMessagesInstance = ( ) ;
215- impl pallet_bridge_messages:: Config < WithBridgeHubPolkadotMessagesInstance > for Runtime {
185+ pub type WithBridgeHubRococoMessagesInstance = ( ) ;
186+ impl pallet_bridge_messages:: Config < WithBridgeHubRococoMessagesInstance > for Runtime {
216187 type RuntimeEvent = RuntimeEvent ;
217188 type WeightInfo = crate :: weights:: bridge_polkadot_messages:: WeightInfo < Runtime > ;
218189
219190 type ThisChain = bp_polkadot_bulletin:: PolkadotBulletin ;
220- type BridgedChain = bp_bridge_hub_polkadot :: BridgeHubPolkadot ;
191+ type BridgedChain = bp_bridge_hub_rococo :: BridgeHubRococo ;
221192 type BridgedHeaderChain = pallet_bridge_parachains:: ParachainHeaders <
222193 Runtime ,
223- WithPolkadotBridgeParachainsInstance ,
224- bp_bridge_hub_polkadot :: BridgeHubPolkadot ,
194+ WithRococoBridgeParachainsInstance ,
195+ bp_bridge_hub_rococo :: BridgeHubRococo ,
225196 > ;
226197
227198 type OutboundPayload = XcmAsPlainPayload ;
@@ -232,7 +203,7 @@ impl pallet_bridge_messages::Config<WithBridgeHubPolkadotMessagesInstance> for R
232203 type DeliveryConfirmationPayments = ( ) ;
233204
234205 type MessageDispatch = WithXcmWeightDispatcher <
235- XcmBlobMessageDispatch < FromBridgeHubPolkadotBlobDispatcher , Self :: WeightInfo > ,
206+ XcmBlobMessageDispatch < FromBridgeHubRococoBlobDispatcher , Self :: WeightInfo > ,
236207 > ;
237208 type OnMessagesDelivered = ( ) ;
238209}
@@ -278,7 +249,7 @@ where
278249}
279250
280251/// Dispatches received XCM messages from the Polkadot Bridge Hub.
281- pub type FromBridgeHubPolkadotBlobDispatcher = crate :: xcm_config:: ImmediateXcmDispatcher ;
252+ pub type FromBridgeHubRococoBlobDispatcher = crate :: xcm_config:: ImmediateXcmDispatcher ;
282253
283254pub struct XcmBlobHauler < Runtime , MessagesInstance > {
284255 _marker : PhantomData < ( Runtime , MessagesInstance ) > ,
@@ -322,9 +293,9 @@ where
322293}
323294
324295/// Export XCM messages to be relayed to the Polkadot Bridge Hub chain.
325- pub type ToBridgeHubPolkadotHaulBlobExporter = HaulBlobExporter <
326- XcmBlobHauler < Runtime , WithBridgeHubPolkadotMessagesInstance > ,
327- PolkadotGlobalConsensusNetworkLocation ,
296+ pub type ToBridgeHubRococoHaulBlobExporter = HaulBlobExporter <
297+ XcmBlobHauler < Runtime , WithBridgeHubRococoMessagesInstance > ,
298+ RococoGlobalConsensusNetworkLocation ,
328299 AlwaysV4 ,
329300 ( ) ,
330301> ;
0 commit comments