Skip to content
Draft
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
25 changes: 8 additions & 17 deletions pkg/workflows/dontime/pb/dontime.pb.go

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

3 changes: 1 addition & 2 deletions pkg/workflows/dontime/pb/dontime.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ option go_package = "github.com/smartcontractkit/chainlink-common/pkg/workflows/
message Observation {
int64 timestamp = 1;
map<string, int64> requests = 2;
reserved 3;
bool limit_by_batch_size_flag = 4;
reserved 3, 4;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit/ is this more desirable than using [deprecated = true]? Because deprecation would be a bit safer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think there's no need to leave the old names around if nobody uses them. What makes it safer?

}

message ObservedDonTimes {
Expand Down
5 changes: 2 additions & 3 deletions pkg/workflows/dontime/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ func (p *Plugin) Observation(ctx context.Context, outctx ocr3types.OutcomeContex
p.metrics.observationBatchOverflow.Record(ctx, int64(overflowCount))

observation := &pb.Observation{
Timestamp: time.Now().UTC().UnixMilli(),
Requests: requests,
LimitByBatchSizeFlag: true,
Timestamp: time.Now().UTC().UnixMilli(),
Requests: requests,
}

return proto.MarshalOptions{Deterministic: true}.Marshal(observation)
Expand Down
11 changes: 5 additions & 6 deletions pkg/workflows/dontime/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,12 @@ func TestPlugin_Outcome_TrimByBatchSize(t *testing.T) {
require.NoError(t, err)

timestamp := time.Now().UnixMilli()
makeObservations := func(limitByBatchSize bool) []types.AttributedObservation {
makeObservations := func() []types.AttributedObservation {
aos := make([]types.AttributedObservation, 4)
for i := range 4 {
obs := &pb.Observation{
Timestamp: timestamp + int64(i),
Requests: map[string]int64{},
LimitByBatchSizeFlag: limitByBatchSize,
Timestamp: timestamp + int64(i),
Requests: map[string]int64{},
}
rawObs, err := proto.Marshal(obs)
require.NoError(t, err)
Expand All @@ -590,8 +589,8 @@ func TestPlugin_Outcome_TrimByBatchSize(t *testing.T) {
prevOutcomeBytes, err := proto.Marshal(prevOutcome)
require.NoError(t, err)

t.Run("trims when all observations set batch size flag", func(t *testing.T) {
outcome, err := plugin.Outcome(ctx, ocr3types.OutcomeContext{PreviousOutcome: prevOutcomeBytes}, query, makeObservations(true))
t.Run("trims observed don times exceeding batch size", func(t *testing.T) {
outcome, err := plugin.Outcome(ctx, ocr3types.OutcomeContext{PreviousOutcome: prevOutcomeBytes}, query, makeObservations())
require.NoError(t, err)

outcomeProto := &pb.Outcome{}
Expand Down
Loading