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

Snowbridge - Disable create agent and create channel calls #506

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Location conversion tests for relays and parachains ([polkadot-fellows/runtimes#487](https://github.com/polkadot-fellows/runtimes/pull/487))

### Changed

- Remove Snowbridge create agent and channel extrinsics. ([polkadot-fellows/runtimes#506](https://github.com/polkadot-fellows/runtimes/pull/506))

Changelog for the runtimes governed by the Polkadot Fellowship.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
Expand Down
1 change: 0 additions & 1 deletion integration-tests/emulated/helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub use xcm_emulator::Chain;
/// TODO: when bumping to polkadot-sdk v1.8.0,
/// remove this crate altogether and get the macros from `emulated-integration-tests-common`.
/// TODO: backport this macros to polkadot-sdk

#[macro_export]
macro_rules! test_relay_is_trusted_teleporter {
( $sender_relay:ty, $sender_xcm_config:ty, vec![$( $receiver_para:ty ),+], ($assets:expr, $amount:expr) ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ fn create_agent() {

BridgeHubPolkadot::execute_with(|| {
type RuntimeEvent = <BridgeHubPolkadot as Chain>::RuntimeEvent;
// Check that a message was sent to Ethereum to create the agent
assert_expected_events!(
BridgeHubPolkadot,
vec![
RuntimeEvent::EthereumSystem(snowbridge_pallet_system::Event::CreateAgent {
..
}) => {},
]

let events = BridgeHubPolkadot::events();
assert!(
events.iter().any(|event| !matches!(
event,
RuntimeEvent::EthereumSystem(snowbridge_pallet_system::Event::CreateAgent { .. })
)),
"Create agent event found while not expected."
);
});
}
Expand Down Expand Up @@ -213,14 +213,13 @@ fn create_channel() {
BridgeHubPolkadot::execute_with(|| {
type RuntimeEvent = <BridgeHubPolkadot as Chain>::RuntimeEvent;

// Check that the Channel was created
assert_expected_events!(
BridgeHubPolkadot,
vec![
RuntimeEvent::EthereumSystem(snowbridge_pallet_system::Event::CreateChannel {
..
}) => {},
]
let events = BridgeHubPolkadot::events();
assert!(
events.iter().any(|event| !matches!(
event,
RuntimeEvent::EthereumSystem(snowbridge_pallet_system::Event::CreateChannel { .. })
)),
"Create channel event found while not expected."
);
});
}
Expand Down
23 changes: 20 additions & 3 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ use frame_support::{
genesis_builder_helper::{build_state, get_preset},
parameter_types,
traits::{
tokens::imbalance::ResolveTo, ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse,
Everything, TransformOrigin,
tokens::imbalance::ResolveTo, ConstBool, ConstU32, ConstU64, ConstU8, Contains,
EitherOfDiverse, TransformOrigin,
},
weights::{ConstantMultiplier, Weight, WeightToFee as _},
PalletId,
Expand Down Expand Up @@ -207,6 +207,23 @@ parameter_types! {
pub const SS58Prefix: u8 = 0;
}

pub struct BaseFilter;
impl Contains<RuntimeCall> for BaseFilter {
fn contains(call: &RuntimeCall) -> bool {
// Disallow these Snowbridge system calls.
if matches!(
call,
RuntimeCall::EthereumSystem(snowbridge_pallet_system::Call::create_agent { .. })
) || matches!(
call,
RuntimeCall::EthereumSystem(snowbridge_pallet_system::Call::create_channel { .. })
) {
return false
}
return true
}
}

// Configure FRAME pallets to include in runtime.

impl frame_system::Config for Runtime {
Expand Down Expand Up @@ -244,7 +261,7 @@ impl frame_system::Config for Runtime {
/// The weight of database operations that the runtime can invoke.
type DbWeight = RocksDbWeight;
/// The basic call filter to use in dispatchable.
type BaseCallFilter = Everything;
type BaseCallFilter = BaseFilter;
/// Weight information for the extrinsics of this pallet.
type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
/// Block & extrinsics weights: base values and limits.
Expand Down
Loading