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: forbid XYK pools containing LRNA #685

Merged
merged 1 commit into from
Oct 5, 2023
Merged
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.

2 changes: 1 addition & 1 deletion 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.12.2"
version = "1.12.3"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down
17 changes: 17 additions & 0 deletions integration-tests/src/call_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,23 @@ fn transfer_should_not_work_when_transfering_omnipool_assets_to_omnipool_account
});
}

#[test]
fn xyk_create_pool_with_lrna_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::XYK(pallet_xyk::Call::create_pool {
asset_a: LRNA,
amount_a: UNITS,
asset_b: DOT,
amount_b: UNITS,
});

assert!(!hydradx_runtime::CallFilter::contains(&call));
});
}

#[test]
fn calling_pallet_xcm_send_extrinsic_should_not_be_filtered_by_call_filter() {
TestNet::reset();
Expand Down
2 changes: 1 addition & 1 deletion runtime/hydradx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hydradx-runtime"
version = "180.0.0"
version = "181.0.0"
authors = ["GalacticCouncil"]
edition = "2021"
license = "Apache 2.0"
Expand Down
2 changes: 1 addition & 1 deletion runtime/hydradx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("hydradx"),
impl_name: create_runtime_str!("hydradx"),
authoring_version: 1,
spec_version: 180,
spec_version: 181,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
13 changes: 10 additions & 3 deletions runtime/hydradx/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ impl Contains<RuntimeCall> for CallFilter {
return false;
}

let hub_asset_id = <Runtime as pallet_omnipool::Config>::HubAssetId::get();

// filter transfers of LRNA and omnipool assets to the omnipool account
if let RuntimeCall::Tokens(orml_tokens::Call::transfer { dest, currency_id, .. })
| RuntimeCall::Tokens(orml_tokens::Call::transfer_keep_alive { dest, currency_id, .. })
| RuntimeCall::Tokens(orml_tokens::Call::transfer_all { dest, currency_id, .. })
| RuntimeCall::Currencies(pallet_currencies::Call::transfer { dest, currency_id, .. }) = call
{
// Lookup::lookup() is not necessary thanks to IdentityLookup
if dest == &Omnipool::protocol_account()
&& (*currency_id == <Runtime as pallet_omnipool::Config>::HubAssetId::get()
|| Omnipool::exists(*currency_id))
if dest == &Omnipool::protocol_account() && (*currency_id == hub_asset_id || Omnipool::exists(*currency_id))
{
return false;
}
Expand All @@ -83,6 +83,13 @@ impl Contains<RuntimeCall> for CallFilter {
}
}

// XYK pools with LRNA are not allowed
if let RuntimeCall::XYK(pallet_xyk::Call::create_pool { asset_a, asset_b, .. }) = call {
if *asset_a == hub_asset_id || *asset_b == hub_asset_id {
return false;
}
}

match call {
RuntimeCall::PolkadotXcm(pallet_xcm::Call::send { .. }) => true,
RuntimeCall::PolkadotXcm(_) => false,
Expand Down