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

Commit

Permalink
Two-stage upgrade for parachains (#392)
Browse files Browse the repository at this point in the history
* Authorised upgrade doesn't pay fee

* Origin not needed

* Fixes
  • Loading branch information
gavofyork authored Apr 16, 2021
1 parent 8c37b0d commit 689cb16
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,15 @@ decl_module! {
}

#[weight = 1_000_000]
fn enact_authorized_upgrade(origin, code: Vec<u8>) {
fn enact_authorized_upgrade(_origin, code: Vec<u8>) -> DispatchResultWithPostInfo {
// No ensure origin on purpose. We validate by checking the code vs hash in storage.
let required_hash = AuthorizedUpgrade::<T>::get()
.ok_or(Error::<T>::NothingAuthorized)?;
let actual_hash = T::Hashing::hash(&code[..]);
ensure!(actual_hash == required_hash, Error::<T>::Unauthorized);
Self::set_code_impl(code)?;
AuthorizedUpgrade::<T>::kill();
Ok(Pays::No.into())
}

fn on_finalize() {
Expand Down

0 comments on commit 689cb16

Please sign in to comment.