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:

§Runtime API Types

This crate also contains some types that are often used in conjuncture with Runtime APIs. Most notable:

  • ApplyExtrinsicResult, and DispatchOutcome, 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§

biguint
Re-export big_uint stuff. Infinite precision unsigned integer for substrate runtime.
bounded_btree_map
Re-export bounded_vec and bounded_btree_map macros only when std is enabled. Traits, types and structs to support a bounded BTreeMap.
bounded_vec
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.
curve
Provides some utilities to define a piecewise linear function.
generic
Generic implementations of crate::traits::Header, crate::traits::Block and crate::traits::ExtrinsicLike.
helpers_128bit
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.
key_types
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.
legacy
Runtime types that existed in old API versions.
offchain
A collection of higher lever helpers for offchain calls.
proving_trie
Types for merkle tries compatible with the runtime.
runtime_logger
A logger that can be used to log from the runtime.
testing
Testing utilities.
traits
Primitives for the runtime modules.
transaction_validity
Transaction validity interface.
type_with_default
Provides a type that wraps another type and provides a default value.

Macros§

assert_eq_error_rate
Checks that $x is equal to $y with an error rate of $error.
assert_eq_error_rate_float
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.
bounded_btree_map
Re-export bounded_vec and bounded_btree_map macros only when std is enabled. Build a bounded btree-map from the given literals.
bounded_vec
Re-export bounded_vec and bounded_btree_map macros only when std is enabled. Build a bounded vec from the given literals.
count
Calls a given macro a number of times with a set of fixed params and an incrementing numeral. e.g.
create_runtime_strDeprecated
Deprecated Cow::Borrowed() wrapper.
impl_opaque_keys
Implement OpaqueKeys for a described struct.
impl_tx_ext_default
Helper macro to be used in a impl TransactionExtension block to add default implementations of weight, validate, prepare or any combinations of the them.
morph_types
Create a Morph and/or TryMorph impls with a simple closure-like expression.

Structs§

AccountId32
Re-export this since it’s part of the API of this crate. An opaque 32-byte cryptographic identifier.
AnySignature
Signature verify that can work with any known signature types..
BoundedBTreeMap
Re-export this since it’s part of the API of this crate. A bounded map based on a B-Tree.
BoundedBTreeSet
Re-export this since it’s part of the API of this crate. A bounded set based on a B-Tree.
BoundedSlice
Re-export this since it’s part of the API of this crate. A bounded slice.
BoundedVec
Re-export this since it’s part of the API of this crate. A bounded vector.
CryptoTypeId
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
DispatchErrorWithPostInfo
Result of a Dispatchable which contains the DispatchResult and additional information about the Dispatchable that is only known post dispatch.
FixedI64
Re-export top-level arithmetic stuff. A fixed point number representation in the range. Fixed Point 64 bits signed, range = [-9223372036.854775808, 9223372036.854775807]
FixedI128
Re-export top-level arithmetic stuff. A fixed point number representation in the range. Fixed Point 128 bits signed, range = [-170141183460469231731.687303715884105728, 170141183460469231731.687303715884105727]
FixedU64
Re-export top-level arithmetic stuff. A fixed point number representation in the range. Fixed Point 64 bits unsigned, range = [0.000000000, 18446744073.709551615]
FixedU128
Re-export top-level arithmetic stuff. A fixed point number representation in the range. Fixed Point 128 bits unsigned, range = [0.000000000000000000, 340282366920938463463.374607431768211455]
Justifications
Collection of justifications for a given block, multiple justifications may be provided by different consensus engines for the same block.
KeyTypeId
Re-export this since it’s part of the API of this crate. An identifier for a type of cryptographic key.
ModuleError
Reason why a pallet call failed.
OpaqueExtrinsic
Simple blob to hold an extrinsic without committing to its format and ensure it is serialized correctly.
OpaqueValue
Simple blob that hold a value in an encoded form without committing to its type.
PerU16
Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1].
Perbill
Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1].
Percent
Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1].
Permill
Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1].
Perquintill
Re-export top-level arithmetic stuff. A fixed point representation of a number in the range [0, 1].
Rational128
Re-export top-level arithmetic stuff. A wrapper for any rational number with a 128 bit numerator and denominator.
Storage
Struct containing data needed for a storage.
StorageChild
Child trie storage data.
WeakBoundedVec
Re-export this since it’s part of the API of this crate. A weakly bounded vector.
Weight
Re-export this since it’s part of the API of this crate.

Enums§

ArithmeticError
Re-export top-level arithmetic stuff. Arithmetic errors.
DispatchError
Reason why a dispatch call failed.
Either
The enum Either with variants Left and Right is a general purpose sum type with two cases.
ExtrinsicInclusionMode
Confines the kind of extrinsics that can be included in a block.
MultiAddress
A multi-format address wrapper for on-chain accounts.
MultiSignature
Signature verify that can work with any known signature types.
MultiSigner
Public key for any known crypto algorithm.
Rounding
Re-export top-level arithmetic stuff. The rounding method to use for unsigned quantities.
StateVersion
Different possible state version.
TokenError
Description of what went wrong when trying to complete an operation on a token.
TransactionOutcome
Describes on what should happen with a storage transaction.
TransactionalError
Errors related to transactional storage layers.

Constants§

MAX_MODULE_ERROR_ENCODED_SIZE
The number of bytes of the module-specific error field defined in ModuleError. In FRAME, this is the maximum encoded size of a pallet error type.

Traits§

BoundToRuntimeAppPublic
Something that is bound to a fixed RuntimeAppPublic.
BuildModuleGenesisStorageDeprecated
Something that can build the genesis storage of a module.
BuildStorage
Complex storage builder stuff.
CryptoType
Re-export this since it’s part of the API of this crate. Type which has a particular kind of crypto associated with it.
Deserialize
A data structure that can be deserialized from any data format supported by Serde.
DeserializeOwned
A data structure that can be deserialized without borrowing any data from the deserializer.
FixedPointNumber
Re-export top-level arithmetic stuff. Something that implements a decimal fixed point number.
FixedPointOperand
Re-export top-level arithmetic stuff. Integer types that can be used to interact with FixedPointNumber implementations.
PerThing
Re-export top-level arithmetic stuff. Something that implements a fixed point ration with an arbitrary granularity X, as parts per X.
RuntimeAppPublic
Runtime interface for an application’s public key.
SaturatedConversion
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 and SaturatedInto.
Serialize
A data structure that can be serialized into any data format supported by Serde.
TypeId
Re-export this since it’s part of the API of this crate. Provide a simple 4 byte identifier for a type.

Functions§

print
Print something that implements Printable from the runtime.
str_array
Utility function to declare string literals backed by an array of length N.
verify_encoded_lazy
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§

ApplyExtrinsicResult
The result of applying of an extrinsic.
ApplyExtrinsicResultWithInfo
Same as ApplyExtrinsicResult but augmented with PostDispatchInfo on success.
ConsensusEngineId
Consensus engine unique ID.
DispatchOutcome
This type specifies the outcome of dispatching a call to a module.
DispatchResult
This is the legacy return type of Dispatchable. It is still exposed for compatibility reasons. The new return type is DispatchResultWithInfo. FRAME runtimes should use frame_support::dispatch::DispatchResult.
DispatchResultWithInfo
Return type of a Dispatchable which contains the DispatchResult and additional information about the Dispatchable that is only known post dispatch.
EncodedJustification
The encoded justification specific to a consensus engine.
InnerOf
Re-export top-level arithmetic stuff. Get the inner type of a PerThing.
Justification
An abstraction over justification for a block’s validity under a consensus algorithm.
RuntimeStringDeprecated
Deprecated alias to improve upgrade experience
TryRuntimeError
The error type used as return type in try runtime hooks.
UpperOf
Re-export top-level arithmetic stuff. Get the upper type of a PerThing.

Derive Macros§

Deserialize
RuntimeDebug
Re-export RuntimeDebug, to avoid dependency clutter.
Serialize