Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove XCM pallet from call filter #885

Closed
wants to merge 3 commits into from
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
4 changes: 2 additions & 2 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "runtime-integration-tests"
version = "1.23.1"
version = "1.23.2"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down Expand Up @@ -216,5 +216,4 @@ runtime-benchmarks = [
"hydradx-runtime/runtime-benchmarks",
"rococo-runtime/runtime-benchmarks",
]
try-runtime = [
]
try-runtime = []
15 changes: 0 additions & 15 deletions integration-tests/src/call_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about keeping the test, but flipping the boolean in the assertion?

});
}

#[test]
fn calling_orml_xcm_extrinsic_should_be_filtered_by_call_filter() {
TestNet::reset();
Expand Down
14 changes: 8 additions & 6 deletions runtime/hydradx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hydradx-runtime"
version = "254.0.0"
version = "255.0.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patch bump as well ? :)

authors = ["GalacticCouncil"]
edition = "2021"
license = "Apache 2.0"
Expand All @@ -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 }
Expand Down Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion runtime/hydradx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions runtime/hydradx/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@ impl Contains<RuntimeCall> 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,
}
Expand Down
24 changes: 24 additions & 0 deletions runtime/hydradx/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,33 @@ where
}
}

/// Matches DOT from Asset Hub
pub struct IsDotFromAssetHub<Origin>(PhantomData<Origin>);
impl<Origin> ContainsPair<Asset, Location> for IsDotFromAssetHub<Origin>
where
Origin: Get<Location>,
{
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,
}),
fun: Fungible(_),
},
)
}
}

pub type Reserves = (
IsForeignNativeAssetFrom<AssetHubLocation>,
MultiNativeAsset<AbsoluteReserveProvider>,
IsDotFromAssetHub<AssetHubLocation>,
);

pub struct XcmConfig;
Expand Down