Skip to content

Commit

Permalink
Make penpal-runtime's TrustedReserves more connfigurable (#3564) …
Browse files Browse the repository at this point in the history
…(patch for 1.7.0) (#3624)

Backport of #3564

Expected patches for (1.7.0):
- penpal-runtime `0.15.1`
  • Loading branch information
bkontur authored Mar 8, 2024
1 parent 64dfe8d commit 33c605c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
15 changes: 7 additions & 8 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 @@ -16,7 +16,8 @@
mod genesis;
pub use genesis::{genesis, ED, PARA_ID_A, PARA_ID_B};
pub use penpal_runtime::xcm_config::{
LocalTeleportableToAssetHub, LocalTeleportableToAssetHubV3, XcmConfig,
CustomizableAssetFromSystemAssetHub, LocalTeleportableToAssetHub,
LocalTeleportableToAssetHubV3, XcmConfig,
};

// Substrate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use codec::{Decode, Encode};
use emulated_integration_tests_common::xcm_emulator::ConvertLocation;
use frame_support::pallet_prelude::TypeInfo;
use hex_literal::hex;
use rococo_system_emulated_network::penpal_emulated_chain::CustomizableAssetFromSystemAssetHub;
use rococo_westend_system_emulated_network::BridgeHubRococoParaSender as BridgeHubRococoSender;
use snowbridge_core::outbound::OperatingMode;
use snowbridge_pallet_inbound_queue_fixtures::{
Expand Down Expand Up @@ -253,6 +254,16 @@ fn send_token_from_ethereum_to_penpal() {
(PenpalASender::get(), INITIAL_FUND),
]);

PenpalA::execute_with(|| {
assert_ok!(<PenpalA as Chain>::System::set_storage(
<PenpalA as Chain>::RuntimeOrigin::root(),
vec![(
CustomizableAssetFromSystemAssetHub::key().to_vec(),
Location::new(2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })]).encode(),
)],
));
});

// The Weth asset location, identified by the contract address on Ethereum
let weth_asset_location: Location =
(Parent, Parent, EthereumNetwork::get(), AccountKey20 { network: None, key: WETH }).into();
Expand Down
2 changes: 0 additions & 2 deletions cumulus/parachains/runtimes/testing/penpal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default-
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false, version = "10.0.0" }
parachain-info = { package = "staging-parachain-info", path = "../../../pallets/parachain-info", default-features = false, version = "0.8.0" }
parachains-common = { path = "../../../common", default-features = false, version = "8.0.0" }
testnet-parachains-constants = { path = "../../constants", default-features = false, features = ["rococo"], version = "1.0.0" }
assets-common = { path = "../../assets/common", default-features = false, version = "0.8.0" }

[features]
Expand Down Expand Up @@ -133,7 +132,6 @@ std = [
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
"testnet-parachains-constants/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
Expand Down
15 changes: 10 additions & 5 deletions cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ use pallet_xcm::XcmPassthrough;
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::impls::ToAuthor;
use sp_runtime::traits::Zero;
use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork;
use xcm::latest::prelude::*;
#[allow(deprecated)]
use xcm_builder::{
Expand Down Expand Up @@ -297,7 +296,13 @@ parameter_types! {
0,
[xcm::v3::Junction::PalletInstance(50), xcm::v3::Junction::GeneralIndex(TELEPORTABLE_ASSET_ID.into())]
);
pub EthereumLocation: Location = Location::new(2, [GlobalConsensus(EthereumNetwork::get())]);

/// The Penpal runtime is utilized for testing with various environment setups.
/// This storage item provides the opportunity to customize testing scenarios
/// by configuring the trusted asset from the `SystemAssetHub`.
///
/// By default, it is configured as a `SystemAssetHubLocation` and can be modified using `System::set_storage`.
pub storage CustomizableAssetFromSystemAssetHub: Location = SystemAssetHubLocation::get();
}

/// Accepts asset with ID `AssetLocation` and is coming from `Origin` chain.
Expand All @@ -312,11 +317,11 @@ impl<AssetLocation: Get<Location>, Origin: Get<Location>> ContainsPair<Asset, Lo
}
}

pub type Reserves = (
pub type TrustedReserves = (
NativeAsset,
AssetsFrom<SystemAssetHubLocation>,
NativeAssetFrom<SystemAssetHubLocation>,
AssetPrefixFrom<EthereumLocation, SystemAssetHubLocation>,
AssetPrefixFrom<CustomizableAssetFromSystemAssetHub, SystemAssetHubLocation>,
);
pub type TrustedTeleporters =
(AssetFromChain<LocalTeleportableToAssetHub, SystemAssetHubLocation>,);
Expand All @@ -328,7 +333,7 @@ impl xcm_executor::Config for XcmConfig {
// How to withdraw and deposit an asset.
type AssetTransactor = AssetTransactors;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
type IsReserve = Reserves;
type IsReserve = TrustedReserves;
// no teleport trust established with other chains
type IsTeleporter = TrustedTeleporters;
type UniversalLocation = UniversalLocation;
Expand Down

0 comments on commit 33c605c

Please sign in to comment.