Init RuntimeLogger automatically for each runtime api call (#8128)

* Init `RuntimeLogger` automatically for each runtime api call

This pr change the runtime api in such a way to always and automatically
enable the `RuntimeLogger`. This enables the user to use `log` or
`tracing` from inside the runtime to create log messages. As logging
introduces some extra code and especially increases the size of the wasm
blob. It is advised to disable all logging completely with
`sp-api/disable-logging` when doing the wasm builds for the on-chain
wasm runtime.

Besides these changes, the pr also brings most of the logging found in
frame to the same format "runtime::*".

* Update frame/im-online/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update test-utils/runtime/Cargo.toml

* Fix test

* Don't use tracing in the runtime, as we don't support it :D

* Fixes

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Bastian Köcher
2021-03-01 15:29:17 +01:00
committed by GitHub
parent f2d9bb9ea6
commit 68390d4085
65 changed files with 571 additions and 422 deletions
@@ -92,6 +92,7 @@ pub struct GenesisParameters {
changes_trie_config: Option<ChangesTrieConfiguration>,
heap_pages_override: Option<u64>,
extra_storage: Storage,
wasm_code: Option<Vec<u8>>,
}
impl GenesisParameters {
@@ -113,6 +114,11 @@ impl GenesisParameters {
self.extra_storage.clone(),
)
}
/// Set the wasm code that should be used at genesis.
pub fn set_wasm_code(&mut self, code: Vec<u8>) {
self.wasm_code = Some(code);
}
}
impl substrate_test_client::GenesisInit for GenesisParameters {
@@ -121,6 +127,10 @@ impl substrate_test_client::GenesisInit for GenesisParameters {
let mut storage = self.genesis_config().genesis_map();
if let Some(ref code) = self.wasm_code {
storage.top.insert(sp_core::storage::well_known_keys::CODE.to_vec(), code.clone());
}
let child_roots = storage.children_default.iter().map(|(_sk, child_content)| {
let state_root = <<<runtime::Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
child_content.data.clone().into_iter().collect()