Skip to content
Closed
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
3 changes: 1 addition & 2 deletions config_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ var (
func TestConfigDocs(t *testing.T) {
config, err := docs.GenerateConfig()
assert.NoError(t, err, "invalid config docs")
assert.Equal(t, configMD, config, "docs/CONFIG.md is out of date. Run '"+
"' to regenerate.")
assert.Equal(t, configMD, config, "docs/CONFIG.md is out of date. Run 'make config-docs' to regenerate.")

secrets, err := docs.GenerateSecrets()
assert.NoError(t, err, "invalid secrets docs")
Expand Down
2 changes: 2 additions & 0 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ DefaultTransactionQueueDepth = 1 # Default
SimulateTransactions = false # Default
# TraceLogging enables trace level logging.
TraceLogging = false # Default
# SampleTelemetry enables telemetry sampling.
SampleTelemetry = false # Default
# KeyValueStoreRootDir is the root directory for the key-value store used by OCR3.1.
# This directory must be writable by the Chainlink node process and should support long-term persistence.
KeyValueStoreRootDir = '~/.chainlink-data' # Default
Expand Down
1 change: 1 addition & 0 deletions core/config/ocr2_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type OCR2 interface {
KeyBundleID() (string, error)
// OCR2 config, cannot override in jobs
TraceLogging() bool
SampleTelemetry() bool
CaptureEATelemetry() bool
DefaultTransactionQueueDepth() uint32
SimulateTransactions() bool
Expand Down
4 changes: 4 additions & 0 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,7 @@ type OCR2 struct {
DefaultTransactionQueueDepth *uint32
SimulateTransactions *bool
TraceLogging *bool
SampleTelemetry *bool
KeyValueStoreRootDir *string
}

Expand Down Expand Up @@ -1395,6 +1396,9 @@ func (o *OCR2) setFrom(f *OCR2) {
if v := f.TraceLogging; v != nil {
o.TraceLogging = v
}
if v := f.SampleTelemetry; v != nil {
o.SampleTelemetry = v
}
if v := f.KeyValueStoreRootDir; v != nil {
o.KeyValueStoreRootDir = v
}
Expand Down
4 changes: 4 additions & 0 deletions core/services/chainlink/config_ocr2.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func (o *ocr2Config) TraceLogging() bool {
return *o.c.TraceLogging
}

func (o *ocr2Config) SampleTelemetry() bool {
return *o.c.SampleTelemetry
}

func (o *ocr2Config) CaptureEATelemetry() bool {
return *o.c.CaptureEATelemetry
}
Expand Down
1 change: 1 addition & 0 deletions core/services/chainlink/config_ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestOCR2Config(t *testing.T) {
require.Equal(t, expectedContractSubscribeInterval, ocr2Cfg.ContractSubscribeInterval())
require.False(t, ocr2Cfg.SimulateTransactions())
require.False(t, ocr2Cfg.TraceLogging())
require.False(t, ocr2Cfg.SampleTelemetry())
require.Equal(t, uint32(1), ocr2Cfg.DefaultTransactionQueueDepth())
require.False(t, ocr2Cfg.CaptureEATelemetry())
require.True(t, ocr2Cfg.CaptureAutomationCustomTelemetry())
Expand Down
2 changes: 2 additions & 0 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ func TestConfig_Marshal(t *testing.T) {
DefaultTransactionQueueDepth: ptr[uint32](1),
SimulateTransactions: ptr(false),
TraceLogging: ptr(false),
SampleTelemetry: ptr(false),
KeyValueStoreRootDir: ptr("~/.chainlink-data"),
}
full.OCR = toml.OCR{
Expand Down Expand Up @@ -1129,6 +1130,7 @@ AllowNoBootstrappers = true
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'
`},
{"JobDistributor", Config{Core: toml.Core{JobDistributor: full.JobDistributor}}, `[JobDistributor]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
1 change: 1 addition & 0 deletions core/services/chainlink/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ AllowNoBootstrappers = true
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
2 changes: 2 additions & 0 deletions core/services/feeds/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"

coreconfig "github.com/smartcontractkit/chainlink/v2/core/config"
)

Expand Down Expand Up @@ -42,4 +43,5 @@ type OCR2Config interface {
DefaultTransactionQueueDepth() uint32
SimulateTransactions() bool
TraceLogging() bool
SampleTelemetry() bool
}
2 changes: 2 additions & 0 deletions core/services/llo/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type DelegateConfig struct {

// OCR3
TraceLogging bool
SampleTelemetry bool
BinaryNetworkEndpointFactory ocr2types.BinaryNetworkEndpointFactory
V2Bootstrappers []ocrcommontypes.BootstrapperLocator
// One Oracle will be started for each ContractConfigTracker
Expand Down Expand Up @@ -118,6 +119,7 @@ func NewDelegate(cfg DelegateConfig) (job.ServiceCtx, error) {
CaptureObservationTelemetry: cfg.CaptureObservationTelemetry,
CaptureOutcomeTelemetry: cfg.CaptureOutcomeTelemetry,
CaptureReportTelemetry: cfg.CaptureReportTelemetry,
SampleTelemetry: cfg.SampleTelemetry,
})

ds := observation.NewDataSource(
Expand Down
3 changes: 3 additions & 0 deletions core/services/llo/observation/observation_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ func toUint64(v any) (uint64, error) {
}
}

// TODO this is to return an array of values. maybe a map of streamid->streamval
// map[stream][llo.Streamvalue]

// extractFinalResultAsStreamValue extracts a final StreamValue from a TaskRunResults
func extractFinalResultAsStreamValue(trrs pipeline.TaskRunResults) (llo.StreamValue, error) {
// pipeline.TaskRunResults comes ordered asc by index, this is guaranteed
Expand Down
14 changes: 13 additions & 1 deletion core/services/llo/telem/sampling.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,27 @@ type sampler struct {
samples map[string]map[int32]any
samplesMu sync.Mutex

enabled bool
prunePeriod time.Duration // exists, so we can test pruning
lggr logger.Logger
}

func newSampler(lgger logger.SugaredLogger) *sampler {
func newSampler(lgger logger.SugaredLogger, samplingEnabled bool) *sampler {
return &sampler{
samples: make(map[string]map[int32]any),
enabled: samplingEnabled,
prunePeriod: defaultPrunePeriod,
lggr: lgger,
}
}

// Sample is the method which decides whether we're going to send the data downstream or not.
func (s *sampler) Sample(typ synchronization.TelemetryType, msg proto.Message) bool {
// If sampling is not enabled we want to send each and every telemetry message, so always return true.
if !s.enabled {
return true
}

fp, ots, err := fingerprint(typ, msg)
if err != nil {
if !errors.Is(err, errUnsupportedTelemetryType) {
Expand Down Expand Up @@ -75,6 +82,11 @@ func (s *sampler) Sample(typ synchronization.TelemetryType, msg proto.Message) b
//
// This method is non-blocking. It starts a goroutine and returns.
func (s *sampler) StartPruningLoop(ctx context.Context, wg *sync.WaitGroup) {
// We don't need pruning if sampling is not enabled.
if !s.enabled {
return
}

wg.Add(1)
go func() {
defer wg.Done()
Expand Down
6 changes: 3 additions & 3 deletions core/services/llo/telem/sampling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestSample(t *testing.T) {
lggr := logger.TestSugared(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
samplr := newSampler(lggr)
samplr := newSampler(lggr, true)
samplr.StartPruningLoop(ctx, &sync.WaitGroup{})

t0 := time.Now()
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestPruningLoop(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

samplr := newSampler(lggr)
samplr := newSampler(lggr, true)
// We need a prune time of at least one second in order to detect outdated entries.
// The entries have second-based timestamps and cannot distinguish shorter intervals.
samplr.prunePeriod = time.Second
Expand Down Expand Up @@ -199,7 +199,7 @@ func TestPruningLoop_Exits(t *testing.T) {
wg := &sync.WaitGroup{}

// Start the sampler and its loop. This increments the waitgroup's counter.
samplr := newSampler(lggr)
samplr := newSampler(lggr, true)
samplr.StartPruningLoop(ctx, wg)

// Create a channel which will be closed when the waitgroup is done, i.e. when the loop is closed.
Expand Down
3 changes: 2 additions & 1 deletion core/services/llo/telem/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type TelemeterParams struct {
CaptureObservationTelemetry bool
CaptureOutcomeTelemetry bool
CaptureReportTelemetry bool
SampleTelemetry bool
}

func NewTelemeterService(params TelemeterParams) TelemeterService {
Expand Down Expand Up @@ -78,7 +79,7 @@ func newTelemeter(params TelemeterParams) *telemeter {
}, 10),
currentSeqNr: make(map[string]uint64),
telemetryBuffer: make(map[string]map[uint64][]telemetryEntry),
sampler: newSampler(logger.Sugared(params.Logger)),
sampler: newSampler(logger.Sugared(params.Logger), params.SampleTelemetry),
}
if params.CaptureOutcomeTelemetry {
t.chOutcomeTelemetry = make(chan *datastreamsllo.LLOOutcomeTelemetry, 100) // only one per round so 100 buffer should be more than enough even for very fast rounds
Expand Down
3 changes: 3 additions & 0 deletions core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
ocr2keepers21config "github.com/smartcontractkit/chainlink-automation/pkg/v3/config"
ocr2keepers21 "github.com/smartcontractkit/chainlink-automation/pkg/v3/plugin"
evmconfig "github.com/smartcontractkit/chainlink-evm/pkg/config"

"github.com/smartcontractkit/chainlink/v2/core/capabilities/vault/vaulttypes"
"github.com/smartcontractkit/chainlink/v2/core/config/env"
syncerV2 "github.com/smartcontractkit/chainlink/v2/core/services/workflows/syncer/v2"
Expand Down Expand Up @@ -200,6 +201,7 @@ type ocr2Config interface {
KeyBundleID() (string, error)
SimulateTransactions() bool
TraceLogging() bool
SampleTelemetry() bool
CaptureAutomationCustomTelemetry() bool
AllowNoBootstrappers() bool
KeyValueStoreRootDir() string
Expand Down Expand Up @@ -1447,6 +1449,7 @@ func (d *Delegate) newServicesLLO(
ChainID: rid.ChainID,

TraceLogging: d.cfg.OCR2().TraceLogging(),
SampleTelemetry: d.cfg.OCR2().SampleTelemetry(),
BinaryNetworkEndpointFactory: d.peerWrapper.Peer2,
V2Bootstrappers: bootstrapPeers,
ContractTransmitter: provider.ContractTransmitter(),
Expand Down
1 change: 1 addition & 0 deletions core/services/ocr2/validate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type OCR2Config interface {
DefaultTransactionQueueDepth() uint32
SimulateTransactions() bool
TraceLogging() bool
SampleTelemetry() bool
}

type InsecureConfig interface {
Expand Down
1 change: 1 addition & 0 deletions core/web/resolver/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
1 change: 1 addition & 0 deletions core/web/resolver/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ AllowNoBootstrappers = true
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
7 changes: 7 additions & 0 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ AllowNoBootstrappers = false # Default
DefaultTransactionQueueDepth = 1 # Default
SimulateTransactions = false # Default
TraceLogging = false # Default
SampleTelemetry = false # Default
KeyValueStoreRootDir = '~/.chainlink-data' # Default
```

Expand Down Expand Up @@ -1140,6 +1141,12 @@ TraceLogging = false # Default
```
TraceLogging enables trace level logging.

### SampleTelemetry
```toml
SampleTelemetry = false # Default
```
SampleTelemetry enables telemetry sampling.

### KeyValueStoreRootDir
```toml
KeyValueStoreRootDir = '~/.chainlink-data' # Default
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/config/merge_raw_configs.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/default.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/defaults-override.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/disk-based-logging.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/fallback-override.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/invalid-ocr-p2p.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/invalid.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/valid.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/warnings.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ AllowNoBootstrappers = false
DefaultTransactionQueueDepth = 1
SimulateTransactions = false
TraceLogging = false
SampleTelemetry = false
KeyValueStoreRootDir = '~/.chainlink-data'

[OCR]
Expand Down
Loading