-
Notifications
You must be signed in to change notification settings - Fork 836
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
Move AllPalletsWithSystem::decode_entire_state
to own runtime API
#2263
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -322,10 +322,6 @@ where | |
log::error!(target: LOG_TARGET, "failure: {:?}", e); | ||
e | ||
})?; | ||
if select.any() { | ||
let res = AllPalletsWithSystem::try_decode_entire_state(); | ||
Self::log_decode_result(res)?; | ||
} | ||
drop(_guard); | ||
|
||
// do some of the checks that would normally happen in `final_checks`, but perhaps skip | ||
|
@@ -362,6 +358,12 @@ where | |
Ok(frame_system::Pallet::<System>::block_weight().total()) | ||
} | ||
|
||
pub fn try_decode_entire_state() -> Result<(), TryRuntimeError> { | ||
let _ = frame_support::StorageNoopGuard::default(); | ||
let res = AllPalletsWithSystem::try_decode_entire_state(); | ||
Self::log_decode_result(res) | ||
} | ||
|
||
/// Execute all `OnRuntimeUpgrade` of this runtime. | ||
/// | ||
/// The `checks` param determines whether to execute `pre/post_upgrade` and `try_state` hooks. | ||
|
@@ -375,12 +377,6 @@ where | |
// Nothing should modify the state after the migrations ran: | ||
let _guard = StorageNoopGuard::default(); | ||
|
||
// The state must be decodable: | ||
if checks.any() { | ||
let res = AllPalletsWithSystem::try_decode_entire_state(); | ||
Self::log_decode_result(res)?; | ||
} | ||
Comment on lines
-379
to
-382
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me answer this question in 2 parts.
1. How we could add it to
|
||
|
||
// Check all storage invariants: | ||
if checks.try_state() { | ||
AllPalletsWithSystem::try_state( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just panic inside
try_decode_entire_state
instead of copying this comment everywhere? 🙈