frame-support: Use logging for printing corrupted state (#10612)

`runtime_print!` is printed by default using `debug`, aka not being visible. With `log::error!` it
will be printed directly to the user. Production networks like Polkadot disable logging, but for
them we run special nodes that have logging enabled.
This commit is contained in:
Bastian Köcher
2022-01-08 17:13:54 +01:00
committed by GitHub
parent 46e38e8288
commit e254fd59f2
2 changed files with 8 additions and 3 deletions
+3 -2
View File
@@ -34,8 +34,9 @@ pub fn get<T: Decode + Sized>(child_info: &ChildInfo, key: &[u8]) -> Option<T> {
sp_io::default_child_storage::get(storage_key, key).and_then(|v| { sp_io::default_child_storage::get(storage_key, key).and_then(|v| {
Decode::decode(&mut &v[..]).map(Some).unwrap_or_else(|_| { Decode::decode(&mut &v[..]).map(Some).unwrap_or_else(|_| {
// TODO #3700: error should be handleable. // TODO #3700: error should be handleable.
crate::runtime_print!( log::error!(
"ERROR: Corrupted state in child trie at {:?}/{:?}", target: "runtime::storage",
"Corrupted state in child trie at {:?}/{:?}",
storage_key, storage_key,
key, key,
); );
@@ -25,7 +25,11 @@ pub fn get<T: Decode + Sized>(key: &[u8]) -> Option<T> {
sp_io::storage::get(key).and_then(|val| { sp_io::storage::get(key).and_then(|val| {
Decode::decode(&mut &val[..]).map(Some).unwrap_or_else(|_| { Decode::decode(&mut &val[..]).map(Some).unwrap_or_else(|_| {
// TODO #3700: error should be handleable. // TODO #3700: error should be handleable.
crate::runtime_print!("ERROR: Corrupted state at {:?}", key); log::error!(
target: "runtime::storage",
"Corrupted state at {:?}",
key,
);
None None
}) })
}) })