cluster

package
v0.43.0-dev-malleabili... Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: AGPL-3.0 Imports: 2 Imported by: 6

Documentation

Overview

Package cluster contains models related to collection node cluster consensus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block = flow.GenericBlock[Payload]

Block represents a block in collection node cluster consensus. It contains a standard block header with a payload containing only a single collection.

Zero values for certain HeaderBody fields are allowed only for root blocks, which must be constructed using the NewRootBlock constructor. All non-root blocks must be constructed using NewBlock to ensure validation of the block fields.

func NewBlock added in v0.43.0

func NewBlock(untrusted UntrustedBlock) (*Block, error)

NewBlock creates a new block in collection node cluster consensus. This constructor enforces validation rules to ensure the block is well-formed. It must be used to construct all non-root blocks.

All errors indicate that a valid Block cannot be constructed from the input.

func NewRootBlock added in v0.43.0

func NewRootBlock(untrusted UntrustedBlock) (*Block, error)

NewRootBlock creates a root block in collection node cluster consensus.

This constructor must be used **only** for constructing the root block, which is the only case where zero values are allowed.

type Payload

type Payload struct {

	// Collection is the collection being created.
	Collection flow.Collection

	// ReferenceBlockID is the ID of a reference block on the main chain. It
	// is defined as the ID of the reference block with the lowest height
	// from all transactions within the collection. If the collection is empty,
	// the proposer may choose any reference block, so long as it is finalized
	// and within the epoch the cluster is associated with. If a cluster was
	// assigned for epoch E, then all of its reference blocks must have a view
	// in the range [E.FirstView, E.FinalView]. However, if epoch fallback is
	// triggered in epoch E, then any reference block with view ≥ E.FirstView
	// may be used.
	//
	// This determines when the collection expires, using the same expiry rules
	// as transactions. It is also used as the reference point for committee
	// state (staking, etc.) when validating the containing block.
	//
	// The root block of a cluster chain has an empty reference block ID, as it
	// is created in advance of its members (necessarily) being authorized network
	// members. It is invalid for any non-root block to have an empty reference
	// block ID.
	ReferenceBlockID flow.Identifier
}

Payload is the payload for blocks in collection node cluster consensus. It contains only a single collection.

func NewEmptyPayload added in v0.43.0

func NewEmptyPayload(refID flow.Identifier) *Payload

NewEmptyPayload returns a payload with an empty collection and the given reference block ID.

func NewPayload added in v0.43.0

func NewPayload(untrusted UntrustedPayload) (*Payload, error)

NewPayload creates a payload given a reference block ID and a list of transaction hashes. Construction cluster Payload allowed only within the constructor.

All errors indicate a valid Payload cannot be constructed from the input.

func NewRootPayload added in v0.43.0

func NewRootPayload(untrusted UntrustedPayload) (*Payload, error)

NewRootPayload creates a root payload for a root cluster block.

This constructor must be used **only** for constructing the root payload, which is the only case where zero values are allowed.

func (Payload) Hash

func (p Payload) Hash() flow.Identifier

Hash returns the hash of the payload.

type Proposal added in v0.43.0

type Proposal struct {
	Block           Block
	ProposerSigData []byte
}

Proposal represents a signed proposed block in collection node cluster consensus.

func NewProposal added in v0.43.0

func NewProposal(untrusted UntrustedProposal) (*Proposal, error)

NewProposal creates a new cluster Proposal. This constructor enforces validation rules to ensure the Proposal is well-formed.

All errors indicate that a valid cluster.Proposal cannot be constructed from the input.

func NewRootProposal added in v0.43.0

func NewRootProposal(untrusted UntrustedProposal) (*Proposal, error)

NewRootProposal creates a root cluster proposal. This constructor must be used **only** for constructing the root proposal, which is the only case where zero values are allowed.

func (*Proposal) ProposalHeader added in v0.43.0

func (p *Proposal) ProposalHeader() *flow.ProposalHeader

ProposalHeader converts the proposal into a compact [ProposalHeader] representation, where the payload is compressed to a hash reference.

type UntrustedBlock added in v0.43.0

type UntrustedBlock Block

UntrustedBlock is an untrusted input-only representation of a cluster Block, used for construction.

This type exists to ensure that constructor functions are invoked explicitly with named fields, which improves clarity and reduces the risk of incorrect field ordering during construction.

An instance of UntrustedBlock should be validated and converted into a trusted cluster Block using the NewBlock constructor (or NewRootBlock for the root block).

type UntrustedPayload added in v0.43.0

type UntrustedPayload Payload

UntrustedPayload is an untrusted input-only representation of a cluster Payload, used for construction.

This type exists to ensure that constructor functions are invoked explicitly with named fields, which improves clarity and reduces the risk of incorrect field ordering during construction.

An instance of UntrustedPayload should be validated and converted into a trusted cluster Payload using NewPayload constructor.

type UntrustedProposal added in v0.43.0

type UntrustedProposal Proposal

UntrustedProposal is an untrusted input-only representation of a cluster.Proposal, used for construction.

This type exists to ensure that constructor functions are invoked explicitly with named fields, which improves clarity and reduces the risk of incorrect field ordering during construction.

An instance of UntrustedProposal should be validated and converted into a trusted cluster Proposal using the NewProposal constructor (or NewRootProposal for the root proposal).

Jump to

Keyboard shortcuts

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