Documentation
¶
Overview ¶
Package core provides shared types and utilities for the session layer. These types are imported by both on-chain (lux/node VMs) and off-chain (sessiond) code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToUint32 ¶
BytesToUint32 converts big-endian bytes to uint32.
func BytesToUint64 ¶
BytesToUint64 converts big-endian bytes to uint64.
func Uint32ToBytes ¶
Uint32ToBytes converts a uint32 to big-endian bytes.
func Uint64ToBytes ¶
Uint64ToBytes converts a uint64 to big-endian bytes.
Types ¶
type ID ¶
type ID [32]byte
ID is a 32-byte identifier used throughout the session layer. This is the canonical ID type - all other ID types derive from this.
func ComputeRequestID ¶
ComputeRequestID computes a deterministic oracle request ID. H("LUX:OracleRequest:v1" || service_id || session_id || step || retry || tx_id)
func ComputeSessionID ¶
ComputeSessionID computes a deterministic session ID. H("LUX:Session:v1" || service_id || epoch || tx_id)
func HashWithDomain ¶
HashWithDomain computes a domain-separated hash. domain || data → SHA256
type Session ¶
type Session struct {
// ID is the unique session identifier: H("LUX:Session:v1" || service_id || epoch || tx_id)
ID ID `json:"id"`
// ServiceID identifies the service being executed
ServiceID ID `json:"serviceId"`
// Epoch in which this session was created
Epoch uint64 `json:"epoch"`
// TxID is the transaction that created this session
TxID ID `json:"txId"`
// Committee assigned to execute this session (node IDs)
Committee []ID `json:"committee"`
// State is the current session state
State SessionState `json:"state"`
// CurrentStep is the current step index
CurrentStep uint32 `json:"currentStep"`
// Steps are the step records for this session
Steps []*Step `json:"steps"`
// OutputHash is the final output hash (set when finalized)
OutputHash ID `json:"outputHash,omitempty"`
// OracleRoot is the Merkle root of all oracle observations
OracleRoot ID `json:"oracleRoot,omitempty"`
// ReceiptsRoot is the Merkle root of all relay receipts
ReceiptsRoot ID `json:"receiptsRoot,omitempty"`
// CreatedAt is when the session was created
CreatedAt time.Time `json:"createdAt"`
// FinalizedAt is when the session was finalized (if applicable)
FinalizedAt time.Time `json:"finalizedAt,omitempty"`
// Error message if session failed
Error string `json:"error,omitempty"`
}
Session represents a private permissionless session. This is the canonical session type shared by on-chain and off-chain code.
type SessionState ¶
type SessionState uint8
SessionState represents the state of a session.
const ( // SessionStatePending - session created but not started SessionStatePending SessionState = iota // SessionStateRunning - session actively executing SessionStateRunning // SessionStateWaitingIO - session waiting for external I/O completion SessionStateWaitingIO // SessionStateFinalized - session completed successfully SessionStateFinalized // SessionStateFailed - session failed SessionStateFailed )
func (SessionState) String ¶
func (s SessionState) String() string
type Step ¶
type Step struct {
// StepIndex is the step number (0-indexed)
StepIndex uint32 `json:"stepIndex"`
// Kind indicates the step type
Kind StepKind `json:"kind"`
// RequestID for external I/O steps (oracle/write or oracle/read)
RequestID ID `json:"requestId,omitempty"`
// RetryIndex for retry attempts
RetryIndex uint32 `json:"retryIndex"`
// TxID that triggered this step
TxID ID `json:"txId"`
// InputHash is the hash of step inputs
InputHash ID `json:"inputHash"`
// OutputHash is the hash of step outputs (set when completed)
OutputHash ID `json:"outputHash,omitempty"`
// OracleCommitRoot is the Merkle root from OracleVM (for I/O steps)
OracleCommitRoot ID `json:"oracleCommitRoot,omitempty"`
// AttestationID is the QuantumVM attestation over the oracle commit
AttestationID ID `json:"attestationId,omitempty"`
// State of this step
State StepState `json:"state"`
// StartedAt is when the step started
StartedAt time.Time `json:"startedAt"`
// CompletedAt is when the step completed
CompletedAt time.Time `json:"completedAt,omitempty"`
}
Step represents a single execution step in a session.
type StepKind ¶
type StepKind uint8
StepKind indicates the type of step.
func (StepKind) RequiresOracle ¶
RequiresOracle returns true if this step kind requires oracle interaction.