Documentation
¶
Overview ¶
Package engine houses the three consensus engines: chain, dag, and pq.
Each engine orchestrates a specific transaction topology: - chain: Linear consensus for sequential blocks - dag: DAG-based consensus for parallel, causally-ordered vertices - pq: Post-quantum hardened consensus with quantum-safe certificates
All engines share the same algorithmic pipeline but differ in their data structures and finality mechanisms.
Package engine provides consensus engine implementations.
Index ¶
- Constants
- func CgoAvailable() bool
- func DefaultConfig() types.Config
- type Block
- type BlockStatus
- type CGOConsensus
- func (c *CGOConsensus) Add(block Block) error
- func (c *CGOConsensus) Finalized() bool
- func (c *CGOConsensus) GetPreference() ids.ID
- func (c *CGOConsensus) HealthCheck() error
- func (c *CGOConsensus) IsAccepted(blockID ids.ID) bool
- func (c *CGOConsensus) Parameters() ConsensusParams
- func (c *CGOConsensus) RecordPoll(blockID ids.ID, accept bool) error
- type Chain
- func (c *Chain) Add(ctx context.Context, block *types.Block) error
- func (c *Chain) GetStatus(id types.ID) types.Status
- func (c *Chain) IsAccepted(id types.ID) bool
- func (c *Chain) RecordVote(ctx context.Context, vote *types.Vote) error
- func (c *Chain) Start(ctx context.Context) error
- func (c *Chain) Stop() error
- type Consensus
- type ConsensusFactory
- type ConsensusParams
- type Engine
- type Fx
- type FxLifecycle
- type LuxConsensus
- func (lc *LuxConsensus) Decided() bool
- func (lc *LuxConsensus) Decision(item ids.ID) (types.Decision, bool)
- func (lc *LuxConsensus) Parameters() config.Parameters
- func (lc *LuxConsensus) Poll(responses map[ids.ID]int) bool
- func (lc *LuxConsensus) Preference() ids.ID
- func (lc *LuxConsensus) RecordVote(item ids.ID)
- type Message
- type MessageType
- type SimpleCut
- type SimpleTransport
- type State
- type Stats
Constants ¶
const ( PendingTxs = vm.PendingTxs StateSyncDone = vm.StateSyncDone Unknown = vm.Unknown Starting = vm.Starting Syncing = vm.Syncing Bootstrapping = vm.Bootstrapping Ready = vm.Ready Degraded = vm.Degraded Stopping = vm.Stopping Stopped = vm.Stopped )
Re-export constants from vm package
Variables ¶
This section is empty.
Functions ¶
func CgoAvailable ¶ added in v1.22.26
func CgoAvailable() bool
CgoAvailable returns true when CGO is enabled (but ZMQ is not required)
func DefaultConfig ¶ added in v1.22.0
DefaultConfig returns the default chain configuration
Types ¶
type Block ¶ added in v1.22.26
type Block interface {
ID() ids.ID
ParentID() ids.ID
Height() uint64
Timestamp() int64
Bytes() []byte
Verify(context.Context) error
Accept(context.Context) error
Reject(context.Context) error
}
Block interface for consensus
type BlockStatus ¶ added in v1.22.26
type BlockStatus uint8
BlockStatus represents block status
const ( StatusUnknown BlockStatus = iota StatusProcessing StatusAccepted StatusRejected )
type CGOConsensus ¶ added in v1.22.26
type CGOConsensus struct {
// contains filtered or unexported fields
}
CGOConsensus is a CGO-based implementation of consensus For now, it's the same as the pure Go implementation
func NewCGOConsensus ¶ added in v1.22.26
func NewCGOConsensus(params ConsensusParams) (*CGOConsensus, error)
NewCGOConsensus creates a new CGO consensus engine
func (*CGOConsensus) Add ¶ added in v1.22.26
func (c *CGOConsensus) Add(block Block) error
Add adds a block to consensus
func (*CGOConsensus) Finalized ¶ added in v1.22.26
func (c *CGOConsensus) Finalized() bool
Finalized checks if consensus is finalized
func (*CGOConsensus) GetPreference ¶ added in v1.22.26
func (c *CGOConsensus) GetPreference() ids.ID
GetPreference returns the current preference
func (*CGOConsensus) HealthCheck ¶ added in v1.22.26
func (c *CGOConsensus) HealthCheck() error
HealthCheck performs a health check
func (*CGOConsensus) IsAccepted ¶ added in v1.22.26
func (c *CGOConsensus) IsAccepted(blockID ids.ID) bool
IsAccepted checks if a block is accepted
func (*CGOConsensus) Parameters ¶ added in v1.22.26
func (c *CGOConsensus) Parameters() ConsensusParams
Parameters returns consensus parameters
func (*CGOConsensus) RecordPoll ¶ added in v1.22.26
func (c *CGOConsensus) RecordPoll(blockID ids.ID, accept bool) error
RecordPoll records a poll result
type Chain ¶ added in v1.22.0
type Chain struct {
// contains filtered or unexported fields
}
Chain represents a linear blockchain consensus engine
func (*Chain) IsAccepted ¶ added in v1.22.0
IsAccepted returns whether a block has been accepted
func (*Chain) RecordVote ¶ added in v1.22.0
RecordVote records a vote for a block
type Consensus ¶ added in v1.22.26
type Consensus interface {
Add(Block) error
RecordPoll(ids.ID, bool) error
IsAccepted(ids.ID) bool
GetPreference() ids.ID
Finalized() bool
Parameters() ConsensusParams
HealthCheck() error
}
Consensus interface
type ConsensusFactory ¶ added in v1.22.26
type ConsensusFactory struct{}
ConsensusFactory creates the appropriate consensus implementation This is the CGO version when CGO is enabled
func NewConsensusFactory ¶ added in v1.22.26
func NewConsensusFactory() *ConsensusFactory
NewConsensusFactory creates a new consensus factory
func (*ConsensusFactory) CreateConsensus ¶ added in v1.22.26
func (f *ConsensusFactory) CreateConsensus(params ConsensusParams) (Consensus, error)
CreateConsensus creates a consensus engine instance
type ConsensusParams ¶ added in v1.22.26
type ConsensusParams struct {
K int
AlphaPreference int
AlphaConfidence int
Beta int
ConcurrentPolls int
OptimalProcessing int
MaxOutstandingItems int
MaxItemProcessingTime time.Duration
}
ConsensusParams defines consensus parameters
type Engine ¶ added in v1.22.0
type Engine interface {
// Add a new block to the consensus
Add(ctx context.Context, block *types.Block) error
// RecordVote records a vote for a block
RecordVote(ctx context.Context, vote *types.Vote) error
// IsAccepted returns whether a block has been accepted
IsAccepted(id types.ID) bool
// GetStatus returns the status of a block
GetStatus(id types.ID) types.Status
// Start the consensus engine
Start(ctx context.Context) error
// Stop the consensus engine
Stop() error
}
Engine is the main consensus engine interface
type FxLifecycle ¶ added in v1.22.30
type FxLifecycle = vm.FxLifecycle
Type aliases imported from vm package for consensus internal use
type LuxConsensus ¶
type LuxConsensus struct {
// contains filtered or unexported fields
}
LuxConsensus implements Lux's consensus protocol using Photon → Wave → Focus → Prism → Quasar
func NewLuxConsensus ¶
func NewLuxConsensus(k int, alpha int, beta int) *LuxConsensus
NewLuxConsensus creates a new Lux consensus instance
func (*LuxConsensus) Decided ¶
func (lc *LuxConsensus) Decided() bool
Decided returns whether consensus has been reached
func (*LuxConsensus) Parameters ¶
func (lc *LuxConsensus) Parameters() config.Parameters
Parameters returns the consensus parameters
func (*LuxConsensus) Poll ¶
func (lc *LuxConsensus) Poll(responses map[ids.ID]int) bool
Poll conducts a consensus poll using Lux protocols
func (*LuxConsensus) Preference ¶
func (lc *LuxConsensus) Preference() ids.ID
Preference returns the current preferred item
func (*LuxConsensus) RecordVote ¶
func (lc *LuxConsensus) RecordVote(item ids.ID)
RecordVote records a vote for an item
type MessageType ¶ added in v1.22.26
type MessageType = vm.MessageType
Type aliases imported from vm package for consensus internal use
type SimpleCut ¶
type SimpleCut struct {
// contains filtered or unexported fields
}
SimpleCut implements a basic Cut for sampling
type SimpleTransport ¶
type SimpleTransport struct {
// contains filtered or unexported fields
}
SimpleTransport implements basic transport for voting
func (*SimpleTransport) MakeLocalPhoton ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package chain implements linear consensus protocol.
|
Package chain implements linear consensus protocol. |
|
block/blockmock
Package blockmock is a generated GoMock package.
|
Package blockmock is a generated GoMock package. |
|
block/blocktest
Package blocktest provides test utilities for blocks
|
Package blocktest provides test utilities for blocks |
|
chainmock
Package chainmock provides mock implementations for testing
|
Package chainmock provides mock implementations for testing |
|
chaintest
Package chaintest provides test utilities for chains
|
Package chaintest provides test utilities for chains |
|
syncer
Package syncer provides state synchronization for blockchain engines
|
Package syncer provides state synchronization for blockchain engines |
|
Package dag provides DAG consensus functionality
|
Package dag provides DAG consensus functionality |
|
Package coremock provides mock implementations for core consensus
|
Package coremock provides mock implementations for core consensus |
|
Package enginetest provides test utilities for consensus engines
|
Package enginetest provides test utilities for consensus engines |
|
coretest
Package coretest provides test utilities for consensus engine core
|
Package coretest provides test utilities for consensus engine core |
|
Package interfaces provides consensus engine interfaces.
|
Package interfaces provides consensus engine interfaces. |
|
Package pq implements the post-quantum consensus engine that combines classical and quantum-resistant consensus mechanisms.
|
Package pq implements the post-quantum consensus engine that combines classical and quantum-resistant consensus mechanisms. |