Documentation
¶
Index ¶
- type ConflictSet
- type DAG
- type Engine
- func (e *Engine) Add(ctx context.Context, vertex Vertex) error
- func (e *Engine) Conflicts(vertexID ids.ID) set.Set[ids.ID]
- func (e *Engine) HealthCheck(ctx context.Context) (Health, error)
- func (e *Engine) IsVirtuous(vertexID ids.ID) bool
- func (e *Engine) Preferred() set.Set[ids.ID]
- func (e *Engine) RecordPoll(ctx context.Context, votes map[ids.ID]int) error
- func (e *Engine) Virtuous() set.Set[ids.ID]
- func (e *Engine) Vote(ctx context.Context, vertexID ids.ID) error
- type FlareMetrics
- type FlareState
- type FlareVertex
- func (v *FlareVertex) Accept() error
- func (v *FlareVertex) Bytes() []byte
- func (v *FlareVertex) ConflictSet() ids.ID
- func (v *FlareVertex) Epoch() uint32
- func (v *FlareVertex) FlareHeight() uint64
- func (v *FlareVertex) FlareScore() uint64
- func (v *FlareVertex) Height() uint64
- func (v *FlareVertex) ID() string
- func (v *FlareVertex) IncrementPhotons()
- func (v *FlareVertex) Parents() []ids.ID
- func (v *FlareVertex) Photons() int
- func (v *FlareVertex) Reject() error
- func (v *FlareVertex) SetConflictSet(conflictSetID ids.ID)
- func (v *FlareVertex) Status() choices.Status
- func (v *FlareVertex) Timestamp() time.Time
- func (v *FlareVertex) Txs() []ids.ID
- func (v *FlareVertex) UpdateFlareScore(score uint64)
- func (v *FlareVertex) Verify(ctx context.Context) error
- func (v *FlareVertex) Vertex() ids.ID
- type FlareVertexWrapper
- func (w *FlareVertexWrapper) Accept() error
- func (w *FlareVertexWrapper) Bytes() []byte
- func (w *FlareVertexWrapper) ConflictSet() ids.ID
- func (w *FlareVertexWrapper) Epoch() uint32
- func (w *FlareVertexWrapper) FlareHeight() uint64
- func (w *FlareVertexWrapper) FlareScore() uint64
- func (w *FlareVertexWrapper) Height() uint64
- func (w *FlareVertexWrapper) ID() string
- func (w *FlareVertexWrapper) Parents() []ids.ID
- func (w *FlareVertexWrapper) Photons() int
- func (w *FlareVertexWrapper) Reject() error
- func (w *FlareVertexWrapper) Status() choices.Status
- func (w *FlareVertexWrapper) Verify(ctx context.Context) error
- func (w *FlareVertexWrapper) Vertex() ids.ID
- type Health
- type Parameters
- type Vertex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConflictSet ¶
type ConflictSet struct {
ID ids.ID
Vertices set.Set[ids.ID]
Leader ids.ID // Current preferred vertex in set
}
ConflictSet represents a set of conflicting vertices Only one vertex from each conflict set can be finalized
type DAG ¶
type DAG interface {
// Add a new vertex to the DAG
Add(ctx context.Context, vertex Vertex) error
// Vote for vertex preferences
Vote(ctx context.Context, vertexID ids.ID) error
// RecordPoll records the result of photon sampling
RecordPoll(ctx context.Context, votes map[ids.ID]int) error
// Preferred returns current preferred vertices
Preferred() set.Set[ids.ID]
// Virtuous returns virtuous vertices (no conflicts)
Virtuous() set.Set[ids.ID]
// Conflicts returns conflicting vertex sets
Conflicts(vertexID ids.ID) set.Set[ids.ID]
// IsVirtuous checks if a vertex is virtuous
IsVirtuous(vertexID ids.ID) bool
// HealthCheck returns DAG health metrics
HealthCheck(ctx context.Context) (Health, error)
}
DAG represents flare-based DAG consensus (Previously known as Avalanche DAG in Avalanche consensus)
The flare DAG allows multiple vertices to be processed in parallel, like light flares spreading in multiple directions, eventually converging through the nova finalization process.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine implements the flare DAG consensus engine (Previously Avalanche DAG engine)
func NewEngine ¶
func NewEngine(params Parameters) *Engine
NewEngine creates a new flare consensus engine
func (*Engine) HealthCheck ¶
HealthCheck returns DAG health metrics
func (*Engine) IsVirtuous ¶
IsVirtuous checks if a vertex is virtuous
func (*Engine) RecordPoll ¶
RecordPoll records the result of photon sampling
type FlareMetrics ¶
type FlareMetrics struct {
VerticesAdded uint64
VerticesFinalized uint64
ConflictSetsFormed uint64
ConflictsResolved uint64
PollsProcessed uint64
AveragePollTime time.Duration
}
FlareMetrics tracks DAG consensus performance
type FlareState ¶
type FlareState struct {
PreferredSet set.Set[ids.ID]
VirtuousSet set.Set[ids.ID]
ProcessingSet set.Set[ids.ID]
ConflictingSet set.Set[ids.ID]
OutstandingVertex int
FlareIntensity int // Overall DAG consensus strength (0-100)
}
FlareState represents the current state of DAG consensus
type FlareVertex ¶
type FlareVertex struct {
// contains filtered or unexported fields
}
FlareVertex implements the Vertex interface for flare consensus (Previously a concrete implementation of avalanche.Vertex)
func NewFlareVertex ¶
func NewFlareVertex( id ids.ID, parentIDs []ids.ID, height uint64, timestamp time.Time, bytes []byte, txs []ids.ID, ) *FlareVertex
NewFlareVertex creates a new flare vertex
func (*FlareVertex) Accept ¶
func (v *FlareVertex) Accept() error
Accept marks the vertex as accepted (finalized in the DAG)
func (*FlareVertex) ConflictSet ¶
func (v *FlareVertex) ConflictSet() ids.ID
ConflictSet returns the conflict set this vertex belongs to
func (*FlareVertex) Epoch ¶
func (v *FlareVertex) Epoch() uint32
Epoch returns the epoch of this vertex
func (*FlareVertex) FlareHeight ¶
func (v *FlareVertex) FlareHeight() uint64
FlareHeight returns the vertex's height in the DAG
func (*FlareVertex) FlareScore ¶
func (v *FlareVertex) FlareScore() uint64
FlareScore returns the vertex's consensus score
func (*FlareVertex) IncrementPhotons ¶
func (v *FlareVertex) IncrementPhotons()
IncrementPhotons increments the photon query count
func (*FlareVertex) Parents ¶
func (v *FlareVertex) Parents() []ids.ID
Parents returns the parent vertex IDs
func (*FlareVertex) Photons ¶
func (v *FlareVertex) Photons() int
Photons returns the number of photon queries
func (*FlareVertex) Reject ¶
func (v *FlareVertex) Reject() error
Reject marks the vertex as rejected (excluded from the DAG)
func (*FlareVertex) SetConflictSet ¶
func (v *FlareVertex) SetConflictSet(conflictSetID ids.ID)
SetConflictSet sets the conflict set ID
func (*FlareVertex) Status ¶
func (v *FlareVertex) Status() choices.Status
Status returns the vertex status
func (*FlareVertex) Timestamp ¶
func (v *FlareVertex) Timestamp() time.Time
Timestamp returns the vertex timestamp
func (*FlareVertex) Txs ¶
func (v *FlareVertex) Txs() []ids.ID
Txs returns the transactions in this vertex
func (*FlareVertex) UpdateFlareScore ¶
func (v *FlareVertex) UpdateFlareScore(score uint64)
UpdateFlareScore updates the consensus score
func (*FlareVertex) Verify ¶
func (v *FlareVertex) Verify(ctx context.Context) error
Verify ensures the vertex is valid according to flare rules
func (*FlareVertex) Vertex ¶
func (v *FlareVertex) Vertex() ids.ID
Vertex returns the unique ID of this vertex
type FlareVertexWrapper ¶
type FlareVertexWrapper struct {
// contains filtered or unexported fields
}
FlareVertexWrapper wraps an existing dag.Vertex for flare consensus
func WrapVertex ¶
func WrapVertex(vertex dag.Vertex, height uint64) *FlareVertexWrapper
WrapVertex wraps an existing dag vertex for flare consensus
func (*FlareVertexWrapper) Accept ¶
func (w *FlareVertexWrapper) Accept() error
Accept accepts this element and changes its status to Accepted
func (*FlareVertexWrapper) Bytes ¶
func (w *FlareVertexWrapper) Bytes() []byte
Bytes returns the byte representation of this vertex
func (*FlareVertexWrapper) ConflictSet ¶
func (w *FlareVertexWrapper) ConflictSet() ids.ID
ConflictSet returns the conflict set this vertex belongs to
func (*FlareVertexWrapper) Epoch ¶
func (w *FlareVertexWrapper) Epoch() uint32
Epoch returns the epoch of this vertex
func (*FlareVertexWrapper) FlareHeight ¶
func (w *FlareVertexWrapper) FlareHeight() uint64
FlareHeight returns the vertex's height in the DAG
func (*FlareVertexWrapper) FlareScore ¶
func (w *FlareVertexWrapper) FlareScore() uint64
FlareScore returns the vertex's consensus score
func (*FlareVertexWrapper) Height ¶
func (w *FlareVertexWrapper) Height() uint64
Height returns the height of this vertex
func (*FlareVertexWrapper) ID ¶
func (w *FlareVertexWrapper) ID() string
ID returns the unique ID of this element
func (*FlareVertexWrapper) Parents ¶
func (w *FlareVertexWrapper) Parents() []ids.ID
Parents returns the parents of this vertex
func (*FlareVertexWrapper) Photons ¶
func (w *FlareVertexWrapper) Photons() int
Photons returns the number of photon queries
func (*FlareVertexWrapper) Reject ¶
func (w *FlareVertexWrapper) Reject() error
Reject rejects this element and changes its status to Rejected
func (*FlareVertexWrapper) Status ¶
func (w *FlareVertexWrapper) Status() choices.Status
Status returns the current status
func (*FlareVertexWrapper) Verify ¶
func (w *FlareVertexWrapper) Verify(ctx context.Context) error
Verify that this vertex is valid
func (*FlareVertexWrapper) Vertex ¶
func (w *FlareVertexWrapper) Vertex() ids.ID
Vertex returns the unique ID of this vertex
type Health ¶
type Health struct {
Healthy bool
FlareCoherence float64 // 0-1, how coherent the DAG is
ConflictRatio float64 // Ratio of conflicting to total vertices
VirtuousRatio float64 // Ratio of virtuous to total vertices
LastPollTime time.Time
OutstandingVertex int
ConflictSets int
}
Health represents DAG consensus health
type Parameters ¶
type Parameters struct {
K int // Photon sample size
AlphaPreference int // Wave threshold for preference
AlphaConfidence int // Wave threshold for confidence
Beta int // Focus rounds for finality
MaxPollTime time.Duration // Maximum time for a poll
}
Parameters configures the flare engine
type Vertex ¶
type Vertex interface {
dag.Vertex
// FlareHeight returns the vertex's height in the DAG
FlareHeight() uint64
// FlareScore returns the vertex's consensus score
FlareScore() uint64
// Photons returns the number of photon queries
Photons() int
// ConflictSet returns the conflict set this vertex belongs to
ConflictSet() ids.ID
}
Vertex represents a vertex in the flare DAG (Previously avalanche.Vertex)