-
Notifications
You must be signed in to change notification settings - Fork 798
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
[pallet-broker] add extrinsic to remove a lease #7026
base: master
Are you sure you want to change the base?
Changes from all commits
3b6e4cd
3830afd
417c887
36a58a2
13115e1
05dac06
5a8ba8a
9a0c87e
c4316b7
e84c083
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
||
title: "[pallet-broker] add extrinsic to remove a lease" | ||
|
||
doc: | ||
- audience: Runtime User | ||
description: | | ||
A new `remove_lease` extrinsic is introduced to the broker pallet to allow a lease to be removed by the root origin. | ||
|
||
crates: | ||
- name: pallet-broker | ||
bump: major | ||
- name: coretime-rococo-runtime | ||
bump: patch | ||
- name: coretime-westend-runtime | ||
bump: patch |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -333,6 +333,11 @@ pub mod pallet { | |||||
/// longer apply). | ||||||
until: Timeslice, | ||||||
}, | ||||||
/// A lease has been removed. | ||||||
LeaseRemoved { | ||||||
/// The task to which a core was assigned. | ||||||
task: TaskId, | ||||||
}, | ||||||
/// A lease is about to end. | ||||||
LeaseEnding { | ||||||
/// The task to which a core was assigned. | ||||||
|
@@ -512,6 +517,8 @@ pub mod pallet { | |||||
TooManyReservations, | ||||||
/// The maximum amount of leases has already been reached. | ||||||
TooManyLeases, | ||||||
/// The lease does not exist. | ||||||
LeaseNotFound, | ||||||
/// The revenue for the Instantaneous Core Sales of this period is not (yet) known and thus | ||||||
/// this operation cannot proceed. | ||||||
UnknownRevenue, | ||||||
|
@@ -969,6 +976,16 @@ pub mod pallet { | |||||
Ok(Pays::No.into()) | ||||||
} | ||||||
|
||||||
/// Remove a lease. | ||||||
/// | ||||||
/// - `origin`: Must be Root or pass `AdminOrigin`. | ||||||
/// - `task`: The workload of the lease which should be removed. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Also from memory there can be multiple leases for a given |
||||||
#[pallet::call_index(24)] | ||||||
pub fn remove_lease(origin: OriginFor<T>, task: TaskId) -> DispatchResult { | ||||||
T::AdminOrigin::ensure_origin_or_root(origin)?; | ||||||
Self::do_remove_lease(task) | ||||||
} | ||||||
|
||||||
#[pallet::call_index(99)] | ||||||
#[pallet::weight(T::WeightInfo::swap_leases())] | ||||||
pub fn swap_leases(origin: OriginFor<T>, id: TaskId, other: TaskId) -> DispatchResult { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the worst case would be removing the last task in the vec. Here it removes the first one.
Though in practice the cost should be negligible as
MaxLeasedCores
isn't so big.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, would be nice to target the worst case, especially here where it's as straightforward as just changing the task id.