From 5f8c04ef8cb2a01cd37bbe53e7d7534115176e8f Mon Sep 17 00:00:00 2001 From: patrickhuie19 Date: Wed, 10 Jul 2024 17:45:28 -0400 Subject: [PATCH] fixing usdc attestation API logic --- core/services/ocr2/delegate.go | 4 +++- core/services/ocr2/plugins/ccip/ccipexec/factory.go | 12 ++++++++++-- .../ccip/internal/cache/observed_chain_health.go | 9 +++------ core/services/relay/evm/exec_provider.go | 3 +++ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/core/services/ocr2/delegate.go b/core/services/ocr2/delegate.go index 0812ab4514..0207351d4b 100644 --- a/core/services/ocr2/delegate.go +++ b/core/services/ocr2/delegate.go @@ -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 } diff --git a/core/services/ocr2/plugins/ccip/ccipexec/factory.go b/core/services/ocr2/plugins/ccip/ccipexec/factory.go index 50ff4323d6..544246ae5d 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/factory.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/factory.go @@ -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" { + 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) diff --git a/core/services/ocr2/plugins/ccip/internal/cache/observed_chain_health.go b/core/services/ocr2/plugins/ccip/internal/cache/observed_chain_health.go index fe2a03206e..4d6154a503 100644 --- a/core/services/ocr2/plugins/ccip/internal/cache/observed_chain_health.go +++ b/core/services/ocr2/plugins/ccip/internal/cache/observed_chain_health.go @@ -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( diff --git a/core/services/relay/evm/exec_provider.go b/core/services/relay/evm/exec_provider.go index 12f7d1313e..44a36ac058 100644 --- a/core/services/relay/evm/exec_provider.go +++ b/core/services/relay/evm/exec_provider.go @@ -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)