Skip to content

Commit

Permalink
move config
Browse files Browse the repository at this point in the history
  • Loading branch information
bukata-sa committed Jul 30, 2024
1 parent f2216b5 commit 6a2553e
Show file tree
Hide file tree
Showing 42 changed files with 194 additions and 234 deletions.
5 changes: 5 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ packages:
interfaces:
Config:
FeeConfig:
github.com/smartcontractkit/chainlink/v2/core/services/telemetry:
config:
dir: "{{ .InterfaceDir }}/../../internal/mocks"
interfaces:
MonitoringEndpointGenerator:
github.com/smartcontractkit/chainlink/v2/core/services/webhook:
interfaces:
ExternalInitiatorManager:
Expand Down
1 change: 1 addition & 0 deletions common/headtracker/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ type HeadTrackerConfig interface {
SamplingInterval() time.Duration
FinalityTagBypass() bool
MaxAllowedFinalityDepth() uint32
HeadTelemetryEnabled() bool
}
4 changes: 4 additions & 0 deletions core/chains/evm/config/chain_scoped_head_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ func (h *headTrackerConfig) FinalityTagBypass() bool {
func (h *headTrackerConfig) MaxAllowedFinalityDepth() uint32 {
return *h.c.MaxAllowedFinalityDepth
}

func (h *headTrackerConfig) HeadTelemetryEnabled() bool {
return *h.c.HeadTelemetryEnabled
}
1 change: 1 addition & 0 deletions core/chains/evm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type HeadTracker interface {
SamplingInterval() time.Duration
FinalityTagBypass() bool
MaxAllowedFinalityDepth() uint32
HeadTelemetryEnabled() bool
}

type BalanceMonitor interface {
Expand Down
4 changes: 4 additions & 0 deletions core/chains/evm/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ type HeadTracker struct {
SamplingInterval *commonconfig.Duration
MaxAllowedFinalityDepth *uint32
FinalityTagBypass *bool
HeadTelemetryEnabled *bool
}

func (t *HeadTracker) setFrom(f *HeadTracker) {
Expand All @@ -765,6 +766,9 @@ func (t *HeadTracker) setFrom(f *HeadTracker) {
if v := f.FinalityTagBypass; v != nil {
t.FinalityTagBypass = v
}
if v := f.HeadTelemetryEnabled; v != nil {
t.HeadTelemetryEnabled = v
}
}

func (t *HeadTracker) ValidateConfig() (err error) {
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/config/toml/defaults/fallback.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ MaxBufferSize = 3
SamplingInterval = '1s'
FinalityTagBypass = true
MaxAllowedFinalityDepth = 10000
HeadTelemetryEnabled = false

[NodePool]
PollFailureThreshold = 5
Expand Down
3 changes: 3 additions & 0 deletions core/chains/evm/headtracker/head_saver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ func (h *headTrackerConfig) FinalityTagBypass() bool {
func (h *headTrackerConfig) MaxAllowedFinalityDepth() uint32 {
return 10000
}
func (h *headTrackerConfig) HeadTelemetryEnabled() bool {
return false
}

type config struct {
finalityDepth uint32
Expand Down
3 changes: 1 addition & 2 deletions core/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"sync"
"time"

"github.com/smartcontractkit/chainlink/v2/core/services/telemetry"

"github.com/Depado/ginprom"
"github.com/Masterminds/semver/v3"
"github.com/getsentry/sentry-go"
Expand Down Expand Up @@ -48,6 +46,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/periodicbackup"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc/cache"
"github.com/smartcontractkit/chainlink/v2/core/services/telemetry"
"github.com/smartcontractkit/chainlink/v2/core/services/versioning"
"github.com/smartcontractkit/chainlink/v2/core/services/webhook"
"github.com/smartcontractkit/chainlink/v2/core/sessions"
Expand Down
1 change: 0 additions & 1 deletion core/config/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type AppConfig interface {
Pyroscope() Pyroscope
Sentry() Sentry
TelemetryIngress() TelemetryIngress
HeadReport() HeadReport
Threshold() Threshold
WebServer() WebServer
Tracing() Tracing
Expand Down
2 changes: 2 additions & 0 deletions core/config/docs/chains-evm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ FinalityTagBypass = true # Default
# If actual finality depth exceeds this number, HeadTracker aborts backfill and returns an error.
# Has no effect if `FinalityTagsEnabled` = false
MaxAllowedFinalityDepth = 10000 # Default
# HeadTelemetryEnabled controls if it collects information about new blocks from blockchain
HeadTelemetryEnabled = false # Default

[[EVM.KeySpecific]]
# Key is the account to apply these settings to
Expand Down
6 changes: 1 addition & 5 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,4 @@ TransmitQueueMaxSize = 10_000 # Default
# TransmitTimeout controls how long the transmitter will wait for a response
# when sending a message to the mercury server, before aborting and considering
# the transmission to be failed.
TransmitTimeout = "5s" # Default

[HeadReport]
# TelemetryEnabled controls if it collects information about new blocks from blockchain
TelemetryEnabled = false # Default
TransmitTimeout = "5s" # Default
5 changes: 0 additions & 5 deletions core/config/head_report_config.go

This file was deleted.

12 changes: 0 additions & 12 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ type Core struct {
Insecure Insecure `toml:",omitempty"`
Tracing Tracing `toml:",omitempty"`
Mercury Mercury `toml:",omitempty"`
HeadReport HeadReport `toml:",omitempty"`
Capabilities Capabilities `toml:",omitempty"`
}

Expand All @@ -77,7 +76,6 @@ func (c *Core) SetFrom(f *Core) {
c.TelemetryIngress.setFrom(&f.TelemetryIngress)
c.AuditLogger.SetFrom(&f.AuditLogger)
c.Log.setFrom(&f.Log)
c.HeadReport.setFrom(&f.HeadReport)

c.WebServer.setFrom(&f.WebServer)
c.JobPipeline.setFrom(&f.JobPipeline)
Expand Down Expand Up @@ -487,16 +485,6 @@ func (t *TelemetryIngress) setFrom(f *TelemetryIngress) {
}
}

type HeadReport struct {
TelemetryEnabled *bool
}

func (t *HeadReport) setFrom(f *HeadReport) {
if v := f.TelemetryEnabled; v != nil {
t.TelemetryEnabled = v
}
}

type AuditLogger struct {
Enabled *bool
ForwardToUrl *commonconfig.URL
Expand Down
3 changes: 1 addition & 2 deletions core/internal/cltest/cltest.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"testing"
"time"

"github.com/smartcontractkit/chainlink/v2/core/services/telemetry"

"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -82,6 +80,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc/cache"
"github.com/smartcontractkit/chainlink/v2/core/services/telemetry"
"github.com/smartcontractkit/chainlink/v2/core/services/webhook"
clsessions "github.com/smartcontractkit/chainlink/v2/core/sessions"
"github.com/smartcontractkit/chainlink/v2/core/static"
Expand Down
8 changes: 3 additions & 5 deletions core/internal/cltest/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ import (
"testing"
"time"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"

"github.com/jmoiron/sqlx"

evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr"
evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm"
evmmocks "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm/mocks"
"github.com/smartcontractkit/chainlink/v2/core/cmd"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
Expand Down
88 changes: 88 additions & 0 deletions core/internal/mocks/monitoring_endpoint_generator.go

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

6 changes: 0 additions & 6 deletions core/services/chainlink/config_general.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,6 @@ func (g *generalConfig) RootDir() string {
return h
}

func (g *generalConfig) HeadReport() coreconfig.HeadReport {
return &headReport{
h: g.c.HeadReport,
}
}

func (g *generalConfig) TelemetryIngress() coreconfig.TelemetryIngress {
return &telemetryIngressConfig{
c: g.c.TelemetryIngress,
Expand Down
1 change: 0 additions & 1 deletion core/services/chainlink/config_general_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func TestTOMLGeneralConfig_Defaults(t *testing.T) {
assert.False(t, config.StarkNetEnabled())
assert.Equal(t, false, config.JobPipeline().ExternalInitiatorsEnabled())
assert.Equal(t, 15*time.Minute, config.WebServer().SessionTimeout().Duration())
assert.Equal(t, false, config.HeadReport().TelemetryEnabled())
}

func TestTOMLGeneralConfig_InsecureConfig(t *testing.T) {
Expand Down
13 changes: 0 additions & 13 deletions core/services/chainlink/config_head_report.go

This file was deleted.

18 changes: 0 additions & 18 deletions core/services/chainlink/config_head_report_test.go

This file was deleted.

8 changes: 2 additions & 6 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ func TestConfig_Marshal(t *testing.T) {
SamplingInterval: &hour,
FinalityTagBypass: ptr[bool](false),
MaxAllowedFinalityDepth: ptr[uint32](1500),
HeadTelemetryEnabled: ptr[bool](true),
},

NodePool: evmcfg.NodePool{
Expand Down Expand Up @@ -732,9 +733,6 @@ func TestConfig_Marshal(t *testing.T) {
},
VerboseLogging: ptr(true),
}
full.HeadReport = toml.HeadReport{
TelemetryEnabled: ptr(true),
}
for _, tt := range []struct {
name string
config Config
Expand Down Expand Up @@ -1055,6 +1053,7 @@ MaxBufferSize = 17
SamplingInterval = '1h0m0s'
MaxAllowedFinalityDepth = 1500
FinalityTagBypass = false
HeadTelemetryEnabled = true
[[EVM.KeySpecific]]
Key = '0x2a3e23c6f242F5345320814aC8a1b4E58707D292'
Expand Down Expand Up @@ -1204,9 +1203,6 @@ CertFile = '/path/to/cert.pem'
[Mercury.Transmitter]
TransmitQueueMaxSize = 123
TransmitTimeout = '3m54s'
`},
{"HeadReport", Config{Core: toml.Core{HeadReport: full.HeadReport}}, `[HeadReport]
TelemetryEnabled = true
`},
{"full", full, fullTOML},
{"multi-chain", multiChain, multiChainTOML},
Expand Down
Loading

0 comments on commit 6a2553e

Please sign in to comment.