Skip to content
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

Fix parachain upgrade scheduling when done by the owner/root #3341

Merged
merged 14 commits into from
Apr 2, 2024

Conversation

bkchr
Copy link
Member

@bkchr bkchr commented Feb 15, 2024

When using schedule_code_upgrade to change the code of a parachain in the relay chain runtime, we had already fixed to not set the GoAhead signal. This was done to not brick any parachain after the upgrade, because they were seeing the signal without having any upgrade prepared. The remaining problem is that the parachain code is only upgraded after a parachain header was enacted, aka the parachain made some progress. However, this is quite complicated if the parachain is bricked (which is the most common scenario why to manually schedule a code upgrade). Thus, this pull request replaces SetGoAhead with UpgradeStrategy to signal to the logic kind of strategy want to use. The strategies are either SetGoAheadSignal or ApplyAtExpectedBlock. SetGoAheadSignal sets the go ahead signal as before and awaits a parachain block. ApplyAtExpectedBlock schedules the upgrade and applies it directly at the expected_block without waiting for the parachain to make any kind of progress.

When using `schedule_code_upgrade` to change the code of a parachain in
the relay chain runtime, we had already fixed to not set the `GoAhead`
signal. This was done to not brick any parachain after the upgrade,
because they were seeing the signal without having any upgrade prepared.
The remaining problem is that the parachain code is only upgraded after
a parachain header was enacted, aka the parachain made some progress.
However, this is quite complicated if the parachain is bricked (which is
the most common scenario why to manually schedule a code upgrade). Thus,
this pull request replaces `SetGoAhead` with `EnactUpgradeDirectly` to
signal to the logic that we don't want to set the go ahead signal and
that we want to replace the current parachain code directly without
waiting for some progress of the parachain.
@bkchr bkchr added the T8-polkadot This PR/Issue is related to/affects the Polkadot network. label Feb 15, 2024
now + cfg.minimum_validation_upgrade_delay,
);

if upgrade_strategy == UpgradeStrategy::ApplyAtExpectedBlock {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Why is this not a match? Would be a tad more future proof in case someone introduces more variants.

@bkchr bkchr requested a review from sandreim March 27, 2024 23:36
@bkchr bkchr enabled auto-merge March 28, 2024 09:28
weight += T::DbWeight::get().reads_writes(1, 4);
FutureCodeUpgrades::<T>::insert(&id, expected_at);
match upgrade_strategy {
UpgradeStrategy::SetGoAheadSignal => {
Copy link
Contributor

@sandreim sandreim Apr 1, 2024

Choose a reason for hiding this comment

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

This match arm here seems to be doing what needs to be done for UpgradeStrategy::ApplyAtExpectedBlock.

Copy link
Member Author

Choose a reason for hiding this comment

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

LOL. I'm an idiot. Broken it with one of the last commits.

@bkchr bkchr added this pull request to the merge queue Apr 2, 2024
Merged via the queue into master with commit 12eb285 Apr 2, 2024
133 of 134 checks passed
@bkchr bkchr deleted the bkchr-go-ahead-fix branch April 2, 2024 10:10
Ank4n pushed a commit that referenced this pull request Apr 9, 2024
When using `schedule_code_upgrade` to change the code of a parachain in
the relay chain runtime, we had already fixed to not set the `GoAhead`
signal. This was done to not brick any parachain after the upgrade,
because they were seeing the signal without having any upgrade prepared.
The remaining problem is that the parachain code is only upgraded after
a parachain header was enacted, aka the parachain made some progress.
However, this is quite complicated if the parachain is bricked (which is
the most common scenario why to manually schedule a code upgrade). Thus,
this pull request replaces `SetGoAhead` with `UpgradeStrategy` to signal
to the logic kind of strategy want to use. The strategies are either
`SetGoAheadSignal` or `ApplyAtExpectedBlock`. `SetGoAheadSignal` sets
the go ahead signal as before and awaits a parachain block.
`ApplyAtExpectedBlock` schedules the upgrade and applies it directly at
the `expected_block` without waiting for the parachain to make any kind
of progress.
dharjeezy pushed a commit to dharjeezy/polkadot-sdk that referenced this pull request Apr 9, 2024
…ech#3341)

When using `schedule_code_upgrade` to change the code of a parachain in
the relay chain runtime, we had already fixed to not set the `GoAhead`
signal. This was done to not brick any parachain after the upgrade,
because they were seeing the signal without having any upgrade prepared.
The remaining problem is that the parachain code is only upgraded after
a parachain header was enacted, aka the parachain made some progress.
However, this is quite complicated if the parachain is bricked (which is
the most common scenario why to manually schedule a code upgrade). Thus,
this pull request replaces `SetGoAhead` with `UpgradeStrategy` to signal
to the logic kind of strategy want to use. The strategies are either
`SetGoAheadSignal` or `ApplyAtExpectedBlock`. `SetGoAheadSignal` sets
the go ahead signal as before and awaits a parachain block.
`ApplyAtExpectedBlock` schedules the upgrade and applies it directly at
the `expected_block` without waiting for the parachain to make any kind
of progress.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T8-polkadot This PR/Issue is related to/affects the Polkadot network.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants