Struct frame_system::pallet::Pallet [−][src]
pub struct Pallet<T>(_);
Expand description
The pallet implementing the on-chain logic.
Implementations
A dispatch that will fill the block weight up to the given ratio.
Set the new runtime code.
O(C + S)
whereC
length ofcode
andS
complexity ofcan_set_code
- 1 storage write (codec
O(C)
). - 1 call to
can_set_code
:O(S)
(callssp_io::misc::runtime_version
which is expensive). - 1 event. The weight of this function is dependent on the runtime, but generally this is very expensive. We will treat this as a full block.
pub fn set_code_without_checks(
origin: OriginFor<T>,
code: Vec<u8>
) -> DispatchResultWithPostInfo
pub fn set_code_without_checks(
origin: OriginFor<T>,
code: Vec<u8>
) -> DispatchResultWithPostInfo
pub fn set_changes_trie_config(
origin: OriginFor<T>,
changes_trie_config: Option<ChangesTrieConfiguration>
) -> DispatchResultWithPostInfo
pub fn set_changes_trie_config(
origin: OriginFor<T>,
changes_trie_config: Option<ChangesTrieConfiguration>
) -> DispatchResultWithPostInfo
pub fn kill_prefix(
origin: OriginFor<T>,
prefix: Key,
_subkeys: u32
) -> DispatchResultWithPostInfo
pub fn kill_prefix(
origin: OriginFor<T>,
prefix: Key,
_subkeys: u32
) -> DispatchResultWithPostInfo
Kill all storage items with a key that starts with the given prefix.
NOTE: We rely on the Root origin to provide us the number of subkeys under the prefix we are removing to accurately calculate the weight of this function.
O(P)
whereP
amount of keys with prefixprefix
P
storage deletions.- Base Weight: 0.834 * P µs
- Writes: Number of subkeys + 1
pub fn account<KArg>(k: KArg) -> AccountInfo<T::Index, T::AccountData> where
KArg: EncodeLike<T::AccountId>,
pub fn account<KArg>(k: KArg) -> AccountInfo<T::Index, T::AccountData> where
KArg: EncodeLike<T::AccountId>,
The full account information for a particular account ID.
The current weight for the block.
Map of block numbers to block hashes.
Extrinsics data for the current block (maps an extrinsic’s index to its data).
The current block number being processed. Set by execute_block
.
The number of events in the Events<T>
list.
pub fn event_topics<KArg>(k: KArg) -> Vec<(T::BlockNumber, u32)> where
KArg: EncodeLike<T::Hash>,
pub fn event_topics<KArg>(k: KArg) -> Vec<(T::BlockNumber, u32)> where
KArg: EncodeLike<T::Hash>,
Mapping between a topic (represented by T::Hash) and a vector of indexes
of events in the <Events<T>>
list.
All topic vectors have deterministic storage locations depending on the topic. This allows light-clients to leverage the changes trie storage tracking mechanism and in case of changes fetch the list of events of interest.
The value has the type (T::BlockNumber, EventIndex)
because if we used only just
the EventIndex
then in case if the topic has the same contents on the next block
no notification will be triggered thus the event might be lost.
👎 Deprecated: Use inc_consumers
instead
Use inc_consumers
instead
Increment the reference counter on an account.
👎 Deprecated: Use dec_consumers
instead
Use dec_consumers
instead
Decrement the reference counter on an account. This MUST only be done once for every time
you called inc_consumers
on who
.
👎 Deprecated: Use consumers
instead
Use consumers
instead
The number of outstanding references for the account who
.
👎 Deprecated: Use !is_provider_required
instead
Use !is_provider_required
instead
True if the account has no outstanding references.
Increment the provider reference counter on an account.
Decrement the provider reference counter on an account.
This MUST only be done once for every time you called inc_providers
on who
.
Increment the self-sufficient reference counter on an account.
Decrement the sufficients reference counter on an account.
This MUST only be done once for every time you called inc_sufficients
on who
.
The number of outstanding provider references for the account who
.
The number of outstanding sufficient references for the account who
.
The number of outstanding provider and sufficient references for the account who
.
Increment the reference counter on an account.
The account who
’s providers
must be non-zero or this will return an error.
Decrement the reference counter on an account. This MUST only be done once for every time
you called inc_consumers
on who
.
The number of outstanding references for the account who
.
True if the account has some outstanding consumer references.
True if the account has no outstanding consumer references or more than one provider.
True if the account has at least one provider reference.
Deposits an event into this block’s event record.
Deposits an event into this block’s event record adding this event to the corresponding topic indexes.
This will update storage entries that correspond to the specified topics. It is expected that light-clients could subscribe to this topics.
Gets the index of extrinsic that is currently executing.
Gets extrinsics count.
Inform the system pallet of some additional weight that should be accounted for, in the current block.
NOTE: use with extra care; this function is made public only be used for certain pallets
that need it. A runtime that does not have dynamic calls should never need this and should
stick to static weights. A typical use case for this is inner calls or smart contract calls.
Furthermore, it only makes sense to use this when it is presumably cheap to provide the
argument weight
; In other words, if this function is to be used to account for some
unknown, user provided call’s weight, it would only make sense to use it if you are sure you
can rapidly compute the weight of the inner call.
Even more dangerous is to note that this function does NOT take any action, if the new sum of block weight is more than the block weight limit. This is what the unchecked.
Another potential use-case could be for the on_initialize
and on_finalize
hooks.
pub fn initialize(
number: &T::BlockNumber,
parent_hash: &T::Hash,
digest: &DigestOf<T>,
kind: InitKind
)
pub fn initialize(
number: &T::BlockNumber,
parent_hash: &T::Hash,
digest: &DigestOf<T>,
kind: InitKind
)
Start the execution of a particular block.
Remove temporary “environment” entries in storage, compute the storage root and return the resulting header for this block.
Get the basic externalities for this pallet, useful for tests.
Set the block number to something in particular. Can be used as an alternative to
initialize
for tests that don’t need to bother with the other environment entries.
Sets the index of extrinsic that is currently executing.
Set the parent hash number to something in particular. Can be used as an alternative to
initialize
for tests that don’t need to bother with the other environment entries.
Set the current block weight. This should only be used in some integration tests.
Reset events. Can be used as an alternative to
initialize
for tests that don’t need to bother with the other environment entries.
Assert the given event
exists.
Assert the last event equal to the given event
.
Return the chain’s current runtime version.
Retrieve the account transaction counter from storage.
Increment a particular account’s nonce by 1.
Note what the extrinsic data of the current extrinsic index is.
This is required to be called before applying an extrinsic. The data will used
in Self::finalize
to calculate the correct extrinsics root.
To be called immediately after an extrinsic has been applied.
To be called immediately after note_applied_extrinsic
of the last extrinsic of the block
has been called.
To be called immediately after finishing the initialization of the block
(e.g., called on_initialize
for all pallets).
An account is being created.
Determine whether or not it is possible to update the code.
Checks the given code if it is a valid runtime wasm blob by instantianting it and extracting the runtime version of it. It checks that the runtime version of the old and new runtime has the same spec name and that the spec version is increasing.
Trait Implementations
type BlockNumber = <T as Config>::BlockNumber
type BlockNumber = <T as Config>::BlockNumber
Type of BlockNumber
to provide.
Returns the current block number. Read more
Returns the current storage version as supported by the pallet.
Returns the on-chain storage version of the pallet as stored in the storage.
Perform a module upgrade. Read more
Run integrity test. Read more
The block is being finalized. Implement to have something happen.
This will be run when the block is being finalized (before on_finalize
).
Implement to have something happen using the remaining weight.
Will not fire if the remaining weight is 0.
Return the weight used, the hook will subtract it from current weight used
and pass the result to the next on_idle
hook if it exists. Read more
The block is being initialized. Implement to have something happen. Read more
Execute some pre-checks prior to a runtime upgrade. Read more
Execute some post-checks after a runtime upgrade. Read more
Implementing this function on a module allows you to perform long-running tasks that make (by default) validators generate transactions that feed results of those long-running computations back on chain. Read more
Run integrity test. Read more
This function is being called after every block import (when fully synced). Read more
The block is being finalized. Implement to have something happen. Read more
Something that should happen at genesis.
The block is being finalized.
Implement to have something happen in case there is leftover weight.
Check the passed remaining_weight
to make sure it is high enough to allow for
your pallet’s extra computation. Read more
The block is being initialized. Implement to have something happen. Read more
Implement StoredMap for a simple single-item, provide-when-not-default system. This works fine for storing a single item which allows the account to continue existing as long as it’s not empty/default.
Anything more complex will need more sophisticated logic.
Get the item, or its default if it doesn’t yet exist; we make no distinction between the two. Read more
fn try_mutate_exists<R, E: From<DispatchError>>(
k: &T::AccountId,
f: impl FnOnce(&mut Option<T::AccountData>) -> Result<R, E>
) -> Result<R, E>
fn try_mutate_exists<R, E: From<DispatchError>>(
k: &T::AccountId,
f: impl FnOnce(&mut Option<T::AccountData>) -> Result<R, E>
) -> Result<R, E>
Maybe mutate the item only if an Ok
value is returned from f
. Do nothing if an Err
is
returned. It is removed or reset to default value if it has been mutated to None
Read more
Mutate the item, removing or resetting to default value if it has been mutated to None
. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for Pallet<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Pallet<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Generate a storage key unique to this runtime upgrade. Read more
Get temporary storage data written by Self::set_temp_storage
. Read more
Write some temporary data to a specific storage that can be read (potentially in
post-upgrade hook) via Self::get_temp_storage
. Read more
impl<T> PalletVersionToStorageVersionHelper for T where
T: GetStorageVersion + PalletInfoAccess,
impl<T> PalletVersionToStorageVersionHelper for T where
T: GetStorageVersion + PalletInfoAccess,
type Output = T
type Output = T
Should always be Self
The counterpart to unchecked_from
.
Consume self to return an equivalent value of T
.
pub fn vzip(self) -> V
impl<T> MaybeDebug for T where
T: Debug,
impl<T> MaybeDebug for T where
T: Debug,