system

package
v0.0.1-rc-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventExtrinsicSuccess sc.U8 = iota
	EventExtrinsicFailed
	EventCodeUpdated
	EventNewAccount
	EventKilledAccount
	EventRemarked
)

System module events.

Variables

This section is empty.

Functions

func AccountTryMutateExists

func AccountTryMutateExists(who types.Address32, f func(who *types.AccountInfo) sc.Result[sc.Encodable]) sc.Result[sc.Encodable]

func CanDecProviders

func CanDecProviders(who types.Address32) bool

func DecodeEvent

func DecodeEvent(buffer *bytes.Buffer) types.Event

func DepositEvent

func DepositEvent(event types.Event)

DepositEvent deposits an event into block's event record.

func Finalize

func Finalize() types.Header

func Initialize

func Initialize(blockNumber types.BlockNumber, parentHash types.Blake2bHash, digest types.Digest)

func Mutate

func Mutate(who types.Address32, f func(who *types.AccountInfo) sc.Result[sc.Encodable]) sc.Result[sc.Encodable]

func NewEventCodeUpdated

func NewEventCodeUpdated() types.Event

func NewEventExtrinsicFailed

func NewEventExtrinsicFailed(dispatchError types.DispatchError, dispatchInfo types.DispatchInfo) types.Event

func NewEventExtrinsicSuccess

func NewEventExtrinsicSuccess(dispatchInfo types.DispatchInfo) types.Event

func NewEventKilledAccount

func NewEventKilledAccount(account types.PublicKey) types.Event

func NewEventNewAccount

func NewEventNewAccount(account types.PublicKey) types.Event

func NewEventRemarked

func NewEventRemarked(sender types.PublicKey, hash types.H256) types.Event

func NoteAppliedExtrinsic

NoteAppliedExtrinsic - To be called immediately after an extrinsic has been applied.

Emits an `ExtrinsicSuccess` or `ExtrinsicFailed` event depending on the outcome. The emitted event contains the post-dispatch corrected weight including the base-weight for its dispatch class.

func NoteExtrinsic

func NoteExtrinsic(encodedExt []byte)

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 [`finalize`] to calculate the correct extrinsics root.

func NoteFinishedExtrinsics

func NoteFinishedExtrinsics()

func NoteFinishedInitialize

func NoteFinishedInitialize()

func RegisterExtraWeightUnchecked

func RegisterExtraWeightUnchecked(weight types.Weight, class types.DispatchClass)

RegisterExtraWeightUnchecked - 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.

func ResetEvents

func ResetEvents()

func StorageClearAllExtrinsicsLength

func StorageClearAllExtrinsicsLength()

func StorageClearBlockWeight

func StorageClearBlockWeight()

func StorageClearEventCount

func StorageClearEventCount()

func StorageClearEventTopics

func StorageClearEventTopics(limit sc.U32)

func StorageClearEvents

func StorageClearEvents()

func StorageClearExecutionPhase

func StorageClearExecutionPhase()

func StorageExecutionPhase

func StorageExecutionPhase() types.ExtrinsicPhase

func StorageExistsBlockHash

func StorageExistsBlockHash(blockNumber sc.U32) sc.Bool

Map of block numbers to block hashes.

func StorageGetAccount

func StorageGetAccount(who types.PublicKey) types.AccountInfo

func StorageGetAllExtrinsicsLen

func StorageGetAllExtrinsicsLen() sc.U32

StorageGetAllExtrinsicsLen returns the total length (in bytes) for all extrinsics put together, for the current block.

func StorageGetBlockHash

func StorageGetBlockHash(blockNumber sc.U32) types.Blake2bHash

Map of block numbers to block hashes.

func StorageGetBlockNumber

func StorageGetBlockNumber() types.BlockNumber

StorageGetBlockNumber returns the current block number being processed. Set by `execute_block`.

func StorageGetBlockWeight

func StorageGetBlockWeight() types.ConsumedWeight

block weight

func StorageGetDigest

func StorageGetDigest() types.Digest

func StorageGetExtrinsicCount

func StorageGetExtrinsicCount(clear sc.Bool) sc.U32

func StorageGetExtrinsicIndex

func StorageGetExtrinsicIndex(clear sc.Bool) sc.U32

StorageGetExtrinsicIndex returns the index of extrinsic that is currently executing.

func StorageGetParentHash

func StorageGetParentHash() types.Blake2bHash

func StorageSetAccount

func StorageSetAccount(who types.PublicKey, account types.AccountInfo)

func StorageSetAllExtrinsicsLen

func StorageSetAllExtrinsicsLen(length sc.U32)

func StorageSetBlockHash

func StorageSetBlockHash(blockNumber sc.U32, hash types.Blake2bHash)

func StorageSetBlockNumber

func StorageSetBlockNumber(number types.BlockNumber)

func StorageSetBlockWeight

func StorageSetBlockWeight(weight types.ConsumedWeight)

func StorageSetDigest

func StorageSetDigest(digest types.Digest)

func StorageSetExecutionPhase

func StorageSetExecutionPhase(phase types.ExtrinsicPhase)

func StorageSetExtrinsicCount

func StorageSetExtrinsicCount(extrinsicIndex sc.U32)

func StorageSetExtrinsicIndex

func StorageSetExtrinsicIndex(index sc.U32)

func StorageSetParentHash

func StorageSetParentHash(parentHash types.Blake2bHash)

func TryMutateExists

func TryMutateExists(who types.Address32, f func(who *types.AccountData) sc.Result[sc.Encodable]) sc.Result[sc.Encodable]

Types

type BlockLength

type BlockLength struct {
	//  Maximal total length in bytes for each extrinsic class.
	//
	// In the worst case, the total block length is going to be:
	// `MAX(max)`
	Max types.PerDispatchClass[sc.U32]
}

func DefaultBlockLength

func DefaultBlockLength() BlockLength

func MaxWithNormalRatio

func MaxWithNormalRatio(max sc.U32, normal types.Perbill) BlockLength

MaxWithNormalRatio Create new `BlockLength` with `max` for `Operational` & `Mandatory` and `normal * max` for `Normal`.

func (BlockLength) Bytes

func (bl BlockLength) Bytes() []byte

func (BlockLength) Encode

func (bl BlockLength) Encode(buffer *bytes.Buffer)

type BlockWeights

type BlockWeights struct {
	// Base weight of block execution.
	BaseBlock types.Weight
	// Maximal total weight consumed by all kinds of extrinsics (without `reserved` space).
	MaxBlock types.Weight
	// Weight limits for extrinsics of given dispatch class.
	PerClass types.PerDispatchClass[WeightsPerClass]
}

func DefaultBlockWeights

func DefaultBlockWeights() BlockWeights

func WithSensibleDefaults

func WithSensibleDefaults(expectedBlockWeight types.Weight, normalRatio types.Perbill) BlockWeights

WithSensibleDefaults Create a sensible default weights system given only expected maximal block weight and the ratio that `Normal` extrinsics should occupy.

Assumptions:

  • Average block initialization is assumed to be `10%`.
  • `Operational` transactions have reserved allowance (`1.0 - normal_ratio`)

func (BlockWeights) Bytes

func (bw BlockWeights) Bytes() []byte

func (BlockWeights) Encode

func (bw BlockWeights) Encode(buffer *bytes.Buffer)

func (BlockWeights) Get

Get per-class weight settings.

type BlockWeightsBuilder

type BlockWeightsBuilder struct {
	Weights  BlockWeights
	InitCost sc.Option[types.Perbill]
}

An opinionated builder for `Weights` object.

func NewBlockWeightsBuilder

func NewBlockWeightsBuilder() *BlockWeightsBuilder

Start constructing new `BlockWeights` object.

By default all kinds except of `Mandatory` extrinsics are disallowed.

func (*BlockWeightsBuilder) AvgBlockInitialization

func (b *BlockWeightsBuilder) AvgBlockInitialization(initCost types.Perbill) *BlockWeightsBuilder

AvgBlockInitialization Average block initial ization weight cost.

This value is used to derive maximal allowed extrinsic weight for each class, based on the allowance.

This is to make sure that extrinsics don't stay forever in the pool, because they could seamingly fit the block (since they are below `max_block`), but the cost of calling `on_initialize` always prevents them from being included.

func (*BlockWeightsBuilder) BaseBlock

func (b *BlockWeightsBuilder) BaseBlock(baseBlock types.Weight) *BlockWeightsBuilder

Set base block weight.

func (*BlockWeightsBuilder) Build

func (b *BlockWeightsBuilder) Build() BlockWeights

Construct the `BlockWeights` object.

func (*BlockWeightsBuilder) ForClass

func (b *BlockWeightsBuilder) ForClass(classes []types.DispatchClass, action func(_ *WeightsPerClass)) *BlockWeightsBuilder

ForClass Set parameters for particular class.

Note: `None` values of `max_extrinsic` will be overwritten in `build` in case `avg_block_initialization` rate is set to a non-zero value.

type WeightsPerClass

type WeightsPerClass struct {
	// Base weight of single extrinsic of given class.
	BaseExtrinsic types.Weight

	// Maximal weight of single extrinsic. Should NOT include `base_extrinsic` cost.
	//
	// `None` indicates that this class of extrinsics doesn't have a limit.
	MaxExtrinsic sc.Option[types.Weight]

	// Block maximal total weight for all extrinsics of given class.
	//
	// `None` indicates that weight sum of this class of extrinsics is not
	// restricted. Use this value carefully, since it might produce heavily oversized
	// blocks.
	//
	// In the worst case, the total weight consumed by the class is going to be:
	// `MAX(max_total) + MAX(reserved)`.
	MaxTotal sc.Option[types.Weight]

	// Block reserved allowance for all extrinsics of a particular class.
	//
	// Setting to `None` indicates that extrinsics of that class are allowed
	// to go over total block weight (but at most `max_total` for that class).
	// Setting to `Some(x)` guarantees that at least `x` weight of particular class
	// is processed in every block.
	Reserved sc.Option[types.Weight]
}

WeightsPerClass `DispatchClass`-specific weight configuration.

func DecodeWeightsPerClass

func DecodeWeightsPerClass(buffer *bytes.Buffer) WeightsPerClass

func (WeightsPerClass) Bytes

func (cl WeightsPerClass) Bytes() []byte

func (WeightsPerClass) Encode

func (cl WeightsPerClass) Encode(buffer *bytes.Buffer)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL