types

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: LGPL-3.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const RandomnessLength = 32

RandomnessLength is the length of the epoch randomness (32 bytes)

Variables

View Source
var (
	ErrChainHeadMissingDigest = errors.New("chain head missing digest")
	ErrGenesisHeader          = errors.New("genesis header doesn't have a slot")
)
View Source
var BabeEngineID = ConsensusEngineID{'B', 'A', 'B', 'E'}

BabeEngineID is the hard-coded babe ID

View Source
var ErrNoFirstPreDigest = errors.New("first digest item is not pre-digest")
View Source
var GrandpaEngineID = ConsensusEngineID{'F', 'R', 'N', 'K'}

GrandpaEngineID is the hard-coded grandpa ID

Functions

func DecodeBabePreDigest added in v0.3.0

func DecodeBabePreDigest(in []byte) (any, error)

DecodeBabePreDigest decodes the input into a BabePreRuntimeDigest

func EncodeGrandpaVoters added in v0.7.0

func EncodeGrandpaVoters(voters GrandpaVoters) ([]byte, error)

EncodeGrandpaVoters returns an encoded GrandpaVoters

func ExtrinsicsArrayToBytesArray

func ExtrinsicsArrayToBytesArray(exts []Extrinsic) [][]byte

ExtrinsicsArrayToBytesArray converts an array of extrinsics into an array of byte arrays

func GetSlotFromHeader added in v0.3.0

func GetSlotFromHeader(header *Header) (uint64, error)

GetSlotFromHeader returns the BABE slot from the given header

func IsPrimary added in v0.7.0

func IsPrimary(header *Header) (bool, error)

IsPrimary returns true if the block was authored in a primary slot, false otherwise.

Types

type AccountData added in v0.7.0

type AccountData struct {
	Free       *scale.Uint128
	Reserved   *scale.Uint128
	MiscFrozen *scale.Uint128
	FreeFrozen *scale.Uint128
}

AccountData represents the data of the AccountInfo

type AccountInfo added in v0.3.0

type AccountInfo struct {
	// The number of transactions this account has sent.
	Nonce       uint32
	Consumers   uint32
	Producers   uint32
	Sufficients uint32
	// The additional data that belongs to this account. Used to store the balance(s) in a lot of chains.
	Data AccountData
}

AccountInfo Information of an account.

type AllowedSlots added in v0.7.0

type AllowedSlots byte

AllowedSlots tells in what ways a slot can be claimed.

const (
	// PrimarySlots only allows primary slots.
	PrimarySlots AllowedSlots = iota
	// PrimaryAndSecondaryPlainSlots allow primary and secondary plain slots.
	PrimaryAndSecondaryPlainSlots
	// PrimaryAndSecondaryVRFSlots allows primary and secondary VRF slots.
	PrimaryAndSecondaryVRFSlots
)

https://github.com/paritytech/substrate/blob/ded44948e2d5a398abcb4e342b0513cb690961bb/primitives/consensus/babe/src/lib.rs#L219-L226

type Authority added in v0.2.0

type Authority struct {
	Key crypto.PublicKey
	// Weight exists for potential improvements in the protocol and could
	// have a use-case in the future. In polkadot all authorities have the weight = 1.
	Weight uint64
}

Authority struct to hold authority data

func BABEAuthorityRawToAuthority added in v0.2.0

func BABEAuthorityRawToAuthority(adr []AuthorityRaw) ([]Authority, error)

BABEAuthorityRawToAuthority turns a slice of BABE AuthorityRaw into a slice of Authority

func GrandpaAuthoritiesRawToAuthorities added in v0.3.0

func GrandpaAuthoritiesRawToAuthorities(adr []GrandpaAuthoritiesRaw) ([]Authority, error)

GrandpaAuthoritiesRawToAuthorities turns a slice of GrandpaAuthoritiesRaw into a slice of Authority

func NewAuthority added in v0.2.0

func NewAuthority(pub crypto.PublicKey, weight uint64) *Authority

NewAuthority function to create Authority object

func (*Authority) Decode added in v0.3.0

func (a *Authority) Decode(r io.Reader) error

Decode sets the

func (*Authority) DecodeSr25519 added in v0.2.0

func (a *Authority) DecodeSr25519(r io.Reader) error

DecodeSr25519 sets the Authority to the SCALE decoded input for Authority containing SR25519 Keys.

func (*Authority) DeepCopy added in v0.7.0

func (a *Authority) DeepCopy() *Authority

DeepCopy creates a deep copy of the Authority

func (*Authority) Encode added in v0.2.0

func (a *Authority) Encode() ([]byte, error)

Encode returns the SCALE encoding of the BABEAuthorities.

func (*Authority) FromRawEd25519 added in v0.2.0

func (a *Authority) FromRawEd25519(raw GrandpaAuthoritiesRaw) error

FromRawEd25519 sets the Authority given GrandpaAuthoritiesRaw. It converts the byte representations of the authority public keys into a ed25519.PublicKey.

func (*Authority) FromRawSr25519 added in v0.2.0

func (a *Authority) FromRawSr25519(raw *AuthorityRaw) error

FromRawSr25519 sets the Authority given AuthorityRaw. It converts the byte representations of the authority public keys into a sr25519.PublicKey.

func (*Authority) ToRaw added in v0.2.0

func (a *Authority) ToRaw() *AuthorityRaw

ToRaw returns the BABEAuthorities as BABEAuthoritiesRaw. It encodes the authority public keys.

type AuthorityAsAddress added in v0.7.0

type AuthorityAsAddress struct {
	Address common.Address
	Weight  uint64
}

AuthorityAsAddress represents an Authority with their address instead of public key

func AuthoritiesRawToAuthorityAsAddress added in v0.7.0

func AuthoritiesRawToAuthorityAsAddress(authsRaw []AuthorityRaw, kt crypto.KeyType) ([]AuthorityAsAddress, error)

AuthoritiesRawToAuthorityAsAddress converts an array of AuthorityRaws into an array of AuthorityAsAddress

func (AuthorityAsAddress) MarshalJSON added in v0.8.0

func (a AuthorityAsAddress) MarshalJSON() ([]byte, error)

func (*AuthorityAsAddress) UnmarshalJSON added in v0.8.0

func (a *AuthorityAsAddress) UnmarshalJSON(buf []byte) error

UnmarshalJSON converts data to Go struct of type AuthorityAsAddress.

type AuthorityID added in v0.8.0

type AuthorityID [sr25519.PublicKeyLength]byte

AuthorityID represents a babe authority identifier.

type AuthorityRaw added in v0.2.0

type AuthorityRaw struct {
	Key    [sr25519.PublicKeyLength]byte
	Weight uint64
}

AuthorityRaw struct to hold raw authority data

func AuthoritiesToRaw added in v0.3.0

func AuthoritiesToRaw(auths []Authority) []AuthorityRaw

AuthoritiesToRaw converts an array of Authority in an array of AuthorityRaw

func (*AuthorityRaw) String added in v0.7.0

func (a *AuthorityRaw) String() string

type BABEOnDisabled added in v0.3.0

type BABEOnDisabled struct {
	ID uint32
}

BABEOnDisabled represents a GRANDPA authority being disabled

func (BABEOnDisabled) String added in v0.8.0

func (b BABEOnDisabled) String() string

type BabeConfiguration

type BabeConfiguration struct {
	SlotDuration       uint64 // milliseconds
	EpochLength        uint64 // duration of epoch in slots
	C1                 uint64 // (1-(c1/c2)) is the probability of a slot being empty
	C2                 uint64
	GenesisAuthorities []AuthorityRaw
	Randomness         [RandomnessLength]byte
	SecondarySlots     byte
}

BabeConfiguration contains the genesis data for BABE See https://github.com/paritytech/substrate/blob/426c26b8bddfcdbaf8d29f45b128e0864b57de1c/core/consensus/babe/primitives/src/lib.rs#L132

type BabeConsensusDigest added in v0.9.0

type BabeConsensusDigest struct {
	// contains filtered or unexported fields
}

func NewBabeConsensusDigest added in v0.7.0

func NewBabeConsensusDigest() BabeConsensusDigest

NewBabeConsensusDigest constructs a vdt representing a babe consensus digest

func (BabeConsensusDigest) IndexValue added in v0.9.0

func (mvdt BabeConsensusDigest) IndexValue() (index uint, value any, err error)

func (*BabeConsensusDigest) SetValue added in v0.9.0

func (mvdt *BabeConsensusDigest) SetValue(value any) (err error)

func (BabeConsensusDigest) Value added in v0.9.0

func (mvdt BabeConsensusDigest) Value() (value any, err error)

func (BabeConsensusDigest) ValueAt added in v0.9.0

func (mvdt BabeConsensusDigest) ValueAt(index uint) (value any, err error)

type BabeConsensusDigestValues added in v0.9.0

type BabeConsensusDigestValues interface {
	NextEpochData | BABEOnDisabled | VersionedNextConfigData
}

type BabeDigest added in v0.9.0

type BabeDigest struct {
	// contains filtered or unexported fields
}

func NewBabeDigest added in v0.7.0

func NewBabeDigest() BabeDigest

NewBabeDigest returns a new VaryingDataType to represent a BabeDigest

func (BabeDigest) IndexValue added in v0.9.0

func (mvdt BabeDigest) IndexValue() (index uint, value any, err error)

func (*BabeDigest) SetValue added in v0.9.0

func (mvdt *BabeDigest) SetValue(value any) (err error)

func (BabeDigest) Value added in v0.9.0

func (mvdt BabeDigest) Value() (value any, err error)

func (BabeDigest) ValueAt added in v0.9.0

func (mvdt BabeDigest) ValueAt(index uint) (value any, err error)

type BabeDigestValues added in v0.9.0

type BabeEquivocationProof added in v0.8.0

type BabeEquivocationProof struct {
	// Offender is the public key of the equivocator.
	Offender AuthorityID
	// Slot at which the equivocation happened.
	Slot uint64
	// FirstHeader is the first header involved in the equivocation.
	FirstHeader Header
	// SecondHeader is the second header involved in the equivocation.
	SecondHeader Header
}

BabeEquivocationProof represents a babe equivocation proof. An equivocation happens when a validator produces more than one block on the same slot. The proof of equivocation are the given distinct headers that were signed by the validator and which include the slot number.

type BabePrimaryPreDigest added in v0.3.0

type BabePrimaryPreDigest struct {
	AuthorityIndex uint32
	SlotNumber     uint64
	VRFOutput      [sr25519.VRFOutputLength]byte
	VRFProof       [sr25519.VRFProofLength]byte
}

BabePrimaryPreDigest as defined in Polkadot RE Spec, definition 5.10 in section 5.1.4

func NewBabePrimaryPreDigest added in v0.3.0

func NewBabePrimaryPreDigest(authorityIndex uint32,
	slotNumber uint64, vrfOutput [sr25519.VRFOutputLength]byte,
	vrfProof [sr25519.VRFProofLength]byte) *BabePrimaryPreDigest

NewBabePrimaryPreDigest returns a new BabePrimaryPreDigest

func (BabePrimaryPreDigest) String added in v0.8.0

func (d BabePrimaryPreDigest) String() string

func (BabePrimaryPreDigest) ToPreRuntimeDigest added in v0.3.1

func (d BabePrimaryPreDigest) ToPreRuntimeDigest() (*PreRuntimeDigest, error)

ToPreRuntimeDigest returns the BabePrimaryPreDigest as a PreRuntimeDigest

type BabeSecondaryPlainPreDigest added in v0.3.0

type BabeSecondaryPlainPreDigest struct {
	AuthorityIndex uint32
	SlotNumber     uint64
}

BabeSecondaryPlainPreDigest is included in a block built by a secondary slot authorized producer

func NewBabeSecondaryPlainPreDigest added in v0.3.0

func NewBabeSecondaryPlainPreDigest(authorityIndex uint32, slotNumber uint64) *BabeSecondaryPlainPreDigest

NewBabeSecondaryPlainPreDigest returns a new BabeSecondaryPlainPreDigest

func (BabeSecondaryPlainPreDigest) String added in v0.8.0

func (BabeSecondaryPlainPreDigest) ToPreRuntimeDigest added in v0.3.2

func (d BabeSecondaryPlainPreDigest) ToPreRuntimeDigest() (*PreRuntimeDigest, error)

ToPreRuntimeDigest returns the BabeSecondaryPlainPreDigest as a PreRuntimeDigest

type BabeSecondaryVRFPreDigest added in v0.3.0

type BabeSecondaryVRFPreDigest struct {
	AuthorityIndex uint32
	SlotNumber     uint64
	VrfOutput      [sr25519.VRFOutputLength]byte
	VrfProof       [sr25519.VRFProofLength]byte
}

BabeSecondaryVRFPreDigest is included in a block built by a secondary slot authorized producer

func NewBabeSecondaryVRFPreDigest added in v0.3.0

func NewBabeSecondaryVRFPreDigest(authorityIndex uint32,
	slotNumber uint64, vrfOutput [sr25519.VRFOutputLength]byte,
	vrfProof [sr25519.VRFProofLength]byte) *BabeSecondaryVRFPreDigest

NewBabeSecondaryVRFPreDigest returns a new NewBabeSecondaryVRFPreDigest

func (BabeSecondaryVRFPreDigest) String added in v0.8.0

func (d BabeSecondaryVRFPreDigest) String() string

func (BabeSecondaryVRFPreDigest) ToPreRuntimeDigest added in v0.7.0

func (d BabeSecondaryVRFPreDigest) ToPreRuntimeDigest() (*PreRuntimeDigest, error)

ToPreRuntimeDigest returns the BabeSecondaryVRFPreDigest as a PreRuntimeDigest

type Block

type Block struct {
	Header Header
	Body   Body
}

Block defines a state block

func NewBlock

func NewBlock(header Header, body Body) Block

NewBlock returns a new Block

func NewEmptyBlock

func NewEmptyBlock() Block

NewEmptyBlock returns a new empty Block

func (*Block) DeepCopy

func (b *Block) DeepCopy() (Block, error)

DeepCopy returns a copy of the block

func (*Block) Empty added in v0.7.0

func (b *Block) Empty() bool

Empty returns a boolean indicating is the Block is empty

func (*Block) Encode

func (b *Block) Encode() ([]byte, error)

Encode returns the SCALE encoding of a block

func (*Block) MustEncode added in v0.2.0

func (b *Block) MustEncode() []byte

MustEncode returns the SCALE encoded block and panics if it fails to encode

func (*Block) String added in v0.7.0

func (b *Block) String() string

String returns the formatted Block string

func (*Block) ToBlockData added in v0.7.0

func (b *Block) ToBlockData() *BlockData

ToBlockData converts a Block to BlockData

type BlockData

type BlockData struct {
	Hash          common.Hash
	Header        *Header
	Body          *Body
	Receipt       *[]byte
	MessageQueue  *[]byte
	Justification *[]byte
}

BlockData is stored within the BlockDB The BlockData fields are optionals and thus are represented as pointers to ensure correct encoding

func NewEmptyBlockData added in v0.7.0

func NewEmptyBlockData() *BlockData

NewEmptyBlockData Creates an empty blockData struct

func (*BlockData) Number added in v0.3.0

func (bd *BlockData) Number() uint

Number returns the block header number.

func (*BlockData) String added in v0.3.0

func (bd *BlockData) String() string

type Body

type Body []Extrinsic

Body is the extrinsics(not encoded) inside a state block.

func NewBody

func NewBody(e []Extrinsic) *Body

NewBody returns a Body from an Extrinsic array.

func NewBodyFromBytes added in v0.3.0

func NewBodyFromBytes(b []byte) (*Body, error)

NewBodyFromBytes returns a Body from a SCALE encoded byte array.

func NewBodyFromEncodedBytes added in v0.3.0

func NewBodyFromEncodedBytes(exts [][]byte) (*Body, error)

NewBodyFromEncodedBytes returns a new Body from a slice of byte slices that are SCALE encoded extrinsics

func NewBodyFromExtrinsicStrings

func NewBodyFromExtrinsicStrings(ss []string) (body *Body, err error)

NewBodyFromExtrinsicStrings creates a block body given an array of hex-encoded 0x-prefixed strings.

func (*Body) AsEncodedExtrinsics added in v0.3.0

func (b *Body) AsEncodedExtrinsics() ([]Extrinsic, error)

AsEncodedExtrinsics decodes the body into an array of SCALE encoded extrinsics

func (*Body) DeepCopy added in v0.7.0

func (b *Body) DeepCopy() Body

DeepCopy creates a new copy of the body.

func (*Body) HasExtrinsic added in v0.7.0

func (b *Body) HasExtrinsic(target Extrinsic) (bool, error)

HasExtrinsic returns true if body contains target Extrinsic

type ConfigData added in v0.3.0

type ConfigData struct {
	C1             uint64
	C2             uint64
	SecondarySlots byte
}

ConfigData represents a BABE configuration update

type ConsensusDigest

type ConsensusDigest digestItem

ConsensusDigest contains messages from the runtime to the consensus engine.

func (ConsensusDigest) String added in v0.3.0

func (d ConsensusDigest) String() string

String returns the digest as a string

type ConsensusEngineID

type ConsensusEngineID [4]byte

ConsensusEngineID is a 4-character identifier of the consensus engine that produced the digest.

func (ConsensusEngineID) String added in v0.7.0

func (h ConsensusEngineID) String() string

func (ConsensusEngineID) ToBytes

func (h ConsensusEngineID) ToBytes() []byte

ToBytes turns ConsensusEngineID to a byte array

type Digest added in v0.3.0

type Digest []DigestItem

Digest is slice of DigestItem

func NewDigest added in v0.7.0

func NewDigest() Digest

NewDigest returns a new Digest as a varying data type slice.

func (*Digest) Add added in v0.9.0

func (d *Digest) Add(values ...any) (err error)

func (*Digest) String added in v0.9.0

func (d *Digest) String() string

type DigestItem

type DigestItem struct {
	// contains filtered or unexported fields
}

func NewDigestItem added in v0.7.0

func NewDigestItem() DigestItem

NewDigestItem returns a new VaryingDataType to represent a DigestItem

func (DigestItem) IndexValue added in v0.9.0

func (mvdt DigestItem) IndexValue() (index uint, value any, err error)

func (*DigestItem) SetValue added in v0.9.0

func (mvdt *DigestItem) SetValue(value any) (err error)

func (DigestItem) String added in v0.3.0

func (mvdt DigestItem) String() string

func (DigestItem) Value added in v0.9.0

func (mvdt DigestItem) Value() (value any, err error)

func (DigestItem) ValueAt added in v0.9.0

func (mvdt DigestItem) ValueAt(index uint) (value any, err error)

type DigestItemValues added in v0.9.0

type DigestItemValues interface {
	PreRuntimeDigest | ConsensusDigest | SealDigest | RuntimeEnvironmentUpdated
}

type EpochData added in v0.3.0

type EpochData struct {
	Authorities []Authority
	Randomness  [RandomnessLength]byte
}

EpochData is the data provided for a BABE epoch

func (*EpochData) ToEpochDataRaw added in v0.3.0

func (d *EpochData) ToEpochDataRaw() *EpochDataRaw

ToEpochDataRaw returns the EpochData as an EpochDataRaw, converting the Authority to AuthorityRaw

type EpochDataRaw added in v0.3.0

type EpochDataRaw struct {
	Authorities []AuthorityRaw
	Randomness  [RandomnessLength]byte
}

EpochDataRaw is the data provided for an epoch, with Authority as AuthorityRaw

func (*EpochDataRaw) ToEpochData added in v0.3.0

func (d *EpochDataRaw) ToEpochData() (*EpochData, error)

ToEpochData returns the EpochDataRaw as EpochData

type Extrinsic

type Extrinsic []byte

Extrinsic is a generic transaction whose format is verified in the runtime

func BytesArrayToExtrinsics

func BytesArrayToExtrinsics(b [][]byte) []Extrinsic

BytesArrayToExtrinsics converts an array of byte arrays into an array of extrinsics

func NewExtrinsic

func NewExtrinsic(e []byte) Extrinsic

NewExtrinsic creates a new Extrinsic given a byte slice

func (Extrinsic) Hash

func (e Extrinsic) Hash() common.Hash

Hash returns the blake2b hash of the extrinsic

func (Extrinsic) String added in v0.7.0

func (e Extrinsic) String() string

type FeeDetails added in v0.7.0

type FeeDetails struct {
	InclusionFee InclusionFee
	Tip          *scale.Uint128
}

FeeDetails composed of InclusionFee and Tip

type FinalisationInfo added in v0.7.0

type FinalisationInfo struct {
	Header Header
	Round  uint64
	SetID  uint64
}

FinalisationInfo represents information about what block was finalised in what round and setID

type GrandpaAuthoritiesRaw added in v0.3.0

type GrandpaAuthoritiesRaw struct {
	Key [ed25519.PublicKeyLength]byte
	ID  uint64
}

GrandpaAuthoritiesRaw represents a GRANDPA authority where their key is a byte array

func (GrandpaAuthoritiesRaw) String added in v0.8.0

func (g GrandpaAuthoritiesRaw) String() string

type GrandpaConsensusDigest added in v0.9.0

type GrandpaConsensusDigest struct {
	// contains filtered or unexported fields
}

func NewGrandpaConsensusDigest added in v0.7.0

func NewGrandpaConsensusDigest() GrandpaConsensusDigest

NewGrandpaConsensusDigest constructs a vdt representing a grandpa consensus digest

func (GrandpaConsensusDigest) IndexValue added in v0.9.0

func (mvdt GrandpaConsensusDigest) IndexValue() (index uint, value any, err error)

func (*GrandpaConsensusDigest) SetValue added in v0.9.0

func (mvdt *GrandpaConsensusDigest) SetValue(value any) (err error)

func (GrandpaConsensusDigest) Value added in v0.9.0

func (mvdt GrandpaConsensusDigest) Value() (value any, err error)

func (GrandpaConsensusDigest) ValueAt added in v0.9.0

func (mvdt GrandpaConsensusDigest) ValueAt(index uint) (value any, err error)

type GrandpaConsensusDigestValues added in v0.9.0

type GrandpaConsensusDigestValues interface {
	GrandpaScheduledChange | GrandpaForcedChange | GrandpaOnDisabled | GrandpaPause | GrandpaResume
}

type GrandpaEquivocation added in v0.8.0

type GrandpaEquivocation struct {
	RoundNumber     uint64
	ID              [32]byte
	FirstVote       GrandpaVote
	FirstSignature  [64]byte
	SecondVote      GrandpaVote
	SecondSignature [64]byte
}

GrandpaEquivocation is used to create a proof of equivocation https://github.com/paritytech/finality-grandpa/blob/19d251d0b0105d51a79d3c4532a9aae75a5035bd/src/lib.rs#L213 //nolint:lll

type GrandpaEquivocationEnum added in v0.8.0

type GrandpaEquivocationEnum struct {
	// contains filtered or unexported fields
}

GrandpaEquivocationEnum is a wrapper object for GRANDPA equivocation proofs, useful for unifying prevote and precommit equivocations under a common type. https://github.com/paritytech/substrate/blob/fb22096d2ec6bf38e67ce811ad2c31415237a9a5/primitives/finality-grandpa/src/lib.rs#L272 //nolint:lll

func NewGrandpaEquivocation added in v0.8.0

func NewGrandpaEquivocation() *GrandpaEquivocationEnum

NewGrandpaEquivocation returns a new VaryingDataType to represent a grandpa Equivocation

func (GrandpaEquivocationEnum) IndexValue added in v0.9.0

func (mvdt GrandpaEquivocationEnum) IndexValue() (index uint, value any, err error)

func (*GrandpaEquivocationEnum) SetValue added in v0.9.0

func (mvdt *GrandpaEquivocationEnum) SetValue(value any) (err error)

func (GrandpaEquivocationEnum) Value added in v0.8.0

func (mvdt GrandpaEquivocationEnum) Value() (value any, err error)

func (GrandpaEquivocationEnum) ValueAt added in v0.9.0

func (mvdt GrandpaEquivocationEnum) ValueAt(index uint) (value any, err error)

type GrandpaEquivocationEnumValues added in v0.9.0

type GrandpaEquivocationEnumValues interface {
	PreVote | PreCommit
}

type GrandpaEquivocationProof added in v0.8.0

type GrandpaEquivocationProof struct {
	SetID        uint64
	Equivocation GrandpaEquivocationEnum
}

GrandpaEquivocationProof is used to report grandpa equivocations https://github.com/paritytech/substrate/blob/fb22096d2ec6bf38e67ce811ad2c31415237a9a5/primitives/finality-grandpa/src/lib.rs#L238 //nolint:lll

type GrandpaForcedChange added in v0.2.0

type GrandpaForcedChange struct {
	// BestFinalizedBlock is specified by the governance mechanism, defines
	// the starting block at which Delay is applied.
	// https://github.com/w3f/polkadot-spec/pull/506#issuecomment-1128849492
	BestFinalizedBlock uint32
	Auths              []GrandpaAuthoritiesRaw
	Delay              uint32
}

GrandpaForcedChange represents a GRANDPA forced authority change

func (GrandpaForcedChange) String added in v0.8.0

func (g GrandpaForcedChange) String() string

type GrandpaOnDisabled added in v0.3.0

type GrandpaOnDisabled struct {
	ID uint64
}

GrandpaOnDisabled represents a GRANDPA authority being disabled

func (GrandpaOnDisabled) String added in v0.8.0

func (g GrandpaOnDisabled) String() string

type GrandpaOpaqueKeyOwnershipProof added in v0.8.0

type GrandpaOpaqueKeyOwnershipProof []byte

GrandpaOpaqueKeyOwnershipProof contains a key ownership proof for reporting equivocations https://github.com/paritytech/substrate/blob/fb22096d2ec6bf38e67ce811ad2c31415237a9a5/primitives/finality-grandpa/src/lib.rs#L533 //nolint:lll

type GrandpaPause added in v0.3.0

type GrandpaPause struct {
	Delay uint32
}

GrandpaPause represents an authority set pause

func (GrandpaPause) String added in v0.8.0

func (g GrandpaPause) String() string

type GrandpaResume added in v0.3.0

type GrandpaResume struct {
	Delay uint32
}

GrandpaResume represents an authority set resume

func (GrandpaResume) String added in v0.8.0

func (g GrandpaResume) String() string

type GrandpaScheduledChange added in v0.2.0

type GrandpaScheduledChange struct {
	Auths []GrandpaAuthoritiesRaw
	Delay uint32
}

GrandpaScheduledChange represents a GRANDPA scheduled authority change

func (GrandpaScheduledChange) String added in v0.8.0

func (g GrandpaScheduledChange) String() string

type GrandpaSignedVote added in v0.7.0

type GrandpaSignedVote struct {
	Vote        GrandpaVote
	Signature   [64]byte
	AuthorityID ed25519.PublicKeyBytes
}

GrandpaSignedVote represents a signed precommit message for a finalised block

func (*GrandpaSignedVote) String added in v0.7.0

func (s *GrandpaSignedVote) String() string

type GrandpaVote added in v0.7.0

type GrandpaVote struct {
	Hash   common.Hash
	Number uint32
}

GrandpaVote represents a vote for a block with the given hash and number

func (GrandpaVote) String added in v0.7.0

func (v GrandpaVote) String() string

type GrandpaVoter added in v0.7.0

type GrandpaVoter struct {
	Key ed25519.PublicKey
	ID  uint64
}

GrandpaVoter represents a GRANDPA voter

func NewGrandpaVotersFromAuthorities added in v0.7.0

func NewGrandpaVotersFromAuthorities(ad []Authority) []GrandpaVoter

NewGrandpaVotersFromAuthorities returns an array of GrandpaVoters given an array of GrandpaAuthorities

func NewGrandpaVotersFromAuthoritiesRaw added in v0.7.0

func NewGrandpaVotersFromAuthoritiesRaw(ad []GrandpaAuthoritiesRaw) ([]GrandpaVoter, error)

NewGrandpaVotersFromAuthoritiesRaw returns an array of GrandpaVoters given an array of GrandpaAuthoritiesRaw

func (*GrandpaVoter) PublicKeyBytes added in v0.7.0

func (gv *GrandpaVoter) PublicKeyBytes() ed25519.PublicKeyBytes

PublicKeyBytes returns the voter key as PublicKeyBytes

func (*GrandpaVoter) String added in v0.7.0

func (gv *GrandpaVoter) String() string

String returns a formatted GrandpaVoter string

type GrandpaVoters added in v0.7.0

type GrandpaVoters []GrandpaVoter

GrandpaVoters represents []GrandpaVoter

func DecodeGrandpaVoters added in v0.7.0

func DecodeGrandpaVoters(in []byte) (GrandpaVoters, error)

DecodeGrandpaVoters returns a decoded GrandpaVoters

func (GrandpaVoters) String added in v0.7.0

func (v GrandpaVoters) String() string

String returns a formatted Voters string

type Header struct {
	ParentHash     common.Hash `json:"parentHash"`
	Number         uint        `json:"number"`
	StateRoot      common.Hash `json:"stateRoot"`
	ExtrinsicsRoot common.Hash `json:"extrinsicsRoot"`
	Digest         Digest      `json:"digest"`
	// contains filtered or unexported fields
}

Header is a state block header

func NewEmptyHeader added in v0.3.0

func NewEmptyHeader() *Header

NewEmptyHeader returns a new header with all zero values

func NewHeader

func NewHeader(parentHash, stateRoot, extrinsicsRoot common.Hash,
	number uint, digest Digest) (blockHeader *Header)

NewHeader creates a new block header and sets its hash field

func (*Header) DeepCopy

func (bh *Header) DeepCopy() (*Header, error)

DeepCopy returns a deep copy of the header to prevent side effects down the road

func (*Header) Empty added in v0.7.0

func (bh *Header) Empty() bool

Empty returns a boolean indicating is the header is empty

func (*Header) Exists added in v0.7.0

func (bh *Header) Exists() bool

Exists returns a boolean indicating if the header exists

func (*Header) Hash

func (bh *Header) Hash() common.Hash

Hash returns the hash of the block header If the internal hash field is nil, it hashes the block and sets the hash field. If hashing the header errors, this will panic.

func (*Header) String

func (bh *Header) String() string

String returns the formatted header as a string

type InclusionFee added in v0.7.0

type InclusionFee struct {
	BaseFee           *scale.Uint128
	LenFee            *scale.Uint128
	AdjustedWeightFee *scale.Uint128
}

InclusionFee represent base fee and adjusted weight and length fees

type InherentData added in v0.7.0

type InherentData struct {
	Data map[[8]byte][]byte
}

InherentData contains a mapping of inherent keys to values keys must be 8 bytes, values are a scale-encoded byte array

func NewInherentData added in v0.7.0

func NewInherentData() *InherentData

NewInherentData returns InherentData

func (*InherentData) Encode added in v0.7.0

func (d *InherentData) Encode() ([]byte, error)

Encode will encode a given []byte using scale.Encode

func (*InherentData) SetInherent added in v0.7.0

func (d *InherentData) SetInherent(inherentIdentifier InherentIdentifier, value any) error

SetInherent sets a inherent.

func (*InherentData) String added in v0.7.0

func (d *InherentData) String() string

type InherentIdentifier added in v0.7.0

type InherentIdentifier uint

InherentIdentifier is an identifier for an inherent.

const (
	// Timstap0 is the identifier for the `timestamp` inherent.
	Timstap0 InherentIdentifier = iota
	// Babeslot is the BABE inherent identifier.
	Babeslot
	// Uncles00 is the identifier for the `uncles` inherent.
	Uncles00
	// Parachn0 is an inherent key for parachains inherent.
	Parachn0
	// Newheads is an inherent key for new minimally-attested parachain heads.
	Newheads
)

func (InherentIdentifier) Bytes added in v0.7.0

func (ii InherentIdentifier) Bytes() [8]byte

Bytes returns a byte array of given inherent identifier.

type NextConfigDataV1 added in v0.8.0

type NextConfigDataV1 struct {
	C1             uint64
	C2             uint64
	SecondarySlots byte
}

NextConfigDataV1 is the digest that contains changes to the BABE configuration. It is potentially included in the first block of an epoch to describe the next epoch.

func (NextConfigDataV1) String added in v0.8.0

func (d NextConfigDataV1) String() string

func (*NextConfigDataV1) ToConfigData added in v0.8.0

func (d *NextConfigDataV1) ToConfigData() *ConfigData

ToConfigData returns the NextConfigData as ConfigData

type NextEpochData added in v0.3.0

type NextEpochData struct {
	Authorities []AuthorityRaw
	Randomness  [RandomnessLength]byte
}

NextEpochData is the digest that contains the data for the upcoming BABE epoch. It is included in the first block of every epoch to describe the next epoch.

func (NextEpochData) String added in v0.7.0

func (d NextEpochData) String() string

func (*NextEpochData) ToEpochDataRaw added in v0.8.0

func (d *NextEpochData) ToEpochDataRaw() *EpochDataRaw

ToEpochData returns the NextEpochData as EpochData

type OpaqueKeyOwnershipProof added in v0.8.0

type OpaqueKeyOwnershipProof []byte

OpaqueKeyOwnershipProof is an opaque type used to represent the key ownership proof at the runtime API boundary. The inner value is an encoded representation of the actual key ownership proof which will be parameterized when defining the runtime. At the runtime API boundary this type is unknown and as such we keep this opaque representation, implementers of the runtime API will have to make sure that all usages of `OpaqueKeyOwnershipProof` refer to the same type.

type PreCommit added in v0.8.0

type PreCommit GrandpaEquivocation

PreCommit equivocation type for a precommit

type PreRuntimeDigest

type PreRuntimeDigest digestItem

PreRuntimeDigest contains messages from the consensus engine to the runtime.

func NewBABEPreRuntimeDigest added in v0.3.0

func NewBABEPreRuntimeDigest(data []byte) *PreRuntimeDigest

NewBABEPreRuntimeDigest returns a PreRuntimeDigest with the BABE consensus ID

func (PreRuntimeDigest) String added in v0.3.0

func (d PreRuntimeDigest) String() string

String returns the digest as a string

type PreVote added in v0.8.0

type PreVote GrandpaEquivocation

PreVote equivocation type for a prevote

type RuntimeDispatchInfo added in v0.7.0

type RuntimeDispatchInfo struct {
	Weight uint64
	// Class could be Normal (0), Operational (1), Mandatory (2)
	Class      int
	PartialFee *scale.Uint128
}

RuntimeDispatchInfo represents information related to a dispatchable's class, weight, and fee that can be queried from the runtime

type RuntimeEnvironmentUpdated added in v0.8.0

type RuntimeEnvironmentUpdated struct{}

RuntimeEnvironmentUpdated contains is an indicator for the light clients that the runtime environment is updated

func (RuntimeEnvironmentUpdated) String added in v0.8.0

String returns the digest as a string

type SealDigest

type SealDigest digestItem

SealDigest contains the seal or signature. This is only used by native code.

func (SealDigest) String added in v0.3.0

func (d SealDigest) String() string

String returns the digest as a string

type SystemInfo

type SystemInfo struct {
	SystemName    string
	SystemVersion string
}

SystemInfo struct to hold system related information

type TransactionSource added in v0.3.0

type TransactionSource uint8

TransactionSource represents source of Transaction

const (
	// TxnInBlock indicates transaction is already included in block.
	//
	// This means that we can't really tell where the transaction is coming from,
	// since it's already in the received block. Note that the custom validation logic
	// using either `Local` or `External` should most likely just allow `InBlock`
	// transactions as well.
	TxnInBlock TransactionSource = iota

	// TxnLocal indicates transaction is coming from a local source.
	//
	// This means that the transaction was produced internally by the node
	// (for instance an Off-Chain Worker, or an Off-Chain Call), as opposed
	// to being received over the network.
	TxnLocal

	// TxnExternal indicates transaction has been received externally.
	//
	// This means the transaction has been received from (usually) "untrusted" source,
	// for instance received over the network or RPC.
	TxnExternal
)

type VersionedNextConfigData added in v0.8.0

type VersionedNextConfigData struct {
	// contains filtered or unexported fields
}

func NewVersionedNextConfigData added in v0.8.0

func NewVersionedNextConfigData() VersionedNextConfigData

NewVersionedNextConfigData creates a new VersionedNextConfigData instance

func (VersionedNextConfigData) IndexValue added in v0.9.0

func (mvdt VersionedNextConfigData) IndexValue() (index uint, value any, err error)

func (*VersionedNextConfigData) SetValue added in v0.9.0

func (mvdt *VersionedNextConfigData) SetValue(value any) (err error)

func (VersionedNextConfigData) String added in v0.8.0

func (vncd VersionedNextConfigData) String() string

String returns the string representation for the current VDT value

func (VersionedNextConfigData) Value added in v0.8.0

func (mvdt VersionedNextConfigData) Value() (value any, err error)

func (VersionedNextConfigData) ValueAt added in v0.9.0

func (mvdt VersionedNextConfigData) ValueAt(index uint) (value any, err error)

type VersionedNextConfigDataValues added in v0.9.0

type VersionedNextConfigDataValues interface {
	NextConfigDataV1
}

VersionedNextConfigData represents the enum of next config data consensus digest messages

Jump to

Keyboard shortcuts

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