Skip to content

Commit

Permalink
Mitigate coretime auto-renew benchmarked weights issues (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
seadanda authored Nov 20, 2024
1 parent 5767f90 commit adc262e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion system-parachains/coretime/coretime-kusama/src/coretime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,6 @@ impl pallet_broker::Config for Runtime {
type PalletId = BrokerPalletId;
type AdminOrigin = EnsureRoot<AccountId>;
type SovereignAccountOf = SovereignAccountOf;
type MaxAutoRenewals = ConstU32<100>;
type MaxAutoRenewals = ConstU32<0>;
type PriceAdapter = pallet_broker::CenterTargetPrice<Balance>;
}
18 changes: 13 additions & 5 deletions system-parachains/coretime/coretime-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RuntimeCall> 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<RuntimeCall> 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<IsBrokerCreditPurchaseCall>;
type BaseCallFilter = EverythingBut<IsFilteredBrokerCall>;
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
/// The nonce type for storing how many extrinsics an account has signed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,6 @@ impl pallet_broker::Config for Runtime {
type PalletId = BrokerPalletId;
type AdminOrigin = EnsureRoot<AccountId>;
type SovereignAccountOf = SovereignAccountOf;
type MaxAutoRenewals = ConstU32<100>;
type MaxAutoRenewals = ConstU32<0>;
type PriceAdapter = pallet_broker::CenterTargetPrice<Balance>;
}
14 changes: 9 additions & 5 deletions system-parachains/coretime/coretime-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RuntimeCall> 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 { .. })
)
}
}
Expand Down

0 comments on commit adc262e

Please sign in to comment.