mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
Squashed batch covering all post-Feb-28 consensus work, capped by the LSS-Pulsar cutover (task #53): - Quasar cutover from upstream Corona to LSS-Pulsar adapter: go.mod: drop direct require github.com/luxfi/corona; add github.com/luxfi/pulsar + github.com/luxfi/threshold; local replaces => ../pulsar, ../threshold epoch.go: InitializeEpoch → keyera.Bootstrap; RotateEpoch → lss.DynamicResharePulsar gated by activation cert verification under unchanged GroupKey quasar.go, grouped_threshold.go: import swap corona → pulsar reshare_epoch.go: production wiring; QUASAR-PULSAR-ACTIVATE-v1 domain prefix; ReshareEpoch + RefreshEpoch EpochKeys: gains KeyEraID, Generation, RollbackFrom (LP-105) BundleSigner: re-derives Lambda for participating subset 258 quasar tests pass. - Earlier post-Feb-28 work (gofmt linter fixes across protocol files, METASTABLE_SIGNED_QUERIES.md doc, MLDSAProof rename across 7 test files) included in the squash. Hash profile: consensus passes nil to resolve to Pulsar-SHA3 default (LP-105 / pulsar/hash). Activation message canonical bytes bind chain_id, network_id, key_era_id, generation, group_id, epoch, set hashes, thresholds, group_pk_hash, nebula_root, hash_suite_id, implementation_version, variant, reshare_transcript_hash — all under TupleHash256("PULSAR-TRANSCRIPT-v1", ...). Vocabulary alignment with LP-105 (Lux Finality Stack lexicon): Photon (vote) → Beam (BLS) → ML-DSA (PQ identity) → Pulsar (PQ threshold kernel) → Pulse (cert over Nebula root) → Prism (composition verifier) → Horizon (finality boundary) → Quasar (full consensus). Excluded from this commit: pkg/wire/{candidate,policies_test}.go uncommitted diff (pre-existing local edits; stashed and restored). Untracked protocol/quasar/witness_producer.go (mtime Apr 29; pre-task).
116 lines
2.8 KiB
Go
116 lines
2.8 KiB
Go
// Package core provides core consensus interfaces and contracts.
|
|
// This package has zero dependencies on vm modules to avoid import cycles.
|
|
package core
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/luxfi/consensus/engine/interfaces"
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
// BlockState represents block storage for consensus
|
|
type BlockState interface {
|
|
// GetBlock gets a block
|
|
GetBlock(ids.ID) (Block, error)
|
|
|
|
// PutBlock puts a block
|
|
PutBlock(Block) error
|
|
|
|
// GetLastAccepted gets last accepted
|
|
GetLastAccepted() (ids.ID, error)
|
|
|
|
// SetLastAccepted sets last accepted
|
|
SetLastAccepted(ids.ID) error
|
|
}
|
|
|
|
// Block represents a block
|
|
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
|
|
}
|
|
|
|
// Tx represents a transaction
|
|
type Tx interface {
|
|
ID() ids.ID
|
|
Bytes() []byte
|
|
Verify(context.Context) error
|
|
Accept(context.Context) error
|
|
}
|
|
|
|
// UTXO represents an unspent transaction output
|
|
type UTXO interface {
|
|
ID() ids.ID
|
|
TxID() ids.ID
|
|
OutputIndex() uint32
|
|
Amount() uint64
|
|
}
|
|
|
|
// MessageType defines types of messages sent between VMs and consensus
|
|
type MessageType uint32
|
|
|
|
// Message types for VM communication.
|
|
// Values MUST match engine/chain/block.MessageType constants (iota + 1):
|
|
// - block.PendingTxs = 1
|
|
// - block.StateSyncDone = 2
|
|
//
|
|
// The ForwardVMNotifications bridge casts block.MessageType to core.MessageType
|
|
// by value, so these must be numerically identical.
|
|
const (
|
|
PendingTxs MessageType = iota + 1 // = 1, matches block.PendingTxs
|
|
StateSyncDone // = 2, matches block.StateSyncDone
|
|
)
|
|
|
|
// Message represents a message from VM to consensus engine
|
|
type Message struct {
|
|
Type MessageType
|
|
Data []byte
|
|
}
|
|
|
|
// Fx represents a feature extension interface
|
|
type Fx interface {
|
|
Initialize(vm interface{}) error
|
|
Bootstrapping() error
|
|
Bootstrapped() error
|
|
}
|
|
|
|
// FxLifecycle represents the lifecycle methods for feature extensions
|
|
type FxLifecycle interface {
|
|
Initialize(vm interface{}) error
|
|
Bootstrapping() error
|
|
Bootstrapped() error
|
|
Shutdown() error
|
|
}
|
|
|
|
// VM re-exports engine/interfaces.VM
|
|
type VM = interfaces.VM
|
|
|
|
// AppError represents an application-level error
|
|
type AppError struct {
|
|
Code int
|
|
Message string
|
|
}
|
|
|
|
func (e AppError) Error() string { return e.Message }
|
|
|
|
// State represents the operational state of a VM or consensus engine
|
|
type State = interfaces.State
|
|
|
|
// Re-export state constants from interfaces package
|
|
const (
|
|
Unknown = interfaces.Unknown
|
|
Starting = interfaces.Starting
|
|
Syncing = interfaces.Syncing
|
|
Bootstrapping = interfaces.Bootstrapping
|
|
Ready = interfaces.Ready
|
|
Degraded = interfaces.Degraded
|
|
Stopping = interfaces.Stopping
|
|
Stopped = interfaces.Stopped
|
|
)
|