Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeBabePreDigest(in []byte) (scale.VaryingDataTypeValue, error)
- func EncodeGrandpaVoters(voters GrandpaVoters) ([]byte, error)
- func ExtrinsicsArrayToBytesArray(exts []Extrinsic) [][]byte
- func GetSlotFromHeader(header *Header) (uint64, error)
- func IsPrimary(header *Header) (bool, error)
- func NewBabeConsensusDigest() scale.VaryingDataType
- func NewBabeDigest() scale.VaryingDataType
- func NewDigest() scale.VaryingDataTypeSlice
- func NewDigestItem() scale.VaryingDataType
- func NewGrandpaConsensusDigest() scale.VaryingDataType
- type AccountData
- type AccountInfo
- type AllowedSlots
- type Authority
- func (a *Authority) Decode(r io.Reader) error
- func (a *Authority) DecodeSr25519(r io.Reader) error
- func (a *Authority) DeepCopy() *Authority
- func (a *Authority) Encode() ([]byte, error)
- func (a *Authority) FromRawEd25519(raw GrandpaAuthoritiesRaw) error
- func (a *Authority) FromRawSr25519(raw *AuthorityRaw) error
- func (a *Authority) ToRaw() *AuthorityRaw
- type AuthorityRaw
- type BABEOnDisabled
- type BabeConfiguration
- type BabePrimaryPreDigest
- type BabeSecondaryPlainPreDigest
- type BabeSecondaryVRFPreDigest
- type Block
- type BlockData
- type Body
- type ChangesTrieRootDigest
- type ConfigData
- type ConsensusDigest
- type ConsensusEngineID
- type EpochData
- type EpochDataRaw
- type Extrinsic
- type FinalisationInfo
- type GrandpaAuthoritiesRaw
- type GrandpaForcedChange
- type GrandpaOnDisabled
- type GrandpaPause
- type GrandpaResume
- type GrandpaScheduledChange
- type GrandpaSignedVote
- type GrandpaVote
- type GrandpaVoter
- type GrandpaVoters
- type Header
- type InherentsData
- type NextConfigData
- type NextEpochData
- type PreRuntimeDigest
- type SealDigest
- type SystemInfo
- type TransactionPaymentQueryInfo
- type TransactionSource
Constants ¶
const ( // NoNetworkRole runs a node without networking NoNetworkRole = byte(0) // FullNodeRole runs a full node FullNodeRole = byte(1) // LightClientRole runs a light client LightClientRole = byte(2) // AuthorityRole runs the node as a block-producing and finalising node AuthorityRole = byte(4) )
const RandomnessLength = 32
RandomnessLength is the length of the epoch randomness (32 bytes)
Variables ¶
var ( // Timstap0 is an inherent key. Timstap0 = []byte("timstap0") // Babeslot is an inherent key. Babeslot = []byte("babeslot") // Uncles00 is an inherent key. Uncles00 = []byte("uncles00") )
var BabeEngineID = ConsensusEngineID{'B', 'A', 'B', 'E'}
BabeEngineID is the hard-coded babe ID
var GrandpaEngineID = ConsensusEngineID{'F', 'R', 'N', 'K'}
GrandpaEngineID is the hard-coded grandpa ID
Functions ¶
func DecodeBabePreDigest ¶
func DecodeBabePreDigest(in []byte) (scale.VaryingDataTypeValue, error)
DecodeBabePreDigest decodes the input into a BabePreRuntimeDigest
func EncodeGrandpaVoters ¶
func EncodeGrandpaVoters(voters GrandpaVoters) ([]byte, error)
EncodeGrandpaVoters returns an encoded GrandpaVoters
func ExtrinsicsArrayToBytesArray ¶
ExtrinsicsArrayToBytesArray converts an array of extrinsics into an array of byte arrays
func GetSlotFromHeader ¶
GetSlotFromHeader returns the BABE slot from the given header
func IsPrimary ¶
IsPrimary returns true if the block was authored in a primary slot, false otherwise.
func NewBabeConsensusDigest ¶
func NewBabeConsensusDigest() scale.VaryingDataType
NewBabeConsensusDigest constructs a vdt representing a babe consensus digest
func NewBabeDigest ¶
func NewBabeDigest() scale.VaryingDataType
NewBabeDigest returns a new VaryingDataType to represent a BabeDigest
func NewDigest ¶
func NewDigest() scale.VaryingDataTypeSlice
NewDigest returns a new Digest from the given DigestItems
func NewDigestItem ¶
func NewDigestItem() scale.VaryingDataType
NewDigestItem returns a new VaryingDataType to represent a DigestItem
func NewGrandpaConsensusDigest ¶
func NewGrandpaConsensusDigest() scale.VaryingDataType
NewGrandpaConsensusDigest constructs a vdt representing a grandpa consensus digest
Types ¶
type AccountData ¶
type AccountData struct { Free *scale.Uint128 Reserved *scale.Uint128 MiscFrozen *scale.Uint128 FreeFrozen *scale.Uint128 }
AccountData represents the data of the AccountInfo
type AccountInfo ¶
type AccountInfo struct { // The number of transactions this account has sent. Nonce uint32 Consumers uint32 Producers 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 ¶
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 )
type Authority ¶
Authority struct to hold authority data
func BABEAuthorityRawToAuthority ¶
func BABEAuthorityRawToAuthority(adr []AuthorityRaw) ([]Authority, error)
BABEAuthorityRawToAuthority turns a slice of BABE AuthorityRaw into a slice of Authority
func GrandpaAuthoritiesRawToAuthorities ¶
func GrandpaAuthoritiesRawToAuthorities(adr []GrandpaAuthoritiesRaw) ([]Authority, error)
GrandpaAuthoritiesRawToAuthorities turns a slice of GrandpaAuthoritiesRaw into a slice of Authority
func NewAuthority ¶
NewAuthority function to create Authority object
func (*Authority) DecodeSr25519 ¶
DecodeSr25519 sets the Authority to the SCALE decoded input for Authority containing SR25519 Keys.
func (*Authority) FromRawEd25519 ¶
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 ¶
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 ¶
func (a *Authority) ToRaw() *AuthorityRaw
ToRaw returns the BABEAuthorities as BABEAuthoritiesRaw. It encodes the authority public keys.
type AuthorityRaw ¶
type AuthorityRaw struct { Key [sr25519.PublicKeyLength]byte Weight uint64 }
AuthorityRaw struct to hold raw authority data
func AuthoritiesToRaw ¶
func AuthoritiesToRaw(auths []Authority) []AuthorityRaw
AuthoritiesToRaw converts an array of Authority in an array of AuthorityRaw
func (*AuthorityRaw) String ¶
func (a *AuthorityRaw) String() string
type BABEOnDisabled ¶
type BABEOnDisabled struct {
ID uint32
}
BABEOnDisabled represents a GRANDPA authority being disabled
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 BabePrimaryPreDigest ¶
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 ¶
func NewBabePrimaryPreDigest(authorityIndex uint32, slotNumber uint64, vrfOutput [sr25519.VRFOutputLength]byte, vrfProof [sr25519.VRFProofLength]byte) *BabePrimaryPreDigest
NewBabePrimaryPreDigest returns a new BabePrimaryPreDigest
func (BabePrimaryPreDigest) Index ¶
func (d BabePrimaryPreDigest) Index() uint
Index Returns VDT index
func (*BabePrimaryPreDigest) ToPreRuntimeDigest ¶
func (d *BabePrimaryPreDigest) ToPreRuntimeDigest() (*PreRuntimeDigest, error)
ToPreRuntimeDigest returns the BabePrimaryPreDigest as a PreRuntimeDigest
type BabeSecondaryPlainPreDigest ¶
BabeSecondaryPlainPreDigest is included in a block built by a secondary slot authorized producer
func NewBabeSecondaryPlainPreDigest ¶
func NewBabeSecondaryPlainPreDigest(authorityIndex uint32, slotNumber uint64) *BabeSecondaryPlainPreDigest
NewBabeSecondaryPlainPreDigest returns a new BabeSecondaryPlainPreDigest
func (BabeSecondaryPlainPreDigest) Index ¶
func (d BabeSecondaryPlainPreDigest) Index() uint
Index Returns VDT index
func (*BabeSecondaryPlainPreDigest) ToPreRuntimeDigest ¶
func (d *BabeSecondaryPlainPreDigest) ToPreRuntimeDigest() (*PreRuntimeDigest, error)
ToPreRuntimeDigest returns the BabeSecondaryPlainPreDigest as a PreRuntimeDigest
type BabeSecondaryVRFPreDigest ¶
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 ¶
func NewBabeSecondaryVRFPreDigest(authorityIndex uint32, slotNumber uint64, vrfOutput [sr25519.VRFOutputLength]byte, vrfProof [sr25519.VRFProofLength]byte) *BabeSecondaryVRFPreDigest
NewBabeSecondaryVRFPreDigest returns a new NewBabeSecondaryVRFPreDigest
func (BabeSecondaryVRFPreDigest) Index ¶
func (d BabeSecondaryVRFPreDigest) Index() uint
Index Returns VDT index
func (*BabeSecondaryVRFPreDigest) ToPreRuntimeDigest ¶
func (d *BabeSecondaryVRFPreDigest) ToPreRuntimeDigest() (*PreRuntimeDigest, error)
ToPreRuntimeDigest returns the BabeSecondaryVRFPreDigest as a PreRuntimeDigest
type Block ¶
Block defines a state block
func (*Block) MustEncode ¶
MustEncode returns the SCALE encoded block and panics if it fails to encode
func (*Block) ToBlockData ¶
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 ¶
func NewEmptyBlockData() *BlockData
NewEmptyBlockData Creates an empty blockData struct
type Body ¶
type Body []Extrinsic
Body is the extrinsics(not encoded) inside a state block.
func NewBodyFromBytes ¶
NewBodyFromBytes returns a Body from a SCALE encoded byte array.
func NewBodyFromEncodedBytes ¶
NewBodyFromEncodedBytes returns a new Body from a slice of byte slices that are SCALE encoded extrinsics
func NewBodyFromExtrinsicStrings ¶
NewBodyFromExtrinsicStrings creates a block body given an array of hex-encoded 0x-prefixed strings.
func (*Body) AsEncodedExtrinsics ¶
AsEncodedExtrinsics decodes the body into an array of SCALE encoded extrinsics
type ChangesTrieRootDigest ¶
ChangesTrieRootDigest contains the root of the changes trie at a given block, if the runtime supports it.
func (ChangesTrieRootDigest) Index ¶
func (d ChangesTrieRootDigest) Index() uint
Index Returns VDT index
func (*ChangesTrieRootDigest) String ¶
func (d *ChangesTrieRootDigest) String() string
String returns the digest as a string
type ConfigData ¶
ConfigData represents a BABE configuration update
type ConsensusDigest ¶
type ConsensusDigest struct { ConsensusEngineID ConsensusEngineID Data []byte }
ConsensusDigest contains messages from the runtime to the consensus engine.
func (ConsensusDigest) String ¶
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) ToBytes ¶
func (h ConsensusEngineID) ToBytes() []byte
ToBytes turns ConsensusEngineID to a byte array
type EpochData ¶
type EpochData struct { Authorities []Authority Randomness [RandomnessLength]byte }
EpochData is the data provided for a BABE epoch
func (*EpochData) ToEpochDataRaw ¶
func (d *EpochData) ToEpochDataRaw() *EpochDataRaw
ToEpochDataRaw returns the EpochData as an EpochDataRaw, converting the Authority to AuthorityRaw
type EpochDataRaw ¶
type EpochDataRaw struct { Authorities []AuthorityRaw Randomness [RandomnessLength]byte }
EpochDataRaw is the data provided for an epoch, with Authority as AuthorityRaw
func (*EpochDataRaw) ToEpochData ¶
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 ¶
BytesArrayToExtrinsics converts an array of byte arrays into an array of extrinsics
func NewExtrinsic ¶
NewExtrinsic creates a new Extrinsic given a byte slice
type FinalisationInfo ¶
FinalisationInfo represents information about what block was finalised in what round and setID
type GrandpaAuthoritiesRaw ¶
type GrandpaAuthoritiesRaw struct { Key [ed25519.PublicKeyLength]byte ID uint64 }
GrandpaAuthoritiesRaw represents a GRANDPA authority where their key is a byte array
type GrandpaForcedChange ¶
type GrandpaForcedChange struct { Auths []GrandpaAuthoritiesRaw Delay uint32 }
GrandpaForcedChange represents a GRANDPA forced authority change
func (GrandpaForcedChange) Index ¶
func (fc GrandpaForcedChange) Index() uint
Index Returns VDT index
type GrandpaOnDisabled ¶
type GrandpaOnDisabled struct {
ID uint64
}
GrandpaOnDisabled represents a GRANDPA authority being disabled
type GrandpaPause ¶
type GrandpaPause struct {
Delay uint32
}
GrandpaPause represents an authority set pause
type GrandpaResume ¶
type GrandpaResume struct {
Delay uint32
}
GrandpaResume represents an authority set resume
type GrandpaScheduledChange ¶
type GrandpaScheduledChange struct { Auths []GrandpaAuthoritiesRaw Delay uint32 }
GrandpaScheduledChange represents a GRANDPA scheduled authority change
func (GrandpaScheduledChange) Index ¶
func (sc GrandpaScheduledChange) Index() uint
Index Returns VDT index
type GrandpaSignedVote ¶
type GrandpaSignedVote struct { Vote GrandpaVote Signature [64]byte AuthorityID ed25519.PublicKeyBytes }
GrandpaSignedVote represents a signed precommit message for a finalised block
func (*GrandpaSignedVote) String ¶
func (s *GrandpaSignedVote) String() string
type GrandpaVote ¶
GrandpaVote represents a vote for a block with the given hash and number
func (*GrandpaVote) String ¶
func (v *GrandpaVote) String() string
String returns the Vote as a string
type GrandpaVoter ¶
GrandpaVoter represents a GRANDPA voter
func NewGrandpaVotersFromAuthorities ¶
func NewGrandpaVotersFromAuthorities(ad []Authority) []GrandpaVoter
NewGrandpaVotersFromAuthorities returns an array of GrandpaVoters given an array of GrandpaAuthorities
func NewGrandpaVotersFromAuthoritiesRaw ¶
func NewGrandpaVotersFromAuthoritiesRaw(ad []GrandpaAuthoritiesRaw) ([]GrandpaVoter, error)
NewGrandpaVotersFromAuthoritiesRaw returns an array of GrandpaVoters given an array of GrandpaAuthoritiesRaw
func (*GrandpaVoter) PublicKeyBytes ¶
func (gv *GrandpaVoter) PublicKeyBytes() ed25519.PublicKeyBytes
PublicKeyBytes returns the voter key as PublicKeyBytes
func (*GrandpaVoter) String ¶
func (gv *GrandpaVoter) String() string
String returns a formatted GrandpaVoter string
type GrandpaVoters ¶
type GrandpaVoters []GrandpaVoter
GrandpaVoters represents []GrandpaVoter
func DecodeGrandpaVoters ¶
func DecodeGrandpaVoters(in []byte) (GrandpaVoters, error)
DecodeGrandpaVoters returns a decoded GrandpaVoters
func (GrandpaVoters) String ¶
func (v GrandpaVoters) String() string
String returns a formatted Voters string
type Header ¶
type Header struct { ParentHash common.Hash `json:"parentHash"` Number uint `json:"number"` StateRoot common.Hash `json:"stateRoot"` ExtrinsicsRoot common.Hash `json:"extrinsicsRoot"` Digest scale.VaryingDataTypeSlice `json:"digest"` // contains filtered or unexported fields }
Header is a state block header
func NewEmptyHeader ¶
func NewEmptyHeader() *Header
NewEmptyHeader returns a new header with all zero values
func NewHeader ¶
func NewHeader(parentHash, stateRoot, extrinsicsRoot common.Hash, number uint, digest scale.VaryingDataTypeSlice) (*Header, error)
NewHeader creates a new block header and sets its hash field
func (*Header) DeepCopy ¶
DeepCopy returns a deep copy of the header to prevent side effects down the road
type InherentsData ¶
type InherentsData struct {
// contains filtered or unexported fields
}
InherentsData contains a mapping of inherent keys to values keys must be 8 bytes, values are a scale-encoded byte array
func NewInherentsData ¶
func NewInherentsData() *InherentsData
NewInherentsData returns InherentsData
func (*InherentsData) Encode ¶
func (d *InherentsData) Encode() ([]byte, error)
Encode will encode a given []byte using scale.Encode
func (*InherentsData) SetInt64Inherent ¶
func (d *InherentsData) SetInt64Inherent(key []byte, data uint64) error
SetInt64Inherent set an inherent of type uint64
func (*InherentsData) String ¶
func (d *InherentsData) String() string
type NextConfigData ¶
NextConfigData 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 (*NextConfigData) ToConfigData ¶
func (d *NextConfigData) ToConfigData() *ConfigData
ToConfigData returns the NextConfigData as ConfigData
type NextEpochData ¶
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 ¶
func (d NextEpochData) String() string
func (*NextEpochData) ToEpochData ¶
func (d *NextEpochData) ToEpochData() (*EpochData, error)
ToEpochData returns the NextEpochData as EpochData
type PreRuntimeDigest ¶
type PreRuntimeDigest struct { ConsensusEngineID ConsensusEngineID Data []byte }
PreRuntimeDigest contains messages from the consensus engine to the runtime.
func NewBABEPreRuntimeDigest ¶
func NewBABEPreRuntimeDigest(data []byte) *PreRuntimeDigest
NewBABEPreRuntimeDigest returns a PreRuntimeDigest with the BABE consensus ID
func (*PreRuntimeDigest) String ¶
func (d *PreRuntimeDigest) String() string
String returns the digest as a string
type SealDigest ¶
type SealDigest struct { ConsensusEngineID ConsensusEngineID Data []byte }
SealDigest contains the seal or signature. This is only used by native code.
func (*SealDigest) String ¶
func (d *SealDigest) String() string
String returns the digest as a string
type SystemInfo ¶
SystemInfo struct to hold system related information
type TransactionPaymentQueryInfo ¶
type TransactionPaymentQueryInfo struct { Weight uint64 // Class could be Normal (0), Operational (1), Mandatory (2) Class int PartialFee *scale.Uint128 }
TransactionPaymentQueryInfo represents the basic information of a given encoded extrinsic
type TransactionSource ¶
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 )