From 731099a71478b0fcc64eae40445c7d935258f2fb Mon Sep 17 00:00:00 2001 From: green-jay Date: Mon, 5 Aug 2024 13:32:34 +0200 Subject: [PATCH 1/3] Remove XCM pallet from call filter --- Cargo.lock | 4 ++-- integration-tests/Cargo.toml | 5 ++--- integration-tests/src/call_filter.rs | 15 --------------- runtime/hydradx/Cargo.toml | 14 ++++++++------ runtime/hydradx/src/lib.rs | 2 +- runtime/hydradx/src/system.rs | 2 -- 6 files changed, 13 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1eccf4ce9..948f62f0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4938,7 +4938,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "254.0.0" +version = "255.0.1" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", @@ -11929,7 +11929,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.23.1" +version = "1.23.2" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 83ee43671..190fda703 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "1.23.1" +version = "1.23.2" description = "Integration tests" authors = ["GalacticCouncil"] edition = "2021" @@ -216,5 +216,4 @@ runtime-benchmarks = [ "hydradx-runtime/runtime-benchmarks", "rococo-runtime/runtime-benchmarks", ] -try-runtime = [ -] +try-runtime = [] diff --git a/integration-tests/src/call_filter.rs b/integration-tests/src/call_filter.rs index 419a6353d..00ace1044 100644 --- a/integration-tests/src/call_filter.rs +++ b/integration-tests/src/call_filter.rs @@ -238,21 +238,6 @@ fn calling_pallet_xcm_send_extrinsic_should_not_be_filtered_by_call_filter() { }); } -#[test] -fn calling_pallet_xcm_extrinsic_should_be_filtered_by_call_filter() { - TestNet::reset(); - - Hydra::execute_with(|| { - // the values here don't need to make sense, all we need is a valid Call - let call = hydradx_runtime::RuntimeCall::PolkadotXcm(pallet_xcm::Call::execute { - message: Box::new(VersionedXcm::from(Xcm(vec![]))), - max_weight: Weight::zero(), - }); - - assert!(!hydradx_runtime::CallFilter::contains(&call)); - }); -} - #[test] fn calling_orml_xcm_extrinsic_should_be_filtered_by_call_filter() { TestNet::reset(); diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index 0b38f82bf..debc1815a 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "254.0.0" +version = "255.0.1" authors = ["GalacticCouncil"] edition = "2021" license = "Apache 2.0" @@ -15,8 +15,12 @@ substrate-wasm-builder = { workspace = true } [dependencies] hex-literal = "0.4.1" serde = { features = ["derive"], optional = true, version = "1.0.136" } -codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false, features = [ + "derive", +] } +scale-info = { version = "2.3.1", default-features = false, features = [ + "derive", +] } smallvec = "1.9.0" log = { workspace = true } num_enum = { version = "0.5.1", default-features = false } @@ -396,6 +400,4 @@ try-runtime = [ "pallet-state-trie-migration/try-runtime", ] -metadata-hash = [ - "substrate-wasm-builder/metadata-hash", -] +metadata-hash = ["substrate-wasm-builder/metadata-hash"] diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index f7d4e1b7e..e80d28be2 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -113,7 +113,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 254, + spec_version: 255, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtime/hydradx/src/system.rs b/runtime/hydradx/src/system.rs index 77231cf04..82e9ad60d 100644 --- a/runtime/hydradx/src/system.rs +++ b/runtime/hydradx/src/system.rs @@ -95,11 +95,9 @@ impl Contains for CallFilter { } match call { - RuntimeCall::PolkadotXcm(pallet_xcm::Call::send { .. }) => true, // create and create2 are only allowed through RPC or Runtime API RuntimeCall::EVM(pallet_evm::Call::create { .. }) => false, RuntimeCall::EVM(pallet_evm::Call::create2 { .. }) => false, - RuntimeCall::PolkadotXcm(_) => false, RuntimeCall::OrmlXcm(_) => false, _ => true, } From abb1c806c97c6466bf5e73271d54348a7250ac96 Mon Sep 17 00:00:00 2001 From: green-jay Date: Mon, 26 Aug 2024 10:29:32 +0200 Subject: [PATCH 2/3] add IsDotFromAssetHub --- runtime/hydradx/src/xcm.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/runtime/hydradx/src/xcm.rs b/runtime/hydradx/src/xcm.rs index 57713434a..ad2679421 100644 --- a/runtime/hydradx/src/xcm.rs +++ b/runtime/hydradx/src/xcm.rs @@ -141,9 +141,32 @@ where } } +/// Matches DOT from Asset Hub +pub struct IsDotFromAssetHub(PhantomData); +impl ContainsPair for IsDotFromAssetHub +where + Origin: Get, +{ + fn contains(asset: &Asset, origin: &Location) -> bool { + let loc = Origin::get(); + &loc == origin + && matches!( + asset, + Asset { + id: AssetId(Location { + parents: 1, + interior: Junctions::X1(Parachain(1000)) + }), + fun: Fungible(_), + }, + ) + } +} + pub type Reserves = ( IsForeignNativeAssetFrom, MultiNativeAsset, + IsDotFromAssetHub, ); pub struct XcmConfig; From 1677e5d58ac215275583fcd27b96301fe869b00a Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 26 Aug 2024 14:20:14 +0200 Subject: [PATCH 3/3] fixed interior --- runtime/hydradx/src/xcm.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/hydradx/src/xcm.rs b/runtime/hydradx/src/xcm.rs index ad2679421..dd2c7a5fb 100644 --- a/runtime/hydradx/src/xcm.rs +++ b/runtime/hydradx/src/xcm.rs @@ -149,13 +149,14 @@ where { fn contains(asset: &Asset, origin: &Location) -> bool { let loc = Origin::get(); + let interior = Junctions::X1(Arc::new([Parachain(1000)])); &loc == origin && matches!( asset, Asset { id: AssetId(Location { parents: 1, - interior: Junctions::X1(Parachain(1000)) + interior, }), fun: Fungible(_), },