Skip to content

Commit

Permalink
fixing usdc attestation API logic
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhuie19 committed Jul 10, 2024
1 parent aac498a commit 5f8c04e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
4 changes: 3 additions & 1 deletion core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,9 @@ func (d *Delegate) newServicesCCIPExecution(ctx context.Context, lggr logger.Sug
return nil, err
}

err = pluginJobSpecConfig.USDCConfig.ValidateUSDCConfig()
if pluginJobSpecConfig.USDCConfig.AttestationAPI != "" {
err = pluginJobSpecConfig.USDCConfig.ValidateUSDCConfig()
}
if err != nil {
return nil, err
}
Expand Down
12 changes: 10 additions & 2 deletions core/services/ocr2/plugins/ccip/ccipexec/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,18 @@ func NewExecutionReportingPluginFactoryV2(ctx context.Context, lggr logger.Logge
tokenDataProviders := make(map[cciptypes.Address]tokendata.Reader)
// init usdc token data provider
usdcReader, err2 := srcProvider.NewTokenDataReader(ctx, "")
tokenDataProviders[cciptypes.Address(sourceTokenAddress)] = usdcReader
if err2 != nil {
return nil, fmt.Errorf("new usdc reader: %w", err2)
// in order to not wire the attestation API through this factory, we wire it through the provider
// when the provider is created. In some cases the attestation API can be nil, which means we
// don't want any token data providers. This should not cause creating the job to fail, so we
// give an empty map and move on.
if err2.Error() == "empty USDC attestation API" {

Check failure on line 128 in core/services/ocr2/plugins/ccip/ccipexec/factory.go

View workflow job for this annotation

GitHub Actions / lint

early-return: if c { ... } else { ... return } can be simplified to if !c { ... return } ... (revive)
tokenDataProviders = make(map[cciptypes.Address]tokendata.Reader)
} else {
return nil, fmt.Errorf("new usdc reader: %w", err2)
}
}
tokenDataProviders[cciptypes.Address(sourceTokenAddress)] = usdcReader

// Prom wrappers
onRampReader = observability.NewObservedOnRampReader(onRampReader, srcChainID, ccip.ExecPluginLabel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@ type ObservedChainHealthcheck struct {
}

func (o *ObservedChainHealthcheck) Ready() error {
//TODO implement me
panic("implement me")
return nil
}

func (o *ObservedChainHealthcheck) HealthReport() map[string]error {
//TODO implement me
panic("implement me")
return make(map[string]error)
}

func (o *ObservedChainHealthcheck) Name() string {
//TODO implement me
panic("implement me")
return "ObservedChainHealthcheck"
}

func NewObservedChainHealthCheck(
Expand Down
3 changes: 3 additions & 0 deletions core/services/relay/evm/exec_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ func (s SrcExecProvider) NewPriceRegistryReader(ctx context.Context, addr ccipty
}

func (s SrcExecProvider) NewTokenDataReader(ctx context.Context, _ cciptypes.Address) (tokenDataReader cciptypes.TokenDataReader, err error) {
if s.usdcAttestationAPI == "" {
return nil, fmt.Errorf("empty USDC attestation API")
}
attestationURI, err2 := url.ParseRequestURI(s.usdcAttestationAPI)
if err2 != nil {
return nil, fmt.Errorf("failed to parse USDC attestation API: %w", err2)
Expand Down

0 comments on commit 5f8c04e

Please sign in to comment.