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

Add overall limit on sampled upkeeps #264

Merged
merged 2 commits into from
Sep 6, 2023
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
6 changes: 6 additions & 0 deletions pkg/v3/flows/conditional.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
const (
// This is the ticker interval for sampling conditional flow
SamplingConditionInterval = 3 * time.Second
// Maximum number of upkeeps to be sampled in every round
MaxSampledConditionals = 300
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this isn't used outside this package I would lower case it so that it's not exported

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, but currently i would prefer to keep it consistent with other consts in package (which are also used just within the package but capitalised)

// This is the ticker interval for final conditional flow
FinalConditionalInterval = 1 * time.Second
// These are the maximum number of conditional upkeeps dequeued on every tick from proposal queue in FinalConditionalFlow
Expand Down Expand Up @@ -91,6 +93,10 @@ func (s *sampler) Value(ctx context.Context) ([]ocr2keepers.UpkeepPayload, error
if size <= 0 {
return nil, nil
}
if size > MaxSampledConditionals {
s.logger.Printf("Required sample size %d exceeds max allowed conditional samples %d, limiting to max", size, MaxSampledConditionals)
size = MaxSampledConditionals
}
if len(upkeeps) < size {
size = len(upkeeps)
}
Expand Down