Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host: fix nil pointer when enclave not healthy #1917

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading