Crate sp_runtime
source ·Expand description
Substrate Runtime Primitives.
This crate, among other things, contains a large library of types and utilities that are used in
the Substrate runtime, but are not particularly FRAME
-oriented.
Block, Header and Extrinsics
Most notable, this crate contains some of the types and trait that enable important communication between the client and the runtime. This includes:
- A set of traits to declare what any block/header/extrinsic type should provide.
- A set of types that implement these traits, whilst still providing a high degree of configurability via generics.
Runtime API Types
This crate also contains some types that are often used in conjuncture with Runtime APIs. Most notable:
ApplyExtrinsicResult
, andDispatchOutcome
, which dictate how the client and runtime communicate about the success or failure of an extrinsic.transaction_validity
, which dictates how the client and runtime communicate about the validity of an extrinsic while still in the transaction-queue.
Re-exports
pub use generic::Digest;
pub use generic::DigestItem;
Modules
- Re-export big_uint stuff. Infinite precision unsigned integer for substrate runtime.
- Re-export bounded_vec and bounded_btree_map macros only when std is enabled. Traits, types and structs to support a bounded BTreeMap.
- Re-export bounded_vec and bounded_btree_map macros only when std is enabled. Traits, types and structs to support putting a bounded vector into storage, as a raw value, map or a double map.
- Provides some utilities to define a piecewise linear function.
- Generic implementations of
crate::traits::Header
,crate::traits::Block
andcrate::traits::Extrinsic
. - Re-export 128 bit helpers. Some helper functions to work with 128bit numbers. Note that the functionality provided here is only sensible to use with 128bit numbers because for smaller sizes, you can always rely on assumptions of a bigger type (u128) being available, or simply create a per-thing and use the multiplication implementation provided there.
- Re-export this since it’s part of the API of this crate. Known key types; this also functions as a global registry of key types for projects wishing to avoid collisions with each other.
- Runtime types that existed in old API versions.
- A collection of higher lever helpers for offchain calls.
- A logger that can be used to log from the runtime.
- Testing utilities.
- Primitives for the runtime modules.
- Transaction validity interface.
Macros
- Checks that
$x
is equal to$y
with an error rate of$error
. - Same as
assert_eq_error_rate
, but intended to be used with floating point number, or generally those who do not have over/underflow potentials. - Re-export bounded_vec and bounded_btree_map macros only when std is enabled. Build a bounded btree-map from the given literals.
- Re-export bounded_vec and bounded_btree_map macros only when std is enabled. Build a bounded vec from the given literals.
- Calls a given macro a number of times with a set of fixed params and an incrementing numeral. e.g.
- Create a const
RuntimeString
. - Convenience macro to use the format! interface to get a
RuntimeString::Owned
- Implement
OpaqueKeys
for a described struct. - Create a
Morph
and/orTryMorph
impls with a simple closure-like expression.
Structs
- Re-export this since it’s part of the API of this crate. An opaque 32-byte cryptographic identifier.
- Signature verify that can work with any known signature types..
- Re-export this since it’s part of the API of this crate. A bounded map based on a B-Tree.
- Re-export this since it’s part of the API of this crate. A bounded set based on a B-Tree.
- Re-export this since it’s part of the API of this crate. A bounded slice.
- Re-export this since it’s part of the API of this crate. A bounded vector.
- Re-export this since it’s part of the API of this crate. An identifier for a specific cryptographic algorithm used by a key pair
- Result of a
Dispatchable
which contains theDispatchResult
and additional information about theDispatchable
that is only known post dispatch. - Re-export top-level arithmetic stuff. A fixed point number representation in the range. Fixed Point 64 bits signed, range = [-9223372036.854775808, 9223372036.854775807]
- Re-export top-level arithmetic stuff. A fixed point number representation in the range. Fixed Point 128 bits signed, range = [-170141183460469231731.687303715884105728, 170141183460469231731.687303715884105727]
- Re-export top-level arithmetic stuff. A fixed point number representation in the range. Fixed Point 64 bits unsigned, range = [0.000000000, 18446744073.709551615]
- Re-export top-level arithmetic stuff. A fixed point number representation in the range. Fixed Point 128 bits unsigned, range = [0.000000000000000000, 340282366920938463463.374607431768211455]
- Collection of justifications for a given block, multiple justifications may be provided by different consensus engines for the same block.
- Re-export this since it’s part of the API of this crate. An identifier for a type of cryptographic key.
- Reason why a pallet call failed.
- Simple blob to hold an extrinsic without committing to its format and ensure it is serialized correctly.
- Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1].
- Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1].
- Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1].
- Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1].
- Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1].
- Re-export top-level arithmetic stuff. A wrapper for any rational number with a 128 bit numerator and denominator.
- Struct containing data needed for a storage.
- Child trie storage data.
- Re-export this since it’s part of the API of this crate. A weakly bounded vector.
Enums
- Re-export top-level arithmetic stuff. Arithmetic errors.
- Reason why a dispatch call failed.
- The enum
Either
with variantsLeft
andRight
is a general purpose sum type with two cases. - A multi-format address wrapper for on-chain accounts.
- Signature verify that can work with any known signature types.
- Public key for any known crypto algorithm.
- Re-export top-level arithmetic stuff. The rounding method to use for unsigned quantities.
- A string that wraps a
&'static str
in the runtime andString
/Vec<u8>
on decode. - Different possible state version.
- Description of what went wrong when trying to complete an operation on a token.
- Describes on what should happen with a storage transaction.
- Errors related to transactional storage layers.
Constants
- The number of bytes of the module-specific
error
field defined inModuleError
. In FRAME, this is the maximum encoded size of a pallet error type.
Traits
- Something that is bound to a fixed
RuntimeAppPublic
. - BuildModuleGenesisStorageDeprecatedSomething that can build the genesis storage of a module.
- Complex storage builder stuff.
- Re-export this since it’s part of the API of this crate. Type which has a particular kind of crypto associated with it.
- A data structure that can be deserialized from any data format supported by Serde.
- A data structure that can be deserialized without borrowing any data from the deserializer.
- Re-export top-level arithmetic stuff. Something that implements a decimal fixed point number.
- Re-export top-level arithmetic stuff. Integer types that can be used to interact with
FixedPointNumber
implementations. - Re-export top-level arithmetic stuff. Something that implements a fixed point ration with an arbitrary granularity
X
, as parts perX
. - Runtime interface for an application’s public key.
- Re-export top-level arithmetic stuff. Convenience type to work around the highly unergonomic syntax needed to invoke the functions of overloaded generic traits, in this case
SaturatedFrom
andSaturatedInto
. - A data structure that can be serialized into any data format supported by Serde.
- Re-export this since it’s part of the API of this crate. Provide a simple 4 byte identifier for a type.
Functions
- Print something that implements
Printable
from the runtime. - Verify a signature on an encoded value in a lazy manner. This can be an optimization if the signature scheme has an “unsigned” escape hash.
Type Aliases
- The result of applying of an extrinsic.
- Same as
ApplyExtrinsicResult
but augmented withPostDispatchInfo
on success. - Consensus engine unique ID.
- This type specifies the outcome of dispatching a call to a module.
- This is the legacy return type of
Dispatchable
. It is still exposed for compatibility reasons. The new return type isDispatchResultWithInfo
. FRAME runtimes should useframe_support::dispatch::DispatchResult
. - Return type of a
Dispatchable
which contains theDispatchResult
and additional information about theDispatchable
that is only known post dispatch. - The encoded justification specific to a consensus engine.
- Re-export top-level arithmetic stuff. Get the inner type of a
PerThing
. - An abstraction over justification for a block’s validity under a consensus algorithm.
- The error type used as return type in try runtime hooks.
- Re-export top-level arithmetic stuff. Get the upper type of a
PerThing
.
Derive Macros
- Re-export
RuntimeDebug
, to avoid dependency clutter.