Skip to content

Commit

Permalink
Return empty report when merkleroots not generated
Browse files Browse the repository at this point in the history
Signed-off-by: asoliman <[email protected]>
  • Loading branch information
asoliman92 committed Sep 4, 2024
1 parent cb5eabf commit 0f4b0dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
12 changes: 8 additions & 4 deletions commit/merkleroot/outcome.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,22 @@ func (w *Processor) getOutcome(
return Outcome{}, nextState
}

var outcome Outcome
switch nextState {
case SelectingRangesForReport:
return reportRangesOutcome(query, consensusObservation), nextState
outcome = reportRangesOutcome(query, consensusObservation)
case BuildingReport:
return buildReport(query, consensusObservation, previousOutcome), nextState
outcome = buildReport(query, consensusObservation, previousOutcome)
case WaitingForReportTransmission:
return checkForReportTransmission(
w.lggr, w.cfg.MaxReportTransmissionCheckAttempts, previousOutcome, consensusObservation), nextState
outcome = checkForReportTransmission(
w.lggr, w.cfg.MaxReportTransmissionCheckAttempts, previousOutcome, consensusObservation)
default:
w.lggr.Warnw("Unexpected next state in Outcome", "state", nextState)
return Outcome{}, nextState
}

outcome.Sort()
return outcome, nextState
}

// reportRangesOutcome determines the sequence number ranges for each chain to build a report from in the next round
Expand Down
6 changes: 3 additions & 3 deletions commit/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func (p *Plugin) Reports(seqNr uint64, outcomeBytes ocr3types.Outcome) ([]ocr3ty
}

// Until we start adding tokens and gas to the report, we don't need to report anything
//if outcome.MerkleOutcome.OutcomeType != merkleroot.ReportGenerated {
// return []ocr3types.ReportWithInfo[[]byte]{}, nil
//}
if outcome.MerkleOutcome.OutcomeType != merkleroot.ReportGenerated {
return []ocr3types.ReportWithInfo[[]byte]{}, nil
}

rep := cciptypes.NewCommitPluginReport(
outcome.MerkleOutcome.RootsToReport,
Expand Down
5 changes: 0 additions & 5 deletions commit/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ type Outcome struct {

// Encode encodes an Outcome deterministically
func (o Outcome) Encode() ([]byte, error) {

// Sort all outcomes to ensure deterministic serialization
o.MerkleOutcome.Sort()
o.TokensOutcome.Sort()

encodedOutcome, err := json.Marshal(o)
if err != nil {
return nil, fmt.Errorf("failed to encode Outcome: %w", err)
Expand Down

0 comments on commit 0f4b0dd

Please sign in to comment.