Documentation
¶
Index ¶
- type AggregatedMembership
- func (c *AggregatedMembership) CachedCanotoSize() uint64
- func (c *AggregatedMembership) CalculateCanotoCache()
- func (*AggregatedMembership) CanotoSpec(types ...reflect.Type) *canoto.Spec
- func (c *AggregatedMembership) Equals(members []NodeBLSMapping) bool
- func (c *AggregatedMembership) MarshalCanoto() []byte
- func (c *AggregatedMembership) MarshalCanotoInto(w canoto.Writer) canoto.Writer
- func (c *AggregatedMembership) UnmarshalCanoto(bytes []byte) error
- func (c *AggregatedMembership) UnmarshalCanotoFrom(r canoto.Reader) error
- func (c *AggregatedMembership) ValidCanoto() bool
- type ApprovalStore
- type AuxiliaryInfo
- func (c *AuxiliaryInfo) CachedCanotoSize() uint64
- func (c *AuxiliaryInfo) CalculateCanotoCache()
- func (*AuxiliaryInfo) CanotoSpec(...reflect.Type) *canoto.Spec
- func (ai *AuxiliaryInfo) Clone() *AuxiliaryInfo
- func (ai *AuxiliaryInfo) Equal(a *AuxiliaryInfo) bool
- func (ai *AuxiliaryInfo) IsZero() bool
- func (c *AuxiliaryInfo) MarshalCanoto() []byte
- func (c *AuxiliaryInfo) MarshalCanotoInto(w canoto.Writer) canoto.Writer
- func (c *AuxiliaryInfo) UnmarshalCanoto(bytes []byte) error
- func (c *AuxiliaryInfo) UnmarshalCanotoFrom(r canoto.Reader) error
- func (c *AuxiliaryInfo) ValidCanoto() bool
- type AuxiliaryInfoGenVerifier
- type BlockBuilder
- type BlockRetriever
- type BlockType
- type BlockValidationDescriptor
- func (c *BlockValidationDescriptor) CachedCanotoSize() uint64
- func (c *BlockValidationDescriptor) CalculateCanotoCache()
- func (*BlockValidationDescriptor) CanotoSpec(types ...reflect.Type) *canoto.Spec
- func (bvd *BlockValidationDescriptor) Clone() *BlockValidationDescriptor
- func (bvd *BlockValidationDescriptor) Equals(other *BlockValidationDescriptor) bool
- func (c *BlockValidationDescriptor) MarshalCanoto() []byte
- func (c *BlockValidationDescriptor) MarshalCanotoInto(w canoto.Writer) canoto.Writer
- func (c *BlockValidationDescriptor) UnmarshalCanoto(bytes []byte) error
- func (c *BlockValidationDescriptor) UnmarshalCanotoFrom(r canoto.Reader) error
- func (c *BlockValidationDescriptor) ValidCanoto() bool
- type Config
- type ICMEpochInfo
- func (c *ICMEpochInfo) CachedCanotoSize() uint64
- func (c *ICMEpochInfo) CalculateCanotoCache()
- func (*ICMEpochInfo) CanotoSpec(...reflect.Type) *canoto.Spec
- func (ei *ICMEpochInfo) Clone() ICMEpochInfo
- func (ei *ICMEpochInfo) Equal(other *ICMEpochInfo) bool
- func (c *ICMEpochInfo) MarshalCanoto() []byte
- func (c *ICMEpochInfo) MarshalCanotoInto(w canoto.Writer) canoto.Writer
- func (c *ICMEpochInfo) UnmarshalCanoto(bytes []byte) error
- func (c *ICMEpochInfo) UnmarshalCanotoFrom(r canoto.Reader) error
- func (c *ICMEpochInfo) ValidCanoto() bool
- type ICMEpochInput
- type ICMEpochTransition
- type KeyAggregator
- type NextEpochApprovals
- func (c *NextEpochApprovals) CachedCanotoSize() uint64
- func (c *NextEpochApprovals) CalculateCanotoCache()
- func (*NextEpochApprovals) CanotoSpec(...reflect.Type) *canoto.Spec
- func (nea *NextEpochApprovals) Clone() *NextEpochApprovals
- func (nea *NextEpochApprovals) Equals(other *NextEpochApprovals) bool
- func (c *NextEpochApprovals) MarshalCanoto() []byte
- func (c *NextEpochApprovals) MarshalCanotoInto(w canoto.Writer) canoto.Writer
- func (c *NextEpochApprovals) UnmarshalCanoto(bytes []byte) error
- func (c *NextEpochApprovals) UnmarshalCanotoFrom(r canoto.Reader) error
- func (c *NextEpochApprovals) ValidCanoto() bool
- type NodeBLSMapping
- func (c *NodeBLSMapping) CachedCanotoSize() uint64
- func (c *NodeBLSMapping) CalculateCanotoCache()
- func (*NodeBLSMapping) CanotoSpec(...reflect.Type) *canoto.Spec
- func (nbm *NodeBLSMapping) Clone() NodeBLSMapping
- func (nbm *NodeBLSMapping) Equals(other *NodeBLSMapping) bool
- func (c *NodeBLSMapping) MarshalCanoto() []byte
- func (c *NodeBLSMapping) MarshalCanotoInto(w canoto.Writer) canoto.Writer
- func (c *NodeBLSMapping) UnmarshalCanoto(bytes []byte) error
- func (c *NodeBLSMapping) UnmarshalCanotoFrom(r canoto.Reader) error
- func (c *NodeBLSMapping) ValidCanoto() bool
- type NodeBLSMappings
- func (nbms NodeBLSMappings) Clone() NodeBLSMappings
- func (nbms NodeBLSMappings) Equal(other NodeBLSMappings) bool
- func (nbms NodeBLSMappings) IndexByNodeID() map[avalanchego.NodeID]int
- func (nbms NodeBLSMappings) Nodes() common.Nodes
- func (nbms NodeBLSMappings) SelectSubset(bitmask avalanchego.Bitmask) []common.NodeID
- type PChainProgressListener
- type RawBlock
- func (c *RawBlock) CachedCanotoSize() uint64
- func (c *RawBlock) CalculateCanotoCache()
- func (*RawBlock) CanotoSpec(types ...reflect.Type) *canoto.Spec
- func (c *RawBlock) MarshalCanoto() []byte
- func (c *RawBlock) MarshalCanotoInto(w canoto.Writer) canoto.Writer
- func (c *RawBlock) UnmarshalCanoto(bytes []byte) error
- func (c *RawBlock) UnmarshalCanotoFrom(r canoto.Reader) error
- func (c *RawBlock) ValidCanoto() bool
- type SignatureVerifier
- type SimplexEpochInfo
- func (c *SimplexEpochInfo) CachedCanotoSize() uint64
- func (c *SimplexEpochInfo) CalculateCanotoCache()
- func (*SimplexEpochInfo) CanotoSpec(types ...reflect.Type) *canoto.Spec
- func (sei *SimplexEpochInfo) Clone() SimplexEpochInfo
- func (sei *SimplexEpochInfo) Equal(other *SimplexEpochInfo) bool
- func (sei *SimplexEpochInfo) IsZero() bool
- func (c *SimplexEpochInfo) MarshalCanoto() []byte
- func (c *SimplexEpochInfo) MarshalCanotoInto(w canoto.Writer) canoto.Writer
- func (sei *SimplexEpochInfo) NextState() state
- func (c *SimplexEpochInfo) UnmarshalCanoto(bytes []byte) error
- func (c *SimplexEpochInfo) UnmarshalCanotoFrom(r canoto.Reader) error
- func (c *SimplexEpochInfo) ValidCanoto() bool
- type StateMachine
- func (sm *StateMachine) BuildBlock(ctx context.Context, metadata common.ProtocolMetadata, ...) (*StateMachineBlock, error)
- func (sm *StateMachine) HandleApproval(approval *common.ValidatorSetApproval, timestamp uint64)
- func (sm *StateMachine) VerifyBlock(ctx context.Context, block *StateMachineBlock) error
- func (sm *StateMachine) WaitForPendingBlock(ctx context.Context, currentRoundMetadata common.ProtocolMetadata)
- type StateMachineBlock
- type StateMachineMetadata
- func (c *StateMachineMetadata) CachedCanotoSize() uint64
- func (c *StateMachineMetadata) CalculateCanotoCache()
- func (*StateMachineMetadata) CanotoSpec(types ...reflect.Type) *canoto.Spec
- func (smm *StateMachineMetadata) Clone() StateMachineMetadata
- func (c *StateMachineMetadata) MarshalCanoto() []byte
- func (c *StateMachineMetadata) MarshalCanotoInto(w canoto.Writer) canoto.Writer
- func (c *StateMachineMetadata) UnmarshalCanoto(bytes []byte) error
- func (c *StateMachineMetadata) UnmarshalCanotoFrom(r canoto.Reader) error
- func (c *StateMachineMetadata) ValidCanoto() bool
- type ValidatorSetApprovals
- type ValidatorSetRetriever
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregatedMembership ¶
type AggregatedMembership struct {
Members []NodeBLSMapping `canoto:"repeated value,1"`
// contains filtered or unexported fields
}
func (*AggregatedMembership) CachedCanotoSize ¶
func (c *AggregatedMembership) CachedCanotoSize() uint64
CachedCanotoSize returns the previously calculated size of the Canoto representation from CalculateCanotoCache.
If CalculateCanotoCache has not yet been called, it will return 0.
If the struct has been modified since the last call to CalculateCanotoCache, the returned size may be incorrect.
func (*AggregatedMembership) CalculateCanotoCache ¶
func (c *AggregatedMembership) CalculateCanotoCache()
CalculateCanotoCache populates size and OneOf caches based on the current values in the struct.
It is not safe to copy this struct concurrently.
func (*AggregatedMembership) CanotoSpec ¶
func (*AggregatedMembership) CanotoSpec(types ...reflect.Type) *canoto.Spec
CanotoSpec returns the specification of this canoto message.
func (*AggregatedMembership) Equals ¶
func (c *AggregatedMembership) Equals(members []NodeBLSMapping) bool
func (*AggregatedMembership) MarshalCanoto ¶
func (c *AggregatedMembership) MarshalCanoto() []byte
MarshalCanoto returns the Canoto representation of this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*AggregatedMembership) MarshalCanotoInto ¶
func (c *AggregatedMembership) MarshalCanotoInto(w canoto.Writer) canoto.Writer
MarshalCanotoInto writes the struct into a canoto.Writer and returns the resulting canoto.Writer. Most users should just use MarshalCanoto.
It is assumed that CalculateCanotoCache has been called since the last modification to this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*AggregatedMembership) UnmarshalCanoto ¶
func (c *AggregatedMembership) UnmarshalCanoto(bytes []byte) error
UnmarshalCanoto unmarshals a Canoto-encoded byte slice into the struct.
During parsing, the canoto cache is saved.
func (*AggregatedMembership) UnmarshalCanotoFrom ¶
func (c *AggregatedMembership) UnmarshalCanotoFrom(r canoto.Reader) error
UnmarshalCanotoFrom populates the struct from a canoto.Reader. Most users should just use UnmarshalCanoto.
During parsing, the canoto cache is saved.
This function enables configuration of reader options.
func (*AggregatedMembership) ValidCanoto ¶
func (c *AggregatedMembership) ValidCanoto() bool
ValidCanoto validates that the struct can be correctly marshaled into the Canoto format.
Specifically, ValidCanoto ensures: 1. All OneOfs are specified at most once. 2. All strings are valid utf-8. 3. All custom fields are ValidCanoto.
type ApprovalStore ¶
type ApprovalStore struct {
// contains filtered or unexported fields
}
func NewApprovalStore ¶
func NewApprovalStore(signatureVerifier SignatureVerifier, validators NodeBLSMappings, logger common.Logger) *ApprovalStore
func (*ApprovalStore) Approvals ¶
func (as *ApprovalStore) Approvals() ValidatorSetApprovals
func (*ApprovalStore) HandleApproval ¶
func (as *ApprovalStore) HandleApproval(approval *common.ValidatorSetApproval, timestamp uint64)
func (*ApprovalStore) PutApprovals ¶
func (as *ApprovalStore) PutApprovals(approvalStore *ApprovalStore)
PutApprovals copies all approvals from this store to the given approvalStore.
type AuxiliaryInfo ¶
type AuxiliaryInfo struct {
// Info is opaque bytes that can be used by applications to encode any information that describes
// the current state for the application.
Info []byte `canoto:"bytes,1"`
// PrevAuxInfoSeq is a sequence number that applications can use to find previous AuxiliaryInfo in the chain.
// It is zero if this is the first AuxiliaryInfo for this epoch.
PrevAuxInfoSeq uint64 `canoto:"uint,2"`
// VersionID is an identifier that identifies the application.
// Can be used for backward-compatibility and upgrade purposes.
VersionID common.VersionID `canoto:"uint,3"`
// contains filtered or unexported fields
}
AuxiliaryInfo defines application-specific information for applications that might care about epoch change, such as threshold distributed public key generation.
func (*AuxiliaryInfo) CachedCanotoSize ¶
func (c *AuxiliaryInfo) CachedCanotoSize() uint64
CachedCanotoSize returns the previously calculated size of the Canoto representation from CalculateCanotoCache.
If CalculateCanotoCache has not yet been called, it will return 0.
If the struct has been modified since the last call to CalculateCanotoCache, the returned size may be incorrect.
func (*AuxiliaryInfo) CalculateCanotoCache ¶
func (c *AuxiliaryInfo) CalculateCanotoCache()
CalculateCanotoCache populates size and OneOf caches based on the current values in the struct.
It is not safe to copy this struct concurrently.
func (*AuxiliaryInfo) CanotoSpec ¶
func (*AuxiliaryInfo) CanotoSpec(...reflect.Type) *canoto.Spec
CanotoSpec returns the specification of this canoto message.
func (*AuxiliaryInfo) Clone ¶
func (ai *AuxiliaryInfo) Clone() *AuxiliaryInfo
func (*AuxiliaryInfo) Equal ¶
func (ai *AuxiliaryInfo) Equal(a *AuxiliaryInfo) bool
func (*AuxiliaryInfo) IsZero ¶
func (ai *AuxiliaryInfo) IsZero() bool
func (*AuxiliaryInfo) MarshalCanoto ¶
func (c *AuxiliaryInfo) MarshalCanoto() []byte
MarshalCanoto returns the Canoto representation of this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*AuxiliaryInfo) MarshalCanotoInto ¶
func (c *AuxiliaryInfo) MarshalCanotoInto(w canoto.Writer) canoto.Writer
MarshalCanotoInto writes the struct into a canoto.Writer and returns the resulting canoto.Writer. Most users should just use MarshalCanoto.
It is assumed that CalculateCanotoCache has been called since the last modification to this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*AuxiliaryInfo) UnmarshalCanoto ¶
func (c *AuxiliaryInfo) UnmarshalCanoto(bytes []byte) error
UnmarshalCanoto unmarshals a Canoto-encoded byte slice into the struct.
During parsing, the canoto cache is saved.
func (*AuxiliaryInfo) UnmarshalCanotoFrom ¶
func (c *AuxiliaryInfo) UnmarshalCanotoFrom(r canoto.Reader) error
UnmarshalCanotoFrom populates the struct from a canoto.Reader. Most users should just use UnmarshalCanoto.
During parsing, the canoto cache is saved.
This function enables configuration of reader options.
func (*AuxiliaryInfo) ValidCanoto ¶
func (c *AuxiliaryInfo) ValidCanoto() bool
ValidCanoto validates that the struct can be correctly marshaled into the Canoto format.
Specifically, ValidCanoto ensures: 1. All OneOfs are specified at most once. 2. All strings are valid utf-8. 3. All custom fields are ValidCanoto.
type AuxiliaryInfoGenVerifier ¶
type AuxiliaryInfoGenVerifier interface {
// IsLegalAppend checks whether the given auxiliary information byte slice [x]
// can be appended to the history of auxiliary information for the given versionID, according to the app's rules.
// Returns nil if the append is legal, or an error if the append is not legal or if any error occurs during the check.
IsLegalAppend(versionID common.VersionID, nodes NodeBLSMappings, history [][]byte, x []byte) error
// IsSufficient checks whether the given history of auxiliary information for the given versionID is sufficient
// to start the epoch transition process.
IsSufficient(versionID common.VersionID, nodes NodeBLSMappings, history [][]byte) (bool, error)
// Generate generates an auxiliary information encoded as a byte slice based on the history of auxiliary information
// for the given versionID in the current epoch so far.
// If this is the first invocation in the epoch, DefaultVersionID() should be passed as the VersionID.
// Otherwise, the versionID from previous blocks in the epoch should be used.
// If the application deems the given history to be sufficient for the epoch change, it can return a nil byte slice,
// in which case it will not be appended to the history.
Generate(versionID common.VersionID, nodes NodeBLSMappings, history [][]byte) ([]byte, error)
// DefaultVersionID returns the default VersionID that should be used for epochs that don't have any any auxiliary information yet.
DefaultVersionID() common.VersionID
}
AuxiliaryInfoGenVerifier abstracts the application-specific logic for generating and verifying auxiliary information that is piggybacked on epoch transitions.
type BlockBuilder ¶
type BlockBuilder interface {
BuildBlock(ctx context.Context, pChainHeight uint64) (avalanchego.VMBlock, error)
// WaitForPendingBlock returns when either the given context is cancelled,
// or when the VM signals that a block should be built.
WaitForPendingBlock(ctx context.Context)
}
BlockBuilder builds a new VM block with the given observed P-chain height.
type BlockRetriever ¶
type BlockRetriever func(seq uint64, digest common.Digest) (StateMachineBlock, *common.Finalization, error)
BlockRetriever retrieves a block and its finalization status given the block's sequence number and expected digest. If the block cannot be found it returns ErrBlockNotFound. If an error occurs during retrieval, it returns a non-nil error.
type BlockType ¶
type BlockType uint8
const ( BlockTypeNormal BlockType = iota + 1 // In-epoch block with no epoch transition in progress BlockTypeZero // The first ever Simplex block; establishes the first epoch BlockTypeTelock // Built after the sealing block to extend its epoch until the sealing block finalizes BlockTypeSealing // Seals its epoch; only Telocks may follow it BlockTypeTransitioning // An epoch transition is in progress (collecting aux info and approvals) but the epoch is not yet sealed )
type BlockValidationDescriptor ¶
type BlockValidationDescriptor struct {
AggregatedMembership AggregatedMembership `canoto:"value,1"`
// contains filtered or unexported fields
}
func (*BlockValidationDescriptor) CachedCanotoSize ¶
func (c *BlockValidationDescriptor) CachedCanotoSize() uint64
CachedCanotoSize returns the previously calculated size of the Canoto representation from CalculateCanotoCache.
If CalculateCanotoCache has not yet been called, it will return 0.
If the struct has been modified since the last call to CalculateCanotoCache, the returned size may be incorrect.
func (*BlockValidationDescriptor) CalculateCanotoCache ¶
func (c *BlockValidationDescriptor) CalculateCanotoCache()
CalculateCanotoCache populates size and OneOf caches based on the current values in the struct.
It is not safe to copy this struct concurrently.
func (*BlockValidationDescriptor) CanotoSpec ¶
func (*BlockValidationDescriptor) CanotoSpec(types ...reflect.Type) *canoto.Spec
CanotoSpec returns the specification of this canoto message.
func (*BlockValidationDescriptor) Clone ¶
func (bvd *BlockValidationDescriptor) Clone() *BlockValidationDescriptor
func (*BlockValidationDescriptor) Equals ¶
func (bvd *BlockValidationDescriptor) Equals(other *BlockValidationDescriptor) bool
func (*BlockValidationDescriptor) MarshalCanoto ¶
func (c *BlockValidationDescriptor) MarshalCanoto() []byte
MarshalCanoto returns the Canoto representation of this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*BlockValidationDescriptor) MarshalCanotoInto ¶
func (c *BlockValidationDescriptor) MarshalCanotoInto(w canoto.Writer) canoto.Writer
MarshalCanotoInto writes the struct into a canoto.Writer and returns the resulting canoto.Writer. Most users should just use MarshalCanoto.
It is assumed that CalculateCanotoCache has been called since the last modification to this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*BlockValidationDescriptor) UnmarshalCanoto ¶
func (c *BlockValidationDescriptor) UnmarshalCanoto(bytes []byte) error
UnmarshalCanoto unmarshals a Canoto-encoded byte slice into the struct.
During parsing, the canoto cache is saved.
func (*BlockValidationDescriptor) UnmarshalCanotoFrom ¶
func (c *BlockValidationDescriptor) UnmarshalCanotoFrom(r canoto.Reader) error
UnmarshalCanotoFrom populates the struct from a canoto.Reader. Most users should just use UnmarshalCanoto.
During parsing, the canoto cache is saved.
This function enables configuration of reader options.
func (*BlockValidationDescriptor) ValidCanoto ¶
func (c *BlockValidationDescriptor) ValidCanoto() bool
ValidCanoto validates that the struct can be correctly marshaled into the Canoto format.
Specifically, ValidCanoto ensures: 1. All OneOfs are specified at most once. 2. All strings are valid utf-8. 3. All custom fields are ValidCanoto.
type Config ¶
type Config struct {
// LatestPersistedHeight is the height of the most recently persisted block.
LatestPersistedHeight uint64
// MaxBlockBuildingWaitTime is the maximum duration to wait for the VM to build a block
// before producing a block without an inner block.
MaxBlockBuildingWaitTime time.Duration
// TimeSkewLimit is the maximum allowed time difference between a block's timestamp and the current time.
TimeSkewLimit time.Duration
// GetTime returns the current time.
GetTime func() time.Time
// GetPChainHeightForProposing returns the latest known P-chain height to be used when building a block.
GetPChainHeightForProposing func() uint64
// GetPChainHeightForVerifying returns the latest known P-chain height to be used when verifying a block.
GetPChainHeightForVerifying func() uint64
// BlockBuilder builds new VM blocks.
BlockBuilder BlockBuilder
// Logger is used for logging state machine operations.
Logger common.Logger
// GetValidatorSet retrieves the validator set at a given P-chain height.
GetValidatorSet ValidatorSetRetriever
// GetBlock retrieves a previously built or finalized block.
GetBlock BlockRetriever
// SignatureAggregatorCreator creates a new SignatureAggregator for aggregating validator signatures for epoch transitions.
SignatureAggregatorCreator common.SignatureAggregatorCreator
// KeyAggregator aggregates public keys from validators.
KeyAggregator KeyAggregator
// SignatureVerifier verifies signatures from validators.
SignatureVerifier SignatureVerifier
// PChainProgressListener listens for changes in the P-chain height to trigger block building or epoch transitions.
PChainProgressListener PChainProgressListener
// LastNonSimplexBlockPChainHeight is the P-chain height of the last block built by a non-Simplex proposer.
// It is used to determine the validator set of the first ever Simplex epoch.
LastNonSimplexBlockPChainHeight uint64
// LastNonSimplexInnerBlock is the inner block of the last block built by a non-Simplex proposer.
LastNonSimplexInnerBlock avalanchego.VMBlock
// GenesisValidatorSet is the validator set used for the genesis block.
GenesisValidatorSet NodeBLSMappings
// MyNodeID
MyNodeID common.NodeID
// Signer
Signer common.Signer
// ComputeICMEpoch computes the ICM epoch information in order to know which P-chain height to encode.
ComputeICMEpoch ICMEpochTransition
// AuxiliaryInfoApp abstracts an application that piggybacks on epoch changes.
AuxiliaryInfoApp AuxiliaryInfoGenVerifier
}
Config contains the dependencies and configuration parameters needed to initialize the StateMachine.
type ICMEpochInfo ¶
type ICMEpochInfo struct {
// EpochStartTime is the Unix timestamp when this ICM epoch started.
EpochStartTime uint64 `canoto:"uint,1"`
// EpochNumber is the sequential identifier of this ICM epoch.
EpochNumber uint64 `canoto:"uint,2"`
// PChainEpochHeight is the P-chain height associated with this ICM epoch.
PChainEpochHeight uint64 `canoto:"uint,3"`
// contains filtered or unexported fields
}
ICMEpochInfo is the ICM epoch information that is maintained by the StateMachine and used for the ICM protocol. The StateMachine maintains this information identically to how the proposerVM maintains it, and it does so by building the ICMEpochInput and then passing it into the StateMachine's ComputeICMEpoch function.
func (*ICMEpochInfo) CachedCanotoSize ¶
func (c *ICMEpochInfo) CachedCanotoSize() uint64
CachedCanotoSize returns the previously calculated size of the Canoto representation from CalculateCanotoCache.
If CalculateCanotoCache has not yet been called, it will return 0.
If the struct has been modified since the last call to CalculateCanotoCache, the returned size may be incorrect.
func (*ICMEpochInfo) CalculateCanotoCache ¶
func (c *ICMEpochInfo) CalculateCanotoCache()
CalculateCanotoCache populates size and OneOf caches based on the current values in the struct.
It is not safe to copy this struct concurrently.
func (*ICMEpochInfo) CanotoSpec ¶
func (*ICMEpochInfo) CanotoSpec(...reflect.Type) *canoto.Spec
CanotoSpec returns the specification of this canoto message.
func (*ICMEpochInfo) Clone ¶
func (ei *ICMEpochInfo) Clone() ICMEpochInfo
Clone returns a copy of the ICMEpochInfo, skipping the canoto cache so it is safe to call while the original is being marshaled.
func (*ICMEpochInfo) Equal ¶
func (ei *ICMEpochInfo) Equal(other *ICMEpochInfo) bool
func (*ICMEpochInfo) MarshalCanoto ¶
func (c *ICMEpochInfo) MarshalCanoto() []byte
MarshalCanoto returns the Canoto representation of this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*ICMEpochInfo) MarshalCanotoInto ¶
func (c *ICMEpochInfo) MarshalCanotoInto(w canoto.Writer) canoto.Writer
MarshalCanotoInto writes the struct into a canoto.Writer and returns the resulting canoto.Writer. Most users should just use MarshalCanoto.
It is assumed that CalculateCanotoCache has been called since the last modification to this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*ICMEpochInfo) UnmarshalCanoto ¶
func (c *ICMEpochInfo) UnmarshalCanoto(bytes []byte) error
UnmarshalCanoto unmarshals a Canoto-encoded byte slice into the struct.
During parsing, the canoto cache is saved.
func (*ICMEpochInfo) UnmarshalCanotoFrom ¶
func (c *ICMEpochInfo) UnmarshalCanotoFrom(r canoto.Reader) error
UnmarshalCanotoFrom populates the struct from a canoto.Reader. Most users should just use UnmarshalCanoto.
During parsing, the canoto cache is saved.
This function enables configuration of reader options.
func (*ICMEpochInfo) ValidCanoto ¶
func (c *ICMEpochInfo) ValidCanoto() bool
ValidCanoto validates that the struct can be correctly marshaled into the Canoto format.
Specifically, ValidCanoto ensures: 1. All OneOfs are specified at most once. 2. All strings are valid utf-8. 3. All custom fields are ValidCanoto.
type ICMEpochInput ¶
type ICMEpochInput struct {
// ParentPChainHeight is the P-chain height recorded in the parent block.
ParentPChainHeight uint64
// ParentTimestamp is the timestamp of the parent block.
ParentTimestamp time.Time
// ChildTimestamp is the timestamp of the block being built.
ChildTimestamp time.Time
// ParentEpoch is the ICM epoch information from the parent block.
ParentEpoch ICMEpochInfo
}
ICMEpochInput defines the input for computing the ICM Epoch information for the next block.
type ICMEpochTransition ¶
type ICMEpochTransition func(ICMEpochInput) ICMEpochInfo
ICMEpochTransition computes the next ICM epoch given the current upgrade configuration and epoch input.
type KeyAggregator ¶
KeyAggregator combines multiple public keys into a single aggregated public key.
type NextEpochApprovals ¶
type NextEpochApprovals struct {
NodeIDs []byte `canoto:"bytes,1"`
Signature []byte `canoto:"bytes,2"`
// contains filtered or unexported fields
}
func (*NextEpochApprovals) CachedCanotoSize ¶
func (c *NextEpochApprovals) CachedCanotoSize() uint64
CachedCanotoSize returns the previously calculated size of the Canoto representation from CalculateCanotoCache.
If CalculateCanotoCache has not yet been called, it will return 0.
If the struct has been modified since the last call to CalculateCanotoCache, the returned size may be incorrect.
func (*NextEpochApprovals) CalculateCanotoCache ¶
func (c *NextEpochApprovals) CalculateCanotoCache()
CalculateCanotoCache populates size and OneOf caches based on the current values in the struct.
It is not safe to copy this struct concurrently.
func (*NextEpochApprovals) CanotoSpec ¶
func (*NextEpochApprovals) CanotoSpec(...reflect.Type) *canoto.Spec
CanotoSpec returns the specification of this canoto message.
func (*NextEpochApprovals) Clone ¶
func (nea *NextEpochApprovals) Clone() *NextEpochApprovals
func (*NextEpochApprovals) Equals ¶
func (nea *NextEpochApprovals) Equals(other *NextEpochApprovals) bool
func (*NextEpochApprovals) MarshalCanoto ¶
func (c *NextEpochApprovals) MarshalCanoto() []byte
MarshalCanoto returns the Canoto representation of this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*NextEpochApprovals) MarshalCanotoInto ¶
func (c *NextEpochApprovals) MarshalCanotoInto(w canoto.Writer) canoto.Writer
MarshalCanotoInto writes the struct into a canoto.Writer and returns the resulting canoto.Writer. Most users should just use MarshalCanoto.
It is assumed that CalculateCanotoCache has been called since the last modification to this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*NextEpochApprovals) UnmarshalCanoto ¶
func (c *NextEpochApprovals) UnmarshalCanoto(bytes []byte) error
UnmarshalCanoto unmarshals a Canoto-encoded byte slice into the struct.
During parsing, the canoto cache is saved.
func (*NextEpochApprovals) UnmarshalCanotoFrom ¶
func (c *NextEpochApprovals) UnmarshalCanotoFrom(r canoto.Reader) error
UnmarshalCanotoFrom populates the struct from a canoto.Reader. Most users should just use UnmarshalCanoto.
During parsing, the canoto cache is saved.
This function enables configuration of reader options.
func (*NextEpochApprovals) ValidCanoto ¶
func (c *NextEpochApprovals) ValidCanoto() bool
ValidCanoto validates that the struct can be correctly marshaled into the Canoto format.
Specifically, ValidCanoto ensures: 1. All OneOfs are specified at most once. 2. All strings are valid utf-8. 3. All custom fields are ValidCanoto.
type NodeBLSMapping ¶
type NodeBLSMapping struct {
NodeID avalanchego.NodeID `canoto:"fixed bytes,1"`
BLSKey []byte `canoto:"bytes,2"`
Weight uint64 `canoto:"uint,3"`
// contains filtered or unexported fields
}
func (*NodeBLSMapping) CachedCanotoSize ¶
func (c *NodeBLSMapping) CachedCanotoSize() uint64
CachedCanotoSize returns the previously calculated size of the Canoto representation from CalculateCanotoCache.
If CalculateCanotoCache has not yet been called, it will return 0.
If the struct has been modified since the last call to CalculateCanotoCache, the returned size may be incorrect.
func (*NodeBLSMapping) CalculateCanotoCache ¶
func (c *NodeBLSMapping) CalculateCanotoCache()
CalculateCanotoCache populates size and OneOf caches based on the current values in the struct.
It is not safe to copy this struct concurrently.
func (*NodeBLSMapping) CanotoSpec ¶
func (*NodeBLSMapping) CanotoSpec(...reflect.Type) *canoto.Spec
CanotoSpec returns the specification of this canoto message.
func (*NodeBLSMapping) Clone ¶
func (nbm *NodeBLSMapping) Clone() NodeBLSMapping
func (*NodeBLSMapping) Equals ¶
func (nbm *NodeBLSMapping) Equals(other *NodeBLSMapping) bool
func (*NodeBLSMapping) MarshalCanoto ¶
func (c *NodeBLSMapping) MarshalCanoto() []byte
MarshalCanoto returns the Canoto representation of this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*NodeBLSMapping) MarshalCanotoInto ¶
func (c *NodeBLSMapping) MarshalCanotoInto(w canoto.Writer) canoto.Writer
MarshalCanotoInto writes the struct into a canoto.Writer and returns the resulting canoto.Writer. Most users should just use MarshalCanoto.
It is assumed that CalculateCanotoCache has been called since the last modification to this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*NodeBLSMapping) UnmarshalCanoto ¶
func (c *NodeBLSMapping) UnmarshalCanoto(bytes []byte) error
UnmarshalCanoto unmarshals a Canoto-encoded byte slice into the struct.
During parsing, the canoto cache is saved.
func (*NodeBLSMapping) UnmarshalCanotoFrom ¶
func (c *NodeBLSMapping) UnmarshalCanotoFrom(r canoto.Reader) error
UnmarshalCanotoFrom populates the struct from a canoto.Reader. Most users should just use UnmarshalCanoto.
During parsing, the canoto cache is saved.
This function enables configuration of reader options.
func (*NodeBLSMapping) ValidCanoto ¶
func (c *NodeBLSMapping) ValidCanoto() bool
ValidCanoto validates that the struct can be correctly marshaled into the Canoto format.
Specifically, ValidCanoto ensures: 1. All OneOfs are specified at most once. 2. All strings are valid utf-8. 3. All custom fields are ValidCanoto.
type NodeBLSMappings ¶
type NodeBLSMappings []NodeBLSMapping
func (NodeBLSMappings) Clone ¶
func (nbms NodeBLSMappings) Clone() NodeBLSMappings
func (NodeBLSMappings) Equal ¶
func (nbms NodeBLSMappings) Equal(other NodeBLSMappings) bool
func (NodeBLSMappings) IndexByNodeID ¶
func (nbms NodeBLSMappings) IndexByNodeID() map[avalanchego.NodeID]int
IndexByNodeID returns a mapping from NodeID to the validator's index in the set, which is the position used by approval bitmasks.
func (NodeBLSMappings) Nodes ¶
func (nbms NodeBLSMappings) Nodes() common.Nodes
func (NodeBLSMappings) SelectSubset ¶
func (nbms NodeBLSMappings) SelectSubset(bitmask avalanchego.Bitmask) []common.NodeID
type PChainProgressListener ¶
type PChainProgressListener interface {
// WaitForProgress should block until either the context is cancelled, or the P-chain height has increased from the provided pChainHeight.
WaitForProgress(ctx context.Context, pChainHeight uint64) error
}
PChainProgressListener listens for changes in the P-chain height.
type RawBlock ¶
type RawBlock struct {
Metadata StateMachineMetadata `canoto:"value,1"`
InnerBlockBytes []byte `canoto:"bytes,2"`
// contains filtered or unexported fields
}
RawBlock is the serialized form of a StateMachineBlock.
func (*RawBlock) CachedCanotoSize ¶
CachedCanotoSize returns the previously calculated size of the Canoto representation from CalculateCanotoCache.
If CalculateCanotoCache has not yet been called, it will return 0.
If the struct has been modified since the last call to CalculateCanotoCache, the returned size may be incorrect.
func (*RawBlock) CalculateCanotoCache ¶
func (c *RawBlock) CalculateCanotoCache()
CalculateCanotoCache populates size and OneOf caches based on the current values in the struct.
It is not safe to copy this struct concurrently.
func (*RawBlock) CanotoSpec ¶
CanotoSpec returns the specification of this canoto message.
func (*RawBlock) MarshalCanoto ¶
MarshalCanoto returns the Canoto representation of this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*RawBlock) MarshalCanotoInto ¶
MarshalCanotoInto writes the struct into a canoto.Writer and returns the resulting canoto.Writer. Most users should just use MarshalCanoto.
It is assumed that CalculateCanotoCache has been called since the last modification to this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*RawBlock) UnmarshalCanoto ¶
UnmarshalCanoto unmarshals a Canoto-encoded byte slice into the struct.
During parsing, the canoto cache is saved.
func (*RawBlock) UnmarshalCanotoFrom ¶
UnmarshalCanotoFrom populates the struct from a canoto.Reader. Most users should just use UnmarshalCanoto.
During parsing, the canoto cache is saved.
This function enables configuration of reader options.
func (*RawBlock) ValidCanoto ¶
ValidCanoto validates that the struct can be correctly marshaled into the Canoto format.
Specifically, ValidCanoto ensures: 1. All OneOfs are specified at most once. 2. All strings are valid utf-8. 3. All custom fields are ValidCanoto.
type SignatureVerifier ¶
type SignatureVerifier interface {
VerifySignature(signature []byte, message []byte, publicKey []byte) error
}
SignatureVerifier verifies a cryptographic signature against a message and public key. Used to verify Approvals from validators for epoch transitions.
type SimplexEpochInfo ¶
type SimplexEpochInfo struct {
// PChainReferenceHeight is the P-Chain height that the StateMachine uses as a reference for the current epoch.
// The validator set is determined based on the validators on the P-Chain at the PChainReferenceHeight.
PChainReferenceHeight uint64 `canoto:"uint,1"`
// EpochNumber is the current epoch number.
// The first epoch is numbered 1, and each successive epoch is numbered according to the block sequence
// of the sealing block of the previous epoch.
EpochNumber uint64 `canoto:"uint,2"`
// PrevSealingBlockHash is the hash of the sealing block of the previous epoch.
// It is set to the hash of the zero block in the first epoch, and in subsequent epochs it is set to be
// the hash of the sealing block of the previous epoch.
// This is used to be able to quickly fetch and verify the sealing blocks without having to retrieve the interleaving blocks,
// which allows to bootstrap the BLS keys of the validator set for each epoch before fully syncing the interleaving blocks.
PrevSealingBlockHash [32]byte `canoto:"fixed bytes,3"`
// NextPChainReferenceHeight is the P-Chain height that the StateMachine uses as a reference for the next epoch.
// When the NextPChainReferenceHeight is > 0, it means the StateMachine is on its way to transition to a new epoch
// in which the validator set will be based on the given P-chain height.
// It sets the PChainReferenceHeight for the next epoch.
NextPChainReferenceHeight uint64 `canoto:"uint,4"`
// PrevVMBlockSeq is the block sequence of the previous block that has a VM block (inner block).
// This is used to know on which VM block to build the next block.
PrevVMBlockSeq uint64 `canoto:"uint,5"`
// BlockValidationDescriptor is the metadata that describes the validator set of the next epoch.
// It is only set in the sealing block and zero block, and nil in all other blocks.
BlockValidationDescriptor *BlockValidationDescriptor `canoto:"pointer,6"`
// NextEpochApprovals is the metadata that contains the approvals from validators for the next epoch.
// It is set only in the sealing block and the blocks preceding it starting from a block that has a NextPChainReferenceHeight set.
NextEpochApprovals *NextEpochApprovals `canoto:"pointer,7"`
// SealingBlockSeq is the block sequence of the sealing block of the current epoch.
// It defines the validator set of the next epoch.
// It is set once the first Telock is built and is copied over to subsequent Telocks.
SealingBlockSeq uint64 `canoto:"uint,8"`
// contains filtered or unexported fields
}
SimplexEpochInfo is metadata used by the StateMachine.
func (*SimplexEpochInfo) CachedCanotoSize ¶
func (c *SimplexEpochInfo) CachedCanotoSize() uint64
CachedCanotoSize returns the previously calculated size of the Canoto representation from CalculateCanotoCache.
If CalculateCanotoCache has not yet been called, it will return 0.
If the struct has been modified since the last call to CalculateCanotoCache, the returned size may be incorrect.
func (*SimplexEpochInfo) CalculateCanotoCache ¶
func (c *SimplexEpochInfo) CalculateCanotoCache()
CalculateCanotoCache populates size and OneOf caches based on the current values in the struct.
It is not safe to copy this struct concurrently.
func (*SimplexEpochInfo) CanotoSpec ¶
func (*SimplexEpochInfo) CanotoSpec(types ...reflect.Type) *canoto.Spec
CanotoSpec returns the specification of this canoto message.
func (*SimplexEpochInfo) Clone ¶
func (sei *SimplexEpochInfo) Clone() SimplexEpochInfo
Clone returns a shallow copy of the SimplexEpochInfo, skipping the canoto cache so it is safe to call while the original is being marshaled.
func (*SimplexEpochInfo) Equal ¶
func (sei *SimplexEpochInfo) Equal(other *SimplexEpochInfo) bool
func (*SimplexEpochInfo) IsZero ¶
func (sei *SimplexEpochInfo) IsZero() bool
func (*SimplexEpochInfo) MarshalCanoto ¶
func (c *SimplexEpochInfo) MarshalCanoto() []byte
MarshalCanoto returns the Canoto representation of this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*SimplexEpochInfo) MarshalCanotoInto ¶
func (c *SimplexEpochInfo) MarshalCanotoInto(w canoto.Writer) canoto.Writer
MarshalCanotoInto writes the struct into a canoto.Writer and returns the resulting canoto.Writer. Most users should just use MarshalCanoto.
It is assumed that CalculateCanotoCache has been called since the last modification to this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*SimplexEpochInfo) NextState ¶
func (sei *SimplexEpochInfo) NextState() state
NextState returns the state used to build (or verify) the block that follows the one described by the SimplexEpochInfo.
func (*SimplexEpochInfo) UnmarshalCanoto ¶
func (c *SimplexEpochInfo) UnmarshalCanoto(bytes []byte) error
UnmarshalCanoto unmarshals a Canoto-encoded byte slice into the struct.
During parsing, the canoto cache is saved.
func (*SimplexEpochInfo) UnmarshalCanotoFrom ¶
func (c *SimplexEpochInfo) UnmarshalCanotoFrom(r canoto.Reader) error
UnmarshalCanotoFrom populates the struct from a canoto.Reader. Most users should just use UnmarshalCanoto.
During parsing, the canoto cache is saved.
This function enables configuration of reader options.
func (*SimplexEpochInfo) ValidCanoto ¶
func (c *SimplexEpochInfo) ValidCanoto() bool
ValidCanoto validates that the struct can be correctly marshaled into the Canoto format.
Specifically, ValidCanoto ensures: 1. All OneOfs are specified at most once. 2. All strings are valid utf-8. 3. All custom fields are ValidCanoto.
type StateMachine ¶
type StateMachine struct {
*Config
// contains filtered or unexported fields
}
StateMachine manages block building and verification across epoch transitions.
func NewStateMachine ¶
func NewStateMachine(config *Config) (*StateMachine, error)
func (*StateMachine) BuildBlock ¶
func (sm *StateMachine) BuildBlock(ctx context.Context, metadata common.ProtocolMetadata, blacklist common.Blacklist) (*StateMachineBlock, error)
BuildBlock constructs the next block on top of the given parent block, and passes in the provided simplex metadata and blacklist.
func (*StateMachine) HandleApproval ¶
func (sm *StateMachine) HandleApproval(approval *common.ValidatorSetApproval, timestamp uint64)
func (*StateMachine) VerifyBlock ¶
func (sm *StateMachine) VerifyBlock(ctx context.Context, block *StateMachineBlock) error
VerifyBlock validates a proposed block by checking its metadata, epoch info, and inner block against the previous block and the current state.
func (*StateMachine) WaitForPendingBlock ¶
func (sm *StateMachine) WaitForPendingBlock(ctx context.Context, currentRoundMetadata common.ProtocolMetadata)
WaitForPendingBlock waits for either the VM to signal that a block is ready to be built, or for the state machine to determine that a block should be built immediately due to an epoch transition. In the latter case, we only wait up to MaxBlockBuildingWaitTime before returning.
type StateMachineBlock ¶
type StateMachineBlock struct {
// InnerBlock is the VM-level block, or nil if this is a block without an inner block (e.g., a Telock block).
InnerBlock avalanchego.VMBlock
// Metadata contains the state machine metadata associated with this block.
Metadata StateMachineMetadata
}
A StateMachineBlock is a representation of a parsed OuterBlock, containing the inner block and the metadata.
func (*StateMachineBlock) Bytes ¶
func (smb *StateMachineBlock) Bytes() []byte
func (*StateMachineBlock) Clone ¶
func (smb *StateMachineBlock) Clone() StateMachineBlock
Clone returns a shallow copy of the block, skipping the canoto caches so it is safe to call while the original is being marshaled.
func (*StateMachineBlock) Digest ¶
func (smb *StateMachineBlock) Digest() [32]byte
Digest returns the SHA-256 hash of the combined inner block digest and metadata digest.
func (*StateMachineBlock) SealingBlockInfo ¶
func (smb *StateMachineBlock) SealingBlockInfo() *common.SealingBlockInfo
SealingBlockInfo returns the information derived from this block's BlockValidationDescriptor: the validator set of the next epoch and the hash of the previous sealing block. It returns the zero value for blocks that carry no descriptor (any block that is neither a sealing block nor the zero block).
func (*StateMachineBlock) Type ¶
func (smb *StateMachineBlock) Type() BlockType
type StateMachineMetadata ¶
type StateMachineMetadata struct {
// SimplexEpochInfo is the metadata that the StateMachine uses for its own epoching.
SimplexEpochInfo SimplexEpochInfo `canoto:"value,1"`
// SimplexProtocolMetadata is the metadata that Simplex uses for its protocol, such as sequence and round number.
SimplexProtocolMetadata common.ProtocolMetadata `canoto:"value,2"`
// SimplexBlacklist is the metadata that Simplex uses to keep track of blacklisted nodes.
// Blacklisted nodes do not become leaders.
SimplexBlacklist common.Blacklist `canoto:"value,3"`
// PChainHeight is the P-Chain height that the StateMachine sampled at the time of building the block.
// It's used for ICM epoching, not for Simplex epoching.
// For Simplex epoching, the P-Chain height that matters is the PChainReferenceHeight in the SimplexEpochInfo.
PChainHeight uint64 `canoto:"uint,4"`
// Timestamp is the time when the block is being built, in milliseconds since Unix epoch.
Timestamp uint64 `canoto:"uint,5"`
// ICMEpochInfo is the metadata that the StateMachine uses for ICM epoching.
ICMEpochInfo ICMEpochInfo `canoto:"value,6"`
// AuxiliaryInfo is application-specific information that the StateMachine doesn't need to understand,
// but can be used by applications that care about epoch changes, such as threshold distributed public key generation.
AuxiliaryInfo *AuxiliaryInfo `canoto:"pointer,7"`
// contains filtered or unexported fields
}
StateMachineMetadata defines the metadata that the StateMachine uses to transition between epochs, and maintain ICM epoch information. TODO: change SimplexProtocolMetadata and SimplexBlacklist to be non-opaque types. TODO: This requires to encode the protocol metadata and blacklist using canoto.
func (*StateMachineMetadata) CachedCanotoSize ¶
func (c *StateMachineMetadata) CachedCanotoSize() uint64
CachedCanotoSize returns the previously calculated size of the Canoto representation from CalculateCanotoCache.
If CalculateCanotoCache has not yet been called, it will return 0.
If the struct has been modified since the last call to CalculateCanotoCache, the returned size may be incorrect.
func (*StateMachineMetadata) CalculateCanotoCache ¶
func (c *StateMachineMetadata) CalculateCanotoCache()
CalculateCanotoCache populates size and OneOf caches based on the current values in the struct.
It is not safe to copy this struct concurrently.
func (*StateMachineMetadata) CanotoSpec ¶
func (*StateMachineMetadata) CanotoSpec(types ...reflect.Type) *canoto.Spec
CanotoSpec returns the specification of this canoto message.
func (*StateMachineMetadata) Clone ¶
func (smm *StateMachineMetadata) Clone() StateMachineMetadata
Clone returns a shallow copy of the metadata, skipping the canoto caches so it is safe to call while the original is being marshaled.
func (*StateMachineMetadata) MarshalCanoto ¶
func (c *StateMachineMetadata) MarshalCanoto() []byte
MarshalCanoto returns the Canoto representation of this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*StateMachineMetadata) MarshalCanotoInto ¶
func (c *StateMachineMetadata) MarshalCanotoInto(w canoto.Writer) canoto.Writer
MarshalCanotoInto writes the struct into a canoto.Writer and returns the resulting canoto.Writer. Most users should just use MarshalCanoto.
It is assumed that CalculateCanotoCache has been called since the last modification to this struct.
It is assumed that this struct is ValidCanoto.
It is not safe to copy this struct concurrently.
func (*StateMachineMetadata) UnmarshalCanoto ¶
func (c *StateMachineMetadata) UnmarshalCanoto(bytes []byte) error
UnmarshalCanoto unmarshals a Canoto-encoded byte slice into the struct.
During parsing, the canoto cache is saved.
func (*StateMachineMetadata) UnmarshalCanotoFrom ¶
func (c *StateMachineMetadata) UnmarshalCanotoFrom(r canoto.Reader) error
UnmarshalCanotoFrom populates the struct from a canoto.Reader. Most users should just use UnmarshalCanoto.
During parsing, the canoto cache is saved.
This function enables configuration of reader options.
func (*StateMachineMetadata) ValidCanoto ¶
func (c *StateMachineMetadata) ValidCanoto() bool
ValidCanoto validates that the struct can be correctly marshaled into the Canoto format.
Specifically, ValidCanoto ensures: 1. All OneOfs are specified at most once. 2. All strings are valid utf-8. 3. All custom fields are ValidCanoto.
type ValidatorSetApprovals ¶
type ValidatorSetApprovals []common.ValidatorSetApproval
func (ValidatorSetApprovals) Filter ¶
func (vsa ValidatorSetApprovals) Filter(f func(common.ValidatorSetApproval, common.Logger) bool, logger common.Logger) ValidatorSetApprovals
func (ValidatorSetApprovals) UniqueByNodeID ¶
func (vsa ValidatorSetApprovals) UniqueByNodeID() ValidatorSetApprovals
type ValidatorSetRetriever ¶
type ValidatorSetRetriever func(pChainHeight uint64) (NodeBLSMappings, error)
ValidatorSetRetriever retrieves the validator set at a given P-chain height.