Skip to content

Commit

Permalink
using provider based commitStoreReader for exec
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhuie19 committed Jul 7, 2024
1 parent a4474ab commit 36328d8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
15 changes: 6 additions & 9 deletions core/services/ocr2/plugins/ccip/ccipexec/initializers.go
Original file line number Diff line number Diff line change
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
2 changes: 2 additions & 0 deletions core/services/relay/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ func (r *Relayer) NewCCIPExecProvider(rargs commontypes.RelayArgs, pargs commont
r.lggr,
versionFinder,
r.chain.Client(),
r.chain.GasEstimator(),
r.chain.Config().EVM().GasEstimator().PriceMax().ToInt(),
r.chain.LogPoller(),
execPluginConfig.SourceStartBlock,
execPluginConfig.JobID,
Expand Down
19 changes: 13 additions & 6 deletions core/services/relay/evm/exec_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type SrcExecProvider struct {
client client.Client
lp logpoller.LogPoller
startBlock uint64
estimator gas.EvmFeeEstimator
maxGasPrice *big.Int
usdcReader *ccip.USDCReaderImpl
usdcAttestationAPI string
usdcAttestationAPITimeoutSeconds int
Expand All @@ -39,6 +41,8 @@ func NewSrcExecProvider(
lggr logger.Logger,
versionFinder ccip.VersionFinder,
client client.Client,
estimator gas.EvmFeeEstimator,
maxGasPrice *big.Int,
lp logpoller.LogPoller,
startBlock uint64,
jobID string,
Expand All @@ -60,6 +64,8 @@ func NewSrcExecProvider(
lggr: lggr,
versionFinder: versionFinder,
client: client,
estimator: estimator,
maxGasPrice: maxGasPrice,
lp: lp,
startBlock: startBlock,
usdcReader: usdcReader,
Expand Down Expand Up @@ -120,9 +126,9 @@ func (s SrcExecProvider) Codec() commontypes.Codec {
return nil
}

func (s SrcExecProvider) NewCommitStoreReader(ctx context.Context, addr cciptypes.Address) (cciptypes.CommitStoreReader, error) {
// TODO CCIP-2493
return nil, fmt.Errorf("invalid: NewCommitStoreReader not implemented")
func (s SrcExecProvider) NewCommitStoreReader(ctx context.Context, addr cciptypes.Address) (commitStoreReader cciptypes.CommitStoreReader, err error) {
commitStoreReader = NewIncompleteSourceCommitStoreReader(s.estimator, s.maxGasPrice)
return
}

func (s SrcExecProvider) NewOffRampReader(ctx context.Context, addr cciptypes.Address) (cciptypes.OffRampReader, error) {
Expand Down Expand Up @@ -262,9 +268,10 @@ func (d DstExecProvider) Codec() commontypes.Codec {
return nil
}

func (d DstExecProvider) NewCommitStoreReader(ctx context.Context, addr cciptypes.Address) (cciptypes.CommitStoreReader, error) {
// TODO CCIP-2493
return nil, fmt.Errorf("invalid: NewCommitStoreReader not yet implemented")
func (d DstExecProvider) NewCommitStoreReader(ctx context.Context, addr cciptypes.Address) (commitStoreReader cciptypes.CommitStoreReader, err error) {
versionFinder := ccip.NewEvmVersionFinder()
commitStoreReader, err = NewIncompleteDestCommitStoreReader(d.lggr, versionFinder, addr, d.client, d.lp)
return
}

func (d DstExecProvider) NewOffRampReader(ctx context.Context, offRampAddress cciptypes.Address) (offRampReader cciptypes.OffRampReader, err error) {
Expand Down

0 comments on commit 36328d8

Please sign in to comment.