-
Notifications
You must be signed in to change notification settings - Fork 518
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
Coretime auto-renew #4424
base: master
Are you sure you want to change the base?
Coretime auto-renew #4424
Conversation
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.
If it is the sovereign account of the para, why don't we implement auto renew on the para itself? Major reason, I guess: It would be impossible to mess up the timing. Otherwise each para would need to keep track of the sale cycle on Coretime.
But what if the parachain has multiple cores assigned to it? For example, perhaps the parachain wants to keep renewing only one core but has acquired an additional core for this bulk period due to higher demand. The reason I am storing the |
@eskimor I would appreciate a review to see if what I implemented here is sensible before writing benchmarks. |
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/kusama-coretime-renewal/8219/1 |
Could you please explain why this PR wasn't addressed with the comment, "This is out of scope for the broker pallet," similar to how it was done in this PR: link to PR? |
I think this PR is totally in scope for the broker pallet, renewals are a first-class operation supported directly on the coretime chain and this is a UX improvement for teams who want to renew regularly. |
pub trait TaskAccountInterface { | ||
/// The type for representing accounts. | ||
type AccountId; | ||
|
||
/// The overarching origin type. | ||
type OuterOrigin: Into<Result<Self::TaskOrigin, Self::OuterOrigin>>; | ||
|
||
/// The custom task origin. Given that all tasks on Polkadot are parachains this will most | ||
/// likely be the `Parachain` origin. | ||
type TaskOrigin; | ||
|
||
/// Ensures that the origin is a task origin and returns the associated `TaskId`. | ||
fn ensure_task_sovereign_account(o: Self::OuterOrigin) -> Result<TaskId, BadOrigin>; | ||
|
||
/// Returns the associated account of a task. | ||
fn sovereign_account(task: TaskId) -> Option<Self::AccountId>; | ||
} |
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.
I just realized we don't need this at all. We can deal with sovereign accounts just as simple signed origin so there is no need to use the parachains custom origin.
polkadot-sdk/polkadot/xcm/xcm-builder/src/origin_conversion.rs
Lines 27 to 29 in d539778
/// Sovereign accounts use the system's `Signed` origin with an account ID derived from the | |
/// `LocationConverter`. | |
pub struct SovereignSignedViaLocation<LocationConverter, RuntimeOrigin>( |
This will simplify a lot of the code.
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.
OK cool, I'll abandon my review for now then - I'm not all the way through but just have some comments
The CI pipeline was cancelled due to failure one of the required jobs. |
@@ -232,5 +260,7 @@ impl pallet_broker::Config for Runtime { | |||
type WeightInfo = weights::pallet_broker::WeightInfo<Runtime>; | |||
type PalletId = BrokerPalletId; | |||
type AdminOrigin = EnsureRoot<AccountId>; | |||
type SovereignAccountOf = TaskSovereignAccount; | |||
type MaxAutoRenewals = ConstU32<50>; |
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.
Should we set this to at least the number of cores? Slightly lower might come back to bite us
// If we couldn't find the renewal record for the current bulk period we should | ||
// be able to find it for the upcoming bulk period. | ||
// | ||
// If not the core is not eligable for renewal. |
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.
// If not the core is not eligable for renewal. | |
// If not the core is not eligible for renewal. |
@@ -85,7 +85,7 @@ mod v2 { | |||
}; | |||
|
|||
#[storage_alias] | |||
pub type AllowedRenewals<T: Config> = StorageMap< | |||
pub type PotentialRenewals<T: Config> = StorageMap< |
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.
I think your changes to this file were accidental - these should be reverted
pub struct AutoRenewalRecord { | ||
/// The core for which auto renewal is enabled. | ||
pub core: CoreIndex, | ||
/// The task is assigned to the core. We keep track of it so we don't have to look it up when |
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 task is assigned to the core. We keep track of it so we don't have to look it up when | |
/// The task assigned to the core. We keep track of it so we don't have to look it up when |
/// will be charged at the start of every bulk period for renewing core time. | ||
/// | ||
/// - `origin`: Must be the sovereign account of the task | ||
/// - `core`: The core for which we want to enable auto renewal. |
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.
/// - `core`: The core for which we want to enable auto renewal. | |
/// - `core`: The core to which the task to be renewed is currently assigned. |
pub trait TaskAccountInterface { | ||
/// The type for representing accounts. | ||
type AccountId; | ||
|
||
/// The overarching origin type. | ||
type OuterOrigin: Into<Result<Self::TaskOrigin, Self::OuterOrigin>>; | ||
|
||
/// The custom task origin. Given that all tasks on Polkadot are parachains this will most | ||
/// likely be the `Parachain` origin. | ||
type TaskOrigin; | ||
|
||
/// Ensures that the origin is a task origin and returns the associated `TaskId`. | ||
fn ensure_task_sovereign_account(o: Self::OuterOrigin) -> Result<TaskId, BadOrigin>; | ||
|
||
/// Returns the associated account of a task. | ||
fn sovereign_account(task: TaskId) -> Option<Self::AccountId>; | ||
} |
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.
OK cool, I'll abandon my review for now then - I'm not all the way through but just have some comments
This PR adds functionality that allows tasks to enable auto-renewal. Each task eligible for renewal can enable auto-renewal.
A new storage value is added to track all the cores with auto-renewal enabled and the associated task running on the core. The
BoundedVec
is sorted byCoreIndex
to make disabling auto-renewal more efficient.Cores are renewed at the start of a new bulk sale. If auto-renewal fails(e.g. due to the sovereign account of the task not holding sufficient balance), an event will be emitted, and the renewal will continue for the other cores.
The two added extrinsics are:
enable_auto_renew
: Extrinsic for enabling auto renewal.disable_auto_renew
: Extrinsic for disabling auto renewal.TODOs:
Closes: #4351