diff --git a/Cargo.lock b/Cargo.lock index af14ecfb3343c..afb4d9aae9442 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1991,6 +1991,9 @@ dependencies = [ name = "bp-asset-hub-rococo" version = "0.4.0" dependencies = [ + "bp-bridge-hub-cumulus", + "bp-messages", + "bp-runtime", "bp-xcm-bridge-hub-router", "frame-support", "parity-scale-codec", @@ -2004,6 +2007,9 @@ dependencies = [ name = "bp-asset-hub-westend" version = "0.3.0" dependencies = [ + "bp-bridge-hub-cumulus", + "bp-messages", + "bp-runtime", "bp-xcm-bridge-hub-router", "frame-support", "parity-scale-codec", diff --git a/bridges/chains/chain-asset-hub-rococo/Cargo.toml b/bridges/chains/chain-asset-hub-rococo/Cargo.toml index 16425544076e1..ac194d5656bd5 100644 --- a/bridges/chains/chain-asset-hub-rococo/Cargo.toml +++ b/bridges/chains/chain-asset-hub-rococo/Cargo.toml @@ -22,6 +22,9 @@ frame-support = { workspace = true } sp-core = { workspace = true } # Bridge Dependencies +bp-bridge-hub-cumulus = { workspace = true } +bp-messages = { workspace = true } +bp-runtime = { workspace = true } bp-xcm-bridge-hub-router = { workspace = true } testnet-parachains-constants = { features = ["rococo"], workspace = true } @@ -31,6 +34,9 @@ xcm = { workspace = true } [features] default = ["std"] std = [ + "bp-bridge-hub-cumulus/std", + "bp-messages/std", + "bp-runtime/std", "bp-xcm-bridge-hub-router/std", "codec/std", "frame-support/std", diff --git a/bridges/chains/chain-asset-hub-rococo/src/lib.rs b/bridges/chains/chain-asset-hub-rococo/src/lib.rs index f4fb78b4e1d63..7c4f2107e001b 100644 --- a/bridges/chains/chain-asset-hub-rococo/src/lib.rs +++ b/bridges/chains/chain-asset-hub-rococo/src/lib.rs @@ -23,7 +23,14 @@ extern crate alloc; use codec::{Decode, Encode}; use scale_info::TypeInfo; +pub use bp_bridge_hub_cumulus::*; +use bp_messages::*; +use bp_runtime::{Chain, ChainId, Parachain}; pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall; +use frame_support::{ + dispatch::DispatchClass, + sp_runtime::{RuntimeDebug, StateVersion}, +}; use testnet_parachains_constants::rococo::currency::UNITS; use xcm::latest::prelude::*; @@ -74,3 +81,40 @@ pub fn build_congestion_message( /// Identifier of AssetHubRococo in the Rococo relay chain. pub const ASSET_HUB_ROCOCO_PARACHAIN_ID: u32 = 1000; + +/// AssetHubRococo parachain. +#[derive(RuntimeDebug)] + +pub struct AssetHubRococo; + +impl Chain for AssetHubRococo { + const ID: ChainId = *b"ahro"; + + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; + + type AccountId = AccountId; + type Balance = Balance; + type Nonce = Nonce; + type Signature = Signature; + + const STATE_VERSION: StateVersion = StateVersion::V1; + + fn max_extrinsic_size() -> u32 { + *BlockLength::get().max.get(DispatchClass::Normal) + } + + fn max_extrinsic_weight() -> Weight { + BlockWeightsForAsyncBacking::get() + .get(DispatchClass::Normal) + .max_extrinsic + .unwrap_or(Weight::MAX) + } +} + +impl Parachain for AssetHubRococo { + const PARACHAIN_ID: u32 = ASSET_HUB_ROCOCO_PARACHAIN_ID; + const MAX_HEADER_SIZE: u32 = MAX_ASSET_HUB_HEADER_SIZE; +} diff --git a/bridges/chains/chain-asset-hub-westend/Cargo.toml b/bridges/chains/chain-asset-hub-westend/Cargo.toml index 3ad2cf9359bfd..f84b469861e10 100644 --- a/bridges/chains/chain-asset-hub-westend/Cargo.toml +++ b/bridges/chains/chain-asset-hub-westend/Cargo.toml @@ -22,6 +22,9 @@ frame-support = { workspace = true } sp-core = { workspace = true } # Bridge Dependencies +bp-bridge-hub-cumulus = { workspace = true } +bp-messages = { workspace = true } +bp-runtime = { workspace = true } bp-xcm-bridge-hub-router = { workspace = true } testnet-parachains-constants = { features = ["westend"], workspace = true } @@ -31,6 +34,9 @@ xcm = { workspace = true } [features] default = ["std"] std = [ + "bp-bridge-hub-cumulus/std", + "bp-messages/std", + "bp-runtime/std", "bp-xcm-bridge-hub-router/std", "codec/std", "frame-support/std", diff --git a/bridges/chains/chain-asset-hub-westend/src/lib.rs b/bridges/chains/chain-asset-hub-westend/src/lib.rs index 89b5cddf2d532..6f4bd33a78470 100644 --- a/bridges/chains/chain-asset-hub-westend/src/lib.rs +++ b/bridges/chains/chain-asset-hub-westend/src/lib.rs @@ -20,10 +20,16 @@ extern crate alloc; +pub use bp_bridge_hub_cumulus::*; +use bp_messages::*; +use bp_runtime::{Chain, ChainId, Parachain}; +pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall; use codec::{Decode, Encode}; +use frame_support::{ + dispatch::DispatchClass, + sp_runtime::{RuntimeDebug, StateVersion}, +}; use scale_info::TypeInfo; - -pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall; use testnet_parachains_constants::westend::currency::UNITS; use xcm::latest::prelude::*; @@ -75,3 +81,39 @@ pub fn build_congestion_message( /// Identifier of AssetHubWestend in the Westend relay chain. pub const ASSET_HUB_WESTEND_PARACHAIN_ID: u32 = 1000; + +/// AssetHubWestend parachain. +#[derive(RuntimeDebug)] +pub struct AssetHubWestend; + +impl Chain for AssetHubWestend { + const ID: ChainId = *b"ahwd"; + + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; + + type AccountId = AccountId; + type Balance = Balance; + type Nonce = Nonce; + type Signature = Signature; + + const STATE_VERSION: StateVersion = StateVersion::V1; + + fn max_extrinsic_size() -> u32 { + *BlockLength::get().max.get(DispatchClass::Normal) + } + + fn max_extrinsic_weight() -> Weight { + BlockWeightsForAsyncBacking::get() + .get(DispatchClass::Normal) + .max_extrinsic + .unwrap_or(Weight::MAX) + } +} + +impl Parachain for AssetHubWestend { + const PARACHAIN_ID: u32 = ASSET_HUB_WESTEND_PARACHAIN_ID; + const MAX_HEADER_SIZE: u32 = MAX_ASSET_HUB_HEADER_SIZE; +} diff --git a/bridges/chains/chain-bridge-hub-cumulus/src/lib.rs b/bridges/chains/chain-bridge-hub-cumulus/src/lib.rs index f626fa6df010b..f665d1e224da9 100644 --- a/bridges/chains/chain-bridge-hub-cumulus/src/lib.rs +++ b/bridges/chains/chain-bridge-hub-cumulus/src/lib.rs @@ -39,6 +39,9 @@ use frame_support::{ use frame_system::limits; use sp_std::time::Duration; +/// Maximal asset hub header size. +pub const MAX_ASSET_HUB_HEADER_SIZE: u32 = 4_096; + /// Maximal bridge hub header size. pub const MAX_BRIDGE_HUB_HEADER_SIZE: u32 = 4_096; diff --git a/prdoc/pr_8063.prdoc b/prdoc/pr_8063.prdoc new file mode 100644 index 0000000000000..803c976870026 --- /dev/null +++ b/prdoc/pr_8063.prdoc @@ -0,0 +1,12 @@ +title: 'Bridges: Add initial primitives for AssetHub bridging' +doc: +- audience: Runtime Dev + description: |- + Add initial primitives for AssetHubRococo and AssetHubWestend bridging +crates: +- name: bp-asset-hub-rococo + bump: minor +- name: bp-asset-hub-westend + bump: minor +- name: bp-bridge-hub-cumulus + bump: minor