prism

package
v1.22.25 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package prism provides DAG geometry: frontiers, cuts, and refractions.

Given a partial order (the transaction/vertex DAG), Prism helps project that poset into slices that are easy to vote on and schedule. "Refraction" is the deterministic projection into sub-slices; "frontier" returns a maximal antichain; "cut" selects a thin slice across causal layers.

Prism is DAG-only; linear chains never need antichains or cuts.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidK is returned when K is invalid
	ErrInvalidK = errors.New("invalid K value")

	// ErrInvalidAlpha is returned when Alpha is invalid
	ErrInvalidAlpha = errors.New("invalid Alpha value")

	// ErrInvalidBeta is returned when Beta is invalid
	ErrInvalidBeta = errors.New("invalid Beta value")

	// ErrNoSampler is returned when no sampler is provided
	ErrNoSampler = errors.New("no sampler provided")
)
View Source
var DefaultConfig = Config{
	K:                     1,
	AlphaPreference:       1,
	AlphaConfidence:       1,
	Beta:                  1,
	ConcurrentPolls:       1,
	OptimalProcessing:     1,
	MaxOutstandingItems:   16,
	MaxItemProcessingTime: 10 * time.Second,
}

DefaultConfig returns default photon configuration

Functions

This section is empty.

Types

type Config

type Config struct {
	K                     int
	AlphaPreference       int
	AlphaConfidence       int
	Beta                  int
	ConcurrentPolls       int
	OptimalProcessing     int
	MaxOutstandingItems   int
	MaxItemProcessingTime time.Duration
}

Config represents photon protocol configuration

type Cut

type Cut[T comparable] interface {
	// Sample returns k random peers for voting (cuts k rays from the population)
	Sample(k int) []types.NodeID

	// Luminance returns light intensity metrics for the cut
	Luminance() Luminance
}

Cut provides random cutting of peers for consensus voting (like a prism cuts light)

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine defines prism consensus engine

func New

func New(config *Config) *Engine

New creates a new prism engine

func (*Engine) GetProposal

func (e *Engine) GetProposal(ctx context.Context, proposalID ids.ID) (Proposal, error)

GetProposal gets a proposal

func (*Engine) Initialize

func (e *Engine) Initialize(ctx context.Context, config *Config) error

Initialize initializes the engine

func (*Engine) Propose

func (e *Engine) Propose(ctx context.Context, data []byte) error

Propose proposes a value

func (*Engine) Vote

func (e *Engine) Vote(ctx context.Context, proposalID ids.ID, accept bool) error

Vote votes on a proposal

type Frontier

type Frontier struct {
	Height   uint64
	Vertices []types.NodeID
}

Frontier represents a cut/frontier in the DAG partial order

type Luminance

type Luminance struct {
	ActivePeers int
	TotalPeers  int
	Lx          float64 // Illuminance in lux (lx) - minimum 1 lx per active peer/photon
}

Luminance measures the intensity of light across the peer network Following SI units: lux (lx) = lumens per square meter

type Metrics

type Metrics struct {
}

Metrics for photon protocol

type NodeConfig

type NodeConfig struct {
	ProposerNodes    int
	VoterNodes       int
	TransactionNodes int
	BlockSize        int
}

NodeConfig defines prism node configuration

type Prism

type Prism interface {
	// Initialize prism consensus
	Initialize(context.Context, *Config) error

	// Propose proposes a value
	Propose(context.Context, []byte) error

	// Vote votes on a proposal
	Vote(context.Context, ids.ID, bool) error

	// GetProposal gets a proposal
	GetProposal(context.Context, ids.ID) (Proposal, error)
}

Prism consensus interface

type Proposal

type Proposal struct {
	ID       ids.ID
	Height   uint64
	Data     []byte
	Votes    int
	Accepted bool
}

Proposal defines a proposal

type Refractor

type Refractor interface {
	// ComputeFrontier returns the current frontier of the DAG
	ComputeFrontier() Frontier

	// RefractPath determines the optimal path through conflicting vertices
	RefractPath(from, to types.NodeID) []types.NodeID

	// Interference checks if two vertices conflict
	Interference(a, b types.NodeID) bool
}

Refractor analyzes light paths through the DAG structure to determine optimal ordering and conflict resolution

type UniformCut

type UniformCut struct {
	// contains filtered or unexported fields
}

UniformCut implements uniform random cutting

func NewUniformCut

func NewUniformCut(peers []types.NodeID) *UniformCut

NewUniformCut creates a new uniform cut

func (*UniformCut) Luminance

func (c *UniformCut) Luminance() Luminance

Luminance implements Cut interface

func (*UniformCut) Sample

func (c *UniformCut) Sample(k int) []types.NodeID

Sample implements Cut interface (cuts k rays from the peer population)

Jump to

Keyboard shortcuts

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