Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCIP-4447 Llo promwrapper #15539

Merged
merged 7 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading