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
+1 -2
View File
@@ -20,8 +20,7 @@ use crate::{Perbill, traits::{SimpleArithmetic, SaturatedConversion}};
use core::ops::Sub;
/// Piecewise Linear function in [0, 1] -> [0, 1].
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(PartialEq, Eq)]
#[derive(PartialEq, Eq, primitives::RuntimeDebug)]
pub struct PiecewiseLinear<'a> {
/// Array of points. Must be in order from the lowest abscissas to the highest.
pub points: &'a [(Perbill, Perbill)]
@@ -23,13 +23,14 @@ use std::fmt;
use serde::{Deserialize, Serialize};
use rstd::prelude::*;
use primitives::RuntimeDebug;
use crate::codec::{Codec, Encode, Decode};
use crate::traits::{self, Member, Block as BlockT, Header as HeaderT, MaybeSerialize};
use crate::Justification;
/// Something to identify a block.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Debug, Serialize))]
#[derive(PartialEq, Eq, Clone, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
pub enum BlockId<Block: BlockT> {
@@ -61,8 +62,8 @@ impl<Block: BlockT> fmt::Display for BlockId<Block> {
}
/// Abstraction over a substrate block.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
pub struct Block<Header, Extrinsic: MaybeSerialize> {
@@ -99,8 +100,8 @@ where
}
/// Abstraction over a substrate block and justification.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
pub struct SignedBlock<Block> {
@@ -26,8 +26,7 @@ use crate::transaction_validity::TransactionValidity;
/// Definition of something that the external world might want to say; its
/// existence implies that it has been checked and is good, particularly with
/// regards to the signature.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(PartialEq, Eq, Clone, primitives::RuntimeDebug)]
pub struct CheckedExtrinsic<AccountId, Call, Extra> {
/// Who this purports to be from and the number of extrinsics have come before
/// from the same signer, if anyone (note this is not a signature).
@@ -23,10 +23,11 @@ use rstd::prelude::*;
use crate::ConsensusEngineId;
use crate::codec::{Decode, Encode, Input, Error};
use primitives::RuntimeDebug;
/// Generic header digest.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct Digest<Hash: Encode + Decode> {
/// A list of logs in the digest.
pub logs: Vec<DigestItem<Hash>>,
@@ -72,8 +73,7 @@ impl<Hash: Encode + Decode> Digest<Hash> {
/// Digest item that is able to encode/decode 'system' digest items and
/// provide opaque access to other items.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(PartialEq, Eq, Clone, RuntimeDebug)]
pub enum DigestItem<Hash> {
/// System digest item that contains the root of changes trie at given
/// block. It is created for every block iff runtime supports changes
@@ -123,8 +123,7 @@ impl<'a, Hash: Decode> serde::Deserialize<'a> for DigestItem<Hash> {
/// A 'referencing view' for digest item. Does not own its contents. Used by
/// final runtime implementations for encoding/decoding its log items.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(PartialEq, Eq, Clone, RuntimeDebug)]
pub enum DigestItemRef<'a, Hash: 'a> {
/// Reference to `DigestItem::ChangesTrieRoot`.
ChangesTrieRoot(&'a Hash),
@@ -28,8 +28,8 @@ pub type Period = u64;
pub type Phase = u64;
/// An era to describe the longevity of a transaction.
#[derive(PartialEq, Eq, Clone, Copy)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
#[derive(PartialEq, Eq, Clone, Copy, primitives::RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum Era {
/// The transaction is valid forever. The genesis hash must be present in the signed content.
Immortal,
@@ -18,20 +18,21 @@
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use log::debug;
use crate::codec::{Decode, Encode, Codec, Input, Output, HasCompact, EncodeAsRef, Error};
use crate::traits::{
self, Member, SimpleArithmetic, SimpleBitOps, MaybeDisplay, Hash as HashT, MaybeSerializeDebug,
MaybeSerializeDebugButNotDeserialize
self, Member, SimpleArithmetic, SimpleBitOps, Hash as HashT,
MaybeSerializeDeserialize, MaybeSerialize, MaybeDisplay,
};
use crate::generic::Digest;
use primitives::U256;
use core::convert::TryFrom;
use rstd::{
convert::TryFrom,
fmt::Debug,
};
/// Abstraction over a block header for a substrate chain.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[derive(PartialEq, Eq, Clone, primitives::RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
pub struct Header<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> {
@@ -103,11 +104,11 @@ impl<Number, Hash> codec::EncodeLike for Header<Number, Hash> where
{}
impl<Number, Hash> traits::Header for Header<Number, Hash> where
Number: Member + MaybeSerializeDebug + rstd::hash::Hash + MaybeDisplay +
Number: Member + MaybeSerializeDeserialize + Debug + rstd::hash::Hash + MaybeDisplay +
SimpleArithmetic + Codec + Copy + Into<U256> + TryFrom<U256>,
Hash: HashT,
Hash::Output: Default + rstd::hash::Hash + Copy + Member +
MaybeSerializeDebugButNotDeserialize + MaybeDisplay + SimpleBitOps + Codec,
MaybeSerialize + Debug + MaybeDisplay + SimpleBitOps + Codec,
{
type Number = Number;
type Hash = <Hash as HashT>::Output;
@@ -127,15 +128,12 @@ impl<Number, Hash> traits::Header for Header<Number, Hash> where
fn digest(&self) -> &Digest<Self::Hash> { &self.digest }
#[cfg(feature = "std")]
fn digest_mut(&mut self) -> &mut Digest<Self::Hash> {
debug!(target: "header", "Retrieving mutable reference to digest");
#[cfg(feature = "std")]
log::debug!(target: "header", "Retrieving mutable reference to digest");
&mut self.digest
}
#[cfg(not(feature = "std"))]
fn digest_mut(&mut self) -> &mut Digest<Self::Hash> { &mut self.digest }
fn new(
number: Self::Number,
extrinsics_root: Self::Hash,
@@ -16,10 +16,8 @@
//! Generic implementation of an unchecked (pre-verification) extrinsic.
#[cfg(feature = "std")]
use std::fmt;
use rstd::prelude::*;
use rstd::fmt;
use runtime_io::blake2_256;
use codec::{Decode, Encode, EncodeLike, Input, Error};
use crate::{
@@ -264,7 +262,6 @@ impl<Address: Encode, Signature: Encode, Call: Encode, Extra: SignedExtension> s
}
}
#[cfg(feature = "std")]
impl<Address, Call, Signature, Extra> fmt::Debug
for UncheckedExtrinsic<Address, Call, Signature, Extra>
where
+21 -13
View File
@@ -62,6 +62,9 @@ pub use generic::{DigestItem, Digest};
pub use primitives::{TypeId, crypto::{key_types, KeyTypeId, CryptoType}};
pub use app_crypto::RuntimeAppPublic;
/// Re-export `RuntimeDebug`, to avoid dependency clutter.
pub use primitives::RuntimeDebug;
/// Re-export top-level arithmetic stuff.
pub use arithmetic::{
Perquintill, Perbill, Permill, Percent,
@@ -166,8 +169,7 @@ impl BuildStorage for (StorageOverlay, ChildrenStorageOverlay) {
pub type ConsensusEngineId = [u8; 4];
/// Signature verify that can work with any known signature types..
#[derive(Eq, PartialEq, Clone, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Eq, PartialEq, Clone, Encode, Decode, RuntimeDebug)]
pub enum MultiSignature {
/// An Ed25519 signature.
Ed25519(ed25519::Signature),
@@ -194,8 +196,8 @@ impl Default for MultiSignature {
}
/// Public key for any known crypto algorithm.
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Encode, Decode, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum MultiSigner {
/// An Ed25519 identity.
Ed25519(ed25519::Public),
@@ -260,8 +262,8 @@ impl Verify for MultiSignature {
}
/// Signature verify that can work with any known signature types..
#[derive(Eq, PartialEq, Clone, Default, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[derive(Eq, PartialEq, Clone, Default, Encode, Decode, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct AnySignature(H512);
impl Verify for AnySignature {
@@ -289,8 +291,8 @@ impl From<ed25519::Signature> for AnySignature {
}
}
#[derive(Eq, PartialEq, Clone, Copy, Decode, Encode)]
#[cfg_attr(feature = "std", derive(Debug, Serialize))]
#[derive(Eq, PartialEq, Clone, Copy, Decode, Encode, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize))]
/// Reason why an extrinsic couldn't be applied (i.e. invalid extrinsic).
pub enum ApplyError {
/// General error to do with the permissions of the sender.
@@ -341,8 +343,8 @@ impl From<DispatchError> for ApplyOutcome {
/// Result from attempt to apply an extrinsic.
pub type ApplyResult = Result<ApplyOutcome, ApplyError>;
#[derive(Eq, PartialEq, Clone, Copy, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug, Serialize))]
#[derive(Eq, PartialEq, Clone, Copy, Encode, Decode, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize))]
/// Reason why a dispatch call failed
pub struct DispatchError {
/// Module index, matching the metadata module index
@@ -564,13 +566,19 @@ macro_rules! assert_eq_error_rate {
#[derive(PartialEq, Eq, Clone, Default, Encode, Decode)]
pub struct OpaqueExtrinsic(pub Vec<u8>);
#[cfg(feature = "std")]
impl std::fmt::Debug for OpaqueExtrinsic {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
impl rstd::fmt::Debug for OpaqueExtrinsic {
#[cfg(feature = "std")]
fn fmt(&self, fmt: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
write!(fmt, "{}", primitives::hexdisplay::HexDisplay::from(&self.0))
}
#[cfg(not(feature = "std"))]
fn fmt(&self, _fmt: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
Ok(())
}
}
#[cfg(feature = "std")]
impl ::serde::Serialize for OpaqueExtrinsic {
fn serialize<S>(&self, seq: S) -> Result<S::Ok, S::Error> where S: ::serde::Serializer {
@@ -51,6 +51,7 @@ use rstd::str;
use rstd::prelude::Vec;
#[cfg(not(feature = "std"))]
use rstd::prelude::vec;
use primitives::RuntimeDebug;
use primitives::offchain::{
Timestamp,
HttpRequestId as RequestId,
@@ -59,8 +60,7 @@ use primitives::offchain::{
};
/// Request method (HTTP verb)
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Eq, RuntimeDebug)]
pub enum Method {
/// GET request
Get,
@@ -93,8 +93,7 @@ mod header {
use super::*;
/// A header type.
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Eq, RuntimeDebug)]
pub struct Header {
name: Vec<u8>,
value: Vec<u8>,
@@ -128,8 +127,7 @@ mod header {
}
/// An HTTP request builder.
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Eq, RuntimeDebug)]
pub struct Request<'a, T = Vec<&'static [u8]>> {
/// Request method
pub method: Method,
@@ -249,8 +247,7 @@ impl<'a, I: AsRef<[u8]>, T: IntoIterator<Item=I>> Request<'a, T> {
}
/// A request error
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Eq, RuntimeDebug)]
pub enum Error {
/// Deadline has been reached.
DeadlineReached,
@@ -261,8 +258,7 @@ pub enum Error {
}
/// A struct representing an uncompleted http request.
#[derive(PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(PartialEq, Eq, RuntimeDebug)]
pub struct PendingRequest {
/// Request ID
pub id: RequestId,
@@ -323,7 +319,7 @@ impl PendingRequest {
}
/// A HTTP response.
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(RuntimeDebug)]
pub struct Response {
/// Request id
pub id: RequestId,
@@ -452,8 +448,7 @@ impl Iterator for ResponseBody {
}
/// A collection of Headers in the response.
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Eq, RuntimeDebug)]
pub struct Headers {
/// Raw headers
pub raw: Vec<(Vec<u8>, Vec<u8>)>,
@@ -483,8 +478,7 @@ impl Headers {
}
/// A custom iterator traversing all the headers.
#[derive(Clone)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, RuntimeDebug)]
pub struct HeadersIterator<'a> {
collection: &'a [(Vec<u8>, Vec<u8>)],
index: Option<usize>,
+52 -31
View File
@@ -17,10 +17,10 @@
//! Primitives for the runtime modules.
use rstd::prelude::*;
use rstd::{self, result, marker::PhantomData, convert::{TryFrom, TryInto}};
use rstd::{self, result, marker::PhantomData, convert::{TryFrom, TryInto}, fmt::Debug};
use runtime_io;
#[cfg(feature = "std")]
use std::fmt::{Debug, Display};
use std::fmt::Display;
#[cfg(feature = "std")]
use serde::{Serialize, Deserialize, de::DeserializeOwned};
use primitives::{self, Hasher, Blake2Hasher, TypeId};
@@ -147,7 +147,7 @@ pub trait Lookup {
/// context.
pub trait StaticLookup {
/// Type to lookup from.
type Source: Codec + Clone + PartialEq + MaybeDebug;
type Source: Codec + Clone + PartialEq + Debug;
/// Type to lookup into.
type Target;
/// Attempt a lookup.
@@ -159,7 +159,7 @@ pub trait StaticLookup {
/// A lookup implementation returning the input value.
#[derive(Default)]
pub struct IdentityLookup<T>(PhantomData<T>);
impl<T: Codec + Clone + PartialEq + MaybeDebug> StaticLookup for IdentityLookup<T> {
impl<T: Codec + Clone + PartialEq + Debug> StaticLookup for IdentityLookup<T> {
type Source = T;
type Target = T;
fn lookup(x: T) -> Result<T, LookupError> { Ok(x) }
@@ -323,10 +323,10 @@ pub trait OffchainWorker<BlockNumber> {
/// Abstraction around hashing
// Stupid bug in the Rust compiler believes derived
// traits must be fulfilled by all type parameters.
pub trait Hash: 'static + MaybeSerializeDebug + Clone + Eq + PartialEq {
pub trait Hash: 'static + MaybeSerializeDeserialize + Debug + Clone + Eq + PartialEq {
/// The hash type produced.
type Output: Member + MaybeSerializeDebug + rstd::hash::Hash + AsRef<[u8]> + AsMut<[u8]> + Copy
+ Default + Encode + Decode;
type Output: Member + MaybeSerializeDeserialize + Debug + rstd::hash::Hash
+ AsRef<[u8]> + AsMut<[u8]> + Copy + Default + Encode + Decode;
/// The associated hash_db Hasher type.
type Hasher: Hasher<Out=Self::Output>;
@@ -353,8 +353,8 @@ pub trait Hash: 'static + MaybeSerializeDebug + Clone + Eq + PartialEq {
}
/// Blake2-256 Hash implementation.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[derive(PartialEq, Eq, Clone, primitives::RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct BlakeTwo256;
impl Hash for BlakeTwo256 {
@@ -410,7 +410,7 @@ impl CheckEqual for primitives::H256 {
}
}
impl<H: PartialEq + Eq + MaybeDebug> CheckEqual for super::generic::DigestItem<H> where H: Encode {
impl<H: PartialEq + Eq + Debug> CheckEqual for super::generic::DigestItem<H> where H: Encode {
#[cfg(feature = "std")]
fn check_equal(&self, other: &Self) {
if self != other {
@@ -447,23 +447,17 @@ macro_rules! impl_maybe_marker {
}
impl_maybe_marker!(
/// A type that implements Debug when in std environment.
MaybeDebug: Debug;
/// A type that implements Display when in std environment.
MaybeDisplay: Display;
/// A type that implements Hash when in std environment.
MaybeHash: ::rstd::hash::Hash;
MaybeHash: rstd::hash::Hash;
/// A type that implements Serialize when in std environment.
MaybeSerialize: Serialize;
/// A type that implements Serialize, DeserializeOwned and Debug when in std environment.
MaybeSerializeDebug: Debug, DeserializeOwned, Serialize;
/// A type that implements Serialize and Debug when in std environment.
MaybeSerializeDebugButNotDeserialize: Debug, Serialize
MaybeSerializeDeserialize: DeserializeOwned, Serialize
);
/// A type that provides a randomness beacon.
@@ -483,8 +477,8 @@ pub trait RandomnessBeacon {
}
/// A type that can be used in runtime structures.
pub trait Member: Send + Sync + Sized + MaybeDebug + Eq + PartialEq + Clone + 'static {}
impl<T: Send + Sync + Sized + MaybeDebug + Eq + PartialEq + Clone + 'static> Member for T {}
pub trait Member: Send + Sync + Sized + Debug + Eq + PartialEq + Clone + 'static {}
impl<T: Send + Sync + Sized + Debug + Eq + PartialEq + Clone + 'static> Member for T {}
/// Determine if a `MemberId` is a valid member.
pub trait IsMember<MemberId> {
@@ -497,11 +491,13 @@ pub trait IsMember<MemberId> {
/// `parent_hash`, as well as a `digest` and a block `number`.
///
/// You can also create a `new` one from those fields.
pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerializeDebugButNotDeserialize + 'static {
pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static {
/// Header number.
type Number: Member + MaybeSerializeDebug + ::rstd::hash::Hash + Copy + MaybeDisplay + SimpleArithmetic + Codec;
type Number: Member + MaybeSerializeDeserialize + Debug + rstd::hash::Hash
+ Copy + MaybeDisplay + SimpleArithmetic + Codec;
/// Header hash type
type Hash: Member + MaybeSerializeDebug + ::rstd::hash::Hash + Copy + MaybeDisplay + Default + SimpleBitOps + Codec + AsRef<[u8]> + AsMut<[u8]>;
type Hash: Member + MaybeSerializeDeserialize + Debug + rstd::hash::Hash
+ Copy + MaybeDisplay + Default + SimpleBitOps + Codec + AsRef<[u8]> + AsMut<[u8]>;
/// Hashing algorithm
type Hashing: Hash<Output = Self::Hash>;
@@ -549,13 +545,14 @@ pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerializeDebugButNotDe
/// `Extrinsic` piece of information as well as a `Header`.
///
/// You can get an iterator over each of the `extrinsics` and retrieve the `header`.
pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerializeDebugButNotDeserialize + 'static {
pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static {
/// Type of extrinsics.
type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize;
/// Header type.
type Header: Header<Hash=Self::Hash>;
/// Block hash type.
type Hash: Member + MaybeSerializeDebug + ::rstd::hash::Hash + Copy + MaybeDisplay + Default + SimpleBitOps + Codec + AsRef<[u8]> + AsMut<[u8]>;
type Hash: Member + MaybeSerializeDeserialize + Debug + rstd::hash::Hash
+ Copy + MaybeDisplay + Default + SimpleBitOps + Codec + AsRef<[u8]> + AsMut<[u8]>;
/// Returns a reference to the header.
fn header(&self) -> &Self::Header;
@@ -661,7 +658,7 @@ pub trait Dispatchable {
/// Means by which a transaction may be extended. This type embodies both the data and the logic
/// that should be additionally associated with the transaction. It should be plain old data.
pub trait SignedExtension: Codec + MaybeDebug + Sync + Send + Clone + Eq + PartialEq {
pub trait SignedExtension: Codec + Debug + Sync + Send + Clone + Eq + PartialEq {
/// The type which encodes the sender identity.
type AccountId;
@@ -1080,8 +1077,13 @@ macro_rules! impl_opaque_keys {
)*
}
) => {
#[derive(Default, Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)]
#[cfg_attr(feature = "std", derive(Debug, $crate::serde::Serialize, $crate::serde::Deserialize))]
#[derive(
Default, Clone, PartialEq, Eq,
$crate::codec::Encode,
$crate::codec::Decode,
$crate::RuntimeDebug
)]
#[cfg_attr(feature = "std", derive($crate::serde::Serialize, $crate::serde::Deserialize))]
pub struct $name {
$(
pub $field: $type,
@@ -1131,7 +1133,25 @@ pub trait Printable {
impl Printable for u8 {
fn print(&self) {
u64::from(*self).print()
(*self as u64).print()
}
}
impl Printable for u32 {
fn print(&self) {
(*self as u64).print()
}
}
impl Printable for usize {
fn print(&self) {
(*self as u64).print()
}
}
impl Printable for u64 {
fn print(&self) {
runtime_io::print_num(*self);
}
}
@@ -1147,9 +1167,10 @@ impl Printable for &str {
}
}
impl Printable for u64 {
#[impl_for_tuples(1, 12)]
impl Printable for Tuple {
fn print(&self) {
runtime_io::print_num(*self);
for_tuples!( #( Tuple.print(); )* )
}
}
@@ -18,6 +18,7 @@
use rstd::prelude::*;
use crate::codec::{Encode, Decode};
use crate::RuntimeDebug;
/// Priority for a transaction. Additive. Higher is better.
pub type TransactionPriority = u64;
@@ -30,8 +31,8 @@ pub type TransactionLongevity = u64;
pub type TransactionTag = Vec<u8>;
/// An invalid transaction validity.
#[derive(Clone, PartialEq, Eq, Encode, Decode, Copy)]
#[cfg_attr(feature = "std", derive(Debug, serde::Serialize))]
#[derive(Clone, PartialEq, Eq, Encode, Decode, Copy, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(serde::Serialize))]
pub enum InvalidTransaction {
/// The call of the transaction is not expected.
Call,
@@ -81,8 +82,8 @@ impl From<InvalidTransaction> for &'static str {
}
/// An unknown transaction validity.
#[derive(Clone, PartialEq, Eq, Encode, Decode, Copy)]
#[cfg_attr(feature = "std", derive(Debug, serde::Serialize))]
#[derive(Clone, PartialEq, Eq, Encode, Decode, Copy, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(serde::Serialize))]
pub enum UnknownTransaction {
/// Could not lookup some information that is required to validate the transaction.
CannotLookup,
@@ -105,8 +106,8 @@ impl From<UnknownTransaction> for &'static str {
}
/// Errors that can occur while checking the validity of a transaction.
#[derive(Clone, PartialEq, Eq, Encode, Decode, Copy)]
#[cfg_attr(feature = "std", derive(Debug, serde::Serialize))]
#[derive(Clone, PartialEq, Eq, Encode, Decode, Copy, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(serde::Serialize))]
pub enum TransactionValidityError {
/// The transaction is invalid.
Invalid(InvalidTransaction),
@@ -173,8 +174,7 @@ impl Into<TransactionValidity> for UnknownTransaction {
}
/// Information concerning a valid transaction.
#[derive(Clone, PartialEq, Eq, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
pub struct ValidTransaction {
/// Priority of the transaction.
///
+6 -5
View File
@@ -23,16 +23,17 @@
//! Note that the decl_module macro _cannot_ enforce this and will simply fail if an invalid struct
//! (something that does not implement `Weighable`) is passed in.
pub use crate::transaction_validity::TransactionPriority;
use arithmetic::traits::Bounded;
use crate::RuntimeDebug;
pub use crate::transaction_validity::TransactionPriority;
/// Numeric range of a transaction weight.
pub type Weight = u32;
/// A generalized group of dispatch types. This is only distinguishing normal, user-triggered transactions
/// (`Normal`) and anything beyond which serves a higher purpose to the system (`Operational`).
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(PartialEq, Eq, Clone, Copy)]
#[derive(PartialEq, Eq, Clone, Copy, RuntimeDebug)]
pub enum DispatchClass {
/// A normal dispatch.
Normal,
@@ -61,8 +62,8 @@ impl From<SimpleDispatchInfo> for DispatchClass {
}
/// A bundle of static information collected from the `#[weight = $x]` attributes.
#[cfg_attr(feature = "std", derive(PartialEq, Eq, Debug))]
#[derive(Clone, Copy, Default)]
#[cfg_attr(feature = "std", derive(PartialEq, Eq))]
#[derive(Clone, Copy, Default, RuntimeDebug)]
pub struct DispatchInfo {
/// Weight of this transaction.
pub weight: Weight,