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 SafeCallFilter and pallet_xcm from call filter #909

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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.23.4"
version = "1.23.5"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down
16 changes: 0 additions & 16 deletions integration-tests/src/call_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use frame_support::{
assert_ok,
sp_runtime::{FixedU128, Permill},
traits::Contains,
weights::Weight,
};
use polkadot_xcm::v3::prelude::*;
use polkadot_xcm::VersionedXcm;
Expand Down Expand Up @@ -238,21 +237,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();
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/omnipool_liquidity_mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ fn claim_rewards_should_work_when_farm_is_updated() {
10_000 * UNITS as i128,
));

let position_id = omnipool_add_liquidity(CHARLIE.into(), DOT, 1 * UNITS);
let position_id = omnipool_add_liquidity(CHARLIE.into(), DOT, UNITS);
assert_nft_owner!(
hydradx_runtime::OmnipoolCollectionId::get(),
position_id,
Expand Down
2 changes: 0 additions & 2 deletions integration-tests/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,6 @@ mod omnipool_router_tests {
let extra_ed_charge = UNITS / 10;
assert_balance!(ALICE.into(), HDX, 1000 * UNITS - ed);

let amount_to_sell = amount_to_sell;
assert_ok!(Router::sell(
hydradx_runtime::RuntimeOrigin::signed(ALICE.into()),
insufficient_asset_1,
Expand Down Expand Up @@ -5408,7 +5407,6 @@ mod sell_all {
assert_balance!(ALICE.into(), pool_id, 0);

//Act
let amount_to_sell = 3000 * UNITS;
Roznovjak marked this conversation as resolved.
Show resolved Hide resolved
assert_ok!(Router::sell_all(
hydradx_runtime::RuntimeOrigin::signed(ALICE.into()),
stable_asset_1,
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 = "257.0.0"
version = "258.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 @@ -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: 257,
spec_version: 258,
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
92 changes: 1 addition & 91 deletions runtime/hydradx/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl Config for XcmConfig {
type MessageExporter = ();
type UniversalAliases = Nothing;
type CallDispatcher = RuntimeCall;
type SafeCallFilter = SafeCallFilter;
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = xcm_builder::FrameTransactionalProcessor;
}
Expand Down Expand Up @@ -436,93 +436,3 @@ pub type LocalAssetTransactor = ReroutingMultiCurrencyAdapter<
OmnipoolProtocolAccount,
TreasuryAccount,
>;

/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
/// account for proof size weights.
///
/// Calls that are allowed through this filter must:
/// 1. Have a fixed weight;
/// 2. Cannot lead to another call being made;
/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters.
pub struct SafeCallFilter;
impl Contains<RuntimeCall> for SafeCallFilter {
fn contains(call: &RuntimeCall) -> bool {
#[cfg(feature = "runtime-benchmarks")]
{
if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) {
return true;
}
}

// check the runtime call filter
if !CallFilter::contains(call) {
return false;
}

matches!(
call,
RuntimeCall::System(frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. })
| RuntimeCall::Timestamp(..)
| RuntimeCall::Balances(..)
| RuntimeCall::Treasury(..)
| RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. })
| RuntimeCall::Vesting(..)
| RuntimeCall::Proxy(..)
| RuntimeCall::CollatorSelection(
pallet_collator_selection::Call::set_desired_candidates { .. }
| pallet_collator_selection::Call::set_candidacy_bond { .. }
| pallet_collator_selection::Call::register_as_candidate { .. }
| pallet_collator_selection::Call::leave_intent { .. },
) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. })
| RuntimeCall::Uniques(
pallet_uniques::Call::create { .. }
| pallet_uniques::Call::force_create { .. }
| pallet_uniques::Call::mint { .. }
| pallet_uniques::Call::burn { .. }
| pallet_uniques::Call::transfer { .. }
| pallet_uniques::Call::freeze { .. }
| pallet_uniques::Call::thaw { .. }
| pallet_uniques::Call::freeze_collection { .. }
| pallet_uniques::Call::thaw_collection { .. }
| pallet_uniques::Call::transfer_ownership { .. }
| pallet_uniques::Call::set_team { .. }
| pallet_uniques::Call::approve_transfer { .. }
| pallet_uniques::Call::cancel_approval { .. }
| pallet_uniques::Call::force_item_status { .. }
| pallet_uniques::Call::set_attribute { .. }
| pallet_uniques::Call::clear_attribute { .. }
| pallet_uniques::Call::set_metadata { .. }
| pallet_uniques::Call::clear_metadata { .. }
| pallet_uniques::Call::set_collection_metadata { .. }
| pallet_uniques::Call::clear_collection_metadata { .. }
| pallet_uniques::Call::set_accept_ownership { .. }
| pallet_uniques::Call::set_price { .. }
| pallet_uniques::Call::buy_item { .. },
) | RuntimeCall::Identity(
pallet_identity::Call::add_registrar { .. }
| pallet_identity::Call::set_identity { .. }
| pallet_identity::Call::clear_identity { .. }
| pallet_identity::Call::request_judgement { .. }
| pallet_identity::Call::cancel_request { .. }
| pallet_identity::Call::set_fee { .. }
| pallet_identity::Call::set_account_id { .. }
| pallet_identity::Call::set_fields { .. }
| pallet_identity::Call::provide_judgement { .. }
| pallet_identity::Call::kill_identity { .. }
| pallet_identity::Call::add_sub { .. }
| pallet_identity::Call::rename_sub { .. }
| pallet_identity::Call::remove_sub { .. }
| pallet_identity::Call::quit_sub { .. },
) | RuntimeCall::Omnipool(..)
| RuntimeCall::OmnipoolLiquidityMining(..)
| RuntimeCall::OTC(..)
| RuntimeCall::CircuitBreaker(..)
| RuntimeCall::Router(..)
| RuntimeCall::DCA(..)
| RuntimeCall::MultiTransactionPayment(..)
| RuntimeCall::Currencies(..)
| RuntimeCall::Tokens(..)
| RuntimeCall::OrmlXcm(..)
)
}
}
Loading