Skip to content

Commit

Permalink
CCIP-4447 Llo promwrapper (#15539)
Browse files Browse the repository at this point in the history
* Adding OCR3 metrics promwrapper to LLO

* Changeset bump

* Added some logging

* Added some logging

* Added some logging
  • Loading branch information
mateusz-sekara authored Dec 9, 2024
1 parent ddd012e commit 49b7704
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-files-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

Adding OCR3 promwrapper to LLO #internal
4 changes: 2 additions & 2 deletions core/capabilities/ccip/oraclecreator/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter(
rmnPeerClient,
rmnCrypto,
)
factory = promwrapper.NewReportingPluginFactory[[]byte](factory, chainID, "CCIPCommit")
factory = promwrapper.NewReportingPluginFactory[[]byte](factory, i.lggr, chainID, "CCIPCommit")
transmitter = ocrimpls.NewCommitContractTransmitter[[]byte](destChainWriter,
ocrtypes.Account(destFromAccounts[0]),
hexutil.Encode(config.Config.OfframpAddress), // TODO: this works for evm only, how about non-evm?
Expand All @@ -291,7 +291,7 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter(
contractReaders,
chainWriters,
)
factory = promwrapper.NewReportingPluginFactory[[]byte](factory, chainID, "CCIPExec")
factory = promwrapper.NewReportingPluginFactory[[]byte](factory, i.lggr, chainID, "CCIPExec")
transmitter = ocrimpls.NewExecContractTransmitter[[]byte](destChainWriter,
ocrtypes.Account(destFromAccounts[0]),
hexutil.Encode(config.Config.OfframpAddress), // TODO: this works for evm only, how about non-evm?
Expand Down
19 changes: 17 additions & 2 deletions core/services/llo/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

corelogger "github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr3/promwrapper"
"github.com/smartcontractkit/chainlink/v2/core/services/streams"
)

Expand Down Expand Up @@ -59,6 +60,7 @@ type DelegateConfig struct {
ShouldRetireCache datastreamsllo.ShouldRetireCache
EAMonitoringEndpoint ocrcommontypes.MonitoringEndpoint
DonID uint32
ChainID string

// OCR3
TraceLogging bool
Expand Down Expand Up @@ -151,8 +153,21 @@ func (d *delegate) Start(ctx context.Context) error {
OffchainConfigDigester: d.cfg.OffchainConfigDigester,
OffchainKeyring: d.cfg.OffchainKeyring,
OnchainKeyring: d.cfg.OnchainKeyring,
ReportingPluginFactory: datastreamsllo.NewPluginFactory(
d.cfg.ReportingPluginConfig, psrrc, d.src, d.cfg.RetirementReportCodec, d.cfg.ChannelDefinitionCache, d.ds, logger.Named(lggr, "ReportingPlugin"), llo.EVMOnchainConfigCodec{}, d.reportCodecs,
ReportingPluginFactory: promwrapper.NewReportingPluginFactory(
datastreamsllo.NewPluginFactory(
d.cfg.ReportingPluginConfig,
psrrc,
d.src,
d.cfg.RetirementReportCodec,
d.cfg.ChannelDefinitionCache,
d.ds,
logger.Named(lggr, "ReportingPlugin"),
llo.EVMOnchainConfigCodec{},
d.reportCodecs,
),
lggr,
d.cfg.ChainID,
"llo",
),
MetricsRegisterer: prometheus.WrapRegistererWith(map[string]string{"job_name": d.cfg.JobName.ValueOrZero()}, prometheus.DefaultRegisterer),
})
Expand Down
1 change: 1 addition & 0 deletions core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@ func (d *Delegate) newServicesLLO(
RetirementReportCodec: datastreamsllo.StandardRetirementReportCodec{},
EAMonitoringEndpoint: d.monitoringEndpointGen.GenMonitoringEndpoint(rid.Network, rid.ChainID, telemetryContractID, synchronization.EnhancedEAMercury),
DonID: pluginCfg.DonID,
ChainID: rid.ChainID,

TraceLogging: d.cfg.OCR2().TraceLogging(),
BinaryNetworkEndpointFactory: d.peerWrapper.Peer2,
Expand Down
9 changes: 9 additions & 0 deletions core/services/ocr3/promwrapper/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@ package promwrapper
import (
"context"

"github.com/smartcontractkit/chainlink-common/pkg/logger"

"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"
)

var _ ocr3types.ReportingPluginFactory[any] = &ReportingPluginFactory[any]{}

type ReportingPluginFactory[RI any] struct {
origin ocr3types.ReportingPluginFactory[RI]
lggr logger.Logger
chainID string
plugin string
}

func NewReportingPluginFactory[RI any](
origin ocr3types.ReportingPluginFactory[RI],
lggr logger.Logger,
chainID string,
plugin string,
) *ReportingPluginFactory[RI] {
return &ReportingPluginFactory[RI]{
origin: origin,
lggr: lggr,
chainID: chainID,
plugin: plugin,
}
Expand All @@ -31,6 +36,10 @@ func (r ReportingPluginFactory[RI]) NewReportingPlugin(ctx context.Context, conf
if err != nil {
return nil, ocr3types.ReportingPluginInfo{}, err
}
r.lggr.Infow("Wrapping ReportingPlugin with prometheus metrics reporter",
"configDigest", config.ConfigDigest,
"oracleID", config.OracleID,
)
wrapped := newReportingPlugin(
plugin,
r.chainID,
Expand Down
6 changes: 4 additions & 2 deletions core/services/ocr3/promwrapper/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import (
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"

"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"

"github.com/smartcontractkit/chainlink/v2/core/logger"
)

func Test_WrapperFactory(t *testing.T) {
validFactory := NewReportingPluginFactory(fakeFactory[uint]{}, "solana", "plugin")
failingFactory := NewReportingPluginFactory(fakeFactory[uint]{err: errors.New("error")}, "123", "plugin")
validFactory := NewReportingPluginFactory(fakeFactory[uint]{}, logger.TestLogger(t), "solana", "plugin")
failingFactory := NewReportingPluginFactory(fakeFactory[uint]{err: errors.New("error")}, logger.TestLogger(t), "123", "plugin")

plugin, _, err := validFactory.NewReportingPlugin(tests.Context(t), ocr3types.ReportingPluginConfig{})
require.NoError(t, err)
Expand Down

0 comments on commit 49b7704

Please sign in to comment.