Skip to content

Commit

Permalink
[Rococo<>Westend bridge] Allow any asset over the lane between the tw…
Browse files Browse the repository at this point in the history
…o Asset Hubs (paritytech#4888)

On Westend Asset Hub, we allow Rococo Asset Hub to act as reserve for
any asset native to the Rococo or Ethereum ecosystems (practically
providing Westend access to Ethereum assets through double bridging:
W<>R<>Eth).

On Rococo Asset Hub, we allow Westend Asset Hub to act as reserve for
any asset native to the Westend ecosystem. We also allow Ethereum
contracts to act as reserves for the foreign assets identified by the
same respective contracts locations.

- [x] add emulated tests for various assets (native, trust-based,
foreign/bridged) going AHR -> AHW,
- [x] add equivalent tests for the other direction AHW -> AHR.

This PR is a prerequisite to doing the same for Polkadot<>Kusama bridge.
  • Loading branch information
acatangiu authored Jun 28, 2024
1 parent 30cdf5d commit 016f394
Show file tree
Hide file tree
Showing 18 changed files with 680 additions and 386 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use sp_core::{sr25519, storage::Storage};
use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, get_account_id_from_seed,
PenpalSiblingSovereignAccount, PenpalTeleportableAssetLocation, RESERVABLE_ASSET_ID,
SAFE_XCM_VERSION,
SAFE_XCM_VERSION, USDT_ID,
};
use parachains_common::{AccountId, Balance};

Expand Down Expand Up @@ -68,7 +68,10 @@ pub fn genesis() -> Storage {
..Default::default()
},
assets: asset_hub_rococo_runtime::AssetsConfig {
assets: vec![(RESERVABLE_ASSET_ID, AssetHubRococoAssetOwner::get(), true, ED)],
assets: vec![
(RESERVABLE_ASSET_ID, AssetHubRococoAssetOwner::get(), true, ED),
(USDT_ID, AssetHubRococoAssetOwner::get(), true, ED),
],
..Default::default()
},
foreign_assets: asset_hub_rococo_runtime::ForeignAssetsConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;

type AccountPublic = <MultiSignature as Verify>::Signer;

// This asset is added to AH as Asset and reserved transfer between Parachain and AH
// (trust-backed) Asset registered on AH and reserve-transferred between Parachain and AH
pub const RESERVABLE_ASSET_ID: u32 = 1;
// This asset is added to AH as ForeignAsset and teleported between Penpal and AH
// ForeignAsset registered on AH and teleported between Penpal and AH
pub const TELEPORTABLE_ASSET_ID: u32 = 2;

// USDT registered on AH as (trust-backed) Asset and reserve-transferred between Parachain and AH
pub const USDT_ID: u32 = 1984;

pub const PENPAL_ID: u32 = 2000;
pub const ASSETS_PALLET_ID: u8 = 50;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use frame_support::{
sp_runtime::traits::Dispatchable,
traits::{
fungible::Inspect,
fungibles::{Create, Inspect as FungiblesInspect, Mutate},
fungibles::{Inspect as FungiblesInspect, Mutate},
},
};
use parachains_common::AccountId;
Expand Down Expand Up @@ -163,7 +163,7 @@ fn spend_roc_on_asset_hub() {
#[test]
fn create_and_claim_treasury_spend_in_usdt() {
const ASSET_ID: u32 = 1984;
const SPEND_AMOUNT: u128 = 1_000_000;
const SPEND_AMOUNT: u128 = 10_000_000;
// treasury location from a sibling parachain.
let treasury_location: Location = Location::new(1, PalletInstance(18));
// treasury account on a sibling parachain.
Expand All @@ -190,13 +190,7 @@ fn create_and_claim_treasury_spend_in_usdt() {
AssetHubRococo::execute_with(|| {
type Assets = <AssetHubRococo as AssetHubRococoPallet>::Assets;

// create an asset class and mint some assets to the treasury account.
assert_ok!(<Assets as Create<_>>::create(
ASSET_ID,
treasury_account.clone(),
true,
SPEND_AMOUNT / 2
));
// USDT created at genesis, mint some assets to the treasury account.
assert_ok!(<Assets as Mutate<_>>::mint_into(ASSET_ID, &treasury_account, SPEND_AMOUNT * 4));
// beneficiary has zero balance.
assert_eq!(<Assets as FungiblesInspect<_>>::balance(ASSET_ID, &alice,), 0u128,);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ mod imports {
xcm_emulator::{
assert_expected_events, bx, Chain, Parachain as Para, RelayChain as Relay, TestExt,
},
ASSETS_PALLET_ID, USDT_ID,
};
pub use parachains_common::AccountId;
pub use rococo_westend_system_emulated_network::{
asset_hub_rococo_emulated_chain::{
genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet as AssetHubRococoPallet,
genesis::{AssetHubRococoAssetOwner, ED as ASSET_HUB_ROCOCO_ED},
AssetHubRococoParaPallet as AssetHubRococoPallet,
},
asset_hub_westend_emulated_chain::{
genesis::ED as ASSET_HUB_WESTEND_ED, AssetHubWestendParaPallet as AssetHubWestendPallet,
Expand Down
Loading

0 comments on commit 016f394

Please sign in to comment.