mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +00:00
Fix parachain upgrade scheduling when done by the owner/root (#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.
This commit is contained in:
@@ -29,7 +29,7 @@ use frame_system::{self, ensure_root, ensure_signed};
|
||||
use primitives::{HeadData, Id as ParaId, ValidationCode, LOWEST_PUBLIC_ID, MIN_CODE_SIZE};
|
||||
use runtime_parachains::{
|
||||
configuration, ensure_parachain,
|
||||
paras::{self, ParaGenesisArgs, SetGoAhead},
|
||||
paras::{self, ParaGenesisArgs, UpgradeStrategy},
|
||||
Origin, ParaLifecycle,
|
||||
};
|
||||
use sp_std::{prelude::*, result};
|
||||
@@ -408,6 +408,13 @@ pub mod pallet {
|
||||
|
||||
/// Schedule a parachain upgrade.
|
||||
///
|
||||
/// This will kick off a check of `new_code` by all validators. After the majority of the
|
||||
/// validators have reported on the validity of the code, the code will either be enacted
|
||||
/// or the upgrade will be rejected. If the code will be enacted, the current code of the
|
||||
/// parachain will be overwritten directly. This means that any PoV will be checked by this
|
||||
/// new code. The parachain itself will not be informed explictely that the validation code
|
||||
/// has changed.
|
||||
///
|
||||
/// Can be called by Root, the parachain, or the parachain manager if the parachain is
|
||||
/// unlocked.
|
||||
#[pallet::call_index(7)]
|
||||
@@ -418,7 +425,11 @@ pub mod pallet {
|
||||
new_code: ValidationCode,
|
||||
) -> DispatchResult {
|
||||
Self::ensure_root_para_or_owner(origin, para)?;
|
||||
runtime_parachains::schedule_code_upgrade::<T>(para, new_code, SetGoAhead::No)?;
|
||||
runtime_parachains::schedule_code_upgrade::<T>(
|
||||
para,
|
||||
new_code,
|
||||
UpgradeStrategy::ApplyAtExpectedBlock,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user