Documentation
¶
Index ¶
- type Config
- type SCPInstance
- type Slot
- type State
- type StateChangeCallback
- type StateMachine
- func (sm *StateMachine) BeginSlot(slot uint64, superblockNumber uint64, lastHash []byte, activeRollups [][]byte) error
- func (sm *StateMachine) CheckAllL2BlocksReceived() bool
- func (sm *StateMachine) GetActiveRollups() [][]byte
- func (sm *StateMachine) GetCurrentSlot() uint64
- func (sm *StateMachine) GetCurrentState() State
- func (sm *StateMachine) GetIncludedXTs() [][]byte
- func (sm *StateMachine) GetL2BlockRequests() map[string]*pb.L2BlockRequest
- func (sm *StateMachine) GetReceivedL2Blocks() map[string]*pb.L2Block
- func (sm *StateMachine) GetSCPInstances() map[string]*SCPInstance
- func (sm *StateMachine) GetTransitionHistory() []StateTransition
- func (sm *StateMachine) ProcessSCPDecision(xtID []byte, decision bool) error
- func (sm *StateMachine) ProcessSCPDecisionWithReason(xtID []byte, decision bool, reason string) error
- func (sm *StateMachine) ReceiveL2Block(block *pb.L2Block) error
- func (sm *StateMachine) RegisterStateChangeCallback(state State, callback StateChangeCallback)
- func (sm *StateMachine) RequestSeal(includedXTs [][]byte) error
- func (sm *StateMachine) Reset()
- func (sm *StateMachine) SeedLastHead(block *pb.L2Block)
- func (sm *StateMachine) StartSCP(instance *SCPInstance) error
- func (sm *StateMachine) TransitionTo(newState State, reason string) error
- type StateTransition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Duration time.Duration `mapstructure:"duration" yaml:"duration"`
SealCutover float64 `mapstructure:"seal_cutover" yaml:"seal_cutover"`
GenesisTime time.Time `mapstructure:"genesis_time" yaml:"genesis_time"`
}
Config holds slot timing configuration
func DefaultConfig ¶
func DefaultConfig() Config
type SCPInstance ¶
type SCPInstance struct {
XtID []byte
Slot uint64
SequenceNumber uint64
Request *pb.XTRequest
ParticipatingChains [][]byte
Votes map[string]bool
Decision *bool
// DecisionReason records why the decision was made (commit/abort/forced abort).
// This is used for diagnostics to explain inclusion/exclusion in RequestSeal.
DecisionReason string
StartTime time.Time
DecisionTime *time.Time
}
type Slot ¶
type Slot interface {
// GetCurrent returns the current slot number based on genesis time
GetCurrent() uint64
// GetStartTime returns the start time for a given slot
GetStartTime(slot uint64) time.Time
// GetProgress returns the progress through the current slot (0.0 to 1.0)
GetProgress() float64
// IsSealTime returns true if we've reached the seal cutover point
IsSealTime() bool
// WaitForNext blocks until the next slot begins
WaitForNext(ctx context.Context) error
// SetGenesisTime updates the genesis time
SetGenesisTime(genesis time.Time)
// GetSealTime returns the seal cutover time for a given slot
GetSealTime(slot uint64) time.Time
// GetEndTime returns the end time for a given slot
GetEndTime(slot uint64) time.Time
// TimeUntilSeal returns duration until the current slot's seal time
TimeUntilSeal() time.Duration
// TimeUntilEnd returns duration until the current slot ends
TimeUntilEnd() time.Duration
}
Slot handles 12-second Ethereum-aligned slots for SBCP coordination. It provides slot timing, progress tracking, and seal time calculations.
type StateChangeCallback ¶
type StateMachine ¶
type StateMachine struct {
// contains filtered or unexported fields
}
func NewStateMachine ¶
func NewStateMachine(slot Slot, log zerolog.Logger) *StateMachine
func (*StateMachine) CheckAllL2BlocksReceived ¶
func (sm *StateMachine) CheckAllL2BlocksReceived() bool
func (*StateMachine) GetActiveRollups ¶
func (sm *StateMachine) GetActiveRollups() [][]byte
func (*StateMachine) GetCurrentSlot ¶
func (sm *StateMachine) GetCurrentSlot() uint64
func (*StateMachine) GetCurrentState ¶
func (sm *StateMachine) GetCurrentState() State
func (*StateMachine) GetIncludedXTs ¶
func (sm *StateMachine) GetIncludedXTs() [][]byte
func (*StateMachine) GetL2BlockRequests ¶
func (sm *StateMachine) GetL2BlockRequests() map[string]*pb.L2BlockRequest
func (*StateMachine) GetReceivedL2Blocks ¶
func (sm *StateMachine) GetReceivedL2Blocks() map[string]*pb.L2Block
func (*StateMachine) GetSCPInstances ¶
func (sm *StateMachine) GetSCPInstances() map[string]*SCPInstance
func (*StateMachine) GetTransitionHistory ¶
func (sm *StateMachine) GetTransitionHistory() []StateTransition
func (*StateMachine) ProcessSCPDecision ¶
func (sm *StateMachine) ProcessSCPDecision(xtID []byte, decision bool) error
ProcessSCPDecision sets the decision for an SCP instance. Prefer ProcessSCPDecisionWithReason to capture an explicit reason in logs.
func (*StateMachine) ProcessSCPDecisionWithReason ¶
func (sm *StateMachine) ProcessSCPDecisionWithReason(xtID []byte, decision bool, reason string) error
ProcessSCPDecisionWithReason sets the decision and records a diagnostic reason.
func (*StateMachine) ReceiveL2Block ¶
func (sm *StateMachine) ReceiveL2Block(block *pb.L2Block) error
func (*StateMachine) RegisterStateChangeCallback ¶
func (sm *StateMachine) RegisterStateChangeCallback(state State, callback StateChangeCallback)
func (*StateMachine) RequestSeal ¶
func (sm *StateMachine) RequestSeal(includedXTs [][]byte) error
func (*StateMachine) Reset ¶
func (sm *StateMachine) Reset()
func (*StateMachine) SeedLastHead ¶
func (sm *StateMachine) SeedLastHead(block *pb.L2Block)
SeedLastHead seeds the last known L2 head for a chain. This allows BeginSlot to compute correct L2BlockRequest values (next block number and parent hash) even on the first slot or after restarts.
func (*StateMachine) StartSCP ¶
func (sm *StateMachine) StartSCP(instance *SCPInstance) error
func (*StateMachine) TransitionTo ¶
func (sm *StateMachine) TransitionTo(newState State, reason string) error
TransitionTo moves SP through SBCP states: Starting→Free→Locked→Sealing