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

Explicit Para Lifecycle w/ Upgrades and Downgrades #2354

Merged
merged 21 commits into from Feb 4, 2021

Conversation

shawntabrizi
Copy link
Contributor

@shawntabrizi shawntabrizi commented Jan 30, 2021

This PR introduces an explicit lifecycle tracking for paras within the runtime_parachains::paras module.

Changes to parachains are delayed by a session, and as such, tracking exactly what is happening to a Para ID was not very easy.

This introduces a new storage item ParaLifecycles which tracks the current lifecycle of any known Para Id. This replaces the Parathreads storage item since that data is now redundant.

The possible lifecycle states are as follows:

/// The possible states of a para, to take into account delayed lifecycle changes.
pub enum ParaLifecycle {
	/// Para is new and is onboarding as a Parathread.
	OnboardingAsParathread,
	/// Para is new and is onboarding as a Parachain.
	OnboardingAsParachain,
	/// Para is a Parathread.
	Parathread,
	/// Para is a Parachain.
	Parachain,
	/// Para is a Parathread which is upgrading to a Parachain.
	UpgradingToParachain,
	/// Para is a Parachain which is downgrading to a Parathread.
	DowngradingToParathread,
	/// Parachain is being offboarded.
	OutgoingParathread,
	/// Parachain is being offboarded.
	OutgoingParachain,
}

Additionally, this PR introduces the workflow for upgrading a parathread into a parachain, and downgrading a parachain into a parathread.

This will be used for both the Slots/Auction module (which will perform upgrades/downgrades based on parachain auctions and offboarding slots), and also for swaps between parachains and parathreads.

@github-actions github-actions bot added the A0-please_review Pull request needs code review. label Jan 30, 2021
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 fine but needs a guide change.

With this approach I do want to note that once #2300 is implemented, Upgrade and Downgrade will take at least 2 full sessions but probably 3 or more, whereas really they only need to take at least 1 full session - the important thing is that the Upgrade and Downgrade are irreversibly on-chain during that 1 full session.

However that's not a pattern we expect often so it's fine if it takes longer than necessary.

@shawntabrizi shawntabrizi added B7-runtimenoteworthy C1-low PR touches the given topic and has a low impact on builders. labels Jan 31, 2021
@shawntabrizi
Copy link
Contributor Author

This should be ready to review

The Paras module is responsible for storing information on parachains and parathreads. Registered parachains and parathreads cannot change except at session boundaries. This is primarily to ensure that the number of bits required for the availability bitfields does not change except at session boundaries.
The Paras module is responsible for storing information on parachains and parathreads. Registered
parachains and parathreads cannot change except at session boundaries. This is primarily to ensure
that the number of bits required for the availability bitfields does not change except at session
Copy link
Member

@gavofyork gavofyork Feb 1, 2021

Choose a reason for hiding this comment

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

why would the number of bits alter when upgrading/downgrading between parthread and parachain?

Copy link
Contributor

Choose a reason for hiding this comment

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

Every availability core gets its own bit in the bitfield. Parathreads are multiplexed over a fixed number of cores (configured per-session), whereas Parachains each get their own dedicated core. Upgrading from parathread to parachain would alter the amount of availability cores, which would alter the division of validators into groups, which could lead to consensus issues across forks.

Copy link
Member

@gavofyork gavofyork left a comment

Choose a reason for hiding this comment

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

Seems ok. Would be nice to revisit at a later stage when we're thinking about more exotic scheduling systems (e.g. static slot scheduling where two or more parachains occupy slots in a fixed and repetitive pattern).

@gavofyork
Copy link
Member

Would it be convenient to build in parachain/thread swap logic in here now?

@rphmeier
Copy link
Contributor

rphmeier commented Feb 1, 2021

Would it be convenient to build in parachain/thread swap logic in here now?

@gavofyork In a way, that could be done already with the higher-level code (slots) triggering a downgrade of one and an upgrade of the other.

@shawntabrizi
Copy link
Contributor Author

@rphmeier @gavofyork yeah, this is what I did in Registrar. A swap is just a scheduled upgrade and downgrade. I think that is granular enough.

@gavofyork gavofyork mentioned this pull request Feb 3, 2021
8 tasks
@shawntabrizi
Copy link
Contributor Author

There is more that needs to be updated in future PRs, but this is a reasonable checkpoint i think for the direction we are headed.

Some more notes on what is next here: https://hackmd.io/XDkKzaYMSYumhNWzRMEvCQ

@rphmeier rphmeier merged commit 485ccc8 into master Feb 4, 2021
@rphmeier rphmeier deleted the shawntabrizi-para-lifecycle branch February 4, 2021 17:05
ordian added a commit that referenced this pull request Feb 5, 2021
* master:
  node: pass local authorship info to the transaction pool (#2385)
  Explicit Para Lifecycle w/ Upgrades and Downgrades (#2354)
  Cancel Proxy Type (#2334)
  Cargo.lock: Update to libp2p-swarm v0.27.2 (#2384)
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
Development

Successfully merging this pull request may close these issues.

None yet

3 participants