Skip to content

Commit

Permalink
using provider based commitStoreReader for exec (#1150)
Browse files Browse the repository at this point in the history
## Motivation
Follow on to #1080, using a provider based commitStoreReader in the exec
plugin

---------

Co-authored-by: ilija42 <[email protected]>
Co-authored-by: Aaron Lu <[email protected]>
  • Loading branch information
3 people authored Jul 9, 2024
1 parent 5da59de commit daa6627
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 4 additions & 1 deletion core/services/ocr2/plugins/ccip/ccipcommit/initializers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 7 additions & 10 deletions core/services/ocr2/plugins/ccip/ccipexec/initializers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit daa6627

Please sign in to comment.