From adc262e86f770e8d55eb8a57656b6210719677c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=B3nal=20Murray?= Date: Wed, 20 Nov 2024 13:52:35 +0100 Subject: [PATCH] Mitigate coretime auto-renew benchmarked weights issues (#6) --- .../coretime/coretime-kusama/src/coretime.rs | 2 +- .../coretime/coretime-kusama/src/lib.rs | 18 +++++++++++++----- .../coretime/coretime-polkadot/src/coretime.rs | 2 +- .../coretime/coretime-polkadot/src/lib.rs | 14 +++++++++----- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/system-parachains/coretime/coretime-kusama/src/coretime.rs b/system-parachains/coretime/coretime-kusama/src/coretime.rs index 489e0a1fc4..a1f861e8ff 100644 --- a/system-parachains/coretime/coretime-kusama/src/coretime.rs +++ b/system-parachains/coretime/coretime-kusama/src/coretime.rs @@ -345,6 +345,6 @@ impl pallet_broker::Config for Runtime { type PalletId = BrokerPalletId; type AdminOrigin = EnsureRoot; type SovereignAccountOf = SovereignAccountOf; - type MaxAutoRenewals = ConstU32<100>; + type MaxAutoRenewals = ConstU32<0>; type PriceAdapter = pallet_broker::CenterTargetPrice; } diff --git a/system-parachains/coretime/coretime-kusama/src/lib.rs b/system-parachains/coretime/coretime-kusama/src/lib.rs index ceddd02ac9..9547cd5f07 100644 --- a/system-parachains/coretime/coretime-kusama/src/lib.rs +++ b/system-parachains/coretime/coretime-kusama/src/lib.rs @@ -183,19 +183,27 @@ parameter_types! { pub const SS58Prefix: u8 = 2; } -/// Filter out credit purchase calls until the credit system is implemented. Otherwise, users +/// Filter: +/// - Credit purchase calls until the credit system is implemented. Otherwise, users /// may have chance of locking their funds forever on purchased credits they cannot use. -pub struct IsBrokerCreditPurchaseCall; -impl Contains for IsBrokerCreditPurchaseCall { +/// - Auto-renew functionality until resolution of polkadot-sdk issue +/// [#6474](https://github.com/paritytech/polkadot-sdk/issues/6474) +pub struct IsFilteredBrokerCall; +impl Contains for IsFilteredBrokerCall { fn contains(c: &RuntimeCall) -> bool { - matches!(c, RuntimeCall::Broker(pallet_broker::Call::purchase_credit { .. })) + matches!( + c, + RuntimeCall::Broker(pallet_broker::Call::purchase_credit { .. }) | + RuntimeCall::Broker(pallet_broker::Call::enable_auto_renew { .. }) | + RuntimeCall::Broker(pallet_broker::Call::disable_auto_renew { .. }) + ) } } // Configure FRAME pallets to include in runtime. #[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Runtime { - type BaseCallFilter = EverythingBut; + type BaseCallFilter = EverythingBut; /// The identifier used to distinguish between accounts. type AccountId = AccountId; /// The nonce type for storing how many extrinsics an account has signed. diff --git a/system-parachains/coretime/coretime-polkadot/src/coretime.rs b/system-parachains/coretime/coretime-polkadot/src/coretime.rs index bd4bed70bf..4a4e438a88 100644 --- a/system-parachains/coretime/coretime-polkadot/src/coretime.rs +++ b/system-parachains/coretime/coretime-polkadot/src/coretime.rs @@ -348,6 +348,6 @@ impl pallet_broker::Config for Runtime { type PalletId = BrokerPalletId; type AdminOrigin = EnsureRoot; type SovereignAccountOf = SovereignAccountOf; - type MaxAutoRenewals = ConstU32<100>; + type MaxAutoRenewals = ConstU32<0>; type PriceAdapter = pallet_broker::CenterTargetPrice; } diff --git a/system-parachains/coretime/coretime-polkadot/src/lib.rs b/system-parachains/coretime/coretime-polkadot/src/lib.rs index 41c30ac263..c6c9d9f434 100644 --- a/system-parachains/coretime/coretime-polkadot/src/lib.rs +++ b/system-parachains/coretime/coretime-polkadot/src/lib.rs @@ -180,17 +180,21 @@ parameter_types! { pub const SS58Prefix: u8 = 0; } -/// Filter out credit purchase calls until the credit system is implemented. -/// -/// Otherwise, users may have chance of locking their funds forever on purchased credits they cannot -/// use. Also filter the interlace call until the relay can support this fully. +/// Filter: +/// - Credit purchase calls until the credit system is implemented. Otherwise, users +/// may have chance of locking their funds forever on purchased credits they cannot use. +/// - The interlace call until the relay can support this fully +/// - Auto-renew functionality until resolution of polkadot-sdk issue +/// [#6474](https://github.com/paritytech/polkadot-sdk/issues/6474) pub struct IsFilteredBrokerCall; impl Contains for IsFilteredBrokerCall { fn contains(c: &RuntimeCall) -> bool { matches!( c, RuntimeCall::Broker(pallet_broker::Call::purchase_credit { .. }) | - RuntimeCall::Broker(pallet_broker::Call::interlace { .. }) + RuntimeCall::Broker(pallet_broker::Call::interlace { .. }) | + RuntimeCall::Broker(pallet_broker::Call::enable_auto_renew { .. }) | + RuntimeCall::Broker(pallet_broker::Call::disable_auto_renew { .. }) ) } }