diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 8291eb6d15c1ef25fe0ae2dc4826c5b66ab48e70..cd135d16f1d3bab77e387206e4ad49ae951a4355 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -786,6 +786,7 @@ name = "native-runtime" version = "0.1.0" dependencies = [ "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "runtime-std 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/substrate/native-runtime/Cargo.toml b/substrate/native-runtime/Cargo.toml index 5ee1706e9cf08f630bee634b589cd15c0a2f74b8..2d8f7c7c65a550f4898bb075d6f08e122c39c402 100644 --- a/substrate/native-runtime/Cargo.toml +++ b/substrate/native-runtime/Cargo.toml @@ -12,3 +12,4 @@ without-std = [] runtime-std = { path = "./std", version = "0.1" } rustc-hex = "1.0" hex-literal = "0.1.0" +log = "0.3" diff --git a/substrate/wasm-runtime/polkadot/src/lib.rs b/substrate/wasm-runtime/polkadot/src/lib.rs index eefa6e44a875b7605cbd3eb24c59f5521d1c2262..3729611866e0be401d3bacdd3defbde098af7b6d 100644 --- a/substrate/wasm-runtime/polkadot/src/lib.rs +++ b/substrate/wasm-runtime/polkadot/src/lib.rs @@ -24,6 +24,9 @@ extern crate runtime_std; #[cfg(feature = "with-std")] extern crate rustc_hex; +#[cfg(feature = "with-std")] +#[macro_use] +extern crate log; #[cfg(test)] #[macro_use] diff --git a/substrate/wasm-runtime/polkadot/src/runtime/system.rs b/substrate/wasm-runtime/polkadot/src/runtime/system.rs index acde21aa751d9d04372d7dea838a86f2df9e7185..9655b0ea53619244fd0246a415d3adbcde95e58c 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/system.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/system.rs @@ -146,7 +146,7 @@ fn initial_checks(block: &Block) { let txs = block.transactions.iter().map(Slicable::to_vec).collect::<Vec<_>>(); let txs = txs.iter().map(Vec::as_slice).collect::<Vec<_>>(); let txs_root = enumerated_trie_root(&txs); - debug_assert_hash(&header.transaction_root, &txs_root); + info_expect_equal_hash(&header.transaction_root, &txs_root); assert!(header.transaction_root == txs_root, "Transaction trie root must be valid."); } @@ -160,7 +160,7 @@ fn final_checks(block: &Block) { // check storage root. let storage_root = storage_root(); - debug_assert_hash(&header.state_root, &storage_root); + info_expect_equal_hash(&header.state_root, &storage_root); assert!(header.state_root == storage_root, "Storage root must match that calculated."); } @@ -171,15 +171,15 @@ fn post_finalise(header: &Header) { } #[cfg(feature = "with-std")] -fn debug_assert_hash(given: &Hash, expected: &Hash) { +fn info_expect_equal_hash(given: &Hash, expected: &Hash) { use support::HexDisplay; if given != expected { - println!("Hash: given={}, expected={}", HexDisplay::from(given), HexDisplay::from(expected)); + info!("Hash: given={}, expected={}", HexDisplay::from(given), HexDisplay::from(expected)); } } #[cfg(not(feature = "with-std"))] -fn debug_assert_hash(_given: &Hash, _expected: &Hash) {} +fn info_expect_equal_hash(_given: &Hash, _expected: &Hash) {} #[cfg(test)] mod tests {