Runtime logging. (#3821)

* Implement Printable for tuples.

* Add debugging function.

* Add debug 1.

* Implement  for everything.

* RuntimeDebug derive.

* Introduce RuntimeDebug.

* Add some dummy logging.

* Replace RuntimeDebug with Debug.

* Revert "Replace RuntimeDebug with Debug."

This reverts commit bc47070a8cb30241b2b590b2fa29fd195088162f.

* Working on Debug for all.

* Fix bounds.

* Add debug utils.

* Implement runtime logging.

* Add some docs and clean up.

* Clean up derives.

* Fix custom derive impl.

* Bump runtime.

* Fix long lines.

* Fix doc test.

* Use CARGO_CFG_STD.

* Revert "Use CARGO_CFG_STD."

This reverts commit ea429566de18ed0fa052571b359eb9826a64a9f4.

* Use parse_macro_input

* Update lockfile.

* Apply review suggestions.

* Remove stray re-export.

* Add no-std impl.

* Update lockfile.
This commit is contained in:
Tomasz Drwięga
2019-10-22 14:13:44 +02:00
committed by Bastian Köcher
parent 934d7aac1c
commit 20a3989785
86 changed files with 1266 additions and 469 deletions
+3 -2
View File
@@ -60,7 +60,7 @@ impl ExecReturnValue {
/// VM-specific errors during execution (eg. division by 0, OOB access, failure to satisfy some
/// precondition of a system call, etc.) or errors with the orchestration (eg. out-of-gas errors, a
/// non-existent destination contract, etc.).
#[cfg_attr(test, derive(Debug))]
#[cfg_attr(test, derive(sr_primitives::RuntimeDebug))]
pub struct ExecError {
pub reason: &'static str,
/// This is an allocated buffer that may be reused. The buffer must be cleared explicitly
@@ -231,7 +231,8 @@ impl<T: Trait> Token<T> for ExecFeeToken {
}
}
#[cfg_attr(any(feature = "std", test), derive(Debug, PartialEq, Eq, Clone))]
#[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq, Clone))]
#[derive(sr_primitives::RuntimeDebug)]
pub enum DeferredAction<T: Trait> {
DepositEvent {
/// A list of topics this event will be deposited with.
+19 -17
View File
@@ -109,15 +109,16 @@ pub use crate::exec::{ExecResult, ExecReturnValue, ExecError, StatusCode};
#[cfg(feature = "std")]
use serde::{Serialize, Deserialize};
use primitives::crypto::UncheckedFrom;
use rstd::{prelude::*, marker::PhantomData};
use rstd::{prelude::*, marker::PhantomData, fmt::Debug};
use codec::{Codec, Encode, Decode};
use runtime_io::blake2_256;
use sr_primitives::{
traits::{Hash, StaticLookup, Zero, MaybeSerializeDebug, Member, SignedExtension},
traits::{Hash, StaticLookup, Zero, MaybeSerializeDeserialize, Member, SignedExtension},
weights::DispatchInfo,
transaction_validity::{
ValidTransaction, InvalidTransaction, TransactionValidity, TransactionValidityError,
},
RuntimeDebug,
};
use support::dispatch::{Result, Dispatchable};
use support::{
@@ -143,8 +144,7 @@ pub trait ComputeDispatchFee<Call, Balance> {
/// Information for managing an acocunt and its sub trie abstraction.
/// This is the required info to cache for an account
#[derive(Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Encode, Decode, RuntimeDebug)]
pub enum ContractInfo<T: Trait> {
Alive(AliveContractInfo<T>),
Tombstone(TombstoneContractInfo<T>),
@@ -207,9 +207,7 @@ pub type AliveContractInfo<T> =
/// Information for managing an account and its sub trie abstraction.
/// This is the required info to cache for an account.
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
#[derive(Encode, Decode, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
pub struct RawAliveContractInfo<CodeHash, Balance, BlockNumber> {
/// Unique ID for the subtree encoded as a bytes vector.
pub trie_id: TrieId,
@@ -228,15 +226,14 @@ pub struct RawAliveContractInfo<CodeHash, Balance, BlockNumber> {
pub type TombstoneContractInfo<T> =
RawTombstoneContractInfo<<T as system::Trait>::Hash, <T as system::Trait>::Hashing>;
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
#[derive(Encode, Decode, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Encode, Decode, PartialEq, Eq, RuntimeDebug)]
pub struct RawTombstoneContractInfo<H, Hasher>(H, PhantomData<Hasher>);
impl<H, Hasher> RawTombstoneContractInfo<H, Hasher>
where
H: Member + MaybeSerializeDebug + AsRef<[u8]> + AsMut<[u8]> + Copy + Default + rstd::hash::Hash
+ Codec,
H: Member + MaybeSerializeDeserialize+ Debug
+ AsRef<[u8]> + AsMut<[u8]> + Copy + Default
+ rstd::hash::Hash + Codec,
Hasher: Hash<Output=H>,
{
fn new(storage_root: &[u8], code_hash: H) -> Self {
@@ -891,8 +888,8 @@ impl<T: Trait> Config<T> {
}
/// Definition of the cost schedule and other parameterizations for wasm vm.
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
#[derive(Clone, Encode, Decode, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug)]
pub struct Schedule {
/// Version of the schedule.
pub version: u32,
@@ -988,9 +985,14 @@ impl<T: Trait + Send + Sync> Default for CheckBlockGasLimit<T> {
}
}
#[cfg(feature = "std")]
impl<T: Trait + Send + Sync> std::fmt::Debug for CheckBlockGasLimit<T> {
fn fmt(&self, _: &mut std::fmt::Formatter) -> std::fmt::Result {
impl<T: Trait + Send + Sync> rstd::fmt::Debug for CheckBlockGasLimit<T> {
#[cfg(feature = "std")]
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
write!(f, "CheckBlockGasLimit")
}
#[cfg(not(feature = "std"))]
fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
Ok(())
}
}