Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,10 @@ bp-rococo = { path = "bridges/chains/chain-rococo", default-features = false }
bp-runtime = { path = "bridges/primitives/runtime", default-features = false }
bp-test-utils = { path = "bridges/primitives/test-utils", default-features = false }
bp-westend = { path = "bridges/chains/chain-westend", default-features = false }
bp-xcm-bridge = { path = "bridges/primitives/xcm-bridge", default-features = false }
bp-xcm-bridge-hub = { path = "bridges/primitives/xcm-bridge-hub", default-features = false }
bp-xcm-bridge-hub-router = { path = "bridges/primitives/xcm-bridge-hub-router", default-features = false }
bp-xcm-bridge-router = { path = "bridges/primitives/xcm-bridge-router", default-features = false }
bridge-hub-common = { path = "cumulus/parachains/runtimes/bridge-hubs/common", default-features = false }
bridge-hub-rococo-emulated-chain = { path = "cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo" }
bridge-hub-rococo-runtime = { path = "cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo", default-features = false }
Expand Down Expand Up @@ -1273,6 +1275,7 @@ snowbridge-pallet-outbound-queue-v2 = { path = "bridges/snowbridge/pallets/outbo
snowbridge-pallet-system = { path = "bridges/snowbridge/pallets/system", default-features = false }
snowbridge-pallet-system-frontend = { path = "bridges/snowbridge/pallets/system-frontend", default-features = false }
snowbridge-pallet-system-v2 = { path = "bridges/snowbridge/pallets/system-v2", default-features = false }
snowbridge-router-primitives = { path = "bridges/snowbridge/primitives/router", default-features = false }
snowbridge-runtime-common = { path = "bridges/snowbridge/runtime/runtime-common", default-features = false }
snowbridge-runtime-test-common = { path = "bridges/snowbridge/runtime/test-common", default-features = false }
snowbridge-system-runtime-api = { path = "bridges/snowbridge/pallets/system/runtime-api", default-features = false }
Expand Down
22 changes: 18 additions & 4 deletions bridges/chains/chain-asset-hub-rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,37 @@ scale-info = { features = ["derive"], workspace = true }

# Substrate Dependencies
frame-support = { workspace = true }
sp-api = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

# Bridge Dependencies
bp-xcm-bridge-hub-router = { workspace = true }
testnet-parachains-constants = { features = ["rococo"], workspace = true }
bp-bridge-hub-cumulus = { workspace = true }
bp-messages = { workspace = true }
bp-runtime = { workspace = true }
bp-xcm-bridge = { workspace = true }
bp-xcm-bridge-router = { workspace = true }

# Polkadot dependencies
xcm = { workspace = true }

[features]
default = ["std"]
std = [
"bp-xcm-bridge-hub-router/std",
"bp-bridge-hub-cumulus/std",
"bp-messages/std",
"bp-runtime/std",
"bp-xcm-bridge-router/std",
"bp-xcm-bridge/std",
"codec/std",
"codec/std",
"frame-support/std",
"frame-support/std",
"scale-info/std",
"sp-api/std",
"sp-core/std",
"testnet-parachains-constants/std",
"sp-runtime/std",
"sp-std/std",
"xcm/std",
]
111 changes: 104 additions & 7 deletions bridges/chains/chain-asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

//! Module with configuration which reflects AssetHubRococo runtime setup.
//! Module with configuration which reflects AssetHubRococo runtime setup (AccountId, Headers,
//! Hashes...)

#![cfg_attr(not(feature = "std"), no_std)]

Expand All @@ -23,8 +24,16 @@ extern crate alloc;
use codec::{Decode, Encode};
use scale_info::TypeInfo;

pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall;
use testnet_parachains_constants::rococo::currency::UNITS;
pub use bp_bridge_hub_cumulus::*;
use bp_messages::*;
use bp_runtime::{
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain,
};
pub use bp_xcm_bridge_router::XcmBridgeHubCall;
use frame_support::{
dispatch::DispatchClass,
sp_runtime::{MultiAddress, MultiSigner, RuntimeDebug, StateVersion},
};
use xcm::latest::prelude::*;

/// `AssetHubRococo` Runtime `Call` enum.
Expand All @@ -40,14 +49,12 @@ use xcm::latest::prelude::*;
pub enum Call {
/// `ToWestendXcmRouter` bridge pallet.
#[codec(index = 45)]
ToWestendXcmRouter(XcmBridgeHubRouterCall),
ToWestendXcmRouter(XcmBridgeHubCall<sp_core::H256>),
}

frame_support::parameter_types! {
/// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`.
pub const XcmBridgeHubRouterTransactCallMaxWeight: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(200_000_000, 6144);
/// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub.
pub const CreateForeignAssetDeposit: u128 = UNITS / 10;
}

/// Builds an (un)congestion XCM program with the `report_bridge_status` call for
Expand All @@ -61,7 +68,7 @@ pub fn build_congestion_message<RuntimeCall>(
Transact {
origin_kind: OriginKind::Xcm,
fallback_max_weight: Some(XcmBridgeHubRouterTransactCallMaxWeight::get()),
call: Call::ToWestendXcmRouter(XcmBridgeHubRouterCall::report_bridge_status {
call: Call::ToWestendXcmRouter(XcmBridgeHubCall::update_bridge_status {
bridge_id,
is_congested,
})
Expand All @@ -74,3 +81,93 @@ pub fn build_congestion_message<RuntimeCall>(

/// 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_BRIDGE_HUB_HEADER_SIZE;
}

/// Describing permissionless lanes instance
impl ChainWithMessages for AssetHubRococo {
const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
WITH_ASSET_HUB_ROCOCO_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;

/// The address format for describing accounts.
pub type Address = MultiAddress<AccountId, ()>;

/// Name of the With-AssetHubRococo messages pallet instance that is deployed at bridged chains.
pub const WITH_ASSET_HUB_ROCOCO_MESSAGES_PALLET_NAME: &str = "BridgeRococoMessages";

/// Name of the With-AssetHubRococo bridge-relayers pallet instance that is deployed at bridged
/// chains.
pub const WITH_ASSET_HUB_ROCOCO_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";

/// Pallet index of `BridgeWestendMessages: pallet_bridge_messages::<Instance1>`.
pub const WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX: u8 = 62;

decl_bridge_finality_runtime_apis!(asset_hub_rococo);
decl_bridge_messages_runtime_apis!(asset_hub_rococo, HashedLaneId);

frame_support::parameter_types! {
/// TODO: FAIL-CI - probably not needed or ise for MessageExporterPrice
/// The XCM fee that is paid for executing XCM program (with `ExportMessage` instruction) at the Rococo
/// BridgeHub.
/// (initially was calculated by test `AssetHubRococo::can_calculate_weight_for_paid_export_message_with_reserve_transfer` + `33%`)
pub const AssetHubRococoBaseXcmFeeInRocs: u128 = 57_325_000;

/// Transaction fee that is paid at the Rococo BridgeHub for delivering single inbound message.
/// (initially was calculated by test `AssetHubRococo::can_calculate_fee_for_standalone_message_delivery_transaction` + `33%`)
pub const AssetHubRococoBaseDeliveryFeeInRocs: u128 = 297_685_840;

/// Transaction fee that is paid at the Rococo BridgeHub for delivering single outbound message confirmation.
/// (initially was calculated by test `AssetHubRococo::can_calculate_fee_for_standalone_message_confirmation_transaction` + `33%`)
pub const AssetHubRococoBaseConfirmationFeeInRocs: u128 = 56_782_099;
}

/// Wrapper over `AssetHubRococo`'s `RuntimeCall` that can be used without a runtime.
#[derive(Decode, Encode)]
pub enum RuntimeCall {
/// Points to the `pallet_xcm_bridge` pallet instance for `AssetHubWestend`.
#[codec(index = 61)]
XcmOverAssetHubWestend(bp_xcm_bridge::XcmBridgeCall),
}
22 changes: 18 additions & 4 deletions bridges/chains/chain-asset-hub-westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,37 @@ scale-info = { features = ["derive"], workspace = true }

# Substrate Dependencies
frame-support = { workspace = true }
sp-api = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

# Bridge Dependencies
bp-xcm-bridge-hub-router = { workspace = true }
testnet-parachains-constants = { features = ["westend"], workspace = true }
bp-bridge-hub-cumulus = { workspace = true }
bp-messages = { workspace = true }
bp-runtime = { workspace = true }
bp-xcm-bridge = { workspace = true }
bp-xcm-bridge-router = { workspace = true }

# Polkadot dependencies
xcm = { workspace = true }

[features]
default = ["std"]
std = [
"bp-xcm-bridge-hub-router/std",
"bp-bridge-hub-cumulus/std",
"bp-messages/std",
"bp-runtime/std",
"bp-xcm-bridge-router/std",
"bp-xcm-bridge/std",
"codec/std",
"codec/std",
"frame-support/std",
"frame-support/std",
"scale-info/std",
"sp-api/std",
"sp-core/std",
"testnet-parachains-constants/std",
"sp-runtime/std",
"sp-std/std",
"xcm/std",
]
Loading
Loading