Metadata V15: Derive TypeInfo for describing runtime types (#13272)

* scale_info: Derive TypeInfo for types present in runtime API

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* cargo: Update Cargo.lock

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2023-02-02 19:14:40 +02:00
committed by GitHub
parent 25388b267e
commit 4b2cc67fc6
18 changed files with 48 additions and 34 deletions
+3
View File
@@ -5615,6 +5615,7 @@ version = "7.0.0"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"parity-scale-codec", "parity-scale-codec",
"scale-info",
"sp-runtime", "sp-runtime",
"sp-std", "sp-std",
"sp-weights", "sp-weights",
@@ -8151,6 +8152,7 @@ dependencies = [
"sc-network", "sc-network",
"sc-network-test", "sc-network-test",
"sc-telemetry", "sc-telemetry",
"scale-info",
"schnorrkel", "schnorrkel",
"sp-api", "sp-api",
"sp-application-crypto", "sp-application-crypto",
@@ -9959,6 +9961,7 @@ dependencies = [
"futures", "futures",
"impl-trait-for-tuples", "impl-trait-for-tuples",
"parity-scale-codec", "parity-scale-codec",
"scale-info",
"sp-core", "sp-core",
"sp-runtime", "sp-runtime",
"sp-std", "sp-std",
@@ -15,6 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies] [dependencies]
async-trait = "0.1.57" async-trait = "0.1.57"
scale-info = { version = "2.1.1", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] }
futures = "0.3.21" futures = "0.3.21"
log = "0.4.17" log = "0.4.17"
+1 -1
View File
@@ -152,7 +152,7 @@ mod tests;
const LOG_TARGET: &str = "babe"; const LOG_TARGET: &str = "babe";
/// BABE epoch information /// BABE epoch information
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)] #[derive(Decode, Encode, PartialEq, Eq, Clone, Debug, scale_info::TypeInfo)]
pub struct Epoch { pub struct Epoch {
/// The epoch index. /// The epoch index.
pub epoch_index: u64, pub epoch_index: u64,
+7 -6
View File
@@ -22,6 +22,7 @@ use frame_support::{
pallet_prelude::*, pallet_prelude::*,
traits::StorageInfo, traits::StorageInfo,
}; };
use scale_info::TypeInfo;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sp_io::hashing::blake2_256; use sp_io::hashing::blake2_256;
@@ -31,7 +32,7 @@ use sp_storage::TrackedStorageKey;
/// An alphabet of possible parameters to use for benchmarking. /// An alphabet of possible parameters to use for benchmarking.
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(Encode, Decode, Clone, Copy, PartialEq, Debug)] #[derive(Encode, Decode, Clone, Copy, PartialEq, Debug, TypeInfo)]
#[allow(missing_docs)] #[allow(missing_docs)]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
pub enum BenchmarkParameter { pub enum BenchmarkParameter {
@@ -72,7 +73,7 @@ impl std::fmt::Display for BenchmarkParameter {
/// The results of a single of benchmark. /// The results of a single of benchmark.
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(Encode, Decode, Clone, PartialEq, Debug)] #[derive(Encode, Decode, Clone, PartialEq, Debug, TypeInfo)]
pub struct BenchmarkBatch { pub struct BenchmarkBatch {
/// The pallet containing this benchmark. /// The pallet containing this benchmark.
#[cfg_attr(feature = "std", serde(with = "serde_as_str"))] #[cfg_attr(feature = "std", serde(with = "serde_as_str"))]
@@ -111,7 +112,7 @@ pub struct BenchmarkBatchSplitResults {
/// Contains duration of the function call in nanoseconds along with the benchmark parameters /// Contains duration of the function call in nanoseconds along with the benchmark parameters
/// used for that benchmark result. /// used for that benchmark result.
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)] #[derive(Encode, Decode, Default, Clone, PartialEq, Debug, TypeInfo)]
pub struct BenchmarkResult { pub struct BenchmarkResult {
pub components: Vec<(BenchmarkParameter, u32)>, pub components: Vec<(BenchmarkParameter, u32)>,
pub extrinsic_time: u128, pub extrinsic_time: u128,
@@ -199,7 +200,7 @@ impl From<DispatchError> for BenchmarkError {
} }
/// Configuration used to setup and run runtime benchmarks. /// Configuration used to setup and run runtime benchmarks.
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)] #[derive(Encode, Decode, Default, Clone, PartialEq, Debug, TypeInfo)]
pub struct BenchmarkConfig { pub struct BenchmarkConfig {
/// The encoded name of the pallet to benchmark. /// The encoded name of the pallet to benchmark.
pub pallet: Vec<u8>, pub pallet: Vec<u8>,
@@ -216,14 +217,14 @@ pub struct BenchmarkConfig {
/// A list of benchmarks available for a particular pallet and instance. /// A list of benchmarks available for a particular pallet and instance.
/// ///
/// All `Vec<u8>` must be valid utf8 strings. /// All `Vec<u8>` must be valid utf8 strings.
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)] #[derive(Encode, Decode, Default, Clone, PartialEq, Debug, TypeInfo)]
pub struct BenchmarkList { pub struct BenchmarkList {
pub pallet: Vec<u8>, pub pallet: Vec<u8>,
pub instance: Vec<u8>, pub instance: Vec<u8>,
pub benchmarks: Vec<BenchmarkMetadata>, pub benchmarks: Vec<BenchmarkMetadata>,
} }
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)] #[derive(Encode, Decode, Default, Clone, PartialEq, Debug, TypeInfo)]
pub struct BenchmarkMetadata { pub struct BenchmarkMetadata {
pub name: Vec<u8>, pub name: Vec<u8>,
pub components: Vec<(BenchmarkParameter, u32, u32)>, pub components: Vec<(BenchmarkParameter, u32, u32)>,
@@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies] [dependencies]
bitflags = "1.0" bitflags = "1.0"
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
# Substrate Dependencies (This crate should not rely on frame) # Substrate Dependencies (This crate should not rely on frame)
@@ -27,4 +28,5 @@ std = [
"codec/std", "codec/std",
"sp-runtime/std", "sp-runtime/std",
"sp-std/std", "sp-std/std",
"scale-info/std",
] ]
@@ -21,6 +21,7 @@
use bitflags::bitflags; use bitflags::bitflags;
use codec::{Decode, Encode}; use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_runtime::{ use sp_runtime::{
traits::{Saturating, Zero}, traits::{Saturating, Zero},
DispatchError, RuntimeDebug, DispatchError, RuntimeDebug,
@@ -31,7 +32,7 @@ use sp_weights::Weight;
/// Result type of a `bare_call` or `bare_instantiate` call. /// Result type of a `bare_call` or `bare_instantiate` call.
/// ///
/// It contains the execution result together with some auxiliary information. /// It contains the execution result together with some auxiliary information.
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug)] #[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct ContractResult<R, Balance> { pub struct ContractResult<R, Balance> {
/// How much weight was consumed during execution. /// How much weight was consumed during execution.
pub gas_consumed: Weight, pub gas_consumed: Weight,
@@ -86,7 +87,7 @@ pub type CodeUploadResult<CodeHash, Balance> =
pub type GetStorageResult = Result<Option<Vec<u8>>, ContractAccessError>; pub type GetStorageResult = Result<Option<Vec<u8>>, ContractAccessError>;
/// The possible errors that can happen querying the storage of a contract. /// The possible errors that can happen querying the storage of a contract.
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug)] #[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub enum ContractAccessError { pub enum ContractAccessError {
/// The given address doesn't point to a contract. /// The given address doesn't point to a contract.
DoesntExist, DoesntExist,
@@ -96,7 +97,7 @@ pub enum ContractAccessError {
bitflags! { bitflags! {
/// Flags used by a contract to customize exit behaviour. /// Flags used by a contract to customize exit behaviour.
#[derive(Encode, Decode)] #[derive(Encode, Decode, TypeInfo)]
pub struct ReturnFlags: u32 { pub struct ReturnFlags: u32 {
/// If this bit is set all changes made by the contract execution are rolled back. /// If this bit is set all changes made by the contract execution are rolled back.
const REVERT = 0x0000_0001; const REVERT = 0x0000_0001;
@@ -104,7 +105,7 @@ bitflags! {
} }
/// Output of a contract call or instantiation which ran to completion. /// Output of a contract call or instantiation which ran to completion.
#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug)] #[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct ExecReturnValue { pub struct ExecReturnValue {
/// Flags passed along by `seal_return`. Empty when `seal_return` was never called. /// Flags passed along by `seal_return`. Empty when `seal_return` was never called.
pub flags: ReturnFlags, pub flags: ReturnFlags,
@@ -120,7 +121,7 @@ impl ExecReturnValue {
} }
/// The result of a successful contract instantiation. /// The result of a successful contract instantiation.
#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug)] #[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct InstantiateReturnValue<AccountId> { pub struct InstantiateReturnValue<AccountId> {
/// The output of the called constructor. /// The output of the called constructor.
pub result: ExecReturnValue, pub result: ExecReturnValue,
@@ -129,7 +130,7 @@ pub struct InstantiateReturnValue<AccountId> {
} }
/// The result of succesfully uploading a contract. /// The result of succesfully uploading a contract.
#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug)] #[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct CodeUploadReturnValue<CodeHash, Balance> { pub struct CodeUploadReturnValue<CodeHash, Balance> {
/// The key under which the new code is stored. /// The key under which the new code is stored.
pub code_hash: CodeHash, pub code_hash: CodeHash,
@@ -138,7 +139,7 @@ pub struct CodeUploadReturnValue<CodeHash, Balance> {
} }
/// Reference to an existing code hash or a new wasm module. /// Reference to an existing code hash or a new wasm module.
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug)] #[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub enum Code<Hash> { pub enum Code<Hash> {
/// A wasm module as raw bytes. /// A wasm module as raw bytes.
Upload(Vec<u8>), Upload(Vec<u8>),
@@ -153,7 +154,7 @@ impl<T: Into<Vec<u8>>, Hash> From<T> for Code<Hash> {
} }
/// The amount of balance that was either charged or refunded in order to pay for storage. /// The amount of balance that was either charged or refunded in order to pay for storage.
#[derive(Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, Clone)] #[derive(Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, Clone, TypeInfo)]
pub enum StorageDeposit<Balance> { pub enum StorageDeposit<Balance> {
/// The transaction reduced storage consumption. /// The transaction reduced storage consumption.
/// ///
@@ -53,7 +53,9 @@ pub trait StorageInstance {
} }
/// Metadata about storage from the runtime. /// Metadata about storage from the runtime.
#[derive(codec::Encode, codec::Decode, crate::RuntimeDebug, Eq, PartialEq, Clone)] #[derive(
codec::Encode, codec::Decode, crate::RuntimeDebug, Eq, PartialEq, Clone, scale_info::TypeInfo,
)]
pub struct StorageInfo { pub struct StorageInfo {
/// Encoded string of pallet name. /// Encoded string of pallet name.
pub pallet_name: Vec<u8>, pub pallet_name: Vec<u8>,
@@ -22,7 +22,7 @@ use sp_arithmetic::traits::AtLeast32BitUnsigned;
use sp_std::prelude::*; use sp_std::prelude::*;
/// Which state tests to execute. /// Which state tests to execute.
#[derive(codec::Encode, codec::Decode, Clone)] #[derive(codec::Encode, codec::Decode, Clone, scale_info::TypeInfo)]
pub enum Select { pub enum Select {
/// None of them. /// None of them.
None, None,
@@ -82,7 +82,7 @@ impl sp_std::str::FromStr for Select {
} }
/// Select which checks should be run when trying a runtime upgrade upgrade. /// Select which checks should be run when trying a runtime upgrade upgrade.
#[derive(codec::Encode, codec::Decode, Clone, Debug, Copy)] #[derive(codec::Encode, codec::Decode, Clone, Debug, Copy, scale_info::TypeInfo)]
pub enum UpgradeCheckSelect { pub enum UpgradeCheckSelect {
/// Run no checks. /// Run no checks.
None, None,
@@ -21,13 +21,15 @@ use codec::{Decode, Encode};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use scale_info::TypeInfo;
use sp_runtime::traits::{AtLeast32BitUnsigned, Zero}; use sp_runtime::traits::{AtLeast32BitUnsigned, Zero};
use sp_std::prelude::*; use sp_std::prelude::*;
use frame_support::dispatch::DispatchClass; use frame_support::dispatch::DispatchClass;
/// The base fee and adjusted weight and length fees constitute the _inclusion fee_. /// The base fee and adjusted weight and length fees constitute the _inclusion fee_.
#[derive(Encode, Decode, Clone, Eq, PartialEq)] #[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] #[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] #[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
pub struct InclusionFee<Balance> { pub struct InclusionFee<Balance> {
@@ -63,7 +65,7 @@ impl<Balance: AtLeast32BitUnsigned + Copy> InclusionFee<Balance> {
/// - (Optional) `inclusion_fee`: Only the `Pays::Yes` transaction can have the inclusion fee. /// - (Optional) `inclusion_fee`: Only the `Pays::Yes` transaction can have the inclusion fee.
/// - `tip`: If included in the transaction, the tip will be added on top. Only signed /// - `tip`: If included in the transaction, the tip will be added on top. Only signed
/// transactions can have a tip. /// transactions can have a tip.
#[derive(Encode, Decode, Clone, Eq, PartialEq)] #[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] #[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] #[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
pub struct FeeDetails<Balance> { pub struct FeeDetails<Balance> {
@@ -91,7 +93,7 @@ impl<Balance: AtLeast32BitUnsigned + Copy> FeeDetails<Balance> {
/// Information related to a dispatchable's class, weight, and fee that can be queried from the /// Information related to a dispatchable's class, weight, and fee that can be queried from the
/// runtime. /// runtime.
#[derive(Eq, PartialEq, Encode, Decode, Default)] #[derive(Eq, PartialEq, Encode, Decode, Default, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] #[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] #[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
#[cfg_attr( #[cfg_attr(
@@ -184,7 +184,7 @@ impl From<BabeConfigurationV1> for BabeConfiguration {
} }
/// Configuration data used by the BABE consensus engine. /// Configuration data used by the BABE consensus engine.
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)] #[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct BabeConfiguration { pub struct BabeConfiguration {
/// The slot duration in milliseconds for BABE. Currently, only /// The slot duration in milliseconds for BABE. Currently, only
/// the value provided by this type at genesis will be used. /// the value provided by this type at genesis will be used.
@@ -327,7 +327,7 @@ where
/// the runtime API boundary this type is unknown and as such we keep this /// the runtime API boundary this type is unknown and as such we keep this
/// opaque representation, implementors of the runtime API will have to make /// opaque representation, implementors of the runtime API will have to make
/// sure that all usages of `OpaqueKeyOwnershipProof` refer to the same type. /// sure that all usages of `OpaqueKeyOwnershipProof` refer to the same type.
#[derive(Decode, Encode, PartialEq)] #[derive(Decode, Encode, PartialEq, TypeInfo)]
pub struct OpaqueKeyOwnershipProof(Vec<u8>); pub struct OpaqueKeyOwnershipProof(Vec<u8>);
impl OpaqueKeyOwnershipProof { impl OpaqueKeyOwnershipProof {
/// Create a new `OpaqueKeyOwnershipProof` using the given encoded /// Create a new `OpaqueKeyOwnershipProof` using the given encoded
@@ -344,7 +344,7 @@ impl OpaqueKeyOwnershipProof {
} }
/// BABE epoch information /// BABE epoch information
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)] #[derive(Decode, Encode, PartialEq, Eq, Clone, Debug, TypeInfo)]
pub struct Epoch { pub struct Epoch {
/// The epoch index. /// The epoch index.
pub epoch_index: u64, pub epoch_index: u64,
+1 -1
View File
@@ -165,7 +165,7 @@ impl sp_std::str::FromStr for Bytes {
} }
/// Stores the encoded `RuntimeMetadata` for the native side as opaque type. /// Stores the encoded `RuntimeMetadata` for the native side as opaque type.
#[derive(Encode, Decode, PartialEq)] #[derive(Encode, Decode, PartialEq, TypeInfo)]
pub struct OpaqueMetadata(Vec<u8>); pub struct OpaqueMetadata(Vec<u8>);
impl OpaqueMetadata { impl OpaqueMetadata {
@@ -529,7 +529,7 @@ impl<'a> Decode for VersionedAuthorityList<'a> {
/// the runtime API boundary this type is unknown and as such we keep this /// the runtime API boundary this type is unknown and as such we keep this
/// opaque representation, implementors of the runtime API will have to make /// opaque representation, implementors of the runtime API will have to make
/// sure that all usages of `OpaqueKeyOwnershipProof` refer to the same type. /// sure that all usages of `OpaqueKeyOwnershipProof` refer to the same type.
#[derive(Decode, Encode, PartialEq)] #[derive(Decode, Encode, PartialEq, TypeInfo)]
pub struct OpaqueKeyOwnershipProof(Vec<u8>); pub struct OpaqueKeyOwnershipProof(Vec<u8>);
impl OpaqueKeyOwnershipProof { impl OpaqueKeyOwnershipProof {
@@ -16,6 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies] [dependencies]
async-trait = { version = "0.1.57", optional = true } async-trait = { version = "0.1.57", optional = true }
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
impl-trait-for-tuples = "0.2.2" impl-trait-for-tuples = "0.2.2"
thiserror = { version = "1.0.30", optional = true } thiserror = { version = "1.0.30", optional = true }
sp-core = { version = "7.0.0", default-features = false, path = "../core" } sp-core = { version = "7.0.0", default-features = false, path = "../core" }
@@ -30,6 +31,7 @@ default = [ "std" ]
std = [ std = [
"async-trait", "async-trait",
"codec/std", "codec/std",
"scale-info/std",
"sp-core/std", "sp-core/std",
"sp-runtime/std", "sp-runtime/std",
"sp-std/std", "sp-std/std",
+2 -2
View File
@@ -204,7 +204,7 @@ pub enum Error {
pub type InherentIdentifier = [u8; 8]; pub type InherentIdentifier = [u8; 8];
/// Inherent data to include in a block. /// Inherent data to include in a block.
#[derive(Clone, Default, Encode, Decode)] #[derive(Clone, Default, Encode, Decode, scale_info::TypeInfo)]
pub struct InherentData { pub struct InherentData {
/// All inherent data encoded with parity-scale-codec and an identifier. /// All inherent data encoded with parity-scale-codec and an identifier.
data: BTreeMap<InherentIdentifier, Vec<u8>>, data: BTreeMap<InherentIdentifier, Vec<u8>>,
@@ -276,7 +276,7 @@ impl InherentData {
/// ///
/// When a fatal error occurs, all other errors are removed and the implementation needs to /// When a fatal error occurs, all other errors are removed and the implementation needs to
/// abort checking inherents. /// abort checking inherents.
#[derive(Encode, Decode, Clone)] #[derive(Encode, Decode, Clone, scale_info::TypeInfo)]
pub struct CheckInherentsResult { pub struct CheckInherentsResult {
/// Did the check succeed? /// Did the check succeed?
okay: bool, okay: bool,
@@ -142,7 +142,7 @@ impl FullLeaf for OpaqueLeaf {
/// ///
/// It is different from [`OpaqueLeaf`], because it does implement `Codec` /// It is different from [`OpaqueLeaf`], because it does implement `Codec`
/// and the encoding has to match raw `Vec<u8>` encoding. /// and the encoding has to match raw `Vec<u8>` encoding.
#[derive(codec::Encode, codec::Decode, RuntimeDebug, PartialEq, Eq)] #[derive(codec::Encode, codec::Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)]
pub struct EncodableOpaqueLeaf(pub Vec<u8>); pub struct EncodableOpaqueLeaf(pub Vec<u8>);
impl EncodableOpaqueLeaf { impl EncodableOpaqueLeaf {
@@ -361,7 +361,7 @@ pub struct Proof<Hash> {
/// Merkle Mountain Range operation error. /// Merkle Mountain Range operation error.
#[cfg_attr(feature = "std", derive(thiserror::Error))] #[cfg_attr(feature = "std", derive(thiserror::Error))]
#[derive(RuntimeDebug, codec::Encode, codec::Decode, PartialEq, Eq)] #[derive(RuntimeDebug, codec::Encode, codec::Decode, PartialEq, Eq, TypeInfo)]
pub enum Error { pub enum Error {
/// Error during translation of a block number into a leaf index. /// Error during translation of a block number into a leaf index.
#[cfg_attr(feature = "std", error("Error performing numeric op"))] #[cfg_attr(feature = "std", error("Error performing numeric op"))]
@@ -78,7 +78,7 @@ impl<Block: BlockT> fmt::Display for BlockId<Block> {
} }
/// Abstraction over a substrate block. /// Abstraction over a substrate block.
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)] #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] #[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "std", serde(deny_unknown_fields))] #[cfg_attr(feature = "std", serde(deny_unknown_fields))]
@@ -226,7 +226,7 @@ impl From<UnknownTransaction> for TransactionValidity {
/// Depending on the source we might apply different validation schemes. /// Depending on the source we might apply different validation schemes.
/// For instance we can disallow specific kinds of transactions if they were not produced /// For instance we can disallow specific kinds of transactions if they were not produced
/// by our local node (for instance off-chain workers). /// by our local node (for instance off-chain workers).
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)] #[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub enum TransactionSource { pub enum TransactionSource {
/// Transaction is already included in block. /// Transaction is already included in block.
/// ///
@@ -251,7 +251,7 @@ pub enum TransactionSource {
} }
/// Information concerning a valid transaction. /// Information concerning a valid transaction.
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)] #[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct ValidTransaction { pub struct ValidTransaction {
/// Priority of the transaction. /// Priority of the transaction.
/// ///
+1 -1
View File
@@ -297,7 +297,7 @@ pub fn run_tests(mut input: &[u8]) -> Vec<u8> {
} }
/// A type that can not be decoded. /// A type that can not be decoded.
#[derive(PartialEq)] #[derive(PartialEq, TypeInfo)]
pub struct DecodeFails<B: BlockT> { pub struct DecodeFails<B: BlockT> {
_phantom: PhantomData<B>, _phantom: PhantomData<B>,
} }