Documentation ¶
Index ¶
- type Guardian
- func (g *Guardian) GetEnclaveClient() common.Enclave
- func (g *Guardian) GetEnclaveState() *StateTracker
- func (g *Guardian) HandleBatch(batch *common.ExtBatch)
- func (g *Guardian) HandleBlock(block *types.Block)
- func (g *Guardian) HandleTransaction(tx common.EncryptedTx)
- func (g *Guardian) HealthStatus(context.Context) host.HealthStatus
- func (g *Guardian) Start() error
- func (g *Guardian) Stop() error
- type Service
- func (e *Service) GetEnclaveClient() common.Enclave
- func (e *Service) HealthStatus(ctx context.Context) host.HealthStatus
- func (e *Service) LookupBatchBySeqNo(ctx context.Context, seqNo *big.Int) (*common.ExtBatch, error)
- func (e *Service) Start() error
- func (e *Service) Stop() error
- func (e *Service) SubmitAndBroadcastTx(ctx context.Context, encryptedParams common.EncryptedParamsSendRawTx) (*responses.RawTx, error)
- func (e *Service) Subscribe(id rpc.ID, encryptedParams common.EncryptedParamsLogSubscription) error
- func (e *Service) Unsubscribe(id rpc.ID) error
- type StateTracker
- func (s *StateTracker) GetEnclaveL1Head() gethcommon.Hash
- func (s *StateTracker) GetEnclaveL2Head() *big.Int
- func (s *StateTracker) GetStatus() Status
- func (s *StateTracker) InSyncWithL1() bool
- func (s *StateTracker) IsUpToDate() bool
- func (s *StateTracker) OnDisconnected()
- func (s *StateTracker) OnEnclaveStatus(es common.Status)
- func (s *StateTracker) OnProcessedBatch(enclL2HeadSeqNo *big.Int)
- func (s *StateTracker) OnProcessedBlock(enclL1Head gethcommon.Hash)
- func (s *StateTracker) OnReceivedBatch(l2HeadSeqNo *big.Int)
- func (s *StateTracker) OnReceivedBlock(l1Head gethcommon.Hash)
- func (s *StateTracker) OnSecretProvided()
- func (s *StateTracker) String() string
- type Status
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 ¶
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 ¶
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 ¶
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(context.Context) host.HealthStatus
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 (*Service) GetEnclaveClient ¶
func (*Service) HealthStatus ¶
func (e *Service) HealthStatus(ctx context.Context) host.HealthStatus
func (*Service) LookupBatchBySeqNo ¶
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) SubmitAndBroadcastTx ¶
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 // 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 )