mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
Make penpal-runtime's TrustedReserves more connfigurable (#3564)
The current `penpal` runtime utilizes the `EthereumLocation` parameter, which is employed for XCM emulated integration tests concerning the Rococo <> ETH bridge. It includes a hard-coded chainId for the Ethereum testnet utilized in Rococo. The `EthereumLocation` serves the purpose of aligning with the `TrustedReserves`. However, due to this hard-coded configuration, reusing `penpal` for testing various environments such as Kusama/Polkadot versus Ethereum bridge becomes unfeasible. This PR introduces the capability to easily customize the asset location for `TrustedReserves` without needing to know anything about Ethereum. ## TODO - [x] fix integration tests with `System::set_storage(CustomizableAssetFromSystemAssetHub::key(), <whatever-location-is-needed>)` @claravanstaden - [ ] ~~maybe add some helper function/macro to support `set_storage` for other runtimes (that we could reuse)~~ - [ ] Release patch for: `penpal-runtime` + emulated crate with `set_storage` support (if needed) - [ ] backport to 1.7.0 - [ ] backport to 1.8.0 --------- Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>
This commit is contained in:
Generated
-1
@@ -11754,7 +11754,6 @@ dependencies = [
|
|||||||
"staging-xcm-builder",
|
"staging-xcm-builder",
|
||||||
"staging-xcm-executor",
|
"staging-xcm-executor",
|
||||||
"substrate-wasm-builder",
|
"substrate-wasm-builder",
|
||||||
"testnet-parachains-constants",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
+2
-1
@@ -16,7 +16,8 @@
|
|||||||
mod genesis;
|
mod genesis;
|
||||||
pub use genesis::{genesis, ED, PARA_ID_A, PARA_ID_B};
|
pub use genesis::{genesis, ED, PARA_ID_A, PARA_ID_B};
|
||||||
pub use penpal_runtime::xcm_config::{
|
pub use penpal_runtime::xcm_config::{
|
||||||
LocalTeleportableToAssetHub, LocalTeleportableToAssetHubV3, XcmConfig,
|
CustomizableAssetFromSystemAssetHub, LocalTeleportableToAssetHub,
|
||||||
|
LocalTeleportableToAssetHubV3, XcmConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Substrate
|
// Substrate
|
||||||
|
|||||||
+11
@@ -18,6 +18,7 @@ use codec::{Decode, Encode};
|
|||||||
use emulated_integration_tests_common::xcm_emulator::ConvertLocation;
|
use emulated_integration_tests_common::xcm_emulator::ConvertLocation;
|
||||||
use frame_support::pallet_prelude::TypeInfo;
|
use frame_support::pallet_prelude::TypeInfo;
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
|
use rococo_system_emulated_network::penpal_emulated_chain::CustomizableAssetFromSystemAssetHub;
|
||||||
use rococo_westend_system_emulated_network::BridgeHubRococoParaSender as BridgeHubRococoSender;
|
use rococo_westend_system_emulated_network::BridgeHubRococoParaSender as BridgeHubRococoSender;
|
||||||
use snowbridge_core::outbound::OperatingMode;
|
use snowbridge_core::outbound::OperatingMode;
|
||||||
use snowbridge_pallet_inbound_queue_fixtures::{
|
use snowbridge_pallet_inbound_queue_fixtures::{
|
||||||
@@ -253,6 +254,16 @@ fn send_token_from_ethereum_to_penpal() {
|
|||||||
(PenpalASender::get(), INITIAL_FUND),
|
(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
|
// The Weth asset location, identified by the contract address on Ethereum
|
||||||
let weth_asset_location: Location =
|
let weth_asset_location: Location =
|
||||||
(Parent, Parent, EthereumNetwork::get(), AccountKey20 { network: None, key: WETH }).into();
|
(Parent, Parent, EthereumNetwork::get(), AccountKey20 { network: None, key: WETH }).into();
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default-
|
|||||||
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
|
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
|
||||||
parachain-info = { package = "staging-parachain-info", path = "../../../pallets/parachain-info", default-features = false }
|
parachain-info = { package = "staging-parachain-info", path = "../../../pallets/parachain-info", default-features = false }
|
||||||
parachains-common = { path = "../../../common", default-features = false }
|
parachains-common = { path = "../../../common", default-features = false }
|
||||||
testnet-parachains-constants = { path = "../../constants", default-features = false, features = ["rococo"] }
|
|
||||||
assets-common = { path = "../../assets/common", default-features = false }
|
assets-common = { path = "../../assets/common", default-features = false }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
@@ -133,7 +132,6 @@ std = [
|
|||||||
"sp-transaction-pool/std",
|
"sp-transaction-pool/std",
|
||||||
"sp-version/std",
|
"sp-version/std",
|
||||||
"substrate-wasm-builder",
|
"substrate-wasm-builder",
|
||||||
"testnet-parachains-constants/std",
|
|
||||||
"xcm-builder/std",
|
"xcm-builder/std",
|
||||||
"xcm-executor/std",
|
"xcm-executor/std",
|
||||||
"xcm/std",
|
"xcm/std",
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ use pallet_xcm::XcmPassthrough;
|
|||||||
use polkadot_parachain_primitives::primitives::Sibling;
|
use polkadot_parachain_primitives::primitives::Sibling;
|
||||||
use polkadot_runtime_common::impls::ToAuthor;
|
use polkadot_runtime_common::impls::ToAuthor;
|
||||||
use sp_runtime::traits::Zero;
|
use sp_runtime::traits::Zero;
|
||||||
use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork;
|
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_builder::{
|
use xcm_builder::{
|
||||||
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
|
||||||
@@ -295,7 +294,13 @@ parameter_types! {
|
|||||||
0,
|
0,
|
||||||
[xcm::v3::Junction::PalletInstance(50), xcm::v3::Junction::GeneralIndex(TELEPORTABLE_ASSET_ID.into())]
|
[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.
|
/// Accepts asset with ID `AssetLocation` and is coming from `Origin` chain.
|
||||||
@@ -310,11 +315,11 @@ impl<AssetLocation: Get<Location>, Origin: Get<Location>> ContainsPair<Asset, Lo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Reserves = (
|
pub type TrustedReserves = (
|
||||||
NativeAsset,
|
NativeAsset,
|
||||||
AssetsFrom<SystemAssetHubLocation>,
|
AssetsFrom<SystemAssetHubLocation>,
|
||||||
NativeAssetFrom<SystemAssetHubLocation>,
|
NativeAssetFrom<SystemAssetHubLocation>,
|
||||||
AssetPrefixFrom<EthereumLocation, SystemAssetHubLocation>,
|
AssetPrefixFrom<CustomizableAssetFromSystemAssetHub, SystemAssetHubLocation>,
|
||||||
);
|
);
|
||||||
pub type TrustedTeleporters =
|
pub type TrustedTeleporters =
|
||||||
(AssetFromChain<LocalTeleportableToAssetHub, SystemAssetHubLocation>,);
|
(AssetFromChain<LocalTeleportableToAssetHub, SystemAssetHubLocation>,);
|
||||||
@@ -326,7 +331,7 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
// How to withdraw and deposit an asset.
|
// How to withdraw and deposit an asset.
|
||||||
type AssetTransactor = AssetTransactors;
|
type AssetTransactor = AssetTransactors;
|
||||||
type OriginConverter = XcmOriginToTransactDispatchOrigin;
|
type OriginConverter = XcmOriginToTransactDispatchOrigin;
|
||||||
type IsReserve = Reserves;
|
type IsReserve = TrustedReserves;
|
||||||
// no teleport trust established with other chains
|
// no teleport trust established with other chains
|
||||||
type IsTeleporter = TrustedTeleporters;
|
type IsTeleporter = TrustedTeleporters;
|
||||||
type UniversalLocation = UniversalLocation;
|
type UniversalLocation = UniversalLocation;
|
||||||
|
|||||||
Reference in New Issue
Block a user