Documentation ¶
Index ¶
- Constants
- func DecodeEvent(moduleIndex sc.U8, buffer *bytes.Buffer) (types.Event, error)
- func EnsureRoot(origin primitives.RuntimeOrigin) error
- func EnsureSigned(origin primitives.RawOrigin) (sc.Option[primitives.AccountId], error)
- func EnsureSignedOrRoot(origin primitives.RawOrigin) (sc.Option[primitives.AccountId], error)
- func MaxWithNormalRatio(max sc.U32, normal types.Perbill) (types.BlockLength, error)
- func NewDefaultOnSetCode(module Module) defaultOnSetCode
- func NewDispatchErrorCallFiltered(moduleId sc.U8) primitives.DispatchError
- func NewDispatchErrorFailedToExtractRuntimeVersion(moduleId sc.U8) primitives.DispatchError
- func NewDispatchErrorInvalidSpecName(moduleId sc.U8) primitives.DispatchError
- func NewDispatchErrorNonDefaultComposite(moduleId sc.U8) primitives.DispatchError
- func NewDispatchErrorNonZeroRefCount(moduleId sc.U8) primitives.DispatchError
- func NewDispatchErrorNothingAuthorized(moduleId sc.U8) primitives.DispatchError
- func NewDispatchErrorSpecVersionNeedsToIncrease(moduleId sc.U8) primitives.DispatchError
- func NewDispatchErrorUnauthorized(moduleId sc.U8) primitives.DispatchError
- func WithSensibleDefaults(expectedBlockWeight types.Weight, normalRatio types.Perbill) (types.BlockWeights, error)
- type BlockWeightsBuilder
- func (b *BlockWeightsBuilder) AvgBlockInitialization(initCost types.Perbill) *BlockWeightsBuilder
- func (b *BlockWeightsBuilder) BaseBlock(baseBlock types.Weight) *BlockWeightsBuilder
- func (b *BlockWeightsBuilder) Build() (types.BlockWeights, error)
- func (b *BlockWeightsBuilder) ForClass(classes []types.DispatchClass, action func(_ *types.WeightsPerClass)) (*BlockWeightsBuilder, error)
- type CodeUpgradeAuthorization
- type CodeUpgrader
- type Config
- type GenesisConfig
- type KeyValue
- type LogDepositor
- type Module
Constants ¶
const ( ErrorInvalidSpecName sc.U8 = iota ErrorSpecVersionNeedsToIncrease ErrorFailedToExtractRuntimeVersion ErrorNonDefaultComposite ErrorNonZeroRefCount ErrorCallFiltered ErrorNothingAuthorized )
System module errors.
const ( EventExtrinsicSuccess sc.U8 = iota EventExtrinsicFailed EventCodeUpdated EventNewAccount EventKilledAccount EventRemarked EventUpgradeAuthorized )
System module events.
Variables ¶
This section is empty.
Functions ¶
func EnsureRoot ¶
func EnsureRoot(origin primitives.RuntimeOrigin) error
EnsureRoot ensures that the origin represents the root.
func EnsureSigned ¶
func EnsureSigned(origin primitives.RawOrigin) (sc.Option[primitives.AccountId], error)
EnsureSigned ensures that the origin represents a signed extrinsic (i.e. transaction). Returns `Ok` with the account that signed the extrinsic or an `Err` otherwise.
func EnsureSignedOrRoot ¶
func EnsureSignedOrRoot(origin primitives.RawOrigin) (sc.Option[primitives.AccountId], error)
EnsureSignedOrRoot ensures the origin represents either a signed extrinsic or the root. Returns an empty Option if the origin is `Root`. Returns an Option with the signer if the origin is signed. Returns a `BadOrigin` error if neither of the above.
func MaxWithNormalRatio ¶
MaxWithNormalRatio Create new `BlockLength` with `max` for `Operational` & `Mandatory` and `normal * max` for `Normal`.
func NewDefaultOnSetCode ¶
func NewDefaultOnSetCode(module Module) defaultOnSetCode
func NewDispatchErrorCallFiltered ¶
func NewDispatchErrorCallFiltered(moduleId sc.U8) primitives.DispatchError
func NewDispatchErrorFailedToExtractRuntimeVersion ¶
func NewDispatchErrorFailedToExtractRuntimeVersion(moduleId sc.U8) primitives.DispatchError
func NewDispatchErrorInvalidSpecName ¶
func NewDispatchErrorInvalidSpecName(moduleId sc.U8) primitives.DispatchError
func NewDispatchErrorNonDefaultComposite ¶
func NewDispatchErrorNonDefaultComposite(moduleId sc.U8) primitives.DispatchError
func NewDispatchErrorNonZeroRefCount ¶
func NewDispatchErrorNonZeroRefCount(moduleId sc.U8) primitives.DispatchError
func NewDispatchErrorNothingAuthorized ¶
func NewDispatchErrorNothingAuthorized(moduleId sc.U8) primitives.DispatchError
func NewDispatchErrorSpecVersionNeedsToIncrease ¶
func NewDispatchErrorSpecVersionNeedsToIncrease(moduleId sc.U8) primitives.DispatchError
func NewDispatchErrorUnauthorized ¶
func NewDispatchErrorUnauthorized(moduleId sc.U8) primitives.DispatchError
func WithSensibleDefaults ¶
func WithSensibleDefaults(expectedBlockWeight types.Weight, normalRatio types.Perbill) (types.BlockWeights, error)
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`)
Types ¶
type BlockWeightsBuilder ¶
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() (types.BlockWeights, error)
Construct the `BlockWeights` object.
func (*BlockWeightsBuilder) ForClass ¶
func (b *BlockWeightsBuilder) ForClass(classes []types.DispatchClass, action func(_ *types.WeightsPerClass)) (*BlockWeightsBuilder, error)
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 CodeUpgradeAuthorization ¶
type CodeUpgradeAuthorization struct { // Hash of the new runtime binary. CodeHash primitives.H256 // Whether or not to carry out version checks. CheckVersion sc.Bool }
Information needed when a new runtime binary is submitted and needs to be authorized before replacing the current runtime.
func DecodeCodeUpgradeAuthorization ¶
func DecodeCodeUpgradeAuthorization(buffer *bytes.Buffer) (CodeUpgradeAuthorization, error)
func (CodeUpgradeAuthorization) Bytes ¶
func (c CodeUpgradeAuthorization) Bytes() []byte
type CodeUpgrader ¶
type Config ¶
type Config struct { BlockHashCount types.BlockHashCount BlockWeights types.BlockWeights BlockLength types.BlockLength DbWeight types.RuntimeDbWeight Version *types.RuntimeVersion MaxConsumers sc.U32 }
func NewConfig ¶
func NewConfig( blockHashCount types.BlockHashCount, blockWeights types.BlockWeights, blockLength types.BlockLength, dbWeight types.RuntimeDbWeight, version *types.RuntimeVersion, maxConsumers sc.U32, ) *Config
type GenesisConfig ¶
type GenesisConfig struct{}
type LogDepositor ¶
type LogDepositor interface {
DepositLog(item primitives.DigestItem)
}
type Module ¶
type Module interface { primitives.Module CodeUpgrader LogDepositor primitives.EventDepositor Initialize(blockNumber sc.U64, parentHash primitives.Blake2bHash, digest primitives.Digest) RegisterExtraWeightUnchecked(weight primitives.Weight, class primitives.DispatchClass) error NoteFinishedInitialize() NoteExtrinsic(encodedExt []byte) error NoteAppliedExtrinsic(postInfo primitives.PostDispatchInfo, postDispatchErr error, info primitives.DispatchInfo) error Finalize() (primitives.Header, error) NoteFinishedExtrinsics() error ResetEvents() Get(key primitives.AccountId) (primitives.AccountInfo, error) CanDecProviders(who primitives.AccountId) (bool, error) CanIncConsumer(who primitives.AccountId) (bool, error) DecConsumers(who primitives.AccountId) error IncConsumers(who primitives.AccountId) error IncConsumersWithoutLimit(who primitives.AccountId) error IncProviders(who primitives.AccountId) (primitives.IncRefStatus, error) TryMutateExists(who primitives.AccountId, f func(who *primitives.AccountData) (sc.Encodable, error)) (sc.Encodable, error) Metadata() primitives.MetadataModule BlockHashCount() types.BlockHashCount BlockLength() types.BlockLength BlockWeights() types.BlockWeights DbWeight() types.RuntimeDbWeight Version() types.RuntimeVersion StorageDigest() (types.Digest, error) StorageBlockWeight() (primitives.ConsumedWeight, error) StorageBlockWeightSet(weight primitives.ConsumedWeight) StorageBlockHash(key sc.U64) (types.Blake2bHash, error) StorageBlockHashSet(key sc.U64, value types.Blake2bHash) StorageBlockHashExists(key sc.U64) bool StorageBlockNumber() (sc.U64, error) StorageBlockNumberSet(sc.U64) StorageLastRuntimeUpgrade() (types.LastRuntimeUpgradeInfo, error) StorageLastRuntimeUpgradeSet(lrui types.LastRuntimeUpgradeInfo) StorageAccount(key types.AccountId) (types.AccountInfo, error) StorageAccountSet(key types.AccountId, value types.AccountInfo) StorageAllExtrinsicsLen() (sc.U32, error) StorageAllExtrinsicsLenSet(value sc.U32) StorageCodeSet(codeBlob sc.Sequence[sc.U8]) }
func New ¶
func New(index sc.U8, config *Config, mdGenerator *primitives.MetadataTypeGenerator, logger log.Logger) Module
Source Files ¶
- call_apply_authorized_upgrade.go
- call_apply_authorized_upgrade_weight.go
- call_authorize_upgrade.go
- call_authorize_upgrade_weight.go
- call_authorize_upgrade_without_checks.go
- call_authorize_upgrade_without_checks_weight.go
- call_kill_prefix.go
- call_kill_prefix_weight.go
- call_kill_storage.go
- call_kill_storage_weight.go
- call_remark.go
- call_remark_weight.go
- call_remark_with_event.go
- call_remark_with_event_weight.go
- call_set_code.go
- call_set_code_weight.go
- call_set_code_without_checks.go
- call_set_code_without_checks_weight.go
- call_set_heap_pages.go
- call_set_heap_pages_weight.go
- call_set_storage.go
- call_set_storage_weight.go
- config.go
- constants.go
- errors.go
- events.go
- genesis_builder.go
- limits.go
- module.go
- on_set_code.go
- storage.go
- types.go