Skip to content

Commit

Permalink
Merge pull request #938 from sander2/fix/sudo-migration
Browse files Browse the repository at this point in the history
fix: properly remove key in the sudo migration
  • Loading branch information
gregdhill authored Feb 22, 2023
2 parents 217e08b + 3b1a8d7 commit fdc136b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions parachain/runtime/interlay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1278,8 +1278,8 @@ struct SudoMigrationCheck;

impl OnRuntimeUpgrade for SudoMigrationCheck {
fn on_runtime_upgrade() -> Weight {
use frame_support::storage::migration::put_storage_value;
put_storage_value(b"Sudo", b"Key", &[], Option::<AccountId>::None);
use frame_support::storage::migration::take_storage_value;
take_storage_value::<AccountId>(b"Sudo", b"Key", &[]);
Default::default()
}
#[cfg(feature = "try-runtime")]
Expand Down
4 changes: 2 additions & 2 deletions parachain/runtime/kintsugi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,8 @@ struct SudoMigrationCheck;

impl OnRuntimeUpgrade for SudoMigrationCheck {
fn on_runtime_upgrade() -> Weight {
use frame_support::storage::migration::put_storage_value;
put_storage_value(b"Sudo", b"Key", &[], Option::<AccountId>::None);
use frame_support::storage::migration::take_storage_value;
take_storage_value::<AccountId>(b"Sudo", b"Key", &[]);
Default::default()
}
#[cfg(feature = "try-runtime")]
Expand Down
4 changes: 2 additions & 2 deletions standalone/runtime/tests/test_governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,9 @@ fn test_sudo_is_disabled_if_key_is_none() {
})
.dispatch(origin_of(account_of(ALICE))),);

use frame_support::storage::migration::put_storage_value;
use frame_support::storage::migration::take_storage_value;
assert!(!pallet_sudo::Pallet::<Runtime>::key().is_none());
put_storage_value(b"Sudo", b"Key", &[], Option::<AccountId>::None);
take_storage_value::<AccountId>(b"Sudo", b"Key", &[]);
assert!(pallet_sudo::Pallet::<Runtime>::key().is_none());

// assert that sudo does not work when key is none
Expand Down

0 comments on commit fdc136b

Please sign in to comment.