Skip to content

Commit

Permalink
Applies default to missing config
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzaldysanchez committed Feb 6, 2025
1 parent 8eaabed commit f1f3074
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 32 deletions.
26 changes: 26 additions & 0 deletions pkg/capabilities/consensus/ocr3/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/services"
)

const (
defaultMaxPhaseOutputBytes = 1000000 // 1 MB
defaultMaxReportCount = 20
)

type factory struct {
store *requests.Store
capability *capability
Expand All @@ -37,6 +42,27 @@ func (o *factory) NewReportingPlugin(_ context.Context, config ocr3types.Reporti
if err != nil {
return nil, ocr3types.ReportingPluginInfo{}, err
}
if configProto.MaxQueryLengthBytes <= 0 {
configProto.MaxQueryLengthBytes = defaultMaxPhaseOutputBytes
}
if configProto.MaxObservationLengthBytes <= 0 {
configProto.MaxObservationLengthBytes = defaultMaxPhaseOutputBytes
}
if configProto.MaxOutcomeLengthBytes <= 0 {
configProto.MaxOutcomeLengthBytes = defaultMaxPhaseOutputBytes
}
if configProto.MaxReportLengthBytes <= 0 {
configProto.MaxReportLengthBytes = defaultMaxPhaseOutputBytes
}
if configProto.MaxBatchSize <= 0 {
configProto.MaxBatchSize = defaultBatchSize
}
if configProto.OutcomePruningThreshold <= 0 {
configProto.OutcomePruningThreshold = defaultOutcomePruningThreshold
}
if configProto.MaxReportCount <= 0 {
configProto.MaxReportCount = defaultMaxReportCount
}
rp, err := newReportingPlugin(o.store, o.capability, int(configProto.MaxBatchSize), config, configProto.OutcomePruningThreshold, o.lggr)
rpInfo := ocr3types.ReportingPluginInfo{
Name: "OCR3 Capability Plugin",
Expand Down
48 changes: 19 additions & 29 deletions pkg/capabilities/consensus/ocr3/types/ocr3_config_types.pb.go

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

5 changes: 2 additions & 3 deletions pkg/capabilities/consensus/ocr3/types/ocr3_config_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ package ocr3_config_types;
message ReportingPluginConfig {
uint32 maxQueryLengthBytes = 1;
uint32 maxObservationLengthBytes = 2;
uint32 maxReportLengthBytes = 3;
uint32 maxOutcomeLengthBytes = 4;
uint32 maxOutcomeLengthBytes = 3;
uint32 maxReportLengthBytes = 4;
uint32 maxReportCount = 5;
uint32 maxBatchSize = 6;
uint64 outcomePruningThreshold = 7;
bool uniqueReports = 8;
}

0 comments on commit f1f3074

Please sign in to comment.