From daa66274df2abfd13cf08f09f11b9581ffcd0470 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 9 Jul 2024 17:22:47 -0400 Subject: [PATCH] using provider based commitStoreReader for exec (#1150) ## Motivation Follow on to #1080, using a provider based commitStoreReader in the exec plugin --------- Co-authored-by: ilija42 <57732589+ilija42@users.noreply.github.com> Co-authored-by: Aaron Lu <50029043+aalu1418@users.noreply.github.com> --- .../plugins/ccip/ccipcommit/initializers.go | 5 ++++- .../ocr2/plugins/ccip/ccipexec/initializers.go | 17 +++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go b/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go index 729d8ca5c1..fde5d61d73 100644 --- a/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go +++ b/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go @@ -56,6 +56,9 @@ func NewCommitServices(ctx context.Context, ds sqlutil.DataSource, srcProvider c } commitStoreAddress := common.HexToAddress(spec.ContractID) + + // commit store contract doesn't exist on the source chain, but we have an implementation of it + // to get access to a gas estimator on the source chain srcCommitStore, err := srcProvider.NewCommitStoreReader(ctx, ccipcalc.EvmAddrToGeneric(commitStoreAddress)) if err != nil { return nil, err @@ -222,7 +225,7 @@ func CommitReportToEthTxMeta(typ ccipconfig.ContractType, ver semver.Version) (f // https://github.com/smartcontractkit/ccip/blob/68e2197472fb017dd4e5630d21e7878d58bc2a44/core/services/feeds/service.go#L716 // TODO once that transaction is broken up, we should be able to simply rely on oracle.Close() to cleanup the filters. // Until then we have to deterministically reload the readers from the spec (and thus their filters) and close them. -func UnregisterCommitPluginLpFilters(ctx context.Context, lggr logger.Logger, jb job.Job, chainSet legacyevm.LegacyChainContainer) error { +func UnregisterCommitPluginLpFilters(_ context.Context, lggr logger.Logger, jb job.Job, chainSet legacyevm.LegacyChainContainer) error { params, err := extractJobSpecParams(jb, chainSet) if err != nil { return err diff --git a/core/services/ocr2/plugins/ccip/ccipexec/initializers.go b/core/services/ocr2/plugins/ccip/ccipexec/initializers.go index a9f474c17d..e30ebd32c7 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/initializers.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/initializers.go @@ -50,7 +50,7 @@ var ( var defaultNewReportingPluginRetryConfig = ccipdata.RetryConfig{InitialDelay: time.Second, MaxDelay: 5 * time.Minute} -func NewExecServices(ctx context.Context, lggr logger.Logger, jb job.Job, srcProvider types.CCIPExecProvider, dstProvider types.CCIPExecProvider, srcChain legacyevm.Chain, dstChain legacyevm.Chain, srcChainID int64, dstChainID int64, chainSet legacyevm.LegacyChainContainer, new bool, argsNoPlugin libocr2.OCR2OracleArgs, logError func(string)) ([]job.ServiceCtx, error) { +func NewExecServices(ctx context.Context, lggr logger.Logger, jb job.Job, srcProvider types.CCIPExecProvider, dstProvider types.CCIPExecProvider, srcChainID int64, dstChainID int64, new bool, argsNoPlugin libocr2.OCR2OracleArgs, logError func(string)) ([]job.ServiceCtx, error) { if jb.OCR2OracleSpec == nil { return nil, fmt.Errorf("spec is nil") } @@ -89,21 +89,18 @@ func NewExecServices(ctx context.Context, lggr logger.Logger, jb job.Job, srcPro return nil, fmt.Errorf("get source wrapped native token: %w", err) } - versionFinder := ccip.NewEvmVersionFinder() - commitStoreReader, err := factory.NewCommitStoreReader(lggr, versionFinder, offRampConfig.CommitStore, dstChain.Client(), dstChain.LogPoller()) + srcCommitStore, err := srcProvider.NewCommitStoreReader(ctx, offRampConfig.CommitStore) if err != nil { - return nil, fmt.Errorf("could not load commitStoreReader reader: %w", err) + return nil, fmt.Errorf("could not create src commitStoreReader reader: %w", err) } - err = commitStoreReader.SetGasEstimator(ctx, srcChain.GasEstimator()) + dstCommitStore, err := dstProvider.NewCommitStoreReader(ctx, offRampConfig.CommitStore) if err != nil { - return nil, fmt.Errorf("could not set gas estimator: %w", err) + return nil, fmt.Errorf("could not create dst commitStoreReader reader: %w", err) } - err = commitStoreReader.SetSourceMaxGasPrice(ctx, srcChain.Config().EVM().GasEstimator().PriceMax().ToInt()) - if err != nil { - return nil, fmt.Errorf("could not set source max gas price: %w", err) - } + var commitStoreReader ccipdata.CommitStoreReader + commitStoreReader = ccip.NewProviderProxyCommitStoreReader(srcCommitStore, dstCommitStore) tokenDataProviders := make(map[cciptypes.Address]tokendata.Reader) // init usdc token data provider