From 10ecf427758ee42e5545baf41d0c6bbaef589068 Mon Sep 17 00:00:00 2001 From: Mateusz Sekara Date: Mon, 2 Sep 2024 12:47:34 +0200 Subject: [PATCH] Adding missing prom reporter. Post merge fixes --- .mockery.yaml | 8 +- .../gas-snapshots/functions.gas-snapshot | 18 +- core/internal/cltest/cltest.go | 2 + core/internal/mocks/prometheus_backend.go | 204 ++++++++++++++++++ core/services/chainlink/application.go | 60 +++--- core/services/headreporter/head_reporter.go | 111 ---------- .../headreporter/head_reporter_mock.go | 130 ----------- .../headreporter/head_reporter_test.go | 51 ----- core/services/headreporter/helper_test.go | 5 - .../headreporter/prometheus_backend_mock.go | 204 ------------------ .../headreporter/telemetry_reporter.go | 69 ------ .../headreporter/telemetry_reporter_test.go | 108 ---------- .../ccip/testhelpers/integration/chainlink.go | 8 +- .../testhelpers_1_4_0/chainlink.go | 8 +- .../prom_reporter.go} | 168 +++++++++++---- .../prom_reporter_test.go} | 172 ++++++++------- core/web/testdata/body/health.html | 6 +- core/web/testdata/body/health.json | 18 +- core/web/testdata/body/health.txt | 2 +- integration-tests/go.mod | 1 - integration-tests/go.sum | 2 - integration-tests/load/go.mod | 21 +- integration-tests/load/go.sum | 42 +--- testdata/scripts/health/default.txtar | 20 +- testdata/scripts/health/multi-chain.txtar | 20 +- 25 files changed, 515 insertions(+), 943 deletions(-) create mode 100644 core/internal/mocks/prometheus_backend.go delete mode 100644 core/services/headreporter/head_reporter.go delete mode 100644 core/services/headreporter/head_reporter_mock.go delete mode 100644 core/services/headreporter/head_reporter_test.go delete mode 100644 core/services/headreporter/helper_test.go delete mode 100644 core/services/headreporter/prometheus_backend_mock.go delete mode 100644 core/services/headreporter/telemetry_reporter.go delete mode 100644 core/services/headreporter/telemetry_reporter_test.go rename core/services/{headreporter/prometheus_reporter.go => promreporter/prom_reporter.go} (63%) rename core/services/{headreporter/prometheus_reporter_test.go => promreporter/prom_reporter_test.go} (64%) diff --git a/.mockery.yaml b/.mockery.yaml index 6e56f27795..34b886d187 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -258,14 +258,10 @@ packages: ORM: Runner: PipelineParamUnmarshaler: - github.com/smartcontractkit/chainlink/v2/core/services/headreporter: + github.com/smartcontractkit/chainlink/v2/core/services/promreporter: config: - dir: "{{ .InterfaceDir }}" - filename: "{{ .InterfaceName | snakecase }}_mock.go" - inpackage: true - mockname: "Mock{{ .InterfaceName | camelcase }}" + dir: core/internal/mocks interfaces: - HeadReporter: PrometheusBackend: github.com/smartcontractkit/libocr/commontypes: config: diff --git a/contracts/gas-snapshots/functions.gas-snapshot b/contracts/gas-snapshots/functions.gas-snapshot index 44d557ebcf..69e0271684 100644 --- a/contracts/gas-snapshots/functions.gas-snapshot +++ b/contracts/gas-snapshots/functions.gas-snapshot @@ -45,7 +45,7 @@ FunctionsCoordinator_SetDONPublicKey:test_SetDONPublicKey_Success() (gas: 88970) FunctionsCoordinator_SetThresholdPublicKey:test_SetThresholdPublicKey_RevertNotOwner() (gas: 13915) FunctionsCoordinator_SetThresholdPublicKey:test_SetThresholdPublicKey_Success() (gas: 513165) FunctionsCoordinator_StartRequest:test_StartRequest_RevertIfNotRouter() (gas: 22802) -FunctionsCoordinator_StartRequest:test_StartRequest_Success() (gas: 150150) +FunctionsCoordinator_StartRequest:test_StartRequest_Success() (gas: 152650) FunctionsCoordinator__IsTransmitter:test__IsTransmitter_SuccessFound() (gas: 15106) FunctionsCoordinator__IsTransmitter:test__IsTransmitter_SuccessNotFound() (gas: 22916) FunctionsRequest_DEFAULT_BUFFER_SIZE:test_DEFAULT_BUFFER_SIZE() (gas: 3089) @@ -200,7 +200,7 @@ FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_ FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_RevertIfBlockedSender() (gas: 89013) FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_RevertIfInvalidSigner() (gas: 23620) FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_RevertIfRecipientContractIsNotSender() (gas: 1866619) -FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_RevertIfRecipientIsNotSender() (gas: 26026) +FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_RevertIfRecipientIsNotSender() (gas: 28526) FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_SuccessIfAcceptingForContract() (gas: 1946966) FunctionsTermsOfServiceAllowList_AcceptTermsOfService:test_AcceptTermsOfService_SuccessIfAcceptingForSelf() (gas: 104555) FunctionsTermsOfServiceAllowList_BlockSender:test_BlockSender_RevertIfNotOwner() (gas: 15535) @@ -232,10 +232,10 @@ FunctionsTermsOfServiceAllowList_UpdateConfig:test_UpdateConfig_Success() (gas: Gas_AcceptTermsOfService:test_AcceptTermsOfService_Gas() (gas: 84725) Gas_AddConsumer:test_AddConsumer_Gas() (gas: 79140) Gas_CreateSubscription:test_CreateSubscription_Gas() (gas: 73419) -Gas_FulfillRequest_DuplicateRequestID:test_FulfillRequest_DuplicateRequestID_MaximumGas() (gas: 20717) -Gas_FulfillRequest_DuplicateRequestID:test_FulfillRequest_DuplicateRequestID_MinimumGas() (gas: 20157) -Gas_FulfillRequest_Success:test_FulfillRequest_Success_MaximumGas() (gas: 501339) -Gas_FulfillRequest_Success:test_FulfillRequest_Success_MinimumGas() (gas: 202509) -Gas_FundSubscription:test_FundSubscription_Gas() (gas: 38524) -Gas_SendRequest:test_SendRequest_MaximumGas() (gas: 988895) -Gas_SendRequest:test_SendRequest_MinimumGas() (gas: 181579) \ No newline at end of file +Gas_FulfillRequest_DuplicateRequestID:test_FulfillRequest_DuplicateRequestID_MaximumGas() (gas: 20562) +Gas_FulfillRequest_DuplicateRequestID:test_FulfillRequest_DuplicateRequestID_MinimumGas() (gas: 20024) +Gas_FulfillRequest_Success:test_FulfillRequest_Success_MaximumGas() (gas: 501184) +Gas_FulfillRequest_Success:test_FulfillRequest_Success_MinimumGas() (gas: 202376) +Gas_FundSubscription:test_FundSubscription_Gas() (gas: 38518) +Gas_SendRequest:test_SendRequest_MaximumGas() (gas: 984338) +Gas_SendRequest:test_SendRequest_MinimumGas() (gas: 181561) \ No newline at end of file diff --git a/core/internal/cltest/cltest.go b/core/internal/cltest/cltest.go index dc51ddd32f..12491300bf 100644 --- a/core/internal/cltest/cltest.go +++ b/core/internal/cltest/cltest.go @@ -461,6 +461,8 @@ func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAn LoopRegistry: plugins.NewLoopRegistry(lggr, nil), MercuryPool: mercuryPool, CapabilitiesRegistry: capabilitiesRegistry, + CapabilitiesDispatcher: dispatcher, + CapabilitiesPeerWrapper: peerWrapper, }) require.NoError(t, err) diff --git a/core/internal/mocks/prometheus_backend.go b/core/internal/mocks/prometheus_backend.go new file mode 100644 index 0000000000..d02f7062cb --- /dev/null +++ b/core/internal/mocks/prometheus_backend.go @@ -0,0 +1,204 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + big "math/big" + + mock "github.com/stretchr/testify/mock" +) + +// PrometheusBackend is an autogenerated mock type for the PrometheusBackend type +type PrometheusBackend struct { + mock.Mock +} + +type PrometheusBackend_Expecter struct { + mock *mock.Mock +} + +func (_m *PrometheusBackend) EXPECT() *PrometheusBackend_Expecter { + return &PrometheusBackend_Expecter{mock: &_m.Mock} +} + +// SetMaxUnconfirmedAge provides a mock function with given fields: _a0, _a1 +func (_m *PrometheusBackend) SetMaxUnconfirmedAge(_a0 *big.Int, _a1 float64) { + _m.Called(_a0, _a1) +} + +// PrometheusBackend_SetMaxUnconfirmedAge_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetMaxUnconfirmedAge' +type PrometheusBackend_SetMaxUnconfirmedAge_Call struct { + *mock.Call +} + +// SetMaxUnconfirmedAge is a helper method to define mock.On call +// - _a0 *big.Int +// - _a1 float64 +func (_e *PrometheusBackend_Expecter) SetMaxUnconfirmedAge(_a0 interface{}, _a1 interface{}) *PrometheusBackend_SetMaxUnconfirmedAge_Call { + return &PrometheusBackend_SetMaxUnconfirmedAge_Call{Call: _e.mock.On("SetMaxUnconfirmedAge", _a0, _a1)} +} + +func (_c *PrometheusBackend_SetMaxUnconfirmedAge_Call) Run(run func(_a0 *big.Int, _a1 float64)) *PrometheusBackend_SetMaxUnconfirmedAge_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*big.Int), args[1].(float64)) + }) + return _c +} + +func (_c *PrometheusBackend_SetMaxUnconfirmedAge_Call) Return() *PrometheusBackend_SetMaxUnconfirmedAge_Call { + _c.Call.Return() + return _c +} + +func (_c *PrometheusBackend_SetMaxUnconfirmedAge_Call) RunAndReturn(run func(*big.Int, float64)) *PrometheusBackend_SetMaxUnconfirmedAge_Call { + _c.Call.Return(run) + return _c +} + +// SetMaxUnconfirmedBlocks provides a mock function with given fields: _a0, _a1 +func (_m *PrometheusBackend) SetMaxUnconfirmedBlocks(_a0 *big.Int, _a1 int64) { + _m.Called(_a0, _a1) +} + +// PrometheusBackend_SetMaxUnconfirmedBlocks_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetMaxUnconfirmedBlocks' +type PrometheusBackend_SetMaxUnconfirmedBlocks_Call struct { + *mock.Call +} + +// SetMaxUnconfirmedBlocks is a helper method to define mock.On call +// - _a0 *big.Int +// - _a1 int64 +func (_e *PrometheusBackend_Expecter) SetMaxUnconfirmedBlocks(_a0 interface{}, _a1 interface{}) *PrometheusBackend_SetMaxUnconfirmedBlocks_Call { + return &PrometheusBackend_SetMaxUnconfirmedBlocks_Call{Call: _e.mock.On("SetMaxUnconfirmedBlocks", _a0, _a1)} +} + +func (_c *PrometheusBackend_SetMaxUnconfirmedBlocks_Call) Run(run func(_a0 *big.Int, _a1 int64)) *PrometheusBackend_SetMaxUnconfirmedBlocks_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*big.Int), args[1].(int64)) + }) + return _c +} + +func (_c *PrometheusBackend_SetMaxUnconfirmedBlocks_Call) Return() *PrometheusBackend_SetMaxUnconfirmedBlocks_Call { + _c.Call.Return() + return _c +} + +func (_c *PrometheusBackend_SetMaxUnconfirmedBlocks_Call) RunAndReturn(run func(*big.Int, int64)) *PrometheusBackend_SetMaxUnconfirmedBlocks_Call { + _c.Call.Return(run) + return _c +} + +// SetPipelineRunsQueued provides a mock function with given fields: n +func (_m *PrometheusBackend) SetPipelineRunsQueued(n int) { + _m.Called(n) +} + +// PrometheusBackend_SetPipelineRunsQueued_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPipelineRunsQueued' +type PrometheusBackend_SetPipelineRunsQueued_Call struct { + *mock.Call +} + +// SetPipelineRunsQueued is a helper method to define mock.On call +// - n int +func (_e *PrometheusBackend_Expecter) SetPipelineRunsQueued(n interface{}) *PrometheusBackend_SetPipelineRunsQueued_Call { + return &PrometheusBackend_SetPipelineRunsQueued_Call{Call: _e.mock.On("SetPipelineRunsQueued", n)} +} + +func (_c *PrometheusBackend_SetPipelineRunsQueued_Call) Run(run func(n int)) *PrometheusBackend_SetPipelineRunsQueued_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int)) + }) + return _c +} + +func (_c *PrometheusBackend_SetPipelineRunsQueued_Call) Return() *PrometheusBackend_SetPipelineRunsQueued_Call { + _c.Call.Return() + return _c +} + +func (_c *PrometheusBackend_SetPipelineRunsQueued_Call) RunAndReturn(run func(int)) *PrometheusBackend_SetPipelineRunsQueued_Call { + _c.Call.Return(run) + return _c +} + +// SetPipelineTaskRunsQueued provides a mock function with given fields: n +func (_m *PrometheusBackend) SetPipelineTaskRunsQueued(n int) { + _m.Called(n) +} + +// PrometheusBackend_SetPipelineTaskRunsQueued_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPipelineTaskRunsQueued' +type PrometheusBackend_SetPipelineTaskRunsQueued_Call struct { + *mock.Call +} + +// SetPipelineTaskRunsQueued is a helper method to define mock.On call +// - n int +func (_e *PrometheusBackend_Expecter) SetPipelineTaskRunsQueued(n interface{}) *PrometheusBackend_SetPipelineTaskRunsQueued_Call { + return &PrometheusBackend_SetPipelineTaskRunsQueued_Call{Call: _e.mock.On("SetPipelineTaskRunsQueued", n)} +} + +func (_c *PrometheusBackend_SetPipelineTaskRunsQueued_Call) Run(run func(n int)) *PrometheusBackend_SetPipelineTaskRunsQueued_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int)) + }) + return _c +} + +func (_c *PrometheusBackend_SetPipelineTaskRunsQueued_Call) Return() *PrometheusBackend_SetPipelineTaskRunsQueued_Call { + _c.Call.Return() + return _c +} + +func (_c *PrometheusBackend_SetPipelineTaskRunsQueued_Call) RunAndReturn(run func(int)) *PrometheusBackend_SetPipelineTaskRunsQueued_Call { + _c.Call.Return(run) + return _c +} + +// SetUnconfirmedTransactions provides a mock function with given fields: _a0, _a1 +func (_m *PrometheusBackend) SetUnconfirmedTransactions(_a0 *big.Int, _a1 int64) { + _m.Called(_a0, _a1) +} + +// PrometheusBackend_SetUnconfirmedTransactions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetUnconfirmedTransactions' +type PrometheusBackend_SetUnconfirmedTransactions_Call struct { + *mock.Call +} + +// SetUnconfirmedTransactions is a helper method to define mock.On call +// - _a0 *big.Int +// - _a1 int64 +func (_e *PrometheusBackend_Expecter) SetUnconfirmedTransactions(_a0 interface{}, _a1 interface{}) *PrometheusBackend_SetUnconfirmedTransactions_Call { + return &PrometheusBackend_SetUnconfirmedTransactions_Call{Call: _e.mock.On("SetUnconfirmedTransactions", _a0, _a1)} +} + +func (_c *PrometheusBackend_SetUnconfirmedTransactions_Call) Run(run func(_a0 *big.Int, _a1 int64)) *PrometheusBackend_SetUnconfirmedTransactions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*big.Int), args[1].(int64)) + }) + return _c +} + +func (_c *PrometheusBackend_SetUnconfirmedTransactions_Call) Return() *PrometheusBackend_SetUnconfirmedTransactions_Call { + _c.Call.Return() + return _c +} + +func (_c *PrometheusBackend_SetUnconfirmedTransactions_Call) RunAndReturn(run func(*big.Int, int64)) *PrometheusBackend_SetUnconfirmedTransactions_Call { + _c.Call.Return(run) + return _c +} + +// NewPrometheusBackend creates a new instance of PrometheusBackend. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewPrometheusBackend(t interface { + mock.TestingT + Cleanup(func()) +}) *PrometheusBackend { + mock := &PrometheusBackend{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/core/services/chainlink/application.go b/core/services/chainlink/application.go index cc130d0283..e880ecfad2 100644 --- a/core/services/chainlink/application.go +++ b/core/services/chainlink/application.go @@ -25,10 +25,13 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox" "github.com/smartcontractkit/chainlink/v2/core/capabilities" + remotetypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/remote/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/services/standardcapabilities" "github.com/smartcontractkit/chainlink/v2/core/static" + "github.com/smartcontractkit/chainlink/v2/core/services/promreporter" + "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/build" "github.com/smartcontractkit/chainlink/v2/core/capabilities/remote" @@ -46,7 +49,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/feeds" "github.com/smartcontractkit/chainlink/v2/core/services/fluxmonitorv2" "github.com/smartcontractkit/chainlink/v2/core/services/gateway" - "github.com/smartcontractkit/chainlink/v2/core/services/headreporter" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keeper" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" @@ -180,6 +182,8 @@ type ApplicationOpts struct { GRPCOpts loop.GRPCOpts MercuryPool wsrpc.Pool CapabilitiesRegistry *capabilities.Registry + CapabilitiesDispatcher remotetypes.Dispatcher + CapabilitiesPeerWrapper p2ptypes.PeerWrapper } // NewApplication initializes a new store if one is not already @@ -199,20 +203,36 @@ func NewApplication(opts ApplicationOpts) (Application, error) { restrictedHTTPClient := opts.RestrictedHTTPClient unrestrictedHTTPClient := opts.UnrestrictedHTTPClient - if opts.CapabilitiesRegistry == nil { // for tests only, in prod Registry is always set at this point + if opts.CapabilitiesRegistry == nil { + // for tests only, in prod Registry should always be set at this point opts.CapabilitiesRegistry = capabilities.NewRegistry(globalLogger) } var externalPeerWrapper p2ptypes.PeerWrapper - var capabilityRegistrySyncer registrysyncer.Syncer + if cfg.Capabilities().Peering().Enabled() { + var dispatcher remotetypes.Dispatcher + if opts.CapabilitiesDispatcher == nil { + externalPeer := externalp2p.NewExternalPeerWrapper(keyStore.P2P(), cfg.Capabilities().Peering(), opts.DS, globalLogger) + signer := externalPeer + externalPeerWrapper = externalPeer + remoteDispatcher := remote.NewDispatcher(externalPeerWrapper, signer, opts.CapabilitiesRegistry, globalLogger) + srvcs = append(srvcs, remoteDispatcher) + + dispatcher = remoteDispatcher + } else { + dispatcher = opts.CapabilitiesDispatcher + externalPeerWrapper = opts.CapabilitiesPeerWrapper + } + + srvcs = append(srvcs, externalPeerWrapper) - if cfg.Capabilities().ExternalRegistry().Address() != "" { rid := cfg.Capabilities().ExternalRegistry().RelayID() registryAddress := cfg.Capabilities().ExternalRegistry().Address() relayer, err := relayerChainInterops.Get(rid) if err != nil { return nil, fmt.Errorf("could not fetch relayer %s configured for capabilities registry: %w", rid, err) } + registrySyncer, err := registrysyncer.New( globalLogger, externalPeerWrapper, @@ -223,31 +243,15 @@ func NewApplication(opts ApplicationOpts) (Application, error) { return nil, fmt.Errorf("could not configure syncer: %w", err) } - capabilityRegistrySyncer = registrySyncer - srvcs = append(srvcs, capabilityRegistrySyncer) - } - - if cfg.Capabilities().Peering().Enabled() { - if capabilityRegistrySyncer == nil { - return nil, errors.Errorf("peering enabled but no capability registry found") - } - externalPeer := externalp2p.NewExternalPeerWrapper(keyStore.P2P(), cfg.Capabilities().Peering(), opts.DS, globalLogger) - signer := externalPeer - externalPeerWrapper = externalPeer - - srvcs = append(srvcs, externalPeerWrapper) - - dispatcher := remote.NewDispatcher(externalPeerWrapper, signer, opts.CapabilitiesRegistry, globalLogger) - wfLauncher := capabilities.NewLauncher( globalLogger, externalPeerWrapper, dispatcher, opts.CapabilitiesRegistry, ) + registrySyncer.AddLauncher(wfLauncher) - capabilityRegistrySyncer.AddLauncher(wfLauncher) - srvcs = append(srvcs, dispatcher, wfLauncher) + srvcs = append(srvcs, dispatcher, wfLauncher, registrySyncer) } // LOOPs can be created as options, in the case of LOOP relayers, or @@ -320,6 +324,8 @@ func NewApplication(opts ApplicationOpts) (Application, error) { srvcs = append(srvcs, mailMon) srvcs = append(srvcs, relayerChainInterops.Services()...) + promReporter := promreporter.NewPromReporter(opts.DS, legacyEVMChains, globalLogger) + srvcs = append(srvcs, promReporter) // Initialize Local Users ORM and Authentication Provider specified in config // BasicAdminUsersORM is initialized and required regardless of separate Authentication Provider @@ -359,16 +365,8 @@ func NewApplication(opts ApplicationOpts) (Application, error) { workflowORM = workflowstore.NewDBStore(opts.DS, globalLogger, clockwork.NewRealClock()) ) - promReporter := headreporter.NewPrometheusReporter(opts.DS, legacyEVMChains) - chainIDs := make([]*big.Int, legacyEVMChains.Len()) - for i, chain := range legacyEVMChains.Slice() { - chainIDs[i] = chain.ID() - } - telemReporter := headreporter.NewTelemetryReporter(telemetryManager, globalLogger, chainIDs...) - headReporter := headreporter.NewHeadReporterService(opts.DS, globalLogger, promReporter, telemReporter) - srvcs = append(srvcs, headReporter) for _, chain := range legacyEVMChains.Slice() { - chain.HeadBroadcaster().Subscribe(headReporter) + chain.HeadBroadcaster().Subscribe(promReporter) chain.TxManager().RegisterResumeCallback(pipelineRunner.ResumeRun) } diff --git a/core/services/headreporter/head_reporter.go b/core/services/headreporter/head_reporter.go deleted file mode 100644 index 94de8ae2be..0000000000 --- a/core/services/headreporter/head_reporter.go +++ /dev/null @@ -1,111 +0,0 @@ -package headreporter - -import ( - "context" - "sync" - "time" - - "github.com/smartcontractkit/chainlink-common/pkg/services" - "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" - "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox" - - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types" - evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" - "github.com/smartcontractkit/chainlink/v2/core/logger" -) - -type ( - HeadReporter interface { - ReportNewHead(ctx context.Context, head *evmtypes.Head) error - ReportPeriodic(ctx context.Context) error - } - - HeadReporterService struct { - services.StateMachine - ds sqlutil.DataSource - lggr logger.Logger - newHeads *mailbox.Mailbox[*evmtypes.Head] - chStop services.StopChan - wgDone sync.WaitGroup - reportPeriod time.Duration - reporters []HeadReporter - unsubscribeFns []func() - } -) - -func NewHeadReporterService(ds sqlutil.DataSource, lggr logger.Logger, reporters ...HeadReporter) *HeadReporterService { - return &HeadReporterService{ - ds: ds, - lggr: lggr.Named("HeadReporter"), - newHeads: mailbox.NewSingle[*evmtypes.Head](), - chStop: make(chan struct{}), - reporters: reporters, - reportPeriod: 15 * time.Second, - } -} - -func (hrd *HeadReporterService) Subscribe(subFn func(types.HeadTrackable) (evmtypes.Head, func())) { - _, unsubscribe := subFn(hrd) - hrd.unsubscribeFns = append(hrd.unsubscribeFns, unsubscribe) -} - -func (hrd *HeadReporterService) Start(context.Context) error { - return hrd.StartOnce(hrd.Name(), func() error { - hrd.wgDone.Add(1) - go hrd.eventLoop() - return nil - }) -} - -func (hrd *HeadReporterService) Close() error { - return hrd.StopOnce(hrd.Name(), func() error { - close(hrd.chStop) - hrd.wgDone.Wait() - return nil - }) -} - -func (hrd *HeadReporterService) Name() string { - return hrd.lggr.Name() -} - -func (hrd *HeadReporterService) HealthReport() map[string]error { - return map[string]error{hrd.Name(): hrd.Healthy()} -} - -func (hrd *HeadReporterService) OnNewLongestChain(ctx context.Context, head *evmtypes.Head) { - hrd.newHeads.Deliver(head) -} - -func (hrd *HeadReporterService) eventLoop() { - hrd.lggr.Debug("Starting event loop") - defer hrd.wgDone.Done() - ctx, cancel := hrd.chStop.NewCtx() - defer cancel() - after := time.After(hrd.reportPeriod) - for { - select { - case <-hrd.newHeads.Notify(): - head, exists := hrd.newHeads.Retrieve() - if !exists { - continue - } - for _, reporter := range hrd.reporters { - err := reporter.ReportNewHead(ctx, head) - if err != nil && ctx.Err() == nil { - hrd.lggr.Errorw("Error reporting new head", "err", err) - } - } - case <-after: - for _, reporter := range hrd.reporters { - err := reporter.ReportPeriodic(ctx) - if err != nil && ctx.Err() == nil { - hrd.lggr.Errorw("Error in periodic report", "err", err) - } - } - after = time.After(hrd.reportPeriod) - case <-hrd.chStop: - return - } - } -} diff --git a/core/services/headreporter/head_reporter_mock.go b/core/services/headreporter/head_reporter_mock.go deleted file mode 100644 index 21978abb86..0000000000 --- a/core/services/headreporter/head_reporter_mock.go +++ /dev/null @@ -1,130 +0,0 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. - -package headreporter - -import ( - context "context" - - types "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" - mock "github.com/stretchr/testify/mock" -) - -// MockHeadReporter is an autogenerated mock type for the HeadReporter type -type MockHeadReporter struct { - mock.Mock -} - -type MockHeadReporter_Expecter struct { - mock *mock.Mock -} - -func (_m *MockHeadReporter) EXPECT() *MockHeadReporter_Expecter { - return &MockHeadReporter_Expecter{mock: &_m.Mock} -} - -// ReportNewHead provides a mock function with given fields: ctx, head -func (_m *MockHeadReporter) ReportNewHead(ctx context.Context, head *types.Head) error { - ret := _m.Called(ctx, head) - - if len(ret) == 0 { - panic("no return value specified for ReportNewHead") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *types.Head) error); ok { - r0 = rf(ctx, head) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockHeadReporter_ReportNewHead_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReportNewHead' -type MockHeadReporter_ReportNewHead_Call struct { - *mock.Call -} - -// ReportNewHead is a helper method to define mock.On call -// - ctx context.Context -// - head *types.Head -func (_e *MockHeadReporter_Expecter) ReportNewHead(ctx interface{}, head interface{}) *MockHeadReporter_ReportNewHead_Call { - return &MockHeadReporter_ReportNewHead_Call{Call: _e.mock.On("ReportNewHead", ctx, head)} -} - -func (_c *MockHeadReporter_ReportNewHead_Call) Run(run func(ctx context.Context, head *types.Head)) *MockHeadReporter_ReportNewHead_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*types.Head)) - }) - return _c -} - -func (_c *MockHeadReporter_ReportNewHead_Call) Return(_a0 error) *MockHeadReporter_ReportNewHead_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockHeadReporter_ReportNewHead_Call) RunAndReturn(run func(context.Context, *types.Head) error) *MockHeadReporter_ReportNewHead_Call { - _c.Call.Return(run) - return _c -} - -// ReportPeriodic provides a mock function with given fields: ctx -func (_m *MockHeadReporter) ReportPeriodic(ctx context.Context) error { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for ReportPeriodic") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context) error); ok { - r0 = rf(ctx) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockHeadReporter_ReportPeriodic_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReportPeriodic' -type MockHeadReporter_ReportPeriodic_Call struct { - *mock.Call -} - -// ReportPeriodic is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockHeadReporter_Expecter) ReportPeriodic(ctx interface{}) *MockHeadReporter_ReportPeriodic_Call { - return &MockHeadReporter_ReportPeriodic_Call{Call: _e.mock.On("ReportPeriodic", ctx)} -} - -func (_c *MockHeadReporter_ReportPeriodic_Call) Run(run func(ctx context.Context)) *MockHeadReporter_ReportPeriodic_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *MockHeadReporter_ReportPeriodic_Call) Return(_a0 error) *MockHeadReporter_ReportPeriodic_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockHeadReporter_ReportPeriodic_Call) RunAndReturn(run func(context.Context) error) *MockHeadReporter_ReportPeriodic_Call { - _c.Call.Return(run) - return _c -} - -// NewMockHeadReporter creates a new instance of MockHeadReporter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockHeadReporter(t interface { - mock.TestingT - Cleanup(func()) -}) *MockHeadReporter { - mock := &MockHeadReporter{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/services/headreporter/head_reporter_test.go b/core/services/headreporter/head_reporter_test.go deleted file mode 100644 index 304dd59a47..0000000000 --- a/core/services/headreporter/head_reporter_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package headreporter - -import ( - "sync/atomic" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" - - evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" - ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" - - "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" - "github.com/smartcontractkit/chainlink/v2/core/logger" -) - -func NewHead() evmtypes.Head { - return evmtypes.Head{Number: 42, EVMChainID: ubig.NewI(0)} -} - -func Test_HeadReporterService(t *testing.T) { - t.Run("report everything", func(t *testing.T) { - db := pgtest.NewSqlxDB(t) - - headReporter := NewMockHeadReporter(t) - service := NewHeadReporterService(db, logger.TestLogger(t), headReporter) - service.reportPeriod = time.Second - err := service.Start(testutils.Context(t)) - require.NoError(t, err) - - var reportCalls atomic.Int32 - head := NewHead() - headReporter.On("ReportNewHead", mock.Anything, &head).Run(func(args mock.Arguments) { - reportCalls.Add(1) - }).Return(nil) - headReporter.On("ReportPeriodic", mock.Anything).Run(func(args mock.Arguments) { - reportCalls.Add(1) - }).Return(nil) - service.OnNewLongestChain(testutils.Context(t), &head) - - require.Eventually(t, func() bool { return reportCalls.Load() == 2 }, 5*time.Second, 100*time.Millisecond) - }) - - t.Run("has default report period", func(t *testing.T) { - service := NewHeadReporterService(pgtest.NewSqlxDB(t), logger.TestLogger(t), NewMockHeadReporter(t)) - assert.Equal(t, service.reportPeriod, 15*time.Second) - }) -} diff --git a/core/services/headreporter/helper_test.go b/core/services/headreporter/helper_test.go deleted file mode 100644 index fa05182a85..0000000000 --- a/core/services/headreporter/helper_test.go +++ /dev/null @@ -1,5 +0,0 @@ -package headreporter - -func (p *prometheusReporter) SetBackend(b PrometheusBackend) { - p.backend = b -} diff --git a/core/services/headreporter/prometheus_backend_mock.go b/core/services/headreporter/prometheus_backend_mock.go deleted file mode 100644 index ca83f6c4fb..0000000000 --- a/core/services/headreporter/prometheus_backend_mock.go +++ /dev/null @@ -1,204 +0,0 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. - -package headreporter - -import ( - big "math/big" - - mock "github.com/stretchr/testify/mock" -) - -// MockPrometheusBackend is an autogenerated mock type for the PrometheusBackend type -type MockPrometheusBackend struct { - mock.Mock -} - -type MockPrometheusBackend_Expecter struct { - mock *mock.Mock -} - -func (_m *MockPrometheusBackend) EXPECT() *MockPrometheusBackend_Expecter { - return &MockPrometheusBackend_Expecter{mock: &_m.Mock} -} - -// SetMaxUnconfirmedAge provides a mock function with given fields: _a0, _a1 -func (_m *MockPrometheusBackend) SetMaxUnconfirmedAge(_a0 *big.Int, _a1 float64) { - _m.Called(_a0, _a1) -} - -// MockPrometheusBackend_SetMaxUnconfirmedAge_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetMaxUnconfirmedAge' -type MockPrometheusBackend_SetMaxUnconfirmedAge_Call struct { - *mock.Call -} - -// SetMaxUnconfirmedAge is a helper method to define mock.On call -// - _a0 *big.Int -// - _a1 float64 -func (_e *MockPrometheusBackend_Expecter) SetMaxUnconfirmedAge(_a0 interface{}, _a1 interface{}) *MockPrometheusBackend_SetMaxUnconfirmedAge_Call { - return &MockPrometheusBackend_SetMaxUnconfirmedAge_Call{Call: _e.mock.On("SetMaxUnconfirmedAge", _a0, _a1)} -} - -func (_c *MockPrometheusBackend_SetMaxUnconfirmedAge_Call) Run(run func(_a0 *big.Int, _a1 float64)) *MockPrometheusBackend_SetMaxUnconfirmedAge_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*big.Int), args[1].(float64)) - }) - return _c -} - -func (_c *MockPrometheusBackend_SetMaxUnconfirmedAge_Call) Return() *MockPrometheusBackend_SetMaxUnconfirmedAge_Call { - _c.Call.Return() - return _c -} - -func (_c *MockPrometheusBackend_SetMaxUnconfirmedAge_Call) RunAndReturn(run func(*big.Int, float64)) *MockPrometheusBackend_SetMaxUnconfirmedAge_Call { - _c.Call.Return(run) - return _c -} - -// SetMaxUnconfirmedBlocks provides a mock function with given fields: _a0, _a1 -func (_m *MockPrometheusBackend) SetMaxUnconfirmedBlocks(_a0 *big.Int, _a1 int64) { - _m.Called(_a0, _a1) -} - -// MockPrometheusBackend_SetMaxUnconfirmedBlocks_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetMaxUnconfirmedBlocks' -type MockPrometheusBackend_SetMaxUnconfirmedBlocks_Call struct { - *mock.Call -} - -// SetMaxUnconfirmedBlocks is a helper method to define mock.On call -// - _a0 *big.Int -// - _a1 int64 -func (_e *MockPrometheusBackend_Expecter) SetMaxUnconfirmedBlocks(_a0 interface{}, _a1 interface{}) *MockPrometheusBackend_SetMaxUnconfirmedBlocks_Call { - return &MockPrometheusBackend_SetMaxUnconfirmedBlocks_Call{Call: _e.mock.On("SetMaxUnconfirmedBlocks", _a0, _a1)} -} - -func (_c *MockPrometheusBackend_SetMaxUnconfirmedBlocks_Call) Run(run func(_a0 *big.Int, _a1 int64)) *MockPrometheusBackend_SetMaxUnconfirmedBlocks_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*big.Int), args[1].(int64)) - }) - return _c -} - -func (_c *MockPrometheusBackend_SetMaxUnconfirmedBlocks_Call) Return() *MockPrometheusBackend_SetMaxUnconfirmedBlocks_Call { - _c.Call.Return() - return _c -} - -func (_c *MockPrometheusBackend_SetMaxUnconfirmedBlocks_Call) RunAndReturn(run func(*big.Int, int64)) *MockPrometheusBackend_SetMaxUnconfirmedBlocks_Call { - _c.Call.Return(run) - return _c -} - -// SetPipelineRunsQueued provides a mock function with given fields: n -func (_m *MockPrometheusBackend) SetPipelineRunsQueued(n int) { - _m.Called(n) -} - -// MockPrometheusBackend_SetPipelineRunsQueued_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPipelineRunsQueued' -type MockPrometheusBackend_SetPipelineRunsQueued_Call struct { - *mock.Call -} - -// SetPipelineRunsQueued is a helper method to define mock.On call -// - n int -func (_e *MockPrometheusBackend_Expecter) SetPipelineRunsQueued(n interface{}) *MockPrometheusBackend_SetPipelineRunsQueued_Call { - return &MockPrometheusBackend_SetPipelineRunsQueued_Call{Call: _e.mock.On("SetPipelineRunsQueued", n)} -} - -func (_c *MockPrometheusBackend_SetPipelineRunsQueued_Call) Run(run func(n int)) *MockPrometheusBackend_SetPipelineRunsQueued_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int)) - }) - return _c -} - -func (_c *MockPrometheusBackend_SetPipelineRunsQueued_Call) Return() *MockPrometheusBackend_SetPipelineRunsQueued_Call { - _c.Call.Return() - return _c -} - -func (_c *MockPrometheusBackend_SetPipelineRunsQueued_Call) RunAndReturn(run func(int)) *MockPrometheusBackend_SetPipelineRunsQueued_Call { - _c.Call.Return(run) - return _c -} - -// SetPipelineTaskRunsQueued provides a mock function with given fields: n -func (_m *MockPrometheusBackend) SetPipelineTaskRunsQueued(n int) { - _m.Called(n) -} - -// MockPrometheusBackend_SetPipelineTaskRunsQueued_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPipelineTaskRunsQueued' -type MockPrometheusBackend_SetPipelineTaskRunsQueued_Call struct { - *mock.Call -} - -// SetPipelineTaskRunsQueued is a helper method to define mock.On call -// - n int -func (_e *MockPrometheusBackend_Expecter) SetPipelineTaskRunsQueued(n interface{}) *MockPrometheusBackend_SetPipelineTaskRunsQueued_Call { - return &MockPrometheusBackend_SetPipelineTaskRunsQueued_Call{Call: _e.mock.On("SetPipelineTaskRunsQueued", n)} -} - -func (_c *MockPrometheusBackend_SetPipelineTaskRunsQueued_Call) Run(run func(n int)) *MockPrometheusBackend_SetPipelineTaskRunsQueued_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int)) - }) - return _c -} - -func (_c *MockPrometheusBackend_SetPipelineTaskRunsQueued_Call) Return() *MockPrometheusBackend_SetPipelineTaskRunsQueued_Call { - _c.Call.Return() - return _c -} - -func (_c *MockPrometheusBackend_SetPipelineTaskRunsQueued_Call) RunAndReturn(run func(int)) *MockPrometheusBackend_SetPipelineTaskRunsQueued_Call { - _c.Call.Return(run) - return _c -} - -// SetUnconfirmedTransactions provides a mock function with given fields: _a0, _a1 -func (_m *MockPrometheusBackend) SetUnconfirmedTransactions(_a0 *big.Int, _a1 int64) { - _m.Called(_a0, _a1) -} - -// MockPrometheusBackend_SetUnconfirmedTransactions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetUnconfirmedTransactions' -type MockPrometheusBackend_SetUnconfirmedTransactions_Call struct { - *mock.Call -} - -// SetUnconfirmedTransactions is a helper method to define mock.On call -// - _a0 *big.Int -// - _a1 int64 -func (_e *MockPrometheusBackend_Expecter) SetUnconfirmedTransactions(_a0 interface{}, _a1 interface{}) *MockPrometheusBackend_SetUnconfirmedTransactions_Call { - return &MockPrometheusBackend_SetUnconfirmedTransactions_Call{Call: _e.mock.On("SetUnconfirmedTransactions", _a0, _a1)} -} - -func (_c *MockPrometheusBackend_SetUnconfirmedTransactions_Call) Run(run func(_a0 *big.Int, _a1 int64)) *MockPrometheusBackend_SetUnconfirmedTransactions_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*big.Int), args[1].(int64)) - }) - return _c -} - -func (_c *MockPrometheusBackend_SetUnconfirmedTransactions_Call) Return() *MockPrometheusBackend_SetUnconfirmedTransactions_Call { - _c.Call.Return() - return _c -} - -func (_c *MockPrometheusBackend_SetUnconfirmedTransactions_Call) RunAndReturn(run func(*big.Int, int64)) *MockPrometheusBackend_SetUnconfirmedTransactions_Call { - _c.Call.Return(run) - return _c -} - -// NewMockPrometheusBackend creates a new instance of MockPrometheusBackend. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockPrometheusBackend(t interface { - mock.TestingT - Cleanup(func()) -}) *MockPrometheusBackend { - mock := &MockPrometheusBackend{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/services/headreporter/telemetry_reporter.go b/core/services/headreporter/telemetry_reporter.go deleted file mode 100644 index 0d93ca59a4..0000000000 --- a/core/services/headreporter/telemetry_reporter.go +++ /dev/null @@ -1,69 +0,0 @@ -package headreporter - -import ( - "context" - "math/big" - - "github.com/pkg/errors" - - "github.com/smartcontractkit/libocr/commontypes" - "google.golang.org/protobuf/proto" - - evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" - "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/synchronization" - "github.com/smartcontractkit/chainlink/v2/core/services/synchronization/telem" - "github.com/smartcontractkit/chainlink/v2/core/services/telemetry" -) - -type telemetryReporter struct { - lggr logger.Logger - endpoints map[uint64]commontypes.MonitoringEndpoint -} - -func NewTelemetryReporter(monitoringEndpointGen telemetry.MonitoringEndpointGenerator, lggr logger.Logger, chainIDs ...*big.Int) HeadReporter { - endpoints := make(map[uint64]commontypes.MonitoringEndpoint) - for _, chainID := range chainIDs { - endpoints[chainID.Uint64()] = monitoringEndpointGen.GenMonitoringEndpoint("EVM", chainID.String(), "", synchronization.HeadReport) - } - return &telemetryReporter{lggr: lggr.Named("TelemetryReporter"), endpoints: endpoints} -} - -func (t *telemetryReporter) ReportNewHead(ctx context.Context, head *evmtypes.Head) error { - monitoringEndpoint := t.endpoints[head.EVMChainID.ToInt().Uint64()] - if monitoringEndpoint == nil { - return errors.Errorf("No monitoring endpoint provided chain_id=%d", head.EVMChainID.Int64()) - } - var finalized *telem.Block - latestFinalizedHead := head.LatestFinalizedHead() - if latestFinalizedHead != nil { - finalized = &telem.Block{ - Timestamp: uint64(latestFinalizedHead.GetTimestamp().UTC().Unix()), - Number: uint64(latestFinalizedHead.BlockNumber()), - Hash: latestFinalizedHead.BlockHash().Hex(), - } - } - request := &telem.HeadReportRequest{ - ChainID: head.EVMChainID.String(), - Latest: &telem.Block{ - Timestamp: uint64(head.Timestamp.UTC().Unix()), - Number: uint64(head.Number), - Hash: head.Hash.Hex(), - }, - Finalized: finalized, - } - bytes, err := proto.Marshal(request) - if err != nil { - return errors.WithMessage(err, "telem.HeadReportRequest marshal error") - } - monitoringEndpoint.SendLog(bytes) - if finalized == nil { - t.lggr.Infow("No finalized block was found", "chainID", head.EVMChainID.Int64(), - "head.number", head.Number, "chainLength", head.ChainLength()) - } - return nil -} - -func (t *telemetryReporter) ReportPeriodic(ctx context.Context) error { - return nil -} diff --git a/core/services/headreporter/telemetry_reporter_test.go b/core/services/headreporter/telemetry_reporter_test.go deleted file mode 100644 index 85bfea5866..0000000000 --- a/core/services/headreporter/telemetry_reporter_test.go +++ /dev/null @@ -1,108 +0,0 @@ -package headreporter_test - -import ( - "math/big" - "testing" - "time" - - "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/assert" - "google.golang.org/protobuf/proto" - - mocks2 "github.com/smartcontractkit/chainlink/v2/common/types/mocks" - evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" - ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" - "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/headreporter" - "github.com/smartcontractkit/chainlink/v2/core/services/synchronization" - "github.com/smartcontractkit/chainlink/v2/core/services/synchronization/telem" - "github.com/smartcontractkit/chainlink/v2/core/services/telemetry" -) - -func Test_TelemetryReporter_NewHead(t *testing.T) { - head := evmtypes.Head{ - Number: 42, - EVMChainID: ubig.NewI(100), - Hash: common.HexToHash("0x1010"), - Timestamp: time.UnixMilli(1000), - IsFinalized: false, - Parent: &evmtypes.Head{ - Number: 41, - Hash: common.HexToHash("0x1009"), - Timestamp: time.UnixMilli(999), - IsFinalized: true, - }, - } - requestBytes, err := proto.Marshal(&telem.HeadReportRequest{ - ChainID: "100", - Latest: &telem.Block{ - Timestamp: uint64(head.Timestamp.UTC().Unix()), - Number: 42, - Hash: head.Hash.Hex(), - }, - Finalized: &telem.Block{ - Timestamp: uint64(head.Parent.Timestamp.UTC().Unix()), - Number: 41, - Hash: head.Parent.Hash.Hex(), - }, - }) - assert.NoError(t, err) - - monitoringEndpoint := mocks2.NewMonitoringEndpoint(t) - monitoringEndpoint.On("SendLog", requestBytes).Return() - - monitoringEndpointGen := telemetry.NewMockMonitoringEndpointGenerator(t) - monitoringEndpointGen. - On("GenMonitoringEndpoint", "EVM", "100", "", synchronization.HeadReport). - Return(monitoringEndpoint) - reporter := headreporter.NewTelemetryReporter(monitoringEndpointGen, logger.TestLogger(t), big.NewInt(100)) - - err = reporter.ReportNewHead(testutils.Context(t), &head) - assert.NoError(t, err) -} - -func Test_TelemetryReporter_NewHeadMissingFinalized(t *testing.T) { - head := evmtypes.Head{ - Number: 42, - EVMChainID: ubig.NewI(100), - Hash: common.HexToHash("0x1010"), - Timestamp: time.UnixMilli(1000), - IsFinalized: false, - } - requestBytes, err := proto.Marshal(&telem.HeadReportRequest{ - ChainID: "100", - Latest: &telem.Block{ - Timestamp: uint64(head.Timestamp.UTC().Unix()), - Number: 42, - Hash: head.Hash.Hex(), - }, - }) - assert.NoError(t, err) - - monitoringEndpoint := mocks2.NewMonitoringEndpoint(t) - monitoringEndpoint.On("SendLog", requestBytes).Return() - - monitoringEndpointGen := telemetry.NewMockMonitoringEndpointGenerator(t) - monitoringEndpointGen. - On("GenMonitoringEndpoint", "EVM", "100", "", synchronization.HeadReport). - Return(monitoringEndpoint) - reporter := headreporter.NewTelemetryReporter(monitoringEndpointGen, logger.TestLogger(t), big.NewInt(100)) - - err = reporter.ReportNewHead(testutils.Context(t), &head) - assert.NoError(t, err) -} - -func Test_TelemetryReporter_NewHead_MissingEndpoint(t *testing.T) { - monitoringEndpointGen := telemetry.NewMockMonitoringEndpointGenerator(t) - monitoringEndpointGen. - On("GenMonitoringEndpoint", "EVM", "100", "", synchronization.HeadReport). - Return(nil) - - reporter := headreporter.NewTelemetryReporter(monitoringEndpointGen, logger.TestLogger(t), big.NewInt(100)) - - head := evmtypes.Head{Number: 42, EVMChainID: ubig.NewI(100)} - - err := reporter.ReportNewHead(testutils.Context(t), &head) - assert.Errorf(t, err, "No monitoring endpoint provided chain_id=100") -} diff --git a/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go b/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go index 73c5992470..bb2f6b0f7c 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go @@ -38,6 +38,7 @@ import ( cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" + evmcapabilities "github.com/smartcontractkit/chainlink/v2/core/capabilities" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" v2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" @@ -460,9 +461,10 @@ func setupNodeCCIP( } loopRegistry := plugins.NewLoopRegistry(lggr.Named("LoopRegistry"), config.Tracing()) relayerFactory := chainlink.RelayerFactory{ - Logger: lggr, - LoopRegistry: loopRegistry, - GRPCOpts: loop.GRPCOpts{}, + Logger: lggr, + LoopRegistry: loopRegistry, + GRPCOpts: loop.GRPCOpts{}, + CapabilitiesRegistry: evmcapabilities.NewRegistry(logger.TestLogger(t)), } testCtx := testutils.Context(t) // evm alway enabled for backward compatibility diff --git a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go b/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go index 5099a4b57e..8d7a4551f1 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go @@ -37,6 +37,7 @@ import ( cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" + evmcapabilities "github.com/smartcontractkit/chainlink/v2/core/capabilities" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" v2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" @@ -457,9 +458,10 @@ func setupNodeCCIP( } loopRegistry := plugins.NewLoopRegistry(lggr.Named("LoopRegistry"), config.Tracing()) relayerFactory := chainlink.RelayerFactory{ - Logger: lggr, - LoopRegistry: loopRegistry, - GRPCOpts: loop.GRPCOpts{}, + Logger: lggr, + LoopRegistry: loopRegistry, + GRPCOpts: loop.GRPCOpts{}, + CapabilitiesRegistry: evmcapabilities.NewRegistry(lggr), } testCtx := testutils.Context(t) // evm alway enabled for backward compatibility diff --git a/core/services/headreporter/prometheus_reporter.go b/core/services/promreporter/prom_reporter.go similarity index 63% rename from core/services/headreporter/prometheus_reporter.go rename to core/services/promreporter/prom_reporter.go index 3e39c7aca4..31d5f1129e 100644 --- a/core/services/headreporter/prometheus_reporter.go +++ b/core/services/promreporter/prom_reporter.go @@ -1,28 +1,40 @@ -package headreporter +package promreporter import ( "context" "fmt" "math/big" + "sync" "time" + "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" + txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" + "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "go.uber.org/multierr" - "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" - txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" + "github.com/smartcontractkit/chainlink-common/pkg/services" + "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" + "github.com/smartcontractkit/chainlink/v2/core/logger" ) type ( - prometheusReporter struct { - ds sqlutil.DataSource - chains legacyevm.LegacyChainContainer - backend PrometheusBackend + promReporter struct { + services.StateMachine + ds sqlutil.DataSource + chains legacyevm.LegacyChainContainer + lggr logger.Logger + backend PrometheusBackend + newHeads *mailbox.Mailbox[*evmtypes.Head] + chStop services.StopChan + wgDone sync.WaitGroup + reportPeriod time.Duration } PrometheusBackend interface { @@ -59,15 +71,103 @@ var ( }) ) -func NewPrometheusReporter(ds sqlutil.DataSource, chainContainer legacyevm.LegacyChainContainer) *prometheusReporter { - return &prometheusReporter{ - ds: ds, - chains: chainContainer, - backend: defaultBackend{}, +func (defaultBackend) SetUnconfirmedTransactions(evmChainID *big.Int, n int64) { + promUnconfirmedTransactions.WithLabelValues(evmChainID.String()).Set(float64(n)) +} + +func (defaultBackend) SetMaxUnconfirmedAge(evmChainID *big.Int, s float64) { + promMaxUnconfirmedAge.WithLabelValues(evmChainID.String()).Set(s) +} + +func (defaultBackend) SetMaxUnconfirmedBlocks(evmChainID *big.Int, n int64) { + promMaxUnconfirmedBlocks.WithLabelValues(evmChainID.String()).Set(float64(n)) +} + +func (defaultBackend) SetPipelineRunsQueued(n int) { + promPipelineTaskRunsQueued.Set(float64(n)) +} + +func (defaultBackend) SetPipelineTaskRunsQueued(n int) { + promPipelineRunsQueued.Set(float64(n)) +} + +func NewPromReporter(ds sqlutil.DataSource, chainContainer legacyevm.LegacyChainContainer, lggr logger.Logger, opts ...interface{}) *promReporter { + var backend PrometheusBackend = defaultBackend{} + period := 15 * time.Second + for _, opt := range opts { + switch v := opt.(type) { + case time.Duration: + period = v + case PrometheusBackend: + backend = v + } + } + + chStop := make(chan struct{}) + return &promReporter{ + ds: ds, + chains: chainContainer, + lggr: lggr.Named("PromReporter"), + backend: backend, + newHeads: mailbox.NewSingle[*evmtypes.Head](), + chStop: chStop, + reportPeriod: period, } } -func (pr *prometheusReporter) getTxm(evmChainID *big.Int) (txmgr.TxManager, error) { +// Start starts PromReporter. +func (pr *promReporter) Start(context.Context) error { + return pr.StartOnce("PromReporter", func() error { + pr.wgDone.Add(1) + go pr.eventLoop() + return nil + }) +} + +func (pr *promReporter) Close() error { + return pr.StopOnce("PromReporter", func() error { + close(pr.chStop) + pr.wgDone.Wait() + return nil + }) +} +func (pr *promReporter) Name() string { + return pr.lggr.Name() +} + +func (pr *promReporter) HealthReport() map[string]error { + return map[string]error{pr.Name(): pr.Healthy()} +} + +func (pr *promReporter) OnNewLongestChain(ctx context.Context, head *evmtypes.Head) { + pr.newHeads.Deliver(head) +} + +func (pr *promReporter) eventLoop() { + pr.lggr.Debug("Starting event loop") + defer pr.wgDone.Done() + ctx, cancel := pr.chStop.NewCtx() + defer cancel() + for { + select { + case <-pr.newHeads.Notify(): + head, exists := pr.newHeads.Retrieve() + if !exists { + continue + } + pr.reportHeadMetrics(ctx, head) + case <-time.After(pr.reportPeriod): + if err := errors.Wrap(pr.reportPipelineRunStats(ctx), "reportPipelineRunStats failed"); err != nil { + pr.lggr.Errorw("Error reporting prometheus metrics", "err", err) + } + + case <-pr.chStop: + return + } + } +} + +func (pr *promReporter) getTxm(evmChainID *big.Int) (txmgr.TxManager, error) { chain, err := pr.chains.Get(evmChainID.String()) if err != nil { return nil, fmt.Errorf("failed to get chain: %w", err) @@ -75,16 +175,20 @@ func (pr *prometheusReporter) getTxm(evmChainID *big.Int) (txmgr.TxManager, erro return chain.TxManager(), nil } -func (pr *prometheusReporter) ReportNewHead(ctx context.Context, head *evmtypes.Head) error { +func (pr *promReporter) reportHeadMetrics(ctx context.Context, head *evmtypes.Head) { evmChainID := head.EVMChainID.ToInt() - return multierr.Combine( + err := multierr.Combine( errors.Wrap(pr.reportPendingEthTxes(ctx, evmChainID), "reportPendingEthTxes failed"), errors.Wrap(pr.reportMaxUnconfirmedAge(ctx, evmChainID), "reportMaxUnconfirmedAge failed"), errors.Wrap(pr.reportMaxUnconfirmedBlocks(ctx, head), "reportMaxUnconfirmedBlocks failed"), ) + + if err != nil && ctx.Err() == nil { + pr.lggr.Errorw("Error reporting prometheus metrics", "err", err) + } } -func (pr *prometheusReporter) reportPendingEthTxes(ctx context.Context, evmChainID *big.Int) (err error) { +func (pr *promReporter) reportPendingEthTxes(ctx context.Context, evmChainID *big.Int) (err error) { txm, err := pr.getTxm(evmChainID) if err != nil { return fmt.Errorf("failed to get txm: %w", err) @@ -98,7 +202,7 @@ func (pr *prometheusReporter) reportPendingEthTxes(ctx context.Context, evmChain return nil } -func (pr *prometheusReporter) reportMaxUnconfirmedAge(ctx context.Context, evmChainID *big.Int) (err error) { +func (pr *promReporter) reportMaxUnconfirmedAge(ctx context.Context, evmChainID *big.Int) (err error) { txm, err := pr.getTxm(evmChainID) if err != nil { return fmt.Errorf("failed to get txm: %w", err) @@ -117,7 +221,7 @@ func (pr *prometheusReporter) reportMaxUnconfirmedAge(ctx context.Context, evmCh return nil } -func (pr *prometheusReporter) reportMaxUnconfirmedBlocks(ctx context.Context, head *evmtypes.Head) (err error) { +func (pr *promReporter) reportMaxUnconfirmedBlocks(ctx context.Context, head *evmtypes.Head) (err error) { txm, err := pr.getTxm(head.EVMChainID.ToInt()) if err != nil { return fmt.Errorf("failed to get txm: %w", err) @@ -136,11 +240,7 @@ func (pr *prometheusReporter) reportMaxUnconfirmedBlocks(ctx context.Context, he return nil } -func (pr *prometheusReporter) ReportPeriodic(ctx context.Context) error { - return errors.Wrap(pr.reportPipelineRunStats(ctx), "reportPipelineRunStats failed") -} - -func (pr *prometheusReporter) reportPipelineRunStats(ctx context.Context) (err error) { +func (pr *promReporter) reportPipelineRunStats(ctx context.Context) (err error) { rows, err := pr.ds.QueryContext(ctx, ` SELECT pipeline_run_id FROM pipeline_task_runs WHERE finished_at IS NULL `) @@ -171,23 +271,3 @@ SELECT pipeline_run_id FROM pipeline_task_runs WHERE finished_at IS NULL return nil } - -func (defaultBackend) SetUnconfirmedTransactions(evmChainID *big.Int, n int64) { - promUnconfirmedTransactions.WithLabelValues(evmChainID.String()).Set(float64(n)) -} - -func (defaultBackend) SetMaxUnconfirmedAge(evmChainID *big.Int, s float64) { - promMaxUnconfirmedAge.WithLabelValues(evmChainID.String()).Set(s) -} - -func (defaultBackend) SetMaxUnconfirmedBlocks(evmChainID *big.Int, n int64) { - promMaxUnconfirmedBlocks.WithLabelValues(evmChainID.String()).Set(float64(n)) -} - -func (defaultBackend) SetPipelineRunsQueued(n int) { - promPipelineTaskRunsQueued.Set(float64(n)) -} - -func (defaultBackend) SetPipelineTaskRunsQueued(n int) { - promPipelineRunsQueued.Set(float64(n)) -} diff --git a/core/services/headreporter/prometheus_reporter_test.go b/core/services/promreporter/prom_reporter_test.go similarity index 64% rename from core/services/headreporter/prometheus_reporter_test.go rename to core/services/promreporter/prom_reporter_test.go index 32d2c09d0e..b61fa25bdc 100644 --- a/core/services/headreporter/prometheus_reporter_test.go +++ b/core/services/promreporter/prom_reporter_test.go @@ -1,7 +1,8 @@ -package headreporter_test +package promreporter_test import ( "math/big" + "sync/atomic" "testing" "time" @@ -9,40 +10,90 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-common/pkg/services/servicetest" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" + evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" + ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" + "github.com/smartcontractkit/chainlink/v2/core/internal/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/headreporter" + "github.com/smartcontractkit/chainlink/v2/core/services/promreporter" ) -func Test_PrometheusReporter(t *testing.T) { +func newHead() evmtypes.Head { + return evmtypes.Head{Number: 42, EVMChainID: ubig.NewI(0)} +} + +func newLegacyChainContainer(t *testing.T, db *sqlx.DB) legacyevm.LegacyChainContainer { + config, dbConfig, evmConfig := txmgr.MakeTestConfigs(t) + keyStore := cltest.NewKeyStore(t, db).Eth() + ethClient := evmtest.NewEthClientMockWithDefaultChain(t) + estimator, err := gas.NewEstimator(logger.TestLogger(t), ethClient, config, evmConfig.GasEstimator()) + require.NoError(t, err) + lggr := logger.TestLogger(t) + lpOpts := logpoller.Opts{ + PollPeriod: 100 * time.Millisecond, + FinalityDepth: 2, + BackfillBatchSize: 3, + RpcBatchSize: 2, + KeepFinalizedBlocksDepth: 1000, + } + ht := headtracker.NewSimulatedHeadTracker(ethClient, lpOpts.UseFinalityTag, lpOpts.FinalityDepth) + lp := logpoller.NewLogPoller(logpoller.NewORM(testutils.FixtureChainID, db, lggr), ethClient, lggr, ht, lpOpts) + + txm, err := txmgr.NewTxm( + db, + evmConfig, + evmConfig.GasEstimator(), + evmConfig.Transactions(), + nil, + dbConfig, + dbConfig.Listener(), + ethClient, + lggr, + lp, + keyStore, + estimator) + require.NoError(t, err) + + cfg := configtest.NewGeneralConfig(t, nil) + return cltest.NewLegacyChainsWithMockChainAndTxManager(t, ethClient, cfg, txm) +} + +func Test_PromReporter_OnNewLongestChain(t *testing.T) { t.Run("with nothing in the database", func(t *testing.T) { db := pgtest.NewSqlxDB(t) - backend := headreporter.NewMockPrometheusBackend(t) + backend := mocks.NewPrometheusBackend(t) + reporter := promreporter.NewPromReporter(db, newLegacyChainContainer(t, db), logger.TestLogger(t), backend, 10*time.Millisecond) + + var subscribeCalls atomic.Int32 + backend.On("SetUnconfirmedTransactions", big.NewInt(0), int64(0)).Return() backend.On("SetMaxUnconfirmedAge", big.NewInt(0), float64(0)).Return() backend.On("SetMaxUnconfirmedBlocks", big.NewInt(0), int64(0)).Return() + backend.On("SetPipelineTaskRunsQueued", 0).Return() + backend.On("SetPipelineRunsQueued", 0). + Run(func(args mock.Arguments) { + subscribeCalls.Add(1) + }). + Return() - reporter := headreporter.NewPrometheusReporter(db, newLegacyChainContainer(t, db)) - reporter.SetBackend(backend) + servicetest.Run(t, reporter) - head := headreporter.NewHead() - err := reporter.ReportNewHead(testutils.Context(t), &head) - require.NoError(t, err) + head := newHead() + reporter.OnNewLongestChain(testutils.Context(t), &head) - backend.On("SetPipelineTaskRunsQueued", 0).Return() - backend.On("SetPipelineRunsQueued", 0).Return() - err = reporter.ReportPeriodic(testutils.Context(t)) - require.NoError(t, err) + require.Eventually(t, func() bool { return subscribeCalls.Load() >= 1 }, 12*time.Second, 100*time.Millisecond) }) t.Run("with unconfirmed evm.txes", func(t *testing.T) { @@ -51,92 +102,61 @@ func Test_PrometheusReporter(t *testing.T) { ethKeyStore := cltest.NewKeyStore(t, db).Eth() _, fromAddress := cltest.MustInsertRandomKey(t, ethKeyStore) - etx := cltest.MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t, txStore, 0, fromAddress) - cltest.MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t, txStore, 1, fromAddress) - cltest.MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t, txStore, 2, fromAddress) - require.NoError(t, txStore.UpdateTxAttemptBroadcastBeforeBlockNum(testutils.Context(t), etx.ID, 7)) + var subscribeCalls atomic.Int32 - backend := headreporter.NewMockPrometheusBackend(t) + backend := mocks.NewPrometheusBackend(t) backend.On("SetUnconfirmedTransactions", big.NewInt(0), int64(3)).Return() backend.On("SetMaxUnconfirmedAge", big.NewInt(0), mock.MatchedBy(func(s float64) bool { return s > 0 })).Return() backend.On("SetMaxUnconfirmedBlocks", big.NewInt(0), int64(35)).Return() + backend.On("SetPipelineTaskRunsQueued", 0).Return() + backend.On("SetPipelineRunsQueued", 0). + Run(func(args mock.Arguments) { + subscribeCalls.Add(1) + }). + Return() + reporter := promreporter.NewPromReporter(db, newLegacyChainContainer(t, db), logger.TestLogger(t), backend, 10*time.Millisecond) + servicetest.Run(t, reporter) - reporter := headreporter.NewPrometheusReporter(db, newLegacyChainContainer(t, db)) - reporter.SetBackend(backend) - - head := headreporter.NewHead() - err := reporter.ReportNewHead(testutils.Context(t), &head) - require.NoError(t, err) + etx := cltest.MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t, txStore, 0, fromAddress) + cltest.MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t, txStore, 1, fromAddress) + cltest.MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t, txStore, 2, fromAddress) + require.NoError(t, txStore.UpdateTxAttemptBroadcastBeforeBlockNum(testutils.Context(t), etx.ID, 7)) - backend.On("SetPipelineTaskRunsQueued", 0).Return() - backend.On("SetPipelineRunsQueued", 0).Return() + head := newHead() + reporter.OnNewLongestChain(testutils.Context(t), &head) - err = reporter.ReportPeriodic(testutils.Context(t)) - require.NoError(t, err) + require.Eventually(t, func() bool { return subscribeCalls.Load() >= 1 }, 12*time.Second, 100*time.Millisecond) }) t.Run("with unfinished pipeline task runs", func(t *testing.T) { db := pgtest.NewSqlxDB(t) pgtest.MustExec(t, db, `SET CONSTRAINTS pipeline_task_runs_pipeline_run_id_fkey DEFERRED`) + backend := mocks.NewPrometheusBackend(t) + reporter := promreporter.NewPromReporter(db, newLegacyChainContainer(t, db), logger.TestLogger(t), backend, 10*time.Millisecond) + cltest.MustInsertUnfinishedPipelineTaskRun(t, db, 1) cltest.MustInsertUnfinishedPipelineTaskRun(t, db, 1) cltest.MustInsertUnfinishedPipelineTaskRun(t, db, 2) - backend := headreporter.NewMockPrometheusBackend(t) + var subscribeCalls atomic.Int32 + backend.On("SetUnconfirmedTransactions", big.NewInt(0), int64(0)).Return() backend.On("SetMaxUnconfirmedAge", big.NewInt(0), float64(0)).Return() backend.On("SetMaxUnconfirmedBlocks", big.NewInt(0), int64(0)).Return() - - reporter := headreporter.NewPrometheusReporter(db, newLegacyChainContainer(t, db)) - reporter.SetBackend(backend) - - head := headreporter.NewHead() - err := reporter.ReportNewHead(testutils.Context(t), &head) - require.NoError(t, err) - backend.On("SetPipelineTaskRunsQueued", 3).Return() - backend.On("SetPipelineRunsQueued", 2).Return() - - err = reporter.ReportPeriodic(testutils.Context(t)) - require.NoError(t, err) - }) -} - -func newLegacyChainContainer(t *testing.T, db *sqlx.DB) legacyevm.LegacyChainContainer { - config, dbConfig, evmConfig := txmgr.MakeTestConfigs(t) - keyStore := cltest.NewKeyStore(t, db).Eth() - ethClient := evmtest.NewEthClientMockWithDefaultChain(t) - estimator, err := gas.NewEstimator(logger.TestLogger(t), ethClient, config, evmConfig.GasEstimator()) - require.NoError(t, err) - lggr := logger.TestLogger(t) - lpOpts := logpoller.Opts{ - PollPeriod: 100 * time.Millisecond, - FinalityDepth: 2, - BackfillBatchSize: 3, - RpcBatchSize: 2, - KeepFinalizedBlocksDepth: 1000, - } - ht := headtracker.NewSimulatedHeadTracker(ethClient, lpOpts.UseFinalityTag, lpOpts.FinalityDepth) - lp := logpoller.NewLogPoller(logpoller.NewORM(testutils.FixtureChainID, db, lggr), ethClient, lggr, ht, lpOpts) + backend.On("SetPipelineRunsQueued", 2). + Run(func(args mock.Arguments) { + subscribeCalls.Add(1) + }). + Return() + servicetest.Run(t, reporter) - txm, err := txmgr.NewTxm( - db, - evmConfig, - evmConfig.GasEstimator(), - evmConfig.Transactions(), - nil, - dbConfig, - dbConfig.Listener(), - ethClient, - lggr, - lp, - keyStore, - estimator) - require.NoError(t, err) + head := newHead() + reporter.OnNewLongestChain(testutils.Context(t), &head) - cfg := configtest.NewGeneralConfig(t, nil) - return cltest.NewLegacyChainsWithMockChainAndTxManager(t, ethClient, cfg, txm) + require.Eventually(t, func() bool { return subscribeCalls.Load() >= 1 }, 12*time.Second, 100*time.Millisecond) + }) } diff --git a/core/web/testdata/body/health.html b/core/web/testdata/body/health.html index 4e244a9fe7..2a1b222753 100644 --- a/core/web/testdata/body/health.html +++ b/core/web/testdata/body/health.html @@ -69,9 +69,6 @@ -
- HeadReporter -
JobSpawner
@@ -99,6 +96,9 @@ BridgeCache +
+ PromReporter +
TelemetryManager
diff --git a/core/web/testdata/body/health.json b/core/web/testdata/body/health.json index 224a3534c9..10415c0abd 100644 --- a/core/web/testdata/body/health.json +++ b/core/web/testdata/body/health.json @@ -99,15 +99,6 @@ "output": "" } }, - { - "type": "checks", - "id": "HeadReporter", - "attributes": { - "name": "HeadReporter", - "status": "passing", - "output": "" - } - }, { "type": "checks", "id": "JobSpawner", @@ -171,6 +162,15 @@ "output": "" } }, + { + "type": "checks", + "id": "PromReporter", + "attributes": { + "name": "PromReporter", + "status": "passing", + "output": "" + } + }, { "type": "checks", "id": "TelemetryManager", diff --git a/core/web/testdata/body/health.txt b/core/web/testdata/body/health.txt index 0fbac846a6..09c8cff6c2 100644 --- a/core/web/testdata/body/health.txt +++ b/core/web/testdata/body/health.txt @@ -10,7 +10,6 @@ ok EVM.0.Txm.BlockHistoryEstimator ok EVM.0.Txm.Broadcaster ok EVM.0.Txm.Confirmer ok EVM.0.Txm.WrappedEvmEstimator -ok HeadReporter ok JobSpawner ok Mailbox.Monitor ok Mercury.WSRPCPool @@ -18,4 +17,5 @@ ok Mercury.WSRPCPool.CacheSet ok PipelineORM ok PipelineRunner ok PipelineRunner.BridgeCache +ok PromReporter ok TelemetryManager diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 38bce599a7..bb07aca3ae 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -37,7 +37,6 @@ require ( github.com/smartcontractkit/chainlink-common v0.2.2-0.20240723123524-e407ecd120b1 github.com/smartcontractkit/chainlink-testing-framework v1.34.5 github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240405215812-5a72bc9af239 - github.com/smartcontractkit/chainlink-testing-framework/seth v1.2.1 github.com/smartcontractkit/chainlink/integration-tests v0.0.0-00010101000000-000000000000 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/havoc/k8schaos v0.0.0-20240409145249-e78d20847e37 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 3f6009ae72..7e5179b252 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1413,8 +1413,6 @@ github.com/smartcontractkit/chainlink-testing-framework v1.34.5 h1:6itLSDW4NHDDN github.com/smartcontractkit/chainlink-testing-framework v1.34.5/go.mod h1:hRZEDh2+afO8MSZb9qYNscmWb+3mHZf01J5ACZuIdTQ= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240405215812-5a72bc9af239 h1:Kk5OVlx/5g9q3Z3lhxytZS4/f8ds1MiNM8yaHgK3Oe8= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240405215812-5a72bc9af239/go.mod h1:DC8sQMyTlI/44UCTL8QWFwb0bYNoXCfjwCv2hMivYZU= -github.com/smartcontractkit/chainlink-testing-framework/seth v1.2.1 h1:GRAAvtn2+jhO/8Z3lig10eQXVcV4VuOI4UgCyoPdJBg= -github.com/smartcontractkit/chainlink-testing-framework/seth v1.2.1/go.mod h1:afY3QmNgeR/VI1pRbGH8g3YXGy7C2RrFOwUzEFvL3L8= github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo= github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 4806e99bdd..eef855ef03 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -16,8 +16,8 @@ require ( github.com/rs/zerolog v1.33.0 github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.4 - github.com/smartcontractkit/chainlink-common v0.2.2-0.20240829145110-4a45c426fbe8 - github.com/smartcontractkit/chainlink-testing-framework v1.34.12 + github.com/smartcontractkit/chainlink-common v0.2.2-0.20240723123524-e407ecd120b1 + github.com/smartcontractkit/chainlink-testing-framework v1.34.5 github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240214231432-4ad5eb95178c github.com/smartcontractkit/chainlink/v2 v2.9.0-beta0.0.20240216210048-da02459ddad8 github.com/smartcontractkit/libocr v0.0.0-20240717100443-f6226e09bee7 @@ -36,30 +36,13 @@ require ( cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/math v1.3.0 // indirect github.com/awalterschulze/gographviz v2.0.3+incompatible // indirect - github.com/aws/aws-sdk-go-v2 v1.30.4 // indirect - github.com/aws/aws-sdk-go-v2/config v1.27.28 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.28 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.12 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.16 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.16 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.18 // indirect - github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.5 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.22.5 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.5 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.30.4 // indirect - github.com/aws/smithy-go v1.20.4 // indirect github.com/containerd/errdefs v0.1.0 // indirect - github.com/go-viper/mapstructure/v2 v2.1.0 // indirect github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 // indirect - github.com/smartcontractkit/chainlink-testing-framework/seth v1.2.1 // indirect - github.com/smartcontractkit/chainlink-testing-framework/wasp v0.4.10 // indirect github.com/testcontainers/testcontainers-go v0.28.0 // indirect k8s.io/apimachinery v0.31.0 // indirect ) diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index da5b0c3cdf..86712da168 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -203,38 +203,10 @@ github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpi github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.45.25 h1:c4fLlh5sLdK2DCRTY1z0hyuJZU4ygxX8m1FswL6/nF4= github.com/aws/aws-sdk-go v1.45.25/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.30.4 h1:frhcagrVNrzmT95RJImMHgabt99vkXGslubDaDagTk8= -github.com/aws/aws-sdk-go-v2 v1.30.4/go.mod h1:CT+ZPWXbYrci8chcARI3OmI/qgd+f6WtuLOoaIA8PR0= -github.com/aws/aws-sdk-go-v2/config v1.27.28 h1:OTxWGW/91C61QlneCtnD62NLb4W616/NM1jA8LhJqbg= -github.com/aws/aws-sdk-go-v2/config v1.27.28/go.mod h1:uzVRVtJSU5EFv6Fu82AoVFKozJi2ZCY6WRCXj06rbvs= -github.com/aws/aws-sdk-go-v2/credentials v1.17.28 h1:m8+AHY/ND8CMHJnPoH7PJIRakWGa4gbfbxuY9TGTUXM= -github.com/aws/aws-sdk-go-v2/credentials v1.17.28/go.mod h1:6TF7dSc78ehD1SL6KpRIPKMA1GyyWflIkjqg+qmf4+c= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.12 h1:yjwoSyDZF8Jth+mUk5lSPJCkMC0lMy6FaCD51jm6ayE= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.12/go.mod h1:fuR57fAgMk7ot3WcNQfb6rSEn+SUffl7ri+aa8uKysI= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.16 h1:TNyt/+X43KJ9IJJMjKfa3bNTiZbUP7DeCxfbTROESwY= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.16/go.mod h1:2DwJF39FlNAUiX5pAc0UNeiz16lK2t7IaFcm0LFHEgc= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.16 h1:jYfy8UPmd+6kJW5YhY0L1/KftReOGxI/4NtVSTh9O/I= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.16/go.mod h1:7ZfEPZxkW42Afq4uQB8H2E2e6ebh6mXTueEpYzjCzcs= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4 h1:KypMCbLPPHEmf9DgMGw51jMj77VfGPAN2Kv4cfhlfgI= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4/go.mod h1:Vz1JQXliGcQktFTN/LN6uGppAIRoLBR2bMvIMP0gOjc= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.18 h1:tJ5RnkHCiSH0jyd6gROjlJtNwov0eGYNz8s8nFcR0jQ= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.18/go.mod h1:++NHzT+nAF7ZPrHPsA+ENvsXkOO8wEu+C6RXltAG4/c= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.5 h1:UDXu9dqpCZYonj7poM4kFISjzTdWI0v3WUusM+w+Gfc= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.5/go.mod h1:5NPkI3RsTOhwz1CuG7VVSgJCm3CINKkoIaUbUZWQ67w= -github.com/aws/aws-sdk-go-v2/service/sso v1.22.5 h1:zCsFCKvbj25i7p1u94imVoO447I/sFv8qq+lGJhRN0c= -github.com/aws/aws-sdk-go-v2/service/sso v1.22.5/go.mod h1:ZeDX1SnKsVlejeuz41GiajjZpRSWR7/42q/EyA/QEiM= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.5 h1:SKvPgvdvmiTWoi0GAJ7AsJfOz3ngVkD/ERbs5pUnHNI= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.5/go.mod h1:20sz31hv/WsPa3HhU3hfrIet2kxM4Pe0r20eBZ20Tac= -github.com/aws/aws-sdk-go-v2/service/sts v1.30.4 h1:iAckBT2OeEK/kBDyN/jDtpEExhjeeA/Im2q4X0rJZT8= -github.com/aws/aws-sdk-go-v2/service/sts v1.30.4/go.mod h1:vmSqFK+BVIwVpDAGZB3CoCXHzurt4qBE8lf+I/kRTh0= github.com/aws/constructs-go/constructs/v10 v10.1.255 h1:5hARfEmhBqHSTQf/C3QLA3sWOxO2Dfja0iA1W7ZcI7g= github.com/aws/constructs-go/constructs/v10 v10.1.255/go.mod h1:DCdBSjN04Ck2pajCacTD4RKFqSA7Utya8d62XreYctI= github.com/aws/jsii-runtime-go v1.75.0 h1:NhpUfyiL7/wsRuUekFsz8FFBCYLfPD/l61kKg9kL/a4= github.com/aws/jsii-runtime-go v1.75.0/go.mod h1:TKCyrtM0pygEPo4rDZzbMSDNCDNTSYSN6/mGyHI6O3I= -github.com/aws/smithy-go v1.20.4 h1:2HK1zBdPgRbjFOHlfeQZfpC4r72MOb9bZkiFwggKO+4= -github.com/aws/smithy-go v1.20.4/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df h1:GSoSVRLoBaFpOOds6QyY1L8AX7uoY+Ln3BHc22W40X0= @@ -624,8 +596,6 @@ github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1v github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= -github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/go-webauthn/webauthn v0.9.4 h1:YxvHSqgUyc5AK2pZbqkWWR55qKeDPhP8zLDr6lpIc2g= github.com/go-webauthn/webauthn v0.9.4/go.mod h1:LqupCtzSef38FcxzaklmOn7AykGKhAhr9xlRbdbgnTw= github.com/go-webauthn/x v0.1.5 h1:V2TCzDU2TGLd0kSZOXdrqDVV5JB9ILnKxA9S53CSBw0= @@ -1393,8 +1363,8 @@ github.com/smartcontractkit/chain-selectors v1.0.23 h1:D2Eaex4Cw/O7Lg3tX6WklOqnj github.com/smartcontractkit/chain-selectors v1.0.23/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8= github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= -github.com/smartcontractkit/chainlink-common v0.2.2-0.20240829145110-4a45c426fbe8 h1:MOFuL1J4/rRcR0x09qSlOsKIiq4I7YzbZcQ421KqUZA= -github.com/smartcontractkit/chainlink-common v0.2.2-0.20240829145110-4a45c426fbe8/go.mod h1:TJSY2ETKiXLRPvGHNO7Dp1tlpFIPSCWwN3iIdrsadIE= +github.com/smartcontractkit/chainlink-common v0.2.2-0.20240723123524-e407ecd120b1 h1:pdEpjgbZ5w/Sd5lzg/XiuC5gVyrmSovOo+3nUD46SP8= +github.com/smartcontractkit/chainlink-common v0.2.2-0.20240723123524-e407ecd120b1/go.mod h1:Jg1sCTsbxg76YByI8ifpFby3FvVqISStHT8ypy9ocmY= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45 h1:NBQLtqk8zsyY4qTJs+NElI3aDFTcAo83JHvqD04EvB0= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240710121324-3ed288aa9b45/go.mod h1:LV0h7QBQUpoC2UUi6TcUvcIFm1xjP/DtEcqV8+qeLUs= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240718160222-2dc0c8136bfa h1:g75H8oh2ws52s8BekwvGQ9XvBVu3E7WM1rfiA0PN0zk= @@ -1405,14 +1375,10 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240712132946-267a37c5ac6 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240712132946-267a37c5ac6e/go.mod h1:hsFhop+SlQHKD+DEFjZrMJmbauT1A/wvtZIeeo4PxFU= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240709043547-03612098f799 h1:HyLTySm7BR+oNfZqDTkVJ25wnmcTtxBBD31UkFL+kEM= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240709043547-03612098f799/go.mod h1:UVFRacRkP7O7TQAzFmR52v5mUlxf+G1ovMlCQAB/cHU= -github.com/smartcontractkit/chainlink-testing-framework v1.34.12 h1:pI0ESAspOcEqQ1fm53+3o2laGNwP8wbQNAmrGp5Tw1A= -github.com/smartcontractkit/chainlink-testing-framework v1.34.12/go.mod h1:ekYJbRAxXcs/YgOjHsY9/tlvDvXzv3lxcZK2eFUZduc= +github.com/smartcontractkit/chainlink-testing-framework v1.34.5 h1:6itLSDW4NHDDNR+Y+Z8YDzxxCN9SjdKb6SmLCl0vTFM= +github.com/smartcontractkit/chainlink-testing-framework v1.34.5/go.mod h1:hRZEDh2+afO8MSZb9qYNscmWb+3mHZf01J5ACZuIdTQ= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.1 h1:1/r1wQZ4TOFpZ13w94r7amdF096Z96RuEnkOmrz1BGE= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.1/go.mod h1:DC8sQMyTlI/44UCTL8QWFwb0bYNoXCfjwCv2hMivYZU= -github.com/smartcontractkit/chainlink-testing-framework/seth v1.2.1 h1:GRAAvtn2+jhO/8Z3lig10eQXVcV4VuOI4UgCyoPdJBg= -github.com/smartcontractkit/chainlink-testing-framework/seth v1.2.1/go.mod h1:afY3QmNgeR/VI1pRbGH8g3YXGy7C2RrFOwUzEFvL3L8= -github.com/smartcontractkit/chainlink-testing-framework/wasp v0.4.10 h1:s7e9YPU/ECQ9xCyLc60ApFbf0blMjg9LWi31CAEjaZY= -github.com/smartcontractkit/chainlink-testing-framework/wasp v0.4.10/go.mod h1:E7x2ICsT8vzy0nL6wwBphoQMoNwOMl0L9voQpEl1FoM= github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo= github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= diff --git a/testdata/scripts/health/default.txtar b/testdata/scripts/health/default.txtar index 777d3e5e12..1dbf6b8eb9 100644 --- a/testdata/scripts/health/default.txtar +++ b/testdata/scripts/health/default.txtar @@ -31,7 +31,6 @@ fj293fbBnlQ!f9vNs HTTPPort = $PORT -- out.txt -- -ok HeadReporter ok JobSpawner ok Mailbox.Monitor ok Mercury.WSRPCPool @@ -39,20 +38,12 @@ ok Mercury.WSRPCPool.CacheSet ok PipelineORM ok PipelineRunner ok PipelineRunner.BridgeCache +ok PromReporter ok TelemetryManager -- out.json -- { "data": [ - { - "type": "checks", - "id": "HeadReporter", - "attributes": { - "name": "HeadReporter", - "status": "passing", - "output": "" - } - }, { "type": "checks", "id": "JobSpawner", @@ -116,6 +107,15 @@ ok TelemetryManager "output": "" } }, + { + "type": "checks", + "id": "PromReporter", + "attributes": { + "name": "PromReporter", + "status": "passing", + "output": "" + } + }, { "type": "checks", "id": "TelemetryManager", diff --git a/testdata/scripts/health/multi-chain.txtar b/testdata/scripts/health/multi-chain.txtar index 3bd15850af..8178f8e821 100644 --- a/testdata/scripts/health/multi-chain.txtar +++ b/testdata/scripts/health/multi-chain.txtar @@ -75,7 +75,6 @@ ok EVM.1.Txm.BlockHistoryEstimator ok EVM.1.Txm.Broadcaster ok EVM.1.Txm.Confirmer ok EVM.1.Txm.WrappedEvmEstimator -ok HeadReporter ok JobSpawner ok Mailbox.Monitor ok Mercury.WSRPCPool @@ -83,6 +82,7 @@ ok Mercury.WSRPCPool.CacheSet ok PipelineORM ok PipelineRunner ok PipelineRunner.BridgeCache +ok PromReporter ok Solana.Bar ok StarkNet.Baz ok TelemetryManager @@ -216,15 +216,6 @@ ok TelemetryManager "output": "" } }, - { - "type": "checks", - "id": "HeadReporter", - "attributes": { - "name": "HeadReporter", - "status": "passing", - "output": "" - } - }, { "type": "checks", "id": "JobSpawner", @@ -288,6 +279,15 @@ ok TelemetryManager "output": "" } }, + { + "type": "checks", + "id": "PromReporter", + "attributes": { + "name": "PromReporter", + "status": "passing", + "output": "" + } + }, { "type": "checks", "id": "Solana.Bar",