Documentation
¶
Overview ¶
Package session implements the session-ready architecture for private permissionless workloads. It provides: - Session state machine (pending → running → waiting_io → finalized) - Oracle request creation with deterministic request_id - Step management with QuantumVM attestation verification - Integration with OracleVM and RelayVM
Index ¶
- func ComputeOracleRequestID(serviceID ids.ID, sessionID [32]byte, step, retry uint32, txID ids.ID) [32]byte
- func ComputeSessionID(serviceID ids.ID, epoch uint64, txID ids.ID) [32]byte
- func ValidateAttestationForStep(step *Step, attestationDomain string, attestationSubjectID [32]byte, ...) error
- type Manager
- func (m *Manager) CompleteStep(sessionID [32]byte, stepIndex uint32, oracleCommitRoot [32]byte, ...) error
- func (m *Manager) CreateOracleRequest(sessionID [32]byte, kind StepKind, txID ids.ID, inputHash [32]byte) ([32]byte, error)
- func (m *Manager) CreateSession(serviceID ids.ID, epoch uint64, txID ids.ID, committee []ids.NodeID) (*Session, error)
- func (m *Manager) FailSession(sessionID [32]byte, err string) error
- func (m *Manager) FinalizeSession(sessionID [32]byte, outputHash [32]byte, oracleRoot [32]byte, ...) error
- func (m *Manager) GetPendingRequestsForSession(sessionID [32]byte) []*OracleRequestRef
- func (m *Manager) GetSession(sessionID [32]byte) (*Session, error)
- func (m *Manager) StartSession(sessionID [32]byte) error
- type OracleRequestRef
- type Session
- type SessionState
- type Step
- type StepKind
- type StepState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeOracleRequestID ¶
func ComputeOracleRequestID(serviceID ids.ID, sessionID [32]byte, step, retry uint32, txID ids.ID) [32]byte
ComputeOracleRequestID computes a deterministic oracle request ID This matches the OracleVM.ComputeRequestID format
func ComputeSessionID ¶
ComputeSessionID computes a deterministic session ID
func ValidateAttestationForStep ¶
func ValidateAttestationForStep( step *Step, attestationDomain string, attestationSubjectID [32]byte, attestationCommitRoot [32]byte, ) error
ValidateAttestationForStep validates that an attestation is valid for a step This should be called before CompleteStep to verify the attestation
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages sessions and coordinates with OracleVM and ThresholdVM
func (*Manager) CompleteStep ¶
func (m *Manager) CompleteStep( sessionID [32]byte, stepIndex uint32, oracleCommitRoot [32]byte, attestationID [32]byte, outputHash [32]byte, ) error
CompleteStep marks a step as complete with QuantumVM attestation verification This is called when PlatformVM receives attestation over oracle commit
func (*Manager) CreateOracleRequest ¶
func (m *Manager) CreateOracleRequest(sessionID [32]byte, kind StepKind, txID ids.ID, inputHash [32]byte) ([32]byte, error)
CreateOracleRequest creates an oracle request for an external I/O step Returns the deterministic request_id that should be submitted to OracleVM
func (*Manager) CreateSession ¶
func (m *Manager) CreateSession(serviceID ids.ID, epoch uint64, txID ids.ID, committee []ids.NodeID) (*Session, error)
CreateSession creates a new session
func (*Manager) FailSession ¶
FailSession marks a session as failed
func (*Manager) FinalizeSession ¶
func (m *Manager) FinalizeSession( sessionID [32]byte, outputHash [32]byte, oracleRoot [32]byte, receiptsRoot [32]byte, attestationID [32]byte, ) error
FinalizeSession marks a session as finalized This requires a QuantumVM attestation over the session completion
func (*Manager) GetPendingRequestsForSession ¶
func (m *Manager) GetPendingRequestsForSession(sessionID [32]byte) []*OracleRequestRef
GetPendingRequestsForSession returns all pending oracle requests for a session
func (*Manager) GetSession ¶
GetSession retrieves a session by ID
func (*Manager) StartSession ¶
StartSession transitions a session from pending to running
type OracleRequestRef ¶
type OracleRequestRef struct {
RequestID [32]byte
SessionID [32]byte
StepIndex uint32
Kind StepKind
CreatedAt time.Time
}
OracleRequestRef tracks a pending oracle request
type Session ¶
type Session struct {
// SessionID is the unique identifier
SessionID [32]byte `json:"sessionId"`
// ServiceID identifies the service being executed
ServiceID ids.ID `json:"serviceId"`
// Epoch in which this session was created
Epoch uint64 `json:"epoch"`
// Committee assigned to execute this session
Committee []ids.NodeID `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 [32]byte `json:"outputHash,omitempty"`
// OracleRoot is the Merkle root of all oracle observations
OracleRoot [32]byte `json:"oracleRoot,omitempty"`
// ReceiptsRoot is the Merkle root of all relay receipts
ReceiptsRoot [32]byte `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
type SessionState ¶
type SessionState string
SessionState represents the state of a session
const ( // StatePending - session created but not started StatePending SessionState = "pending" // StateRunning - session actively executing StateRunning SessionState = "running" // StateWaitingIO - session waiting for external I/O completion StateWaitingIO SessionState = "waiting_io" // StateFinalized - session completed successfully StateFinalized SessionState = "finalized" // StateFailed - session failed StateFailed SessionState = "failed" )
type Step ¶
type Step struct {
// StepIndex is the step number
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 [32]byte `json:"requestId,omitempty"`
// RetryIndex for retry attempts
RetryIndex uint32 `json:"retryIndex"`
// TxID that triggered this step
TxID ids.ID `json:"txId"`
// InputHash is the hash of step inputs
InputHash [32]byte `json:"inputHash"`
// OutputHash is the hash of step outputs (set when completed)
OutputHash [32]byte `json:"outputHash,omitempty"`
// OracleCommitRoot is the Merkle root from OracleVM (for I/O steps)
OracleCommitRoot [32]byte `json:"oracleCommitRoot,omitempty"`
// AttestationID is the QuantumVM attestation over the oracle commit
AttestationID [32]byte `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