Skip to content

Commit

Permalink
New log buffer (#12357)
Browse files Browse the repository at this point in the history
* block window utilities

* new buffer (wip)

* integrate log buffer in the provider (wip)

* review fixes:

- comments
- renaming
- new(atomic.Intxx)
- sizeOfWindow(end,start)

* test fix

* clear unused function

* provider integration tests for multiple versions of the buffer

* rename to v1

* fix v1 and add logs

* temp enablement of v1 buffer

* added unit tests

* fix slice alloc

* avoid alloc with cap

* tweak limit values

* config and handle remaining

* trying different config

* fix comparator and block window

* fix redundant import

* sort once instead of maintaining sorted sliced

* align config

* fix tests and set config

* fixes & logs

* custom cla with optmized hook

* lint

* use defer in tests

* update cla version

* Go mod tidy

* alignments

- buffer config
- remove redundant logic in buffer.Dequeue
- remove commented code
- added logs
- renaming
- comments
- remove old rate limiter

* tests

* small fixes in int test

* handle large number of upkeeps (up to max_results)

TODO: handle the case the number is larger than max_results

* update cla version

* tests

* fix logs ordering function to treat tx hash if log index is equal

* Feature flag for new log buffer (#12653)

* feature flag useBufferV1

* changesets

* align enum

* changesets

* Revert "update cla version"

This reverts commit e3c58e5.

* align buffer config

* align buffer metrics

(added label expired)

* update cla version (temp)

* lint

* set feature flag in load test (temp)

* update cla version

* types alignment

* Revert "set feature flag in load test (temp)"

This reverts commit 7b097e5.

* comment

* remove wrong assertion

* alignments:

- log states in buffer
- renaming of vars
- types

* lint

* review

* review:

- result 1 or -1

* normalize compare result

* linked TODOs

* review fix

* lock while SetConfig

* remove redundant defaulting

* align trigger states + comments

* fix func name

---------

Co-authored-by: Fergal Gribben <[email protected]>
  • Loading branch information
amirylm and ferglor authored Apr 8, 2024
1 parent b74079b commit a532acc
Show file tree
Hide file tree
Showing 18 changed files with 1,778 additions and 655 deletions.
7 changes: 7 additions & 0 deletions .changeset/pretty-experts-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"chainlink": patch
---

Added log buffer v1 with improved performance, stability and control over scaling parameters.

Added a feature flag for using log buffer v1.
9 changes: 9 additions & 0 deletions core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/autotelemetry21"
ocr2keeper21core "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/core"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider"
ocr2vrfconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2vrf/config"
ocr2coordinator "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2vrf/coordinator"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2vrf/juelsfeecoin"
Expand Down Expand Up @@ -1313,6 +1314,14 @@ func (d *Delegate) newServicesOCR2Keepers21(
return nil, errors.New("could not coerce PluginProvider to AutomationProvider")
}

// TODO: (AUTO-9355) remove once we remove v0
if useBufferV1 := cfg.UseBufferV1 != nil && *cfg.UseBufferV1; useBufferV1 {
logProviderFeatures, ok := keeperProvider.LogEventProvider().(logprovider.LogEventProviderFeatures)
if ok {
logProviderFeatures.WithBufferVersion("v1")
}
}

services, err := ocr2keeper.EVMDependencies21(kb)
if err != nil {
return nil, errors.Wrap(err, "could not build dependencies for ocr2 keepers")
Expand Down
3 changes: 3 additions & 0 deletions core/services/ocr2/plugins/ocr2keeper/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type PluginConfig struct {
ContractVersion string `json:"contractVersion"`
// CaptureAutomationCustomTelemetry is a bool flag to toggle Custom Telemetry Service
CaptureAutomationCustomTelemetry *bool `json:"captureAutomationCustomTelemetry,omitempty"`
// UseBufferV1 is a bool flag to toggle the new log buffer implementation
// TODO: (AUTO-9355) remove once we have a single version
UseBufferV1 *bool `json:"useBufferV1,omitempty"`
}

func ValidatePluginConfig(cfg PluginConfig) error {
Expand Down
Loading

0 comments on commit a532acc

Please sign in to comment.