Expand description
frame_system’s parent crate, which is mandatory in all pallets build with this crate.
Conveniently, the keyword frame_system is in scope as one uses use polkadot_sdk_frame::prelude::*.
§System Pallet
The System pallet provides low-level access to core types and cross-cutting utilities. It acts as the base layer for other pallets to interact with the Substrate framework components.
§Overview
The System pallet defines the core data types used in a Substrate runtime. It also provides
several utility functions (see Pallet) for other FRAME pallets.
In addition, it manages the storage items for extrinsic data, indices, event records, and digest items, among other things that support the execution of the current block.
It also handles low-level tasks like depositing logs, basic set up and take down of temporary storage entries, and access to previous block hashes.
§Interface
§Dispatchable Functions
The System pallet provides dispatchable functions that, with the exception of remark, manage
low-level or privileged functionality of a Substrate-based runtime.
remark: Make some on-chain remark.set_heap_pages: Set the number of pages in the WebAssembly environment’s heap.set_code: Set the new runtime code.set_code_without_checks: Set the new runtime code without any checks.set_storage: Set some items of storage.kill_storage: Kill some items from storage.kill_prefix: Kill all storage items with a key that starts with the given prefix.remark_with_event: Make some on-chain remark and emit an event.do_task: Do some specified task.authorize_upgrade: Authorize new runtime code.authorize_upgrade_without_checks: Authorize new runtime code and an upgrade sans verification.apply_authorized_upgrade: Provide new, already-authorized runtime code.
§A Note on Upgrades
The pallet provides two primary means of upgrading the runtime, a single-phase means using
set_code and a two-phase means using authorize_upgrade followed by
apply_authorized_upgrade. The first will directly attempt to apply the provided code
(application may have to be scheduled, depending on the context and implementation of the
OnSetCode trait).
The authorize_upgrade route allows the authorization of a runtime’s code hash. Once
authorized, anyone may upload the correct runtime to apply the code. This pattern is useful when
providing the runtime ahead of time may be unwieldy, for example when a large preimage (the
code) would need to be stored on-chain or sent over a message transport protocol such as a
bridge.
The *_without_checks variants do not perform any version checks, so using them runs the risk
of applying a downgrade or entirely other chain specification. They will still validate that the
code meets the authorized hash.
§Public Functions
See the Pallet struct for details of publicly available functions.
§Signed Extensions
The System pallet defines the following extensions:
CheckWeight: Checks the weight and length of the block and ensure that it does not exceed the limits.CheckNonce: Checks the nonce of the transaction. Contains a single payload of typeT::Nonce.CheckEra: Checks the era of the transaction. Contains a single payload of typeEra.CheckGenesis: Checks the provided genesis hash of the transaction. Must be a part of the signed payload of the transaction.CheckSpecVersion: Checks that the runtime version is the same as the one used to sign the transaction.CheckTxVersion: Checks that the transaction version is the same as the one used to sign the transaction.
Look up the runtime aggregator file (e.g. node/runtime) to see the full list of signed
extensions included in a chain.
Modules§
- limits
 - Block resource limits configuration structures.
 - migrations
 - Migrate the reference counting state.
 - mocking
 - Provide types to help defining a mock environment when testing pallets.
 - offchain
 - Module helpers for off-chain calls.
 - pallet
 - The 
palletmodule in each FRAME pallet hosts the most important items needed to construct this pallet. - pallet_
prelude  - Prelude to be used alongside pallet macro, for ease of use.
 - weights
 - Autogenerated weights for 
frame_system 
Structs§
- Account
Info  - Information of an account.
 - Authorize
Call  - A transaction extension that authorizes some calls (i.e. dispatchable functions) to be included in the block.
 - Chain
Context  - Check
Era  - Check for transaction mortality.
 - Check
Genesis  - Genesis hash check to provide replay protection between different networks.
 - Check
Mortality  - Check for transaction mortality.
 - Check
NonZero Sender  - Check to ensure that the sender is not the zero address.
 - Check
Nonce  - Nonce check and increment to give replay protection for transactions.
 - Check
Spec Version  - Ensure the runtime version registered in the transaction is the same as at present.
 - Check
TxVersion  - Ensure the transaction version registered in the transaction is the same as at present.
 - Check
Weight  - Block resource (weight) limit check.
 - Code
Upgrade Authorization  - Information needed when a new runtime binary is submitted and needs to be authorized before replacing the current runtime.
 - Consumer
 - Event handler which registers a consumer when created.
 - Dispatch
Event Info  - Information about the dispatch of a call, to be displayed in the
ExtrinsicSuccessandExtrinsicFailedevents. - Ensure
Never  - Always fail.
 - Ensure
None  - Ensure the origin is 
None. i.e. unsigned transaction. - Ensure
Root  - Ensure the origin is Root.
 - Ensure
Root With Success  - Ensure the origin is Root and return the provided 
Successvalue. - Ensure
Signed  - Ensure the origin is any 
Signedorigin. - Ensure
Signed By  - Ensure the origin is 
Signedorigin from the givenAccountId. - Ensure
With Success  - Ensure the origin is provided 
Ensureorigin and return the providedSuccessvalue. - Event
Record  - Record of an event happening.
 - Genesis
Config  - Can be used to configure the genesis state of this pallet.
 - Last
Runtime Upgrade Info  - Stores the 
spec_versionandspec_nameof when the last runtime upgrade happened. - Pallet
 - The 
Palletstruct, the main type that implements traits and standalone functions within the pallet. - Provider
 - Event handler which registers a provider when created.
 - RunTo
Block Hooks  - Hooks for the 
Pallet::run_to_block_withfunction. - Self
Sufficient  - Event handler which registers a self-sufficient when created.
 - Substrate
Extensions Weight  - Weights for 
frame_system_extensionsusing the Substrate node and recommended hardware. - Valid
Nonce Info  - For a valid transaction the provides and requires information related to the nonce.
 - Weight
Reclaim  - Reclaim the unused weight using the post dispatch information
 
Enums§
- Call
 - Contains a variant per dispatchable extrinsic that this pallet has.
 - CanSet
Code Result  - Result of 
Pallet::can_set_code. - DecRef
Status  - Some resultant status relevant to decrementing a provider/self-sufficient reference.
 - Error
 - Error for the System pallet
 - Event
 - Event for the System pallet.
 - IncRef
Status  - Some resultant status relevant to incrementing a provider/self-sufficient reference.
 - Phase
 - A phase of a block’s execution.
 - RawOrigin
 - Origin for the System pallet.
 - RefStatus
 - Reference status; can be either referenced or unreferenced.
 
Traits§
- Config
 - Configuration trait of this pallet.
 - Consumer
Limits  - Numeric limits over the ability to add a consumer ref using 
inc_consumers. - Default
Config  - Based on 
Config. Auto-generated by#[pallet::config(with_default)]. Can be used in tandem with#[register_default_config]and#[derive_impl]to derive test config traits based on existing pallet config traits in a safe and developer-friendly way. - Extensions
Weight Info  - Weight functions needed for 
frame_system_extensions. - SetCode
 - Do something when we should be setting the code.
 - Weight
Info  - Weight functions needed for 
frame_system. 
Functions§
- ensure_
authorized  - Ensure that the origin 
orepresents an extrinsic with authorized call. ReturnsOkor anErrotherwise. - ensure_
none  - Ensure that the origin 
orepresents an unsigned extrinsic. ReturnsOkor anErrotherwise. - ensure_
root  - Ensure that the origin 
orepresents the root. ReturnsOkor anErrotherwise. - ensure_
signed  - Ensure that the origin 
orepresents a signed extrinsic (i.e. transaction). ReturnsOkwith the account that signed the extrinsic or anErrotherwise. - ensure_
signed_ or_ root  - Ensure that the origin 
orepresents either a signed extrinsic (i.e. transaction) or the root. ReturnsOkwith the account that signed the extrinsic,Noneif it was root, or anErrotherwise. - extrinsics_
data_ root  - Compute the trie root of a list of extrinsics.
 - extrinsics_
root  - Compute the trie root of a list of extrinsics.
 - split_
inner  - Split an 
optioninto two constituent options, as defined by asplitterfunction. - unique
 - Returns a 32 byte datum which is guaranteed to be universally unique. 
entropyis provided as a facility to reduce the potential for precalculating results. 
Type Aliases§
- Account
 - The full account information for a particular account ID.
 - AllExtrinsics
Len  - Total length (in bytes) for all extrinsics put together, for the current block.
 - Block
Hash  - Map of block numbers to block hashes.
 - Block
Weight  - The current weight for the block.
 - Consumed
Weight  - An object to track the currently used extrinsic weight in a block.
 - Extrinsic
Weight Reclaimed  - The weight reclaimed for the extrinsic.
 - Inherents
Applied  - Whether all inherents have been applied.
 - Key
 - KeyValue
 - Last
Runtime Upgrade  - Stores the 
spec_versionandspec_nameof when the last runtime upgrade happened. - Module
Deprecated  - Type alias to 
Pallet, to be used byconstruct_runtime. - Origin
 - Exposed trait-generic origin type.
 - RefCount
 - Type used to encode the number of references an account has.