-
Notifications
You must be signed in to change notification settings - Fork 18
remove Litmus sudo #876
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
Merged
Merged
remove Litmus sudo #876
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2d6f802
sudo
wangminqi 648ab92
Merge branch 'dev' into sudo
wangminqi f5a1fb1
change Root into Root +democracy
wangminqi 262e7e0
Merge branch 'sudo' of https://github.com/litentry/litentry-parachain…
wangminqi e10a70a
Merge branch 'dev' into sudo
wangminqi 67a34b3
debug: recover chainspec rootkey
wangminqi b361dd9
Merge branch 'sudo' of https://github.com/litentry/litentry-parachain…
wangminqi bbaf458
Merge branch 'dev' into sudo
wangminqi 48d380d
Merge branch 'dev' into sudo
Kailai-Wang 6bdc5e7
Merge remote-tracking branch 'origin/dev' into sudo
864adea
fix clippy
94ee47e
Merge branch 'dev' into sudo
wangminqi 265030f
Merge branch 'dev' into sudo
wangminqi 8693f35
Merge branch 'dev' into sudo
wangminqi dda61a3
Merge branch 'dev' into sudo
wangminqi 16c6e55
Merge branch 'dev' into sudo
wangminqi 44e9e15
try to fix #900
0e22a5f
add debug log #900
4943943
make CI tests pass after remove litmus `Sudo`
63fc1ea
fmt
0bfa81b
debug
aeec002
debug
16b534c
Merge branch 'dev' into sudo
Kailai-Wang 85434ff
rococo/litentry align with litmus
3c6622c
remove useless test code
db91322
Merge remote-tracking branch 'origin/sudo' into sudo
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2020-2021 Litentry Technologies GmbH. | ||
// This file is part of Litentry. | ||
// | ||
// Litentry is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Litentry is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Litentry. If not, see <https://www.gnu.org/licenses/>. | ||
use frame_support::{ | ||
traits::{Get, OnRuntimeUpgrade}, | ||
StorageHasher, Twox128, | ||
}; | ||
use sp_std::marker::PhantomData; | ||
|
||
pub struct RemoveSudoAndStorage<T>(PhantomData<T>); | ||
impl<T> OnRuntimeUpgrade for RemoveSudoAndStorage<T> | ||
where | ||
T: frame_system::Config, | ||
{ | ||
#[cfg(feature = "try-runtime")] | ||
fn pre_upgrade() -> Result<(), &'static str> { | ||
log::info!("Pre check pallet Sudo exists"); | ||
assert!( | ||
frame_support::storage::migration::have_storage_value(b"Sudo", b"Key", b"",), | ||
"Storage query fails: Sudo Key" | ||
); | ||
Ok(()) | ||
} | ||
|
||
fn on_runtime_upgrade() -> frame_support::weights::Weight { | ||
use sp_io::KillStorageResult; | ||
// Remove Sudo Storage | ||
// TODO: Very Weak safety | ||
let entries: u64 = 4 + 100; | ||
let _res: KillStorageResult = frame_support::storage::unhashed::clear_prefix( | ||
&Twox128::hash(b"Sudo"), | ||
Some(entries.try_into().unwrap()), | ||
None, | ||
) | ||
.into(); | ||
<T as frame_system::Config>::DbWeight::get().writes(entries) | ||
} | ||
|
||
#[cfg(feature = "try-runtime")] | ||
fn post_upgrade() -> Result<(), &'static str> { | ||
use sp_io::KillStorageResult; | ||
|
||
log::info!("Post check Sudo"); | ||
let res: KillStorageResult = | ||
frame_support::storage::unhashed::clear_prefix(&Twox128::hash(b"Sudo"), Some(0), None) | ||
.into(); | ||
|
||
match res { | ||
KillStorageResult::AllRemoved(0) | KillStorageResult::SomeRemaining(0) => {}, | ||
KillStorageResult::AllRemoved(n) | KillStorageResult::SomeRemaining(n) => { | ||
log::error!("Remaining entries: {:?}", n); | ||
return Err("Sudo not removed") | ||
}, | ||
}; | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.