Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Session Delayed Para Changes / Actions Queue #2406

Merged
merged 48 commits into from
Feb 19, 2021

Conversation

shawntabrizi
Copy link
Member

@shawntabrizi shawntabrizi commented Feb 9, 2021

Fixes: #2300

Design Notes: https://hackmd.io/XDkKzaYMSYumhNWzRMEvCQ

This PR introduces a full session delay to any changes to parachains and parathreads in the para module and any changes to the parachains runtime configuration.

Changes:

  • Shared Module for tracking the current session index and safe session to schedule changes.
  • Remove multiple different queues in favor of a single ActionQueue which tracks all paras that need to be updated at the start of a specific session.
  • ActionQueue is a map from SessionIndex -> Vec<ParaId> so we can schedule the change of a para for a future session.
  • Actions are queued for current_session + 2 session index in the future, solving the problem in issue 2300.
  • Cannot queue any other changes to a para when there is already a change in the queue. As such, any para scheduling now returns a result to handle the case where we are not allowed to schedule some task.
  • Configurations are queued for future session.

@shawntabrizi shawntabrizi added A0-please_review Pull request needs code review. B7-runtimenoteworthy C1-low PR touches the given topic and has a low impact on builders. labels Feb 9, 2021
@rphmeier
Copy link
Contributor

This should not close #2300 unless it does something similar for Configuration updates. (disclaimer: haven't looked)

@shawntabrizi
Copy link
Member Author

I am happy to update for PendingConfig too.

Probably best to do it in a follow up PR unless you want me to make this PR larger.

@shawntabrizi
Copy link
Member Author

@rphmeier should be good to go and completely close #2300

@shawntabrizi
Copy link
Member Author

One issue with this PR as it currently stands is that it is possible that a parachain cannot be queued to be offboarded. It is possible to imagine that some combinations of states could be used to grief the parachains system and prevent an offboarding.

That being said, we will always return the result of trying to schedule offboarding, so it can always be handled, but maybe we need to create a more low level API to make sure that a parachain will be offboarded in the future.

@rphmeier rphmeier linked an issue Feb 16, 2021 that may be closed by this pull request
Copy link
Contributor

@rphmeier rphmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks for the cleanup of tests and addition of Shared module

) {
<paras::Module<T>>::schedule_para_initialize(id, genesis);
) -> Result<(), ()> {
<paras::Module<T>>::schedule_para_initialize(id, genesis).map_err(|_| ())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An API nit. When you want to do swapping I assume you'd call onboard() on one and offboard() on the other. The first might succeed and the second might fail. You could either have some kind of atomic updating API where you update multiple paras at once or you just expose the can_* functions here. Something for a follow-up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, will follow up in another PR and with more consideration specifically with the swap integration in registrar

@rphmeier rphmeier merged commit afb6daa into master Feb 19, 2021
@rphmeier rphmeier deleted the shawntabrizi-para-session-delay branch February 19, 2021 03:20
@@ -309,7 +308,7 @@ mod tests {
parameter_types! {
pub const BlockHashCount: u32 = 250;
pub BlockWeights: limits::BlockWeights =
limits::BlockWeights::with_sensible_defaults(4 * 1024 * 1024, NORMAL_RATIO);
frame_system::limits::BlockWeights::simple_max(1024);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering: what was the motivation here?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
6 participants