enclave

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Guardian

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

Guardian is a host service which monitors an enclave, it's responsibilities include: - monitor the enclave state and feed it the data it needs - if it is an active sequencer then the guardian will trigger batch/rollup creation - guardian provides access to the enclave data and reports the enclave status for other services - acting as a gatekeeper

func NewGuardian

func NewGuardian(cfg *config.HostConfig, hostData host.Identity, serviceLocator guardianServiceLocator, enclaveClient common.Enclave, storage storage.Storage, interrupter *stopcontrol.StopControl, logger gethlog.Logger) *Guardian

func (*Guardian) GetEnclaveClient

func (g *Guardian) GetEnclaveClient() common.Enclave

GetEnclaveClient returns the enclave client for use by other services todo (@matt) avoid exposing client directly and return errors if enclave is not ready for requests

func (*Guardian) GetEnclaveState

func (g *Guardian) GetEnclaveState() *StateTracker

func (*Guardian) HandleBatch

func (g *Guardian) HandleBatch(batch *common.ExtBatch)

HandleBatch is called by the L2 repository when a new batch arrives Note: this should only be called for validators, sequencers produce their own batches

func (*Guardian) HandleBlock

func (g *Guardian) HandleBlock(block *types.Block)

HandleBlock is called by the L1 repository when new blocks arrive. Note: The L1 processing behaviour has two modes based on the state, either - enclave is behind: lookup blocks to feed it 1-by-1 (see `catchupWithL1()`), ignore new live blocks that arrive here - enclave is up-to-date: feed it these live blocks as they arrive, no need to lookup blocks

func (*Guardian) HandleTransaction

func (g *Guardian) HandleTransaction(tx common.EncryptedTx)

func (*Guardian) HealthStatus

func (g *Guardian) HealthStatus() host.HealthStatus

func (*Guardian) Start

func (g *Guardian) Start() error

func (*Guardian) Stop

func (g *Guardian) Stop() error

type Service

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

Service is a host service that provides access to the enclave(s) - it handles failover, load balancing, circuit breaking when a host has multiple enclaves

func NewService

func NewService(hostData host.Identity, serviceLocator enclaveServiceLocator, enclaveGuardians []*Guardian, logger gethlog.Logger) *Service

func (*Service) GetEnclaveClient

func (e *Service) GetEnclaveClient() common.Enclave

func (*Service) HealthStatus

func (e *Service) HealthStatus() host.HealthStatus

func (*Service) HealthyGuardian added in v0.24.0

func (e *Service) HealthyGuardian() *Guardian

func (*Service) LookupBatchBySeqNo

func (e *Service) LookupBatchBySeqNo(seqNo *big.Int) (*common.ExtBatch, error)

LookupBatchBySeqNo is used to fetch batch data from the enclave - it is only used as a fallback for the sequencer host if it's missing a batch (other host services should use L2Repo to fetch batch data)

func (*Service) Start

func (e *Service) Start() error

func (*Service) Stop

func (e *Service) Stop() error

func (*Service) SubmitAndBroadcastTx

func (e *Service) SubmitAndBroadcastTx(encryptedParams common.EncryptedParamsSendRawTx) (*responses.RawTx, error)

func (*Service) Subscribe

func (e *Service) Subscribe(id rpc.ID, encryptedParams common.EncryptedParamsLogSubscription) error

func (*Service) Unsubscribe

func (e *Service) Unsubscribe(id rpc.ID) error

type StateTracker

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

StateTracker is the state machine for the enclave

func NewStateTracker

func NewStateTracker(logger gethlog.Logger) *StateTracker

func (*StateTracker) GetEnclaveL1Head

func (s *StateTracker) GetEnclaveL1Head() gethcommon.Hash

func (*StateTracker) GetEnclaveL2Head

func (s *StateTracker) GetEnclaveL2Head() *big.Int

func (*StateTracker) GetStatus

func (s *StateTracker) GetStatus() Status

func (*StateTracker) InSyncWithL1

func (s *StateTracker) InSyncWithL1() bool

InSyncWithL1 returns true if the enclave is up-to-date with L1 data so guardian can process L1 blocks as they arrive

func (*StateTracker) IsUpToDate

func (s *StateTracker) IsUpToDate() bool

func (*StateTracker) OnDisconnected

func (s *StateTracker) OnDisconnected()

OnDisconnected is called if the enclave is unreachable/not returning a valid Status

func (*StateTracker) OnEnclaveStatus

func (s *StateTracker) OnEnclaveStatus(es common.Status)

func (*StateTracker) OnProcessedBatch

func (s *StateTracker) OnProcessedBatch(enclL2HeadSeqNo *big.Int)

func (*StateTracker) OnProcessedBlock

func (s *StateTracker) OnProcessedBlock(enclL1Head gethcommon.Hash)

func (*StateTracker) OnReceivedBatch

func (s *StateTracker) OnReceivedBatch(l2HeadSeqNo *big.Int)

func (*StateTracker) OnReceivedBlock

func (s *StateTracker) OnReceivedBlock(l1Head gethcommon.Hash)

func (*StateTracker) OnSecretProvided

func (s *StateTracker) OnSecretProvided()

func (*StateTracker) String

func (s *StateTracker) String() string

type Status

type Status int

Status is the status of the enclave from the host's perspective (including what it knows of the outside world)

const (
	// Live - enclave is up-to-date with known external data. It can process L1 and L2 blocks as they arrive and respond to requests.
	Live Status = iota
	// Disconnected - enclave is unreachable or not returning a valid status (this overrides state calculations)
	Disconnected
	// Unavailable - enclave responding with 'Unavailable' status code
	Unavailable
	// AwaitingSecret - enclave is waiting for host to request and provide secret
	AwaitingSecret
	// L1Catchup - enclave is behind on L1 data, host should submit L1 blocks to catch up
	L1Catchup
	// L2Catchup - enclave is behind on L2 data, host should request and submit L2 batches to catch up
	L2Catchup
)

func (Status) String

func (es Status) String() string

Jump to

Keyboard shortcuts

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