Skip to content
Closed
Show file tree
Hide file tree
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
32 changes: 30 additions & 2 deletions offchainreporting2/reportingplugin/median/median.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ type OffchainConfig struct {
// NumericalMedianFactory has the same effect; if either flag is true,
// the condition applies.
AcceptAfterFullTransmissionScheduleElapsed bool
// If BuildReportDespiteContractReadError is true and MedianContract reads
// return an error, Report will return that a report should be built. "If
// in doubt, report!"
//
// Be careful setting this. It can cause increased transaction load and
// costs.
BuildReportDespiteContractReadError bool
}

func DecodeOffchainConfig(b []byte) (OffchainConfig, error) {
Expand All @@ -144,6 +151,7 @@ func DecodeOffchainConfig(b []byte) (OffchainConfig, error) {
time.Duration(configProto.GetDeltaCNanoseconds()),
configProto.GetTransmitDespiteContractReadError(),
configProto.GetAcceptAfterFullTransmissionScheduleElapsed(),
configProto.GetBuildReportDespiteContractReadError(),
}, nil
}

Expand All @@ -161,6 +169,7 @@ func (c OffchainConfig) Encode() []byte {
uint64(c.DeltaC),
c.TransmitDespiteContractReadError,
c.AcceptAfterFullTransmissionScheduleElapsed,
c.BuildReportDespiteContractReadError,
}
result, err := proto.Marshal(&configProto)
if err != nil {
Expand Down Expand Up @@ -611,11 +620,22 @@ func (nm *numericalMedian) shouldReport(ctx context.Context, repts types.ReportT
})
subs.Wait()

buildDespiteContractReadError := false
if err := errors.Join(resultTransmissionDetails.err, resultRoundRequested.err); err != nil {
return false, fmt.Errorf("error during LatestTransmissionDetails/LatestRoundRequested: %w", err)
if nm.offchainConfig.BuildReportDespiteContractReadError {
buildDespiteContractReadError = true
nm.logger.Error("error during LatestTransmissionDetails/LatestRoundRequested", commontypes.LogFields{
"error": err,
"timestamp": repts,
})
// We intentionally do not return an error here.
} else {
return false, fmt.Errorf("error during LatestTransmissionDetails/LatestRoundRequested: %w", err)
}
}

if resultTransmissionDetails.latestAnswer == nil {
// On a contract read error, latestAnswer is legitimately nil.
if !buildDespiteContractReadError && resultTransmissionDetails.latestAnswer == nil {
return false, fmt.Errorf("nil latestAnswer was returned by LatestTransmissionDetails. This should never happen")
}

Expand All @@ -636,6 +656,14 @@ func (nm *numericalMedian) shouldReport(ctx context.Context, repts types.ReportT
return false, nil
}

// The branches below depend on the contract read, which errored.
if buildDespiteContractReadError {
nm.logger.Info("shouldReport: yes, because of BuildReportDespiteContractReadError", commontypes.LogFields{
"result": true,
})
return true, nil
}

initialRound := // Is this the first round for this configuration?
resultTransmissionDetails.configDigest == repts.ConfigDigest &&
resultTransmissionDetails.epoch == 0 &&
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions offchainreporting2plus/confighelper/confighelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func ContractSetConfigArgsForEthereumIntegrationTest(
0,
false,
false,
false,
}.Encode(),
util.PointerTo(50 * time.Millisecond),
50 * time.Millisecond,
Expand Down
Loading