Skip to content

Commit 8fc7cbb

Browse files
committed
Bridge to Rococo
1 parent 055feee commit 8fc7cbb

File tree

5 files changed

+70
-83
lines changed

5 files changed

+70
-83
lines changed

Cargo.lock

Lines changed: 23 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ bp-parachains = { git = "https://github.com/paritytech/polkadot-sdk.git", rev =
6666
bp-polkadot = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "0e09ad448bce27fcd255370cc2827ea5d2cf3892", default-features = false }
6767
bp-polkadot-bulletin = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "0e09ad448bce27fcd255370cc2827ea5d2cf3892", default-features = false }
6868
bp-polkadot-core = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "0e09ad448bce27fcd255370cc2827ea5d2cf3892", default-features = false }
69+
bp-rococo = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "0e09ad448bce27fcd255370cc2827ea5d2cf3892", default-features = false }
6970
bp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "0e09ad448bce27fcd255370cc2827ea5d2cf3892", default-features = false }
7071
bridge-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "0e09ad448bce27fcd255370cc2827ea5d2cf3892", default-features = false }
7172
pallet-bridge-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "0e09ad448bce27fcd255370cc2827ea5d2cf3892", default-features = false }
@@ -143,6 +144,7 @@ std = [
143144
"bp-polkadot/std",
144145
"bp-polkadot-bulletin/std",
145146
"bp-polkadot-core/std",
147+
"bp-rococo/std",
146148
"bp-runtime/std",
147149
"bridge-runtime-common/std",
148150
"pallet-bridge-grandpa/std",

runtime/src/bridge_config.rs

Lines changed: 38 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,50 @@
22
33
use crate::{
44
xcm_config::{decode_bridge_message, XcmConfig},
5-
AccountId, BridgePolkadotGrandpa, ConstU32, Runtime, RuntimeEvent, RuntimeOrigin,
5+
ConstU32, Runtime, RuntimeEvent,
66
};
77
use bp_messages::{
88
source_chain::MessagesBridge,
99
target_chain::{DispatchMessage, MessageDispatch},
10-
LegacyLaneId, MessageNonce,
10+
LegacyLaneId,
1111
};
1212
use bp_parachains::SingleParaStoredHeaderDataBuilder;
13-
use bp_runtime::{messages::MessageDispatchResult, ChainId, UnderlyingChainProvider};
13+
use bp_runtime::messages::MessageDispatchResult;
1414
use 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-
// };
2815
use frame_support::{parameter_types, CloneNoBound, EqNoBound, PartialEqNoBound};
2916
use pallet_xcm_bridge_hub::XcmAsPlainPayload;
3017
use 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::*};
3721
use xcm_builder::{DispatchBlob, DispatchBlobError, HaulBlob, HaulBlobError, HaulBlobExporter};
3822
use xcm_executor::XcmExecutor;
3923

4024
/// Lane that we are using to send and receive messages.
4125
pub const XCM_LANE: LegacyLaneId = LegacyLaneId([0, 0, 0, 0]);
4226

4327
parameter_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

131102
const 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

283254
pub 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
>;

runtime/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ impl_runtime_apis! {
776776

777777
fn free_headers_interval() -> Option<u32> {
778778
<Runtime as pallet_bridge_grandpa::Config<
779-
bridge_config::WithPolkadotBridgeGrandpaInstance
779+
bridge_config::WithRococoBridgeGrandpaInstance
780780
>>::FreeHeadersInterval::get()
781781
}
782782
}
@@ -801,7 +801,7 @@ impl_runtime_apis! {
801801
) -> Vec<bp_messages::InboundMessageDetails> {
802802
bridge_runtime_common::messages_api::inbound_message_details::<
803803
Runtime,
804-
bridge_config::WithBridgeHubPolkadotMessagesInstance,
804+
bridge_config::WithBridgeHubRococoMessagesInstance,
805805
>(lane, messages)
806806
}
807807
}
@@ -814,7 +814,7 @@ impl_runtime_apis! {
814814
) -> Vec<bp_messages::OutboundMessageDetails> {
815815
bridge_runtime_common::messages_api::outbound_message_details::<
816816
Runtime,
817-
bridge_config::WithBridgeHubPolkadotMessagesInstance,
817+
bridge_config::WithBridgeHubRococoMessagesInstance,
818818
>(lane, begin, end)
819819
}
820820
}

runtime/src/xcm_config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! XCM configuration for Polkadot Bulletin chain.
1818
1919
use crate::{
20-
bridge_config::{BridgedNetwork, ToBridgeHubPolkadotHaulBlobExporter},
20+
bridge_config::{BridgedNetwork, ToBridgeHubRococoHaulBlobExporter},
2121
AllPalletsWithSystem, RuntimeCall, RuntimeOrigin,
2222
};
2323

@@ -28,7 +28,7 @@ use frame_support::{
2828
weights::Weight,
2929
};
3030
use pallet_xcm_bridge_hub::XcmAsPlainPayload;
31-
use sp_core::{ConstU32, Get};
31+
use sp_core::ConstU32;
3232
use sp_io::hashing::blake2_256;
3333
use xcm::{latest::prelude::*, VersionedInteriorLocation, VersionedXcm, MAX_XCM_DECODE_DEPTH};
3434
use xcm_builder::{
@@ -171,7 +171,7 @@ type LocalOriginConverter = (
171171
);
172172

173173
/// Only bridged destination is supported.
174-
pub type XcmRouter = UnpaidLocalExporter<ToBridgeHubPolkadotHaulBlobExporter, UniversalLocation>;
174+
pub type XcmRouter = UnpaidLocalExporter<ToBridgeHubRococoHaulBlobExporter, UniversalLocation>;
175175

176176
/// The barriers one of which must be passed for an XCM message to be executed.
177177
pub type Barrier = TrailingSetTopicAsId<
@@ -208,7 +208,7 @@ impl xcm_executor::Config for XcmConfig {
208208
type PalletInstancesInfo = AllPalletsWithSystem;
209209
type MaxAssetsIntoHolding = ConstU32<0>;
210210
type FeeManager = ();
211-
type MessageExporter = ToBridgeHubPolkadotHaulBlobExporter;
211+
type MessageExporter = ToBridgeHubRococoHaulBlobExporter;
212212
type UniversalAliases = UniversalAliases;
213213
type CallDispatcher = WithOriginFilter<Everything>;
214214
type SafeCallFilter = Everything;

0 commit comments

Comments
 (0)