Skip to content

Commit

Permalink
Host: fix nil pointer when enclave not healthy
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel committed May 15, 2024
1 parent 41095b4 commit f194d67
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions go/host/enclave/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,11 @@ func (e *Service) HealthStatus(ctx context.Context) host.HealthStatus {
return &host.GroupErrsHealthStatus{Errors: errors}
}

func (e *Service) HealthyGuardian(ctx context.Context) *Guardian {
for _, guardian := range e.enclaveGuardians {
if guardian.HealthStatus(ctx).OK() {
return guardian
}
}
return nil
}

// 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 (e *Service) LookupBatchBySeqNo(ctx context.Context, seqNo *big.Int) (*common.ExtBatch, error) {
hg := e.HealthyGuardian(ctx)
// todo (@matt) revisit this flow to make sure it handles HA scenarios properly
hg := e.enclaveGuardians[0]
state := hg.GetEnclaveState()
if state.GetEnclaveL2Head().Cmp(seqNo) < 0 {
return nil, errutil.ErrNotFound
Expand Down

0 comments on commit f194d67

Please sign in to comment.