From 2815d3757afb7ff41b851022ca04a8c5ab626ca6 Mon Sep 17 00:00:00 2001 From: Fergal Gribben Date: Tue, 2 Jul 2024 20:51:31 +0100 Subject: [PATCH] Update comments --- .../evmregistry/v21/logprovider/buffer_v1.go | 17 ++++++++--------- .../evmregistry/v21/logprovider/provider.go | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider/buffer_v1.go b/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider/buffer_v1.go index f745fed67c2..a404517ac88 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider/buffer_v1.go +++ b/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider/buffer_v1.go @@ -22,10 +22,10 @@ type LogBuffer interface { Enqueue(id *big.Int, logs ...logpoller.Log) (added int, dropped int) // Dequeue pulls logs from the buffer that are within the given block window, // with a maximum number of logs per upkeep and a total maximum number of logs to return. - // It also accepts a function to select upkeeps. + // It also accepts a boolean to identify if we are operating under minimum dequeue. // Returns logs (associated to upkeeps) and the number of remaining // logs in that window for the involved upkeeps. - Dequeue(start, end int64, upkeepLimit, maxResults int, bestEffort bool) ([]BufferedLog, int) + Dequeue(start, end int64, upkeepLimit, maxResults int, minimumDequeue bool) ([]BufferedLog, int) // SetConfig sets the buffer size and the maximum number of logs to keep for each upkeep. SetConfig(lookback, blockRate, logLimit uint32) // NumOfUpkeeps returns the number of upkeeps that are being tracked by the buffer. @@ -160,20 +160,19 @@ func (b *logBuffer) Dequeue(start, end int64, upkeepLimit, maxResults int, bestE return b.dequeue(start, end, upkeepLimit, maxResults, bestEffort) } -// dequeue pulls logs from the buffers, depends the given selector (upkeepSelector), -// in block range [start,end] with minimum number of results per upkeep (upkeepLimit) -// and the maximum number of results (capacity). +// dequeue pulls logs from the buffers, in block range [start,end] with minimum number +// of results per upkeep (upkeepLimit) and the maximum number of results (capacity). +// If operating under minimum dequeue, upkeeps are skipped when the minimum number +// of logs have been dequeued for that upkeep. // Returns logs and the number of remaining logs in the buffer for the given range and selector. // NOTE: this method is not thread safe and should be called within a lock. -func (b *logBuffer) dequeue(start, end int64, upkeepLimit, capacity int, bestEffort bool) ([]BufferedLog, int) { +func (b *logBuffer) dequeue(start, end int64, upkeepLimit, capacity int, minimumDequeue bool) ([]BufferedLog, int) { var result []BufferedLog var remainingLogs int for _, qid := range b.queueIDs { q := b.queues[qid] - if bestEffort { - upkeepLimit = capacity - } else if q.dequeued[start] >= upkeepLimit { + if minimumDequeue && q.dequeued[start] >= upkeepLimit { // if we have already dequeued the minimum commitment for this window, skip it continue } diff --git a/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider/provider.go b/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider/provider.go index 83b56187515..48cc657111c 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider/provider.go +++ b/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider/provider.go @@ -292,7 +292,7 @@ func (p *logEventProvider) minimumCommitmentDequeue(latestBlock, start int64) [] startWindow, end := getBlockWindow(start, blockRate) // dequeue the minimum number logs (log limit, varies by chain) per upkeep for this block window - logs, remaining := p.bufferV1.Dequeue(startWindow, end, int(p.opts.LogLimit), MaxPayloads-len(payloads), false) + logs, remaining := p.bufferV1.Dequeue(startWindow, end, int(p.opts.LogLimit), MaxPayloads-len(payloads), true) if len(logs) > 0 { p.lggr.Debugw("Dequeued logs", "start", start, "latestBlock", latestBlock, "logs", len(logs), "remaining", remaining) } @@ -318,7 +318,7 @@ func (p *logEventProvider) bestEffortDequeue(latestBlock, start int64, payloads startWindow, end := getBlockWindow(start, blockRate) // dequeue as many logs as we can, based on remaining capacity, for this block window - logs, remaining := p.bufferV1.Dequeue(startWindow, end, MaxPayloads-len(payloads), MaxPayloads-len(payloads), true) + logs, remaining := p.bufferV1.Dequeue(startWindow, end, MaxPayloads-len(payloads), MaxPayloads-len(payloads), false) if len(logs) > 0 { p.lggr.Debugw("Dequeued logs", "start", start, "latestBlock", latestBlock, "logs", len(logs), "remaining", remaining) }