Documentation
¶
Overview ¶
Package nebula provides DAG consensus mode.
Nebula implements directed acyclic graph (DAG) consensus where vertices can have multiple parents and progress in parallel. It wraps the field engine to provide DAG-specific semantics: frontier tracking, vertex proposal, and parallel finality.
In the cosmic metaphor, a nebula is a stellar nursery - a cloud of possibilities collapsing into ordered structure, representing parallel block creation that eventually achieves consensus ordering.
Nebula is designed for high-throughput chains that benefit from parallel block production, such as the X-Chain for asset transfers.
Key concepts:
- DAG structure: vertices can have multiple parents
- Parallel finality: multiple vertices can be finalized concurrently
- Frontier tracking: maintains the DAG tips (unfinalized vertices)
- Causal ordering: ensures consistent total ordering of finalized vertices
Usage:
cfg := nebula.Config{
PollSize: 20,
Alpha: 0.8,
Beta: 15,
RoundTO: 250 * time.Millisecond,
}
n := nebula.NewNebula(cfg, cut, transport, store, proposer, committer)
n.Start(ctx)
See also: field (underlying engine), wave (voting primitive), horizon (finality).
Index ¶
- type Config
- type Nebula
- func (n *Nebula[V]) GetCommittedVertices() []V
- func (n *Nebula[V]) GetFrontier() []V
- func (n *Nebula[V]) IsFinalized(vertex V) bool
- func (n *Nebula[V]) OnObserve(ctx context.Context, vertex V)
- func (n *Nebula[V]) ProposeVertex(ctx context.Context, parents []V) (V, error)
- func (n *Nebula[V]) Start(ctx context.Context) error
- func (n *Nebula[V]) Stop(ctx context.Context) error
- func (n *Nebula[V]) Tick(ctx context.Context) error
- type VID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
PollSize int // sample size for voting
Alpha float64 // threshold ratio
Beta uint32 // confidence threshold
RoundTO time.Duration // round timeout
GenesisSet []byte // genesis vertex set
}
Config holds configuration for Nebula consensus mode
type Nebula ¶
type Nebula[V VID] struct { // contains filtered or unexported fields }
Nebula implements DAG consensus using the internal Field engine
func NewNebula ¶
func NewNebula[V VID](cfg Config, cut prism.Cut[V], tx wave.Transport[V], store field.Store[V], prop field.Proposer[V], com field.Committer[V]) *Nebula[V]
NewNebula creates a new Nebula instance with Field engine
func (*Nebula[V]) GetCommittedVertices ¶
func (n *Nebula[V]) GetCommittedVertices() []V
GetCommittedVertices returns vertices that have been committed in order
func (*Nebula[V]) GetFrontier ¶
func (n *Nebula[V]) GetFrontier() []V
GetFrontier returns the current DAG frontier (tips)
func (*Nebula[V]) IsFinalized ¶
IsFinalized checks if a vertex is finalized in the DAG
func (*Nebula[V]) OnObserve ¶
OnObserve should be called when observing new vertices from the network
func (*Nebula[V]) ProposeVertex ¶
ProposeVertex proposes a new vertex to the DAG