mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 21:35:44 +00:00
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:
committed by
Bastian Köcher
parent
934d7aac1c
commit
20a3989785
@@ -195,8 +195,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode)]
|
||||
#[cfg_attr(any(feature = "std", test), derive(PartialEq, Debug))]
|
||||
#[derive(Encode, Decode, sr_primitives::RuntimeDebug)]
|
||||
#[cfg_attr(any(feature = "std", test), derive(PartialEq))]
|
||||
enum UncleEntryItem<BlockNumber, Hash, Author> {
|
||||
InclusionHeight(BlockNumber),
|
||||
Uncle(Hash, Option<Author>),
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::{cmp, result, mem};
|
||||
use rstd::{cmp, result, mem, fmt::Debug};
|
||||
use codec::{Codec, Encode, Decode};
|
||||
use support::{
|
||||
StorageValue, Parameter, decl_event, decl_storage, decl_module,
|
||||
@@ -160,8 +160,9 @@ use support::{
|
||||
dispatch::Result,
|
||||
};
|
||||
use sr_primitives::{
|
||||
RuntimeDebug,
|
||||
traits::{
|
||||
Zero, SimpleArithmetic, StaticLookup, Member, CheckedAdd, CheckedSub, MaybeSerializeDebug,
|
||||
Zero, SimpleArithmetic, StaticLookup, Member, CheckedAdd, CheckedSub, MaybeSerializeDeserialize,
|
||||
Saturating, Bounded,
|
||||
},
|
||||
weights::SimpleDispatchInfo,
|
||||
@@ -176,7 +177,7 @@ pub use self::imbalances::{PositiveImbalance, NegativeImbalance};
|
||||
pub trait Subtrait<I: Instance = DefaultInstance>: system::Trait {
|
||||
/// The balance of an account.
|
||||
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy +
|
||||
MaybeSerializeDebug + From<Self::BlockNumber>;
|
||||
MaybeSerializeDeserialize + Debug + From<Self::BlockNumber>;
|
||||
|
||||
/// A function that is invoked when the free-balance has fallen below the existential deposit and
|
||||
/// has been reduced to zero.
|
||||
@@ -200,7 +201,7 @@ pub trait Subtrait<I: Instance = DefaultInstance>: system::Trait {
|
||||
pub trait Trait<I: Instance = DefaultInstance>: system::Trait {
|
||||
/// The balance of an account.
|
||||
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy +
|
||||
MaybeSerializeDebug + From<Self::BlockNumber>;
|
||||
MaybeSerializeDeserialize + Debug + From<Self::BlockNumber>;
|
||||
|
||||
/// A function that is invoked when the free-balance has fallen below the existential deposit and
|
||||
/// has been reduced to zero.
|
||||
@@ -255,8 +256,7 @@ decl_event!(
|
||||
);
|
||||
|
||||
/// Struct to encode the vesting schedule of an individual account.
|
||||
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug)]
|
||||
pub struct VestingSchedule<Balance, BlockNumber> {
|
||||
/// Locked amount at genesis.
|
||||
pub locked: Balance,
|
||||
@@ -283,8 +283,7 @@ impl<Balance: SimpleArithmetic + Copy, BlockNumber: SimpleArithmetic + Copy> Ves
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
|
||||
pub struct BalanceLock<Balance, BlockNumber> {
|
||||
pub id: LockIdentifier,
|
||||
pub amount: Balance,
|
||||
@@ -772,7 +771,7 @@ impl<T: Subtrait<I>, I: Instance> Trait<I> for ElevatedTrait<T, I> {
|
||||
|
||||
impl<T: Trait<I>, I: Instance> Currency<T::AccountId> for Module<T, I>
|
||||
where
|
||||
T::Balance: MaybeSerializeDebug
|
||||
T::Balance: MaybeSerializeDeserialize + Debug
|
||||
{
|
||||
type Balance = T::Balance;
|
||||
type PositiveImbalance = PositiveImbalance<T, I>;
|
||||
@@ -1009,7 +1008,7 @@ where
|
||||
|
||||
impl<T: Trait<I>, I: Instance> ReservableCurrency<T::AccountId> for Module<T, I>
|
||||
where
|
||||
T::Balance: MaybeSerializeDebug
|
||||
T::Balance: MaybeSerializeDeserialize + Debug
|
||||
{
|
||||
fn can_reserve(who: &T::AccountId, value: Self::Balance) -> bool {
|
||||
Self::free_balance(who)
|
||||
@@ -1072,7 +1071,7 @@ where
|
||||
|
||||
impl<T: Trait<I>, I: Instance> LockableCurrency<T::AccountId> for Module<T, I>
|
||||
where
|
||||
T::Balance: MaybeSerializeDebug
|
||||
T::Balance: MaybeSerializeDeserialize + Debug
|
||||
{
|
||||
type Moment = T::BlockNumber;
|
||||
|
||||
@@ -1146,7 +1145,7 @@ where
|
||||
|
||||
impl<T: Trait<I>, I: Instance> IsDeadAccount<T::AccountId> for Module<T, I>
|
||||
where
|
||||
T::Balance: MaybeSerializeDebug
|
||||
T::Balance: MaybeSerializeDeserialize + Debug
|
||||
{
|
||||
fn is_dead_account(who: &T::AccountId) -> bool {
|
||||
Self::total_balance(who).is_zero()
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
use rstd::{prelude::*, result};
|
||||
use primitives::u32_trait::Value as U32;
|
||||
use sr_primitives::RuntimeDebug;
|
||||
use sr_primitives::traits::{Hash, EnsureOrigin};
|
||||
use sr_primitives::weights::SimpleDispatchInfo;
|
||||
use support::{
|
||||
@@ -55,8 +56,7 @@ pub trait Trait<I=DefaultInstance>: system::Trait {
|
||||
}
|
||||
|
||||
/// Origin for the collective module.
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, Clone, RuntimeDebug)]
|
||||
pub enum RawOrigin<AccountId, I> {
|
||||
/// It has been condoned by a given number of members of the collective from a given total.
|
||||
Members(MemberCount, MemberCount),
|
||||
@@ -69,8 +69,7 @@ pub enum RawOrigin<AccountId, I> {
|
||||
/// Origin for the collective module.
|
||||
pub type Origin<T, I=DefaultInstance> = RawOrigin<<T as system::Trait>::AccountId, I>;
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
|
||||
/// Info for keeping track of a motion being voted on.
|
||||
pub struct Votes<AccountId> {
|
||||
/// The proposal's unique index.
|
||||
|
||||
@@ -9,6 +9,7 @@ client = { package = "substrate-client", path = "../../../../core/client", defau
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
rstd = { package = "sr-std", path = "../../../../core/sr-std", default-features = false }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
sr-primitives = { path = "../../../../core/sr-primitives", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -17,4 +18,5 @@ std = [
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"serde",
|
||||
"sr-primitives/std",
|
||||
]
|
||||
|
||||
@@ -24,10 +24,11 @@
|
||||
|
||||
use rstd::vec::Vec;
|
||||
use codec::{Encode, Decode, Codec};
|
||||
use sr_primitives::RuntimeDebug;
|
||||
|
||||
/// A result of execution of a contract.
|
||||
#[derive(Eq, PartialEq, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum ContractExecResult {
|
||||
/// The contract returned successfully.
|
||||
///
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
use rstd::prelude::*;
|
||||
use rstd::{result, convert::TryFrom};
|
||||
use sr_primitives::{
|
||||
RuntimeDebug,
|
||||
traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash, Dispatchable},
|
||||
weights::SimpleDispatchInfo,
|
||||
};
|
||||
@@ -48,8 +49,7 @@ pub type PropIndex = u32;
|
||||
pub type ReferendumIndex = u32;
|
||||
|
||||
/// A value denoting the strength of conviction of a vote.
|
||||
#[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug)]
|
||||
pub enum Conviction {
|
||||
/// 0.1x votes, unlocked.
|
||||
None,
|
||||
@@ -148,8 +148,7 @@ impl Bounded for Conviction {
|
||||
const MAX_RECURSION_LIMIT: u32 = 16;
|
||||
|
||||
/// A number of lock periods, plus a vote, one way or the other.
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Default)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Default, RuntimeDebug)]
|
||||
pub struct Vote {
|
||||
pub aye: bool,
|
||||
pub conviction: Conviction,
|
||||
@@ -231,8 +230,7 @@ pub trait Trait: system::Trait + Sized {
|
||||
}
|
||||
|
||||
/// Info regarding an ongoing referendum.
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
|
||||
pub struct ReferendumInfo<BlockNumber: Parameter, Proposal: Parameter> {
|
||||
/// When voting on this referendum will end.
|
||||
end: BlockNumber,
|
||||
|
||||
@@ -23,8 +23,8 @@ use sr_primitives::traits::{Zero, IntegerSquareRoot};
|
||||
use rstd::ops::{Add, Mul, Div, Rem};
|
||||
|
||||
/// A means of determining if a vote is past pass threshold.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, sr_primitives::RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
pub enum VoteThreshold {
|
||||
/// A supermajority of approvals is needed to pass this vote.
|
||||
SuperMajorityApprove,
|
||||
|
||||
@@ -25,7 +25,10 @@
|
||||
|
||||
use rstd::prelude::*;
|
||||
use sr_primitives::{
|
||||
print, traits::{Zero, One, StaticLookup, Bounded, Saturating}, weights::SimpleDispatchInfo,
|
||||
RuntimeDebug,
|
||||
print,
|
||||
traits::{Zero, One, StaticLookup, Bounded, Saturating},
|
||||
weights::SimpleDispatchInfo,
|
||||
};
|
||||
use support::{
|
||||
dispatch::Result, decl_storage, decl_event, ensure, decl_module,
|
||||
@@ -98,8 +101,7 @@ mod tests;
|
||||
// entries before they increase the capacity.
|
||||
|
||||
/// The activity status of a voter.
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Encode, Decode, Default)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Encode, Decode, Default, RuntimeDebug)]
|
||||
pub struct VoterInfo<Balance> {
|
||||
/// Last VoteIndex in which this voter assigned (or initialized) approvals.
|
||||
last_active: VoteIndex,
|
||||
@@ -114,8 +116,7 @@ pub struct VoterInfo<Balance> {
|
||||
}
|
||||
|
||||
/// Used to demonstrate the status of a particular index in the global voter list.
|
||||
#[derive(PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, RuntimeDebug)]
|
||||
pub enum CellStatus {
|
||||
/// Any out of bound index. Means a push a must happen to the chunk pointed by `NextVoterSet<T>`.
|
||||
/// Voting fee is applied in case a new chunk is created.
|
||||
|
||||
@@ -584,10 +584,9 @@ impl<T: Trait> Module<T> {
|
||||
#[derive(Encode, Decode, Clone, Eq, PartialEq)]
|
||||
pub struct WatchDummy<T: Trait + Send + Sync>(PhantomData<T>);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: Trait + Send + Sync> rstd::fmt::Debug for WatchDummy<T> {
|
||||
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
write!(f, "WatchDummy<T>")
|
||||
write!(f, "WatchDummy")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,12 +153,13 @@
|
||||
|
||||
use codec::{Decode, Encode, HasCompact, Input, Output, Error};
|
||||
|
||||
use sr_primitives::RuntimeDebug;
|
||||
use sr_primitives::traits::{
|
||||
CheckedAdd, CheckedSub, MaybeSerializeDebug, Member, One, Saturating, SimpleArithmetic, Zero, Bounded
|
||||
CheckedAdd, CheckedSub, MaybeSerializeDeserialize, Member, One, Saturating, SimpleArithmetic, Zero, Bounded
|
||||
};
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::{cmp, result};
|
||||
use rstd::{cmp, result, fmt::Debug};
|
||||
use support::dispatch::Result;
|
||||
use support::{
|
||||
decl_event, decl_module, decl_storage, ensure,
|
||||
@@ -181,7 +182,8 @@ pub trait Trait: system::Trait {
|
||||
+ SimpleArithmetic
|
||||
+ Default
|
||||
+ Copy
|
||||
+ MaybeSerializeDebug;
|
||||
+ MaybeSerializeDeserialize
|
||||
+ Debug;
|
||||
type AssetId: Parameter + Member + SimpleArithmetic + Default + Copy;
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
}
|
||||
@@ -192,7 +194,8 @@ pub trait Subtrait: system::Trait {
|
||||
+ SimpleArithmetic
|
||||
+ Default
|
||||
+ Copy
|
||||
+ MaybeSerializeDebug;
|
||||
+ MaybeSerializeDeserialize
|
||||
+ Debug;
|
||||
type AssetId: Parameter + Member + SimpleArithmetic + Default + Copy;
|
||||
}
|
||||
|
||||
@@ -202,8 +205,7 @@ impl<T: Trait> Subtrait for T {
|
||||
}
|
||||
|
||||
/// Asset creation options.
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, Encode, Decode, PartialEq, Eq)]
|
||||
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug)]
|
||||
pub struct AssetOptions<Balance: HasCompact, AccountId> {
|
||||
/// Initial issuance of this asset. All deposit to the creater of the asset.
|
||||
#[codec(compact)]
|
||||
@@ -213,8 +215,7 @@ pub struct AssetOptions<Balance: HasCompact, AccountId> {
|
||||
}
|
||||
|
||||
/// Owner of an asset.
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, Encode, Decode, PartialEq, Eq)]
|
||||
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug)]
|
||||
pub enum Owner<AccountId> {
|
||||
/// No owner.
|
||||
None,
|
||||
@@ -229,8 +230,7 @@ impl<AccountId> Default for Owner<AccountId> {
|
||||
}
|
||||
|
||||
/// Asset permissions
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, Encode, Decode, PartialEq, Eq)]
|
||||
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug)]
|
||||
pub struct PermissionsV1<AccountId> {
|
||||
/// Who have permission to update asset permission
|
||||
pub update: Owner<AccountId>,
|
||||
@@ -240,16 +240,14 @@ pub struct PermissionsV1<AccountId> {
|
||||
pub burn: Owner<AccountId>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, Encode, Decode, PartialEq, Eq)]
|
||||
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug)]
|
||||
#[repr(u8)]
|
||||
enum PermissionVersionNumber {
|
||||
V1 = 0,
|
||||
}
|
||||
|
||||
/// Versioned asset permission
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[derive(Clone, PartialEq, Eq, RuntimeDebug)]
|
||||
pub enum PermissionVersions<AccountId> {
|
||||
V1(PermissionsV1<AccountId>),
|
||||
}
|
||||
@@ -435,8 +433,7 @@ decl_module! {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
|
||||
pub struct BalanceLock<Balance, BlockNumber> {
|
||||
pub id: LockIdentifier,
|
||||
pub amount: Balance,
|
||||
@@ -1065,8 +1062,7 @@ impl<T: Subtrait> Trait for ElevatedTrait<T> {
|
||||
type Event = ();
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
|
||||
pub struct AssetCurrency<T, U>(rstd::marker::PhantomData<T>, rstd::marker::PhantomData<U>);
|
||||
|
||||
impl<T, U> Currency<T::AccountId> for AssetCurrency<T, U>
|
||||
@@ -1200,7 +1196,9 @@ where
|
||||
Self::free_balance(who)
|
||||
.checked_sub(&value)
|
||||
.map_or(false, |new_balance|
|
||||
<Module<T>>::ensure_can_withdraw(&U::asset_id(), who, value, WithdrawReason::Reserve, new_balance).is_ok()
|
||||
<Module<T>>::ensure_can_withdraw(
|
||||
&U::asset_id(), who, value, WithdrawReason::Reserve, new_balance
|
||||
).is_ok()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1254,7 +1252,7 @@ impl<T: Trait> AssetIdProvider for SpendingAssetIdProvider<T> {
|
||||
impl<T> LockableCurrency<T::AccountId> for AssetCurrency<T, StakingAssetIdProvider<T>>
|
||||
where
|
||||
T: Trait,
|
||||
T::Balance: MaybeSerializeDebug,
|
||||
T::Balance: MaybeSerializeDeserialize + Debug,
|
||||
{
|
||||
type Moment = T::BlockNumber;
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ use primitives::offchain::{OpaqueNetworkState, StorageKind};
|
||||
use rstd::prelude::*;
|
||||
use session::historical::IdentificationTuple;
|
||||
use sr_primitives::{
|
||||
RuntimeDebug,
|
||||
traits::{Convert, Member, Printable, Saturating}, Perbill,
|
||||
transaction_validity::{
|
||||
TransactionValidity, TransactionLongevity, ValidTransaction, InvalidTransaction,
|
||||
@@ -86,7 +87,7 @@ use sr_staking_primitives::{
|
||||
offence::{ReportOffence, Offence, Kind},
|
||||
};
|
||||
use support::{
|
||||
decl_module, decl_event, decl_storage, print, ensure, Parameter
|
||||
decl_module, decl_event, decl_storage, print, ensure, Parameter, debug
|
||||
};
|
||||
use system::ensure_none;
|
||||
use system::offchain::SubmitUnsignedTransaction;
|
||||
@@ -146,15 +147,14 @@ const DB_KEY: &[u8] = b"srml/im-online-worker-status";
|
||||
/// finishing it. With every execution of the off-chain worker we check
|
||||
/// if we need to recover and resume gossipping or if there is already
|
||||
/// another off-chain worker in the process of gossipping.
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
|
||||
struct WorkerStatus<BlockNumber> {
|
||||
done: bool,
|
||||
gossipping_at: BlockNumber,
|
||||
}
|
||||
|
||||
/// Error which may occur while executing the off-chain code.
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(RuntimeDebug)]
|
||||
enum OffchainErr {
|
||||
DecodeWorkerStatus,
|
||||
FailedSigning,
|
||||
@@ -176,8 +176,7 @@ impl Printable for OffchainErr {
|
||||
pub type AuthIndex = u32;
|
||||
|
||||
/// Heartbeat which is sent/received.
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
|
||||
pub struct Heartbeat<BlockNumber>
|
||||
where BlockNumber: PartialEq + Eq + Decode + Encode,
|
||||
{
|
||||
@@ -280,6 +279,8 @@ decl_module! {
|
||||
|
||||
// Runs after every block.
|
||||
fn offchain_worker(now: T::BlockNumber) {
|
||||
debug::RuntimeLogger::init();
|
||||
|
||||
// Only send messages if we are a potential validator.
|
||||
if runtime_io::is_validator() {
|
||||
Self::offchain(now);
|
||||
@@ -319,6 +320,14 @@ impl<T: Trait> Module<T> {
|
||||
Ok(_) => {},
|
||||
Err(err) => print(err),
|
||||
}
|
||||
} else {
|
||||
debug::native::trace!(
|
||||
target: "imonline",
|
||||
"Skipping gossip at: {:?} >= {:?} || {:?}",
|
||||
next_gossip,
|
||||
now,
|
||||
if not_yet_gossipped { "not gossipped" } else { "gossipped" }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,6 +355,13 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
let signature = key.sign(&heartbeat_data.encode()).ok_or(OffchainErr::FailedSigning)?;
|
||||
let call = Call::heartbeat(heartbeat_data, signature);
|
||||
|
||||
debug::info!(
|
||||
target: "imonline",
|
||||
"[index: {:?}] Reporting im-online at block: {:?}",
|
||||
authority_index,
|
||||
block_number
|
||||
);
|
||||
T::SubmitTransaction::submit_unsigned(call)
|
||||
.map_err(|_| OffchainErr::SubmitTransaction)?;
|
||||
|
||||
@@ -538,7 +554,8 @@ impl<T: Trait> support::unsigned::ValidateUnsigned for Module<T> {
|
||||
}
|
||||
|
||||
/// An offence that is filed if a validator didn't send a heartbeat message.
|
||||
#[cfg_attr(feature = "std", derive(Clone, Debug, PartialEq, Eq))]
|
||||
#[derive(RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))]
|
||||
pub struct UnresponsivenessOffence<Offender> {
|
||||
/// The current session index in which we report the unresponsive validators.
|
||||
///
|
||||
|
||||
@@ -24,8 +24,8 @@ use codec::{Encode, Decode, Input, Output, Error};
|
||||
|
||||
/// An indices-aware address, which can be either a direct `AccountId` or
|
||||
/// an index.
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Hash))]
|
||||
#[derive(PartialEq, Eq, Clone, sr_primitives::RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Hash))]
|
||||
pub enum Address<AccountId, AccountIndex> where
|
||||
AccountId: Member,
|
||||
AccountIndex: Member,
|
||||
|
||||
@@ -28,6 +28,7 @@ use serde::Serialize;
|
||||
use codec::{Decode, Input, Error};
|
||||
use codec::{Encode, Output};
|
||||
use rstd::vec::Vec;
|
||||
use primitives::RuntimeDebug;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
type StringBuf = String;
|
||||
@@ -84,13 +85,12 @@ impl<B, O> Eq for DecodeDifferent<B, O>
|
||||
where B: Encode + Eq + PartialEq + 'static, O: Encode + Eq + PartialEq + 'static
|
||||
{}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<B, O> std::fmt::Debug for DecodeDifferent<B, O>
|
||||
impl<B, O> rstd::fmt::Debug for DecodeDifferent<B, O>
|
||||
where
|
||||
B: std::fmt::Debug + Eq + 'static,
|
||||
O: std::fmt::Debug + Eq + 'static,
|
||||
B: rstd::fmt::Debug + Eq + 'static,
|
||||
O: rstd::fmt::Debug + Eq + 'static,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
match self {
|
||||
DecodeDifferent::Encode(b) => b.fmt(f),
|
||||
DecodeDifferent::Decoded(o) => o.fmt(f),
|
||||
@@ -114,14 +114,11 @@ impl<B, O> serde::Serialize for DecodeDifferent<B, O>
|
||||
|
||||
pub type DecodeDifferentArray<B, O=B> = DecodeDifferent<&'static [B], Vec<O>>;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
type DecodeDifferentStr = DecodeDifferent<&'static str, StringBuf>;
|
||||
#[cfg(not(feature = "std"))]
|
||||
type DecodeDifferentStr = DecodeDifferent<&'static str, StringBuf>;
|
||||
|
||||
/// All the metadata about a function.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub arguments: DecodeDifferentArray<FunctionArgumentMetadata>,
|
||||
@@ -129,8 +126,8 @@ pub struct FunctionMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about a function argument.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct FunctionArgumentMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub ty: DecodeDifferentStr,
|
||||
@@ -154,9 +151,8 @@ impl<E: Encode + PartialEq> PartialEq for FnEncode<E> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<E: Encode + ::std::fmt::Debug> std::fmt::Debug for FnEncode<E> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
impl<E: Encode + rstd::fmt::Debug> rstd::fmt::Debug for FnEncode<E> {
|
||||
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
self.0().fmt(f)
|
||||
}
|
||||
}
|
||||
@@ -169,8 +165,8 @@ impl<E: Encode + serde::Serialize> serde::Serialize for FnEncode<E> {
|
||||
}
|
||||
|
||||
/// All the metadata about an outer event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct OuterEventMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub events: DecodeDifferentArray<
|
||||
@@ -180,8 +176,8 @@ pub struct OuterEventMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about an event.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct EventMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub arguments: DecodeDifferentArray<&'static str, StringBuf>,
|
||||
@@ -189,8 +185,8 @@ pub struct EventMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about one storage entry.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageEntryMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub modifier: StorageEntryModifier,
|
||||
@@ -200,8 +196,8 @@ pub struct StorageEntryMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about one module constant.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleConstantMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub ty: DecodeDifferentStr,
|
||||
@@ -210,8 +206,8 @@ pub struct ModuleConstantMetadata {
|
||||
}
|
||||
|
||||
/// All the metadata about a module error.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ErrorMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub documentation: DecodeDifferentArray<&'static str, StringBuf>,
|
||||
@@ -265,16 +261,15 @@ impl serde::Serialize for DefaultByteGetter {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl std::fmt::Debug for DefaultByteGetter {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
impl rstd::fmt::Debug for DefaultByteGetter {
|
||||
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
self.0.default_byte().fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
/// Hasher used by storage maps
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageHasher {
|
||||
Blake2_128,
|
||||
Blake2_256,
|
||||
@@ -284,8 +279,8 @@ pub enum StorageHasher {
|
||||
}
|
||||
|
||||
/// A storage entry type.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryType {
|
||||
Plain(DecodeDifferentStr),
|
||||
Map {
|
||||
@@ -304,32 +299,32 @@ pub enum StorageEntryType {
|
||||
}
|
||||
|
||||
/// A storage entry modifier.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum StorageEntryModifier {
|
||||
Optional,
|
||||
Default,
|
||||
}
|
||||
|
||||
/// All metadata of the storage.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct StorageMetadata {
|
||||
/// The common prefix used by all storage entries.
|
||||
pub prefix: DecodeDifferent<&'static str, StringBuf>,
|
||||
pub entries: DecodeDifferent<&'static [StorageEntryMetadata], Vec<StorageEntryMetadata>>,
|
||||
}
|
||||
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Eq, Encode, PartialEq, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
/// Metadata prefixed by a u32 for reserved usage
|
||||
pub struct RuntimeMetadataPrefixed(pub u32, pub RuntimeMetadata);
|
||||
|
||||
/// The metadata of a runtime.
|
||||
/// The version ID encoded/decoded through
|
||||
/// the enum nature of `RuntimeMetadata`.
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Eq, Encode, PartialEq, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub enum RuntimeMetadata {
|
||||
/// Unused; enum filler.
|
||||
V0(RuntimeMetadataDeprecated),
|
||||
@@ -352,8 +347,8 @@ pub enum RuntimeMetadata {
|
||||
}
|
||||
|
||||
/// Enum that should fail.
|
||||
#[derive(Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Serialize))]
|
||||
#[derive(Eq, PartialEq, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize))]
|
||||
pub enum RuntimeMetadataDeprecated { }
|
||||
|
||||
impl Encode for RuntimeMetadataDeprecated {
|
||||
@@ -370,8 +365,8 @@ impl Decode for RuntimeMetadataDeprecated {
|
||||
}
|
||||
|
||||
/// The metadata of a runtime.
|
||||
#[derive(Eq, Encode, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Eq, Encode, PartialEq, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct RuntimeMetadataV8 {
|
||||
pub modules: DecodeDifferentArray<ModuleMetadata>,
|
||||
}
|
||||
@@ -380,8 +375,8 @@ pub struct RuntimeMetadataV8 {
|
||||
pub type RuntimeMetadataLastVersion = RuntimeMetadataV8;
|
||||
|
||||
/// All metadata about an runtime module.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode, Serialize))]
|
||||
pub struct ModuleMetadata {
|
||||
pub name: DecodeDifferentStr,
|
||||
pub storage: Option<DecodeDifferent<FnEncode<StorageMetadata>, StorageMetadata>>,
|
||||
|
||||
@@ -89,14 +89,17 @@ mod mock;
|
||||
mod tests;
|
||||
|
||||
use codec::FullCodec;
|
||||
use rstd::prelude::*;
|
||||
use rstd::{
|
||||
fmt::Debug,
|
||||
prelude::*,
|
||||
};
|
||||
use support::{
|
||||
decl_module, decl_storage, decl_event, ensure,
|
||||
traits::{ChangeMembers, InitializeMembers, Currency, Get, ReservableCurrency},
|
||||
};
|
||||
use system::{self, ensure_root, ensure_signed};
|
||||
use sr_primitives::{
|
||||
traits::{EnsureOrigin, SimpleArithmetic, MaybeSerializeDebug, Zero, StaticLookup},
|
||||
traits::{EnsureOrigin, SimpleArithmetic, MaybeSerializeDeserialize, Zero, StaticLookup},
|
||||
};
|
||||
|
||||
type BalanceOf<T, I> = <<T as Trait<I>>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
@@ -117,7 +120,8 @@ pub trait Trait<I=DefaultInstance>: system::Trait {
|
||||
type Currency: Currency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
|
||||
|
||||
/// The score attributed to a member or candidate.
|
||||
type Score: SimpleArithmetic + Clone + Copy + Default + FullCodec + MaybeSerializeDebug;
|
||||
type Score:
|
||||
SimpleArithmetic + Clone + Copy + Default + FullCodec + MaybeSerializeDeserialize + Debug;
|
||||
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
|
||||
|
||||
@@ -263,6 +263,7 @@ use support::{
|
||||
use session::{historical::OnSessionEnding, SelectInitialValidators};
|
||||
use sr_primitives::{
|
||||
Perbill,
|
||||
RuntimeDebug,
|
||||
curve::PiecewiseLinear,
|
||||
weights::SimpleDispatchInfo,
|
||||
traits::{
|
||||
@@ -313,7 +314,8 @@ impl EraPoints {
|
||||
}
|
||||
|
||||
/// Indicates the initial status of the staker.
|
||||
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
|
||||
#[derive(RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
pub enum StakerStatus<AccountId> {
|
||||
/// Chilling.
|
||||
Idle,
|
||||
@@ -324,8 +326,7 @@ pub enum StakerStatus<AccountId> {
|
||||
}
|
||||
|
||||
/// A destination account for payment.
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Encode, Decode, RuntimeDebug)]
|
||||
pub enum RewardDestination {
|
||||
/// Pay into the stash account, increasing the amount at stake accordingly.
|
||||
Staked,
|
||||
@@ -342,8 +343,7 @@ impl Default for RewardDestination {
|
||||
}
|
||||
|
||||
/// Preference of what happens on a slash event.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
|
||||
pub struct ValidatorPrefs<Balance: HasCompact> {
|
||||
/// Reward that validator takes up-front; only the rest is split between themselves and
|
||||
/// nominators.
|
||||
@@ -360,8 +360,7 @@ impl<B: Default + HasCompact + Copy> Default for ValidatorPrefs<B> {
|
||||
}
|
||||
|
||||
/// Just a Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
|
||||
pub struct UnlockChunk<Balance: HasCompact> {
|
||||
/// Amount of funds to be unlocked.
|
||||
#[codec(compact)]
|
||||
@@ -372,8 +371,7 @@ pub struct UnlockChunk<Balance: HasCompact> {
|
||||
}
|
||||
|
||||
/// The ledger of a (bonded) stash.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
|
||||
pub struct StakingLedger<AccountId, Balance: HasCompact> {
|
||||
/// The stash account whose balance is actually locked and at stake.
|
||||
pub stash: AccountId,
|
||||
@@ -411,8 +409,7 @@ impl<
|
||||
}
|
||||
|
||||
/// The amount of exposure (to slashing) than an individual nominator has.
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, RuntimeDebug)]
|
||||
pub struct IndividualExposure<AccountId, Balance: HasCompact> {
|
||||
/// The stash account of the nominator in question.
|
||||
who: AccountId,
|
||||
@@ -422,8 +419,7 @@ pub struct IndividualExposure<AccountId, Balance: HasCompact> {
|
||||
}
|
||||
|
||||
/// A snapshot of the stake backing a single validator in the system.
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Default)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Default, RuntimeDebug)]
|
||||
pub struct Exposure<AccountId, Balance: HasCompact> {
|
||||
/// The total balance backing this validator.
|
||||
#[codec(compact)]
|
||||
@@ -436,8 +432,7 @@ pub struct Exposure<AccountId, Balance: HasCompact> {
|
||||
}
|
||||
|
||||
/// A slashing event occurred, slashing a validator for a given amount of balance.
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Default)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Default, RuntimeDebug)]
|
||||
pub struct SlashJournalEntry<AccountId, Balance: HasCompact> {
|
||||
who: AccountId,
|
||||
amount: Balance,
|
||||
@@ -532,8 +527,8 @@ pub trait Trait: system::Trait {
|
||||
}
|
||||
|
||||
/// Mode of era-forcing.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
pub enum Forcing {
|
||||
/// Not forcing anything - just let whatever happen.
|
||||
NotForcing,
|
||||
|
||||
@@ -5,6 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
log = "0.4"
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] }
|
||||
srml-metadata = { path = "../metadata", default-features = false }
|
||||
|
||||
@@ -184,8 +184,12 @@ fn create_and_impl_instance_struct(
|
||||
|
||||
quote! {
|
||||
// Those trait are derived because of wrong bounds for generics
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, Eq, PartialEq, #scrate::codec::Encode, #scrate::codec::Decode)]
|
||||
#[derive(
|
||||
Clone, Eq, PartialEq,
|
||||
#scrate::codec::Encode,
|
||||
#scrate::codec::Decode,
|
||||
#scrate::RuntimeDebug,
|
||||
)]
|
||||
#doc
|
||||
pub struct #instance_struct;
|
||||
impl #instance_trait for #instance_struct {
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
// Copyright 2019 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Runtime debugging and logging utilities.
|
||||
//!
|
||||
//! This module contains macros and functions that will allow
|
||||
//! you to print logs out of the runtime code.
|
||||
//!
|
||||
//! First and foremost be aware that adding regular logging code to
|
||||
//! your runtime will have a negative effect on the performance
|
||||
//! and size of the blob. Luckily there are some ways to mitigate
|
||||
//! this that are described below.
|
||||
//!
|
||||
//! First component to utilize debug-printing and loggin is actually
|
||||
//! located in `primitives` crate: `primitives::RuntimeDebug`.
|
||||
//! This custom-derive generates `core::fmt::Debug` implementation,
|
||||
//! just like regular `derive(Debug)`, however it does not generate
|
||||
//! any code when the code is compiled to WASM. This means that
|
||||
//! you can safely sprinkle `RuntimeDebug` in your runtime codebase,
|
||||
//! without affecting the size. This also allows you to print/log
|
||||
//! both when the code is running natively or in WASM, but note
|
||||
//! that WASM debug formatting of structs will be empty.
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
//! use srml_support::debug;
|
||||
//!
|
||||
//! #[derive(primitives::RuntimeDebug)]
|
||||
//! struct MyStruct {
|
||||
//! a: u64,
|
||||
//! }
|
||||
//!
|
||||
//! // First initialize the logger.
|
||||
//! //
|
||||
//! // This is only required when you want the logs to be printed
|
||||
//! // also during non-native run.
|
||||
//! // Note that enabling the logger has performance impact on
|
||||
//! // WASM runtime execution and should be used sparingly.
|
||||
//! debug::RuntimeLogger::init();
|
||||
//!
|
||||
//! let x = MyStruct { a: 5 };
|
||||
//! // will log an info line `"My struct: MyStruct{a:5}"` when running
|
||||
//! // natively, but will only print `"My struct: "` when running WASM.
|
||||
//! debug::info!("My struct: {:?}", x);
|
||||
//!
|
||||
//! // same output here, although this will print to stdout
|
||||
//! // (and without log format)
|
||||
//! debug::print!("My struct: {:?}", x);
|
||||
//! ```
|
||||
//!
|
||||
//! If you want to avoid extra overhead in WASM, but still be able
|
||||
//! to print / log when the code is executed natively you can use
|
||||
//! macros coming from `native` sub-module. This module enables
|
||||
//! logs conditionally and strips out logs in WASM.
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
//! use srml_support::debug::native;
|
||||
//!
|
||||
//! #[derive(primitives::RuntimeDebug)]
|
||||
//! struct MyStruct {
|
||||
//! a: u64,
|
||||
//! }
|
||||
//!
|
||||
//! // We don't initialize the logger, since
|
||||
//! // we are not printing anything out in WASM.
|
||||
//! // debug::RuntimeLogger::init();
|
||||
//!
|
||||
//! let x = MyStruct { a: 5 };
|
||||
//!
|
||||
//! // Displays an info log when running natively, nothing when WASM.
|
||||
//! native::info!("My struct: {:?}", x);
|
||||
//!
|
||||
//! // same output to stdout, no overhead on WASM.
|
||||
//! native::print!("My struct: {:?}", x);
|
||||
//! ```
|
||||
|
||||
use rstd::vec::Vec;
|
||||
use rstd::fmt::{self, Debug};
|
||||
|
||||
pub use log::{info, debug, error, trace, warn};
|
||||
pub use crate::runtime_print as print;
|
||||
|
||||
/// Native-only logging.
|
||||
///
|
||||
/// Using any functions from this module will have any effect
|
||||
/// only if the runtime is running natively (i.e. not via WASM)
|
||||
#[cfg(feature = "std")]
|
||||
pub mod native {
|
||||
pub use super::{info, debug, error, trace, warn, print};
|
||||
}
|
||||
|
||||
/// Native-only logging.
|
||||
///
|
||||
/// Using any functions from this module will have any effect
|
||||
/// only if the runtime is running natively (i.e. not via WASM)
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub mod native {
|
||||
#[macro_export]
|
||||
macro_rules! noop {
|
||||
($($arg:tt)+) => {}
|
||||
}
|
||||
pub use noop as info;
|
||||
pub use noop as debug;
|
||||
pub use noop as error;
|
||||
pub use noop as trace;
|
||||
pub use noop as warn;
|
||||
pub use noop as print;
|
||||
}
|
||||
|
||||
/// Print out a formatted message.
|
||||
#[macro_export]
|
||||
macro_rules! runtime_print {
|
||||
($($arg:tt)+) => {
|
||||
use core::fmt::Write;
|
||||
let mut w = $crate::debug::Writer::default();
|
||||
let _ = core::write!(&mut w, $($arg)+);
|
||||
w.print();
|
||||
}
|
||||
}
|
||||
|
||||
/// Print out the debuggable type.
|
||||
pub fn debug(data: &impl Debug) {
|
||||
runtime_print!("{:?}", data);
|
||||
}
|
||||
|
||||
/// A target for `core::write!` macro - constructs a string in memory.
|
||||
#[derive(Default)]
|
||||
pub struct Writer(Vec<u8>);
|
||||
|
||||
impl fmt::Write for Writer {
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
self.0.extend(s.as_bytes());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Writer {
|
||||
/// Print the content of this `Writer` out.
|
||||
pub fn print(&self) {
|
||||
runtime_io::print_utf8(&self.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Runtime logger implementation - `log` crate backend.
|
||||
///
|
||||
/// The logger should be initialized if you want to display
|
||||
/// logs inside the runtime that is not necessarily running natively.
|
||||
///
|
||||
/// When runtime is executed natively any log statements are displayed
|
||||
/// even if this logger is NOT initialized.
|
||||
///
|
||||
/// Note that even though the logs are not displayed in WASM, they
|
||||
/// may still affect the size and performance of the generated runtime.
|
||||
/// To lower the footprint make sure to only use macros from `native`
|
||||
/// sub-module.
|
||||
pub struct RuntimeLogger;
|
||||
|
||||
impl RuntimeLogger {
|
||||
/// Initialize the logger.
|
||||
///
|
||||
/// This is a no-op when running natively (`std`).
|
||||
#[cfg(feature = "std")]
|
||||
pub fn init() {}
|
||||
|
||||
/// Initialize the logger.
|
||||
///
|
||||
/// This is a no-op when running natively (`std`).
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub fn init() {
|
||||
static LOGGER: RuntimeLogger = RuntimeLogger;;
|
||||
let _ = log::set_logger(&LOGGER);
|
||||
}
|
||||
}
|
||||
|
||||
impl log::Log for RuntimeLogger {
|
||||
fn enabled(&self, _metadata: &log::Metadata) -> bool {
|
||||
// to avoid calling to host twice, we pass everything
|
||||
// and let the host decide what to print.
|
||||
// If someone is initializing the logger they should
|
||||
// know what they are doing.
|
||||
true
|
||||
}
|
||||
|
||||
fn log(&self, record: &log::Record) {
|
||||
use fmt::Write;
|
||||
let mut w = Writer::default();
|
||||
let _ = core::write!(&mut w, "{}", record.args());
|
||||
|
||||
runtime_io::log(
|
||||
record.level().into(),
|
||||
record.target().as_bytes(),
|
||||
&w.0,
|
||||
);
|
||||
}
|
||||
|
||||
fn flush(&self) {}
|
||||
}
|
||||
@@ -17,9 +17,7 @@
|
||||
//! Dispatch system. Contains a macro for defining runtime modules and
|
||||
//! generating values representing lazy module function calls.
|
||||
|
||||
pub use crate::rstd::{result, prelude::{Vec, Clone, Eq, PartialEq}, marker};
|
||||
#[cfg(feature = "std")]
|
||||
pub use std::fmt;
|
||||
pub use crate::rstd::{result, fmt, prelude::{Vec, Clone, Eq, PartialEq}, marker};
|
||||
pub use crate::codec::{Codec, EncodeLike, Decode, Encode, Input, Output, HasCompact, EncodeAsRef};
|
||||
pub use srml_metadata::{
|
||||
FunctionMetadata, DecodeDifferent, DecodeDifferentArray, FunctionArgumentMetadata,
|
||||
@@ -29,7 +27,9 @@ pub use sr_primitives::{
|
||||
weights::{
|
||||
SimpleDispatchInfo, GetDispatchInfo, DispatchInfo, WeighData, ClassifyDispatch,
|
||||
TransactionPriority
|
||||
}, traits::{Dispatchable, DispatchResult, ModuleDispatchError}, DispatchError
|
||||
},
|
||||
traits::{Dispatchable, DispatchResult, ModuleDispatchError},
|
||||
DispatchError,
|
||||
};
|
||||
|
||||
/// A type that cannot be instantiated.
|
||||
@@ -48,18 +48,9 @@ pub trait Callable<T> {
|
||||
// https://github.com/rust-lang/rust/issues/51331
|
||||
pub type CallableCallFor<A, T> = <A as Callable<T>>::Call;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub trait Parameter: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub trait Parameter: Codec + EncodeLike + Clone + Eq {}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq {}
|
||||
|
||||
/// Declares a `Module` struct and a `Call` enum, which implements the dispatch logic.
|
||||
///
|
||||
/// ## Declaration
|
||||
@@ -1071,8 +1062,7 @@ macro_rules! decl_module {
|
||||
$crate::__check_reserved_fn_name! { $( $fn_name )* }
|
||||
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, $crate::RuntimeDebug)]
|
||||
pub struct $mod_type<
|
||||
$trait_instance: $trait_name
|
||||
$(<I>, $instance: $instantiable $( = $module_default_instance)?)?
|
||||
@@ -1223,7 +1213,6 @@ macro_rules! decl_module {
|
||||
for $call_type<$trait_instance $(, $instance)?> where $( $other_where_bounds )*
|
||||
{}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $crate::dispatch::fmt::Debug
|
||||
for $call_type<$trait_instance $(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
@@ -1325,8 +1314,12 @@ macro_rules! impl_outer_dispatch {
|
||||
}
|
||||
) => {
|
||||
$(#[$attr])*
|
||||
#[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(
|
||||
Clone, PartialEq, Eq,
|
||||
$crate::codec::Encode,
|
||||
$crate::codec::Decode,
|
||||
$crate::RuntimeDebug,
|
||||
)]
|
||||
pub enum $call_type {
|
||||
$(
|
||||
$camelcase ( $crate::dispatch::CallableCallFor<$camelcase, $runtime> )
|
||||
|
||||
@@ -56,8 +56,7 @@ macro_rules! decl_error {
|
||||
$(,)?
|
||||
}
|
||||
) => {
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, $crate::RuntimeDebug)]
|
||||
$(#[$attr])*
|
||||
pub enum $error {
|
||||
Other(&'static str),
|
||||
|
||||
@@ -121,8 +121,12 @@ macro_rules! decl_event {
|
||||
}
|
||||
) => {
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
#[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(
|
||||
Clone, PartialEq, Eq,
|
||||
$crate::codec::Encode,
|
||||
$crate::codec::Decode,
|
||||
$crate::RuntimeDebug,
|
||||
)]
|
||||
/// Events for this module.
|
||||
///
|
||||
$(#[$attr])*
|
||||
@@ -260,9 +264,12 @@ macro_rules! __decl_generic_event {
|
||||
/// [`Trait`]: trait.Trait.html
|
||||
pub type Event<$event_generic_param $(, $instance $( = $event_default_instance)? )?> = RawEvent<$( $generic_type ),* $(, $instance)? >;
|
||||
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
#[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(
|
||||
Clone, PartialEq, Eq,
|
||||
$crate::codec::Encode,
|
||||
$crate::codec::Decode,
|
||||
$crate::RuntimeDebug,
|
||||
)]
|
||||
/// Events for this module.
|
||||
///
|
||||
$(#[$attr])*
|
||||
@@ -452,8 +459,12 @@ macro_rules! impl_outer_event {
|
||||
$( $module_name:ident::Event $( <$generic_param:ident> )? $( { $generic_instance:ident } )?, )*;
|
||||
) => {
|
||||
$crate::paste::item! {
|
||||
#[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(
|
||||
Clone, PartialEq, Eq,
|
||||
$crate::codec::Encode,
|
||||
$crate::codec::Decode,
|
||||
$crate::RuntimeDebug,
|
||||
)]
|
||||
$(#[$attr])*
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum $name {
|
||||
|
||||
@@ -40,7 +40,11 @@ pub use paste;
|
||||
pub use runtime_io::with_storage;
|
||||
#[doc(hidden)]
|
||||
pub use runtime_io::storage_root;
|
||||
#[doc(hidden)]
|
||||
pub use sr_primitives::RuntimeDebug;
|
||||
|
||||
#[macro_use]
|
||||
pub mod debug;
|
||||
#[macro_use]
|
||||
pub mod dispatch;
|
||||
#[macro_use]
|
||||
@@ -224,8 +228,7 @@ macro_rules! __assert_eq_uvec {
|
||||
|
||||
/// The void type - it cannot exist.
|
||||
// Oh rust, you crack me up...
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, Eq, PartialEq, RuntimeDebug)]
|
||||
pub enum Void {}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
|
||||
@@ -151,9 +151,7 @@ macro_rules! impl_outer_origin {
|
||||
$( $module:ident $( < $generic:ident > )? $( { $generic_instance:ident } )? ,)*
|
||||
) => {
|
||||
$crate::paste::item! {
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, PartialEq, Eq, $crate::RuntimeDebug)]
|
||||
$(#[$attr])*
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum $name {
|
||||
|
||||
@@ -191,8 +191,7 @@ macro_rules! construct_runtime {
|
||||
)*
|
||||
};
|
||||
) => {
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, $crate::RuntimeDebug)]
|
||||
pub struct $runtime;
|
||||
impl $crate::sr_primitives::traits::GetNodeBlockType for $runtime {
|
||||
type NodeBlock = $node_block;
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
//!
|
||||
//! NOTE: If you're looking for `parameter_types`, it has moved in to the top-level module.
|
||||
|
||||
use rstd::{prelude::*, result, marker::PhantomData, ops::Div};
|
||||
use rstd::{prelude::*, result, marker::PhantomData, ops::Div, fmt::Debug};
|
||||
use codec::{FullCodec, Codec, Encode, Decode};
|
||||
use primitives::u32_trait::Value as U32;
|
||||
use sr_primitives::{
|
||||
ConsensusEngineId,
|
||||
traits::{MaybeSerializeDebug, SimpleArithmetic, Saturating},
|
||||
traits::{MaybeSerializeDeserialize, SimpleArithmetic, Saturating},
|
||||
};
|
||||
|
||||
/// Anything that can have a `::len()` method.
|
||||
@@ -257,7 +257,7 @@ pub enum SignedImbalance<B, P: Imbalance<B>>{
|
||||
impl<
|
||||
P: Imbalance<B, Opposite=N>,
|
||||
N: Imbalance<B, Opposite=P>,
|
||||
B: SimpleArithmetic + FullCodec + Copy + MaybeSerializeDebug + Default,
|
||||
B: SimpleArithmetic + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default,
|
||||
> SignedImbalance<B, P> {
|
||||
pub fn zero() -> Self {
|
||||
SignedImbalance::Positive(P::zero())
|
||||
@@ -320,7 +320,7 @@ impl<
|
||||
/// Abstraction over a fungible assets system.
|
||||
pub trait Currency<AccountId> {
|
||||
/// The balance of an account.
|
||||
type Balance: SimpleArithmetic + FullCodec + Copy + MaybeSerializeDebug + Default;
|
||||
type Balance: SimpleArithmetic + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default;
|
||||
|
||||
/// The opaque token type for an imbalance. This is returned by unbalanced operations
|
||||
/// and must be dealt with. It may be dropped but cannot be cloned.
|
||||
|
||||
@@ -87,8 +87,7 @@ mod module1 {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, Clone, sr_primitives::RuntimeDebug)]
|
||||
pub enum Origin<T: Trait<I>, I> where T::BlockNumber: From<u32> {
|
||||
Members(u32),
|
||||
_Phantom(std::marker::PhantomData<(T, I)>),
|
||||
@@ -150,8 +149,7 @@ mod module2 {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, Clone, sr_primitives::RuntimeDebug)]
|
||||
pub enum Origin<T: Trait<I>, I=DefaultInstance> {
|
||||
Members(u32),
|
||||
_Phantom(std::marker::PhantomData<(T, I)>),
|
||||
|
||||
@@ -38,8 +38,7 @@ support::decl_error! {
|
||||
}
|
||||
|
||||
/// Origin for the system module.
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, Clone, sr_primitives::RuntimeDebug)]
|
||||
pub enum RawOrigin<AccountId> {
|
||||
Root,
|
||||
Signed(AccountId),
|
||||
|
||||
@@ -94,8 +94,10 @@ use rstd::prelude::*;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use rstd::map;
|
||||
use rstd::marker::PhantomData;
|
||||
use rstd::fmt::Debug;
|
||||
use sr_version::RuntimeVersion;
|
||||
use sr_primitives::{
|
||||
RuntimeDebug,
|
||||
generic::{self, Era}, Perbill, ApplyError, ApplyOutcome, DispatchError,
|
||||
weights::{Weight, DispatchInfo, DispatchClass, SimpleDispatchInfo},
|
||||
transaction_validity::{
|
||||
@@ -105,7 +107,7 @@ use sr_primitives::{
|
||||
traits::{
|
||||
self, CheckEqual, SimpleArithmetic, Zero, SignedExtension, Lookup, LookupError,
|
||||
SimpleBitOps, Hash, Member, MaybeDisplay, EnsureOrigin, SaturatedConversion,
|
||||
MaybeSerializeDebugButNotDeserialize, MaybeSerializeDebug, StaticLookup, One, Bounded,
|
||||
MaybeSerialize, MaybeSerializeDeserialize, StaticLookup, One, Bounded,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -158,28 +160,28 @@ pub trait Trait: 'static + Eq + Clone {
|
||||
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>> + From<RawOrigin<Self::AccountId>>;
|
||||
|
||||
/// The aggregated `Call` type.
|
||||
type Call;
|
||||
type Call: Debug;
|
||||
|
||||
/// Account index (aka nonce) type. This stores the number of previous transactions associated with a sender
|
||||
/// account.
|
||||
type Index:
|
||||
Parameter + Member + MaybeSerializeDebugButNotDeserialize + Default + MaybeDisplay + SimpleArithmetic + Copy;
|
||||
Parameter + Member + MaybeSerialize + Debug + Default + MaybeDisplay + SimpleArithmetic + Copy;
|
||||
|
||||
/// The block number type used by the runtime.
|
||||
type BlockNumber:
|
||||
Parameter + Member + MaybeSerializeDebug + MaybeDisplay + SimpleArithmetic + Default + Bounded + Copy
|
||||
+ rstd::hash::Hash;
|
||||
Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + SimpleArithmetic
|
||||
+ Default + Bounded + Copy + rstd::hash::Hash;
|
||||
|
||||
/// The output of the `Hashing` function.
|
||||
type Hash:
|
||||
Parameter + Member + MaybeSerializeDebug + MaybeDisplay + SimpleBitOps + Default + Copy + CheckEqual
|
||||
+ rstd::hash::Hash + AsRef<[u8]> + AsMut<[u8]>;
|
||||
Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + SimpleBitOps
|
||||
+ Default + Copy + CheckEqual + rstd::hash::Hash + AsRef<[u8]> + AsMut<[u8]>;
|
||||
|
||||
/// The hashing system (algorithm) being used in the runtime (e.g. Blake2).
|
||||
type Hashing: Hash<Output = Self::Hash>;
|
||||
|
||||
/// The user account identifier type for the runtime.
|
||||
type AccountId: Parameter + Member + MaybeSerializeDebug + MaybeDisplay + Ord + Default;
|
||||
type AccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default;
|
||||
|
||||
/// Converting trait to take a source type and convert to `AccountId`.
|
||||
///
|
||||
@@ -195,7 +197,7 @@ pub trait Trait: 'static + Eq + Clone {
|
||||
>;
|
||||
|
||||
/// The aggregated event type of the runtime.
|
||||
type Event: Parameter + Member + From<Event>;
|
||||
type Event: Parameter + Member + From<Event> + Debug;
|
||||
|
||||
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||
type BlockHashCount: Get<Self::BlockNumber>;
|
||||
@@ -280,8 +282,8 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// A phase of a block's execution.
|
||||
#[derive(Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, PartialEq, Eq, Clone, Debug))]
|
||||
#[derive(Encode, Decode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, PartialEq, Eq, Clone))]
|
||||
pub enum Phase {
|
||||
/// Applying an extrinsic.
|
||||
ApplyExtrinsic(u32),
|
||||
@@ -290,8 +292,8 @@ pub enum Phase {
|
||||
}
|
||||
|
||||
/// Record of an event happening.
|
||||
#[derive(Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, PartialEq, Eq, Clone, Debug))]
|
||||
#[derive(Encode, Decode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, PartialEq, Eq, Clone))]
|
||||
pub struct EventRecord<E: Parameter + Member, T> {
|
||||
/// The phase of the block it happened in.
|
||||
pub phase: Phase,
|
||||
@@ -323,8 +325,7 @@ decl_error! {
|
||||
}
|
||||
|
||||
/// Origin for the System module.
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(PartialEq, Eq, Clone, RuntimeDebug)]
|
||||
pub enum RawOrigin<AccountId> {
|
||||
/// The system itself ordained this dispatch to happen: this is the highest privilege level.
|
||||
Root,
|
||||
@@ -855,10 +856,15 @@ impl<T: Trait + Send + Sync> SignedExtension for CheckWeight<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: Trait + Send + Sync> rstd::fmt::Debug for CheckWeight<T> {
|
||||
impl<T: Trait + Send + Sync> Debug for CheckWeight<T> {
|
||||
#[cfg(feature = "std")]
|
||||
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
write!(f, "CheckWeight<T>")
|
||||
write!(f, "CheckWeight")
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -873,11 +879,16 @@ impl<T: Trait> CheckNonce<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: Trait> rstd::fmt::Debug for CheckNonce<T> {
|
||||
impl<T: Trait> Debug for CheckNonce<T> {
|
||||
#[cfg(feature = "std")]
|
||||
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> SignedExtension for CheckNonce<T> {
|
||||
@@ -951,11 +962,16 @@ impl<T: Trait + Send + Sync> CheckEra<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: Trait + Send + Sync> rstd::fmt::Debug for CheckEra<T> {
|
||||
impl<T: Trait + Send + Sync> Debug for CheckEra<T> {
|
||||
#[cfg(feature = "std")]
|
||||
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait + Send + Sync> SignedExtension for CheckEra<T> {
|
||||
@@ -994,9 +1010,14 @@ impl<T: Trait + Send + Sync> SignedExtension for CheckEra<T> {
|
||||
#[derive(Encode, Decode, Clone, Eq, PartialEq)]
|
||||
pub struct CheckGenesis<T: Trait + Send + Sync>(rstd::marker::PhantomData<T>);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: Trait + Send + Sync> rstd::fmt::Debug for CheckGenesis<T> {
|
||||
fn fmt(&self, _f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
impl<T: Trait + Send + Sync> Debug for CheckGenesis<T> {
|
||||
#[cfg(feature = "std")]
|
||||
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
write!(f, "CheckGenesis")
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1023,9 +1044,14 @@ impl<T: Trait + Send + Sync> SignedExtension for CheckGenesis<T> {
|
||||
#[derive(Encode, Decode, Clone, Eq, PartialEq)]
|
||||
pub struct CheckVersion<T: Trait + Send + Sync>(rstd::marker::PhantomData<T>);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: Trait + Send + Sync> rstd::fmt::Debug for CheckVersion<T> {
|
||||
fn fmt(&self, _f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
impl<T: Trait + Send + Sync> Debug for CheckVersion<T> {
|
||||
#[cfg(feature = "std")]
|
||||
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
write!(f, "CheckVersion")
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"timstap0";
|
||||
pub type InherentType = u64;
|
||||
|
||||
/// Errors that can occur while checking the timestamp inherent.
|
||||
#[derive(Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Decode))]
|
||||
#[derive(Encode, sr_primitives::RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode))]
|
||||
pub enum InherentError {
|
||||
/// The timestamp is valid in the future.
|
||||
/// This is a non-fatal-error and will not stop checking the inherents.
|
||||
|
||||
@@ -145,11 +145,15 @@ impl<T: Trait + Send + Sync> ChargeTransactionPayment<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<T: Trait + Send + Sync> rstd::fmt::Debug for ChargeTransactionPayment<T> {
|
||||
#[cfg(feature = "std")]
|
||||
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
write!(f, "ChargeTransactionPayment<{:?}>", self.0)
|
||||
}
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait + Send + Sync> SignedExtension for ChargeTransactionPayment<T>
|
||||
|
||||
@@ -213,8 +213,8 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// A spending proposal.
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, sr_primitives::RuntimeDebug)]
|
||||
pub struct Proposal<AccountId, Balance> {
|
||||
proposer: AccountId,
|
||||
value: Balance,
|
||||
|
||||
Reference in New Issue
Block a user