Versions in this module Expand all Collapse all v0 v0.3.0 Aug 6, 2026 Changes in this version + const BlockRecordType + const EmptyNotarizationRecordType + const EmptyVoteRecordType + const FinalizationRecordType + const NotarizationRecordType + const UndefinedRecordType + var ErrBlockNotFound = fmt.Errorf("block not found") + var ErrTooManyPendingVerifications = errors.New("too many blocks being verified to ingest another one") + var ErrorInvalidFinalizationDigest = errors.New("finalization digests do not match") + var ErrorNoVotes = errors.New("no votes to notarize") + func BlacklistUpdatesAsString(updates []BlacklistUpdate) string + func BlockRecord(bh BlockHeader, blockData []byte) ([]byte, error) + func BlockRecordRetentionTerm(record []byte) (uint64, error) + func EmptyVoteRecordRetentionTerm(record []byte) (uint64, error) + func F(n int) int + func NewEmptyNotarizationRecord(emptyNotarization *EmptyNotarization) []byte + func NewEmptyVoteRecord(emptyVote ToBeSignedEmptyVote) []byte + func NewQuorumRecord(qc []byte, rawVote []byte, recordType uint16) []byte + func NewRandomSourceFromSeed(seed int64) *rand.Rand + func Orbit(round uint64, nodeIndex uint16, nodeCount uint16) uint64 + func Quorum(n int) int + func SortNodes(nodes Nodes) + type BasicScheduler struct + func NewScheduler(logger Logger, maxTasks uint64) *BasicScheduler + func (as *BasicScheduler) Close() + func (as *BasicScheduler) Schedule(task Task) + func (as *BasicScheduler) ScheduleOrReplace(task Task) + func (as *BasicScheduler) Size() int + type Blacklist struct + NodeCount uint16 + SuspectedNodes SuspectedNodes + Updates BlacklistUpdates + func NewBlacklist(nodeCount uint16) Blacklist + func (*Blacklist) CanotoSpec(types ...reflect.Type) *canoto.Spec + func (bl *Blacklist) ApplyUpdates(updates []BlacklistUpdate, round uint64) Blacklist + func (bl *Blacklist) Bytes() []byte + func (bl *Blacklist) Clone() Blacklist + func (bl *Blacklist) ComputeBlacklistUpdates(round uint64, nodeCount uint16, timedOut, redeemed map[uint16]uint64) []BlacklistUpdate + func (bl *Blacklist) Equals(b2 *Blacklist) bool + func (bl *Blacklist) FromBytes(buff []byte) error + func (bl *Blacklist) IsEmpty() bool + func (bl *Blacklist) IsNodeSuspected(nodeIndex uint16) bool + func (bl *Blacklist) String() string + func (bl *Blacklist) VerifyProposedBlacklist(candidateBlacklist Blacklist, round uint64) error + func (c *Blacklist) CachedCanotoSize() uint64 + func (c *Blacklist) CalculateCanotoCache() + func (c *Blacklist) MarshalCanoto() []byte + func (c *Blacklist) MarshalCanotoInto(w canoto.Writer) canoto.Writer + func (c *Blacklist) UnmarshalCanoto(bytes []byte) error + func (c *Blacklist) UnmarshalCanotoFrom(r canoto.Reader) error + func (c *Blacklist) ValidCanoto() bool + type BlacklistOpType uint8 + const BlacklistOpType_NodeRedeemed + const BlacklistOpType_NodeSuspected + const BlacklistOpType_Undefined + type BlacklistUpdate struct + NodeIndex uint16 + Type BlacklistOpType + func (*BlacklistUpdate) CanotoSpec(...reflect.Type) *canoto.Spec + func (bu *BlacklistUpdate) Clone() BlacklistUpdate + func (bu *BlacklistUpdate) Equals(bu2 *BlacklistUpdate) bool + func (bu *BlacklistUpdate) String() string + func (c *BlacklistUpdate) CachedCanotoSize() uint64 + func (c *BlacklistUpdate) CalculateCanotoCache() + func (c *BlacklistUpdate) MarshalCanoto() []byte + func (c *BlacklistUpdate) MarshalCanotoInto(w canoto.Writer) canoto.Writer + func (c *BlacklistUpdate) UnmarshalCanoto(bytes []byte) error + func (c *BlacklistUpdate) UnmarshalCanotoFrom(r canoto.Reader) error + func (c *BlacklistUpdate) ValidCanoto() bool + type BlacklistUpdates []BlacklistUpdate + type Block interface + Blacklist func() Blacklist + BlockHeader func() BlockHeader + SealingBlockInfo func() *SealingBlockInfo + Verify func(ctx context.Context) (VerifiedBlock, error) + func BlockFromRecord(ctx context.Context, blockDeserializer BlockDeserializer, record []byte) (Block, error) + type BlockBuilder interface + BuildBlock func(ctx context.Context, metadata ProtocolMetadata, blacklist Blacklist) (VerifiedBlock, bool) + WaitForPendingBlock func(ctx context.Context) + type BlockDependencyManager struct + func NewBlockVerificationScheduler(logger Logger, maxDeps uint64, scheduler Scheduler) *BlockDependencyManager + func (bs *BlockDependencyManager) Close() + func (bs *BlockDependencyManager) ExecuteBlockDependents(prev Digest) + func (bs *BlockDependencyManager) ExecuteEmptyRoundDependents(emptyRound uint64) + func (bs *BlockDependencyManager) IsSequenceScheduled(seq uint64) bool + func (bs *BlockDependencyManager) RemoveOldTasks(seq uint64) + func (bs *BlockDependencyManager) ScheduleTaskWithDependencies(task Task, blockSeq uint64, prev *Digest, emptyRounds []uint64) error + type BlockDeserializer interface + DeserializeBlock func(ctx context.Context, bytes []byte) (Block, error) + type BlockDigestRequest struct + Digest Digest + Seq uint64 + type BlockHeader struct + Digest Digest + func ParseBlockRecord(buff []byte) (BlockHeader, []byte, error) + func (*BlockHeader) CanotoSpec(types ...reflect.Type) *canoto.Spec + func (bh *BlockHeader) Bytes() []byte + func (bh *BlockHeader) Equals(other *BlockHeader) bool + func (bh *BlockHeader) FromBytes(buff []byte) error + func (bh *BlockHeader) Size() int + func (bh *BlockHeader) String() string + func (c *BlockHeader) CachedCanotoSize() uint64 + func (c *BlockHeader) CalculateCanotoCache() + func (c *BlockHeader) MarshalCanoto() []byte + func (c *BlockHeader) MarshalCanotoInto(w canoto.Writer) canoto.Writer + func (c *BlockHeader) UnmarshalCanoto(bytes []byte) error + func (c *BlockHeader) UnmarshalCanotoFrom(r canoto.Reader) error + func (c *BlockHeader) ValidCanoto() bool + type BlockMessage struct + Block Block + Vote Vote + type Communication interface + Broadcast func(msg *Message) + Send func(msg *Message, destination NodeID) + Validators func() Nodes + type Digest [metadataDigestLen]byte + func (d Digest) String() string + type EmptyNotarization struct + QC QuorumCertificate + Vote ToBeSignedEmptyVote + func EmptyNotarizationFromRecord(record []byte, qd QCDeserializer) (EmptyNotarization, error) + func (en *EmptyNotarization) Size() int + func (en *EmptyNotarization) Verify(nodes Nodes) error + type EmptyVote struct + Signature Signature + Vote ToBeSignedEmptyVote + func (v *EmptyVote) Signer() NodeID + type EmptyVoteMetadata struct + Epoch uint64 + Round uint64 + type Finalization struct + Finalization ToBeSignedFinalization + QC QuorumCertificate + func FinalizationFromRecord(record []byte, qd QCDeserializer) (Finalization, error) + func NewFinalization(signatureAggregator SignatureAggregator, finalizeVotes []*FinalizeVote) (Finalization, error) + func (f *Finalization) Size() int + func (f *Finalization) Verify(nodes Nodes) error + type FinalizeVote struct + Finalization ToBeSignedFinalization + Signature Signature + func (v *FinalizeVote) Signer() NodeID + type Logger interface + Debug func(msg string, fields ...log.Field) + Error func(msg string, fields ...log.Field) + Fatal func(msg string, fields ...log.Field) + Info func(msg string, fields ...log.Field) + Trace func(msg string, fields ...log.Field) + Verbo func(msg string, fields ...log.Field) + Warn func(msg string, fields ...log.Field) + type Message struct + BlockDigestRequest *BlockDigestRequest + BlockMessage *BlockMessage + EmptyNotarization *EmptyNotarization + EmptyVoteMessage *EmptyVote + Finalization *Finalization + FinalizeVote *FinalizeVote + Notarization *Notarization + ReplicationRequest *ReplicationRequest + ReplicationResponse *ReplicationResponse + VerifiedBlockMessage *VerifiedBlockMessage + VerifiedReplicationResponse *VerifiedReplicationResponse + VoteMessage *Vote + func (m *Message) IsReplicationMessage() bool + type Node struct + Id NodeID + PK []byte + Weight uint64 + type NodeID []byte + func (node NodeID) Equals(otherNode NodeID) bool + func (node NodeID) String() string + type NodeIDs []NodeID + func (nodes NodeIDs) EqualWeightedNodes() Nodes + func (nodes NodeIDs) IndexOf(id NodeID) int + func (nodes NodeIDs) Remove(targetNode NodeID) []NodeID + func (nodes NodeIDs) String() string + type Nodes []Node + func (nws Nodes) Contains(nodeID NodeID) bool + func (nws Nodes) NodeIDs() []NodeID + type Notarization struct + QC QuorumCertificate + Vote ToBeSignedVote + func NewNotarization(logger Logger, signatureAggregator SignatureAggregator, ...) (Notarization, error) + func NotarizationFromRecord(record []byte, qd QCDeserializer) (Notarization, error) + func (n *Notarization) Size() int + func (n *Notarization) Verify(nodes Nodes) error + type ProtocolMetadata struct + Epoch uint64 + Prev Digest + Round uint64 + Seq uint64 + Version uint8 + func ProtocolMetadataFromBytes(buff []byte) (*ProtocolMetadata, error) + func (*ProtocolMetadata) CanotoSpec(...reflect.Type) *canoto.Spec + func (c *ProtocolMetadata) CachedCanotoSize() uint64 + func (c *ProtocolMetadata) CalculateCanotoCache() + func (c *ProtocolMetadata) MarshalCanoto() []byte + func (c *ProtocolMetadata) MarshalCanotoInto(w canoto.Writer) canoto.Writer + func (c *ProtocolMetadata) UnmarshalCanoto(bytes []byte) error + func (c *ProtocolMetadata) UnmarshalCanotoFrom(r canoto.Reader) error + func (c *ProtocolMetadata) ValidCanoto() bool + func (md *ProtocolMetadata) Bytes() []byte + func (md *ProtocolMetadata) Clone() ProtocolMetadata + type QCDeserializer interface + DeserializeQuorumCertificate func(bytes []byte) (QuorumCertificate, error) + type QuorumCertificate interface + Bytes func() []byte + Signers func() []NodeID + Size func() int + Verify func(msg []byte, nodes Nodes) error + type QuorumRecord struct + QC []byte + Vote []byte + func (qr *QuorumRecord) Bytes() []byte + func (qr *QuorumRecord) FromBytes(buff []byte) error + type QuorumRound struct + Block Block + EmptyNotarization *EmptyNotarization + Finalization *Finalization + Notarization *Notarization + func (q *QuorumRound) GetRound() uint64 + func (q *QuorumRound) GetSequence() uint64 + func (q *QuorumRound) IsWellFormed() error + func (q *QuorumRound) String() string + func (q *QuorumRound) VerifyQCConsistentWithBlock() error + type ReplicationRequest struct + LatestFinalizedSeq uint64 + LatestRound uint64 + Rounds []uint64 + Seqs []uint64 + type ReplicationResponse struct + Data []QuorumRound + LatestRound *QuorumRound + LatestSeq *QuorumRound + type Scheduler interface + Close func() + Schedule func(task Task) + Size func() int + type SealingBlockInfo struct + PrevSealingBlockHash Digest + ValidatorSet Nodes + func (s *SealingBlockInfo) String() string + type Signature struct + Signer NodeID + Value []byte + type SignatureAggregator interface + Aggregate func([]Signature) (QuorumCertificate, error) + AppendSignatures func([]byte, ...[]byte) ([]byte, error) + IsQuorum func([]NodeID) bool + type SignatureAggregatorCreator func([]Node) SignatureAggregator + type SignatureVerifier interface + VerifySignature func(message []byte, signature []byte, publicKey []byte) error + type SignedMessage struct + Context string + Payload []byte + type Signer interface + Sign func(message []byte) ([]byte, error) + type Storage interface + Index func(ctx context.Context, block VerifiedBlock, certificate Finalization) error + NumBlocks func() uint64 + Retrieve func(seq uint64) (VerifiedBlock, Finalization, error) + type SuspectedNode struct + NodeIndex uint16 + OrbitSuspected uint64 + OrbitToRedeem uint64 + RedeemingCount uint16 + SuspectingCount uint16 + func (*SuspectedNode) CanotoSpec(...reflect.Type) *canoto.Spec + func (c *SuspectedNode) CachedCanotoSize() uint64 + func (c *SuspectedNode) CalculateCanotoCache() + func (c *SuspectedNode) MarshalCanoto() []byte + func (c *SuspectedNode) MarshalCanotoInto(w canoto.Writer) canoto.Writer + func (c *SuspectedNode) UnmarshalCanoto(bytes []byte) error + func (c *SuspectedNode) UnmarshalCanotoFrom(r canoto.Reader) error + func (c *SuspectedNode) ValidCanoto() bool + func (sn *SuspectedNode) Clone() SuspectedNode + func (sn *SuspectedNode) Equals(sn2 *SuspectedNode) bool + func (sn *SuspectedNode) String() string + type SuspectedNodes []SuspectedNode + type Task func() Digest + type TaskWithDependents struct + Task Task + func (t *TaskWithDependents) String() string + type TimeoutHandler struct + func NewTimeoutHandler[T comparable](log Logger, name string, startTime time.Time, runInterval time.Duration, ...) *TimeoutHandler[T] + func (t *TimeoutHandler[T]) AddTask(id T) + func (t *TimeoutHandler[T]) Close() + func (t *TimeoutHandler[T]) RemoveOldTasks(shouldRemove func(id T, _ struct{}) bool) + func (t *TimeoutHandler[T]) RemoveTask(ID T) + func (t *TimeoutHandler[T]) Tick(now time.Time) + type ToBeSignedEmptyVote struct + func ParseEmptyNotarizationRecord(buff []byte) ([]byte, ToBeSignedEmptyVote, error) + func ParseEmptyVoteRecord(rawEmptyVote []byte) (ToBeSignedEmptyVote, error) + func (v *ToBeSignedEmptyVote) Bytes() []byte + func (v *ToBeSignedEmptyVote) FromBytes(buff []byte) error + func (v *ToBeSignedEmptyVote) Sign(signer Signer) ([]byte, error) + func (v *ToBeSignedEmptyVote) Size() int + func (v *ToBeSignedEmptyVote) Verify(signature []byte, verifier SignatureVerifier, pk []byte) error + type ToBeSignedFinalization struct + func (f *ToBeSignedFinalization) Sign(signer Signer) ([]byte, error) + func (f *ToBeSignedFinalization) Verify(signature []byte, verifier SignatureVerifier, pk []byte) error + type ToBeSignedVote struct + func ParseNotarizationRecord(r []byte) ([]byte, ToBeSignedVote, error) + func (v *ToBeSignedVote) Sign(signer Signer) ([]byte, error) + func (v *ToBeSignedVote) Verify(signature []byte, verifier SignatureVerifier, pk []byte) error + type ValidatorSetApproval struct + AuxInfoDigest [32]byte + NodeID host.NodeID + PChainHeight uint64 + Signature []byte + type VerifiedBlock interface + Blacklist func() Blacklist + BlockHeader func() BlockHeader + Bytes func() []byte + SealingBlockInfo func() *SealingBlockInfo + Size func() int + type VerifiedBlockMessage struct + VerifiedBlock VerifiedBlock + Vote Vote + type VerifiedFinalizedBlock struct + Finalization Finalization + VerifiedBlock VerifiedBlock + type VerifiedQuorumRound struct + EmptyNotarization *EmptyNotarization + Finalization *Finalization + Notarization *Notarization + VerifiedBlock VerifiedBlock + func (q *VerifiedQuorumRound) GetRound() uint64 + func (q *VerifiedQuorumRound) Size() int + type VerifiedReplicationResponse struct + Data []VerifiedQuorumRound + LatestFinalizedSeq *VerifiedQuorumRound + LatestRound *VerifiedQuorumRound + type VersionID uint32 + type Vote struct + Signature Signature + Vote ToBeSignedVote + func (v *Vote) Signer() NodeID + type WALRetentionReader struct + func (wrr *WALRetentionReader) RetentionTerm(entry []byte) (uint64, error) + type WriteAheadLog interface + Append func([]byte) error + Close func() error + ReadAll func() ([][]byte, error)