From c5a76450d5efbd02d7b5bdf43ca0eeb3446c4568 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Fri, 6 Dec 2024 14:02:04 +0200 Subject: [PATCH 1/8] disable create agent channel --- .../src/tests/snowbridge.rs | 31 +++++++++---------- .../bridge-hub-polkadot/src/lib.rs | 27 ++++++++++++++-- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs index 30f28c9951..f579a049ac 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs @@ -133,14 +133,14 @@ fn create_agent() { BridgeHubPolkadot::execute_with(|| { type RuntimeEvent = ::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." ); }); } @@ -213,14 +213,13 @@ fn create_channel() { BridgeHubPolkadot::execute_with(|| { type RuntimeEvent = ::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." ); }); } diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs index a9285f44e6..a1c3a1e018 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -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, @@ -207,6 +207,27 @@ parameter_types! { pub const SS58Prefix: u8 = 0; } +/// We currently allow all calls. +pub struct BaseFilter; +impl Contains for BaseFilter { + fn contains(call: &RuntimeCall) -> bool { + if matches!( + call, + RuntimeCall::EthereumSystem(snowbridge_pallet_system::Call::create_agent { .. }) + ) || matches!( + call, + RuntimeCall::EthereumSystem(snowbridge_pallet_system::Call::create_channel { .. }) + ) { + log::trace!(target: "xcm::contains", "contains call create_agent or create_channel"); + + return false + } + log::trace!(target: "xcm::contains", "does not contain call create_agent or create_channel"); + + return true + } +} + // Configure FRAME pallets to include in runtime. impl frame_system::Config for Runtime { @@ -244,7 +265,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; /// Block & extrinsics weights: base values and limits. From 9e560734d310035ff3b55ade65cb39997bf785ab Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Fri, 6 Dec 2024 14:04:16 +0200 Subject: [PATCH 2/8] cleanup config --- .../bridge-hubs/bridge-hub-polkadot/src/lib.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs index a1c3a1e018..40b28604b0 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -207,10 +207,10 @@ parameter_types! { pub const SS58Prefix: u8 = 0; } -/// We currently allow all calls. pub struct BaseFilter; impl Contains for BaseFilter { fn contains(call: &RuntimeCall) -> bool { + // Disallow these Snowbridge system calls. if matches!( call, RuntimeCall::EthereumSystem(snowbridge_pallet_system::Call::create_agent { .. }) @@ -218,12 +218,8 @@ impl Contains for BaseFilter { call, RuntimeCall::EthereumSystem(snowbridge_pallet_system::Call::create_channel { .. }) ) { - log::trace!(target: "xcm::contains", "contains call create_agent or create_channel"); - return false } - log::trace!(target: "xcm::contains", "does not contain call create_agent or create_channel"); - return true } } From a2c3a4eb5ace9ee9756c2ee1fb1d4c6babc98f80 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Fri, 6 Dec 2024 14:13:32 +0200 Subject: [PATCH 3/8] adds test --- .../src/tests/snowbridge.rs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs index f579a049ac..4ad7b433ba 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs @@ -86,6 +86,28 @@ pub fn send_inbound_message(fixture: InboundQueueFixture) -> DispatchResult { ) } +#[test] +fn create_agent_2() { + let origin_para: u32 = 1001; + // Fund the origin parachain sovereign account so that it can pay execution fees. + BridgeHubPolkadot::fund_para_sovereign(origin_para.into(), INITIAL_FUND); + // Fund Treasury account with ED so that when create agent fees are paid to treasury, + // the treasury account may exist. + BridgeHubPolkadot::fund_accounts(vec![(RelayTreasuryPalletAccount::get(), INITIAL_FUND)]); + let parachain_sovereign = BridgeHubPolkadot::sovereign_account_id_of(Location::new( + 1, + [Parachain(origin_para.into())], + )); + + BridgeHubPolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + // Check that a message was sent to Ethereum to create the agent + assert_ok!(::EthereumSystem::create_agent( + ::RuntimeOrigin::signed(parachain_sovereign), + )); + }); +} + /// Create an agent on Ethereum. An agent is a representation of an entity in the Polkadot /// ecosystem (like a parachain) on Ethereum. #[test] From 23316fbfc102a818dd4f1b97e53254d8a74d5a8f Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Mon, 9 Dec 2024 08:24:57 +0200 Subject: [PATCH 4/8] Revert "adds test" This reverts commit a2c3a4eb5ace9ee9756c2ee1fb1d4c6babc98f80. --- .../src/tests/snowbridge.rs | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs index 4ad7b433ba..f579a049ac 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs @@ -86,28 +86,6 @@ pub fn send_inbound_message(fixture: InboundQueueFixture) -> DispatchResult { ) } -#[test] -fn create_agent_2() { - let origin_para: u32 = 1001; - // Fund the origin parachain sovereign account so that it can pay execution fees. - BridgeHubPolkadot::fund_para_sovereign(origin_para.into(), INITIAL_FUND); - // Fund Treasury account with ED so that when create agent fees are paid to treasury, - // the treasury account may exist. - BridgeHubPolkadot::fund_accounts(vec![(RelayTreasuryPalletAccount::get(), INITIAL_FUND)]); - let parachain_sovereign = BridgeHubPolkadot::sovereign_account_id_of(Location::new( - 1, - [Parachain(origin_para.into())], - )); - - BridgeHubPolkadot::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - // Check that a message was sent to Ethereum to create the agent - assert_ok!(::EthereumSystem::create_agent( - ::RuntimeOrigin::signed(parachain_sovereign), - )); - }); -} - /// Create an agent on Ethereum. An agent is a representation of an entity in the Polkadot /// ecosystem (like a parachain) on Ethereum. #[test] From 0de263dd03ef7f1e9221c92442e4a17e383b6b88 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Mon, 9 Dec 2024 08:27:56 +0200 Subject: [PATCH 5/8] adds changelog --- CHANGELOG.md | 4 ++++ .../tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48939176a2..8a1c1d6fb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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/). diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs index f579a049ac..7597e6463a 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs @@ -97,7 +97,7 @@ fn create_agent() { // the treasury account may exist. BridgeHubPolkadot::fund_accounts(vec![(RelayTreasuryPalletAccount::get(), INITIAL_FUND)]); - let sudo_origin = ::RuntimeOrigin::root(); + let sudo_origin = ::RuntimeOrigin::root();;ew let destination = Polkadot::child_location_of(BridgeHubPolkadot::para_id()).into(); let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {}); From 95bb2c693dd9a8443c0e9a4b939e716f586466af Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Mon, 9 Dec 2024 08:37:34 +0200 Subject: [PATCH 6/8] revert typo --- .../tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs index 7597e6463a..f579a049ac 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs @@ -97,7 +97,7 @@ fn create_agent() { // the treasury account may exist. BridgeHubPolkadot::fund_accounts(vec![(RelayTreasuryPalletAccount::get(), INITIAL_FUND)]); - let sudo_origin = ::RuntimeOrigin::root();;ew + let sudo_origin = ::RuntimeOrigin::root(); let destination = Polkadot::child_location_of(BridgeHubPolkadot::para_id()).into(); let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {}); From 4335272fa8ff27b78523309f0d1827f46eaed51c Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Mon, 9 Dec 2024 08:54:53 +0200 Subject: [PATCH 7/8] clippy --- integration-tests/emulated/helpers/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/integration-tests/emulated/helpers/src/lib.rs b/integration-tests/emulated/helpers/src/lib.rs index 5e182829fc..08bf402e9d 100644 --- a/integration-tests/emulated/helpers/src/lib.rs +++ b/integration-tests/emulated/helpers/src/lib.rs @@ -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) ) => { From 10108f78abd5a9d22c2ec08716147a695b3ca182 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Thu, 12 Dec 2024 10:04:17 +0200 Subject: [PATCH 8/8] clippy --- relay/polkadot/src/coretime_migration.rs | 2 +- system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/relay/polkadot/src/coretime_migration.rs b/relay/polkadot/src/coretime_migration.rs index 54e498e19a..9fc595031a 100644 --- a/relay/polkadot/src/coretime_migration.rs +++ b/relay/polkadot/src/coretime_migration.rs @@ -244,7 +244,7 @@ fn migrate_send_assignments_to_coretime_chain< }, }; - let time_slice = (valid_until + TIMESLICE_PERIOD - 1) / TIMESLICE_PERIOD; + let time_slice = valid_until.div_ceil(TIMESLICE_PERIOD); log::trace!(target: "coretime-migration", "Sending of lease holding para {:?}, valid_until: {:?}, time_slice: {:?}", p, valid_until, time_slice); Some(mk_coretime_call::(CoretimeCalls::SetLease(p.into(), time_slice))) }); diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 40b28604b0..fb126dd71b 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -218,9 +218,9 @@ impl Contains for BaseFilter { call, RuntimeCall::EthereumSystem(snowbridge_pallet_system::Call::create_channel { .. }) ) { - return false + return false; } - return true + true } }