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

Revert "Commit NewReportingPlugin retries on error" #1198

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .changeset/red-balloons-repeat.md

This file was deleted.

79 changes: 27 additions & 52 deletions core/services/ocr2/plugins/ccip/ccipcommit/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"

cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcommon"

"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc"
Expand Down Expand Up @@ -65,60 +64,40 @@ func (rf *CommitReportingPluginFactory) UpdateDynamicReaders(ctx context.Context
return nil
}

type reportingPluginAndInfo struct {
plugin types.ReportingPlugin
pluginInfo types.ReportingPluginInfo
}

// NewReportingPlugin registers a new ReportingPlugin
// NewReportingPlugin returns the ccip CommitReportingPlugin and satisfies the ReportingPluginFactory interface.
func (rf *CommitReportingPluginFactory) NewReportingPlugin(config types.ReportingPluginConfig) (types.ReportingPlugin, types.ReportingPluginInfo, error) {
initialRetryDelay := rf.config.newReportingPluginRetryConfig.InitialDelay
maxDelay := rf.config.newReportingPluginRetryConfig.MaxDelay
ctx := context.Background() // todo: consider adding some timeout

pluginAndInfo, err := ccipcommon.RetryUntilSuccess(rf.NewReportingPluginFn(config), initialRetryDelay, maxDelay)
destPriceReg, err := rf.config.commitStore.ChangeConfig(ctx, config.OnchainConfig, config.OffchainConfig)
if err != nil {
return nil, types.ReportingPluginInfo{}, err
}
return pluginAndInfo.plugin, pluginAndInfo.pluginInfo, err
}

// NewReportingPluginFn implements the NewReportingPlugin logic. It is defined as a function so that it can easily be
// retried via RetryUntilSuccess. NewReportingPlugin must return successfully in order for the Commit plugin to
// function, hence why we can only keep retrying it until it succeeds.
func (rf *CommitReportingPluginFactory) NewReportingPluginFn(config types.ReportingPluginConfig) func() (reportingPluginAndInfo, error) {
return func() (reportingPluginAndInfo, error) {
ctx := context.Background() // todo: consider adding some timeout

destPriceReg, err := rf.config.commitStore.ChangeConfig(ctx, config.OnchainConfig, config.OffchainConfig)
if err != nil {
return reportingPluginAndInfo{}, err
}

priceRegEvmAddr, err := ccipcalc.GenericAddrToEvm(destPriceReg)
if err != nil {
return reportingPluginAndInfo{}, err
}
if err = rf.UpdateDynamicReaders(ctx, priceRegEvmAddr); err != nil {
return reportingPluginAndInfo{}, err
}
priceRegEvmAddr, err := ccipcalc.GenericAddrToEvm(destPriceReg)
if err != nil {
return nil, types.ReportingPluginInfo{}, err
}
if err = rf.UpdateDynamicReaders(ctx, priceRegEvmAddr); err != nil {
return nil, types.ReportingPluginInfo{}, err
}

pluginOffChainConfig, err := rf.config.commitStore.OffchainConfig(ctx)
if err != nil {
return reportingPluginAndInfo{}, err
}
pluginOffChainConfig, err := rf.config.commitStore.OffchainConfig(ctx)
if err != nil {
return nil, types.ReportingPluginInfo{}, err
}

gasPriceEstimator, err := rf.config.commitStore.GasPriceEstimator(ctx)
if err != nil {
return reportingPluginAndInfo{}, err
}
gasPriceEstimator, err := rf.config.commitStore.GasPriceEstimator(ctx)
if err != nil {
return nil, types.ReportingPluginInfo{}, err
}

err = rf.config.priceService.UpdateDynamicConfig(ctx, gasPriceEstimator, rf.destPriceRegReader)
if err != nil {
return reportingPluginAndInfo{}, err
}
err = rf.config.priceService.UpdateDynamicConfig(ctx, gasPriceEstimator, rf.destPriceRegReader)
if err != nil {
return nil, types.ReportingPluginInfo{}, err
}

lggr := rf.config.lggr.Named("CommitReportingPlugin")
plugin := &CommitReportingPlugin{
lggr := rf.config.lggr.Named("CommitReportingPlugin")
return &CommitReportingPlugin{
sourceChainSelector: rf.config.sourceChainSelector,
sourceNative: rf.config.sourceNative,
onRampReader: rf.config.onRampReader,
Expand All @@ -133,18 +112,14 @@ func (rf *CommitReportingPluginFactory) NewReportingPluginFn(config types.Report
metricsCollector: rf.config.metricsCollector,
chainHealthcheck: rf.config.chainHealthcheck,
priceService: rf.config.priceService,
}

pluginInfo := types.ReportingPluginInfo{
},
types.ReportingPluginInfo{
Name: "CCIPCommit",
UniqueReports: false, // See comment in CommitStore constructor.
Limits: types.ReportingPluginLimits{
MaxQueryLength: ccip.MaxQueryLength,
MaxObservationLength: ccip.MaxObservationLength,
MaxReportLength: MaxCommitReportLength,
},
}

return reportingPluginAndInfo{plugin, pluginInfo}, nil
}
}, nil
}
100 changes: 0 additions & 100 deletions core/services/ocr2/plugins/ccip/ccipcommit/factory_test.go

This file was deleted.

26 changes: 11 additions & 15 deletions core/services/ocr2/plugins/ccip/ccipcommit/initializers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"math/big"
"strings"
"time"

"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/pricegetter"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/rpclib"
Expand Down Expand Up @@ -44,8 +43,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
)

var defaultNewReportingPluginRetryConfig = ccipdata.RetryConfig{InitialDelay: time.Second, MaxDelay: 5 * time.Minute}

func NewCommitServices(ctx context.Context, ds sqlutil.DataSource, srcProvider commontypes.CCIPCommitProvider, dstProvider commontypes.CCIPCommitProvider, chainSet legacyevm.LegacyChainContainer, jb job.Job, lggr logger.Logger, pr pipeline.Runner, argsNoPlugin libocr2.OCR2OracleArgs, new bool, sourceChainID int64, destChainID int64, logError func(string)) ([]job.ServiceCtx, error) {
spec := jb.OCR2OracleSpec

Expand Down Expand Up @@ -177,18 +174,17 @@ func NewCommitServices(ctx context.Context, ds sqlutil.DataSource, srcProvider c
)

wrappedPluginFactory := NewCommitReportingPluginFactory(CommitPluginStaticConfig{
lggr: lggr,
newReportingPluginRetryConfig: defaultNewReportingPluginRetryConfig,
onRampReader: onRampReader,
sourceChainSelector: staticConfig.SourceChainSelector,
sourceNative: sourceNative,
offRamp: offRampReader,
commitStore: commitStoreReader,
destChainSelector: staticConfig.ChainSelector,
priceRegistryProvider: ccip.NewChainAgnosticPriceRegistry(dstProvider),
metricsCollector: metricsCollector,
chainHealthcheck: chainHealthCheck,
priceService: priceService,
lggr: lggr,
onRampReader: onRampReader,
sourceChainSelector: staticConfig.SourceChainSelector,
sourceNative: sourceNative,
offRamp: offRampReader,
commitStore: commitStoreReader,
destChainSelector: staticConfig.ChainSelector,
priceRegistryProvider: ccip.NewChainAgnosticPriceRegistry(dstProvider),
metricsCollector: metricsCollector,
chainHealthcheck: chainHealthCheck,
priceService: priceService,
})
argsNoPlugin.ReportingPluginFactory = promwrapper.NewPromFactory(wrappedPluginFactory, "CCIPCommit", jb.OCR2OracleSpec.Relay, big.NewInt(0).SetInt64(destChainID))
argsNoPlugin.Logger = commonlogger.NewOCRWrapper(commitLggr, true, logError)
Expand Down
3 changes: 1 addition & 2 deletions core/services/ocr2/plugins/ccip/ccipcommit/ocr2.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ type update struct {
}

type CommitPluginStaticConfig struct {
lggr logger.Logger
newReportingPluginRetryConfig ccipdata.RetryConfig
lggr logger.Logger
// Source
onRampReader ccipdata.OnRampReader
sourceChainSelector uint64
Expand Down
Loading