From 05a0c861517ba3af7d0f50a0065e0a56f85b883b Mon Sep 17 00:00:00 2001 From: dimitris Date: Wed, 20 Mar 2024 10:33:20 +0200 Subject: [PATCH] offchain - import chainlink-common (#624) Replacing local `cciptypes` package with `ccip/types` from `chainlink-common`. This change required: - Passing `ctx` to all the reader methods. - Accepting `err` from readers. - Re-generating mocks. - Replacing the imports. Blocked by: https://github.com/smartcontractkit/chainlink-common/pull/409 (Update chainlink-common tag after 409 gets merged) --- .../ocr2/plugins/ccip/ccipcommit/factory.go | 12 +- .../ocr2/plugins/ccip/ccipcommit/inflight.go | 2 +- .../plugins/ccip/ccipcommit/inflight_test.go | 2 +- .../plugins/ccip/ccipcommit/initializers.go | 4 +- .../ccip/ccipcommit/initializers_test.go | 5 +- .../ocr2/plugins/ccip/ccipcommit/ocr2.go | 2 +- .../ocr2/plugins/ccip/ccipcommit/ocr2_test.go | 2 +- .../ocr2/plugins/ccip/ccipexec/batching.go | 2 +- .../plugins/ccip/ccipexec/batching_test.go | 2 +- .../ocr2/plugins/ccip/ccipexec/factory.go | 33 ++- .../ocr2/plugins/ccip/ccipexec/inflight.go | 2 +- .../plugins/ccip/ccipexec/inflight_test.go | 2 +- .../plugins/ccip/ccipexec/initializers.go | 37 ++- .../ccip/ccipexec/initializers_test.go | 5 +- .../ocr2/plugins/ccip/ccipexec/ocr2.go | 26 +- .../ocr2/plugins/ccip/ccipexec/ocr2_test.go | 27 +- .../plugins/ccip/cciptypes/commitstore.go | 85 ------ .../ccip/cciptypes/gaspriceestimator.go | 47 ---- .../ocr2/plugins/ccip/cciptypes/models.go | 20 -- .../plugins/ccip/cciptypes/models_test.go | 36 --- .../ocr2/plugins/ccip/cciptypes/offramp.go | 124 --------- .../ocr2/plugins/ccip/cciptypes/onramp.go | 71 ----- .../plugins/ccip/cciptypes/pricegetter.go | 13 - .../plugins/ccip/cciptypes/priceregistry.go | 47 ---- .../ocr2/plugins/ccip/cciptypes/tokendata.go | 9 - .../ocr2/plugins/ccip/cciptypes/tokenpool.go | 7 - .../ocr2/plugins/ccip/config/config.go | 2 +- .../internal/cache/observed_chain_health.go | 2 +- .../cache/observed_chain_health_test.go | 2 +- .../plugins/ccip/internal/ccipcalc/addr.go | 2 +- .../ccip/internal/ccipcommon/shortcuts.go | 2 +- .../internal/ccipcommon/shortcuts_test.go | 2 +- .../mocks/token_pool_batched_reader_mock.go | 14 +- .../batchreader/token_pool_batch_reader.go | 2 +- .../token_pool_batch_reader_test.go | 2 +- .../mocks/price_registry_mock.go | 16 +- .../ccipdata/ccipdataprovider/provider.go | 6 +- .../internal/ccipdata/commit_store_reader.go | 2 +- .../ccipdata/commit_store_reader_test.go | 2 +- .../internal/ccipdata/factory/commit_store.go | 2 +- .../ccipdata/factory/commit_store_test.go | 2 +- .../ccip/internal/ccipdata/factory/offramp.go | 13 +- .../internal/ccipdata/factory/offramp_test.go | 2 +- .../ccip/internal/ccipdata/factory/onramp.go | 2 +- .../internal/ccipdata/factory/onramp_test.go | 2 +- .../ccipdata/factory/price_registry.go | 13 +- .../ccipdata/factory/price_registry_test.go | 9 +- .../ccipdata/factory/versionfinder.go | 2 +- .../mocks/commit_store_reader_mock.go | 86 +++--- .../ccipdata/mocks/offramp_reader_mock.go | 254 +++++++++++------- .../ccipdata/mocks/onramp_reader_mock.go | 54 ++-- .../mocks/price_registry_reader_mock.go | 80 +++--- .../ccip/internal/ccipdata/offramp_reader.go | 2 +- .../internal/ccipdata/offramp_reader_test.go | 7 +- .../ccip/internal/ccipdata/onramp_reader.go | 2 +- .../internal/ccipdata/onramp_reader_test.go | 2 +- .../ccipdata/price_registry_reader.go | 2 +- .../ccipdata/price_registry_reader_test.go | 10 +- .../plugins/ccip/internal/ccipdata/reader.go | 2 +- .../internal/ccipdata/v1_0_0/commit_store.go | 2 +- .../ccipdata/v1_0_0/commit_store_test.go | 2 +- .../ccip/internal/ccipdata/v1_0_0/offramp.go | 32 +-- .../ccipdata/v1_0_0/offramp_reader_test.go | 7 +- .../v1_0_0/offramp_reader_unit_test.go | 2 +- .../ccip/internal/ccipdata/v1_0_0/onramp.go | 2 +- .../ccipdata/v1_0_0/price_registry.go | 6 +- .../internal/ccipdata/v1_0_0/test_helpers.go | 2 +- .../ccip/internal/ccipdata/v1_1_0/onramp.go | 2 +- .../internal/ccipdata/v1_2_0/commit_store.go | 2 +- .../ccipdata/v1_2_0/commit_store_test.go | 2 +- .../ccip/internal/ccipdata/v1_2_0/offramp.go | 16 +- .../ccipdata/v1_2_0/offramp_reader_test.go | 7 +- .../ccip/internal/ccipdata/v1_2_0/onramp.go | 2 +- .../ccipdata/v1_2_0/price_registry.go | 2 +- .../internal/ccipdata/v1_2_0/test_helpers.go | 2 +- .../ccip/internal/ccipdata/v1_5_0/onramp.go | 2 +- .../internal/observability/commit_store.go | 2 +- .../internal/observability/metrics_test.go | 2 +- .../ccip/internal/observability/offramp.go | 2 +- .../ccip/internal/observability/onramp.go | 2 +- .../internal/observability/price_registry.go | 2 +- .../plugins/ccip/internal/pricegetter/evm.go | 2 +- .../ccip/internal/pricegetter/evm_test.go | 2 +- .../plugins/ccip/internal/pricegetter/mock.go | 14 +- .../ccip/internal/pricegetter/pipeline.go | 2 +- .../internal/pricegetter/pipeline_test.go | 2 +- .../ccip/internal/pricegetter/pricegetter.go | 2 +- .../ocr2/plugins/ccip/observations.go | 2 +- .../ocr2/plugins/ccip/observations_test.go | 16 +- .../plugins/ccip/prices/da_price_estimator.go | 2 +- .../ccip/prices/da_price_estimator_test.go | 2 +- .../ccip/prices/exec_price_estimator.go | 2 +- .../ccip/prices/exec_price_estimator_test.go | 2 +- .../ccip/prices/gas_price_estimator.go | 2 +- .../prices/gas_price_estimator_exec_mock.go | 10 +- .../ccip/prices/gas_price_estimator_mock.go | 10 +- .../ccip/testhelpers/ccip_contracts.go | 2 +- .../ccip/testhelpers/integration/chainlink.go | 2 +- .../ocr2/plugins/ccip/testhelpers/offramp.go | 2 +- .../ocr2/plugins/ccip/tokendata/bgworker.go | 2 +- .../plugins/ccip/tokendata/bgworker_test.go | 2 +- .../observability/usdc_client_test.go | 2 +- .../ocr2/plugins/ccip/tokendata/reader.go | 2 +- .../plugins/ccip/tokendata/reader_mock.go | 10 +- .../ocr2/plugins/ccip/tokendata/usdc/usdc.go | 2 +- .../ccip/tokendata/usdc/usdc_blackbox_test.go | 2 +- .../plugins/ccip/tokendata/usdc/usdc_test.go | 2 +- 107 files changed, 554 insertions(+), 878 deletions(-) delete mode 100644 core/services/ocr2/plugins/ccip/cciptypes/commitstore.go delete mode 100644 core/services/ocr2/plugins/ccip/cciptypes/gaspriceestimator.go delete mode 100644 core/services/ocr2/plugins/ccip/cciptypes/models.go delete mode 100644 core/services/ocr2/plugins/ccip/cciptypes/models_test.go delete mode 100644 core/services/ocr2/plugins/ccip/cciptypes/offramp.go delete mode 100644 core/services/ocr2/plugins/ccip/cciptypes/onramp.go delete mode 100644 core/services/ocr2/plugins/ccip/cciptypes/pricegetter.go delete mode 100644 core/services/ocr2/plugins/ccip/cciptypes/priceregistry.go delete mode 100644 core/services/ocr2/plugins/ccip/cciptypes/tokendata.go delete mode 100644 core/services/ocr2/plugins/ccip/cciptypes/tokenpool.go diff --git a/core/services/ocr2/plugins/ccip/ccipcommit/factory.go b/core/services/ocr2/plugins/ccip/ccipcommit/factory.go index e29cbebbad..ebfa42deef 100644 --- a/core/services/ocr2/plugins/ccip/ccipcommit/factory.go +++ b/core/services/ocr2/plugins/ccip/ccipcommit/factory.go @@ -8,8 +8,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" ) @@ -37,7 +37,7 @@ func NewCommitReportingPluginFactory(config CommitPluginStaticConfig) *CommitRep } } -func (rf *CommitReportingPluginFactory) UpdateDynamicReaders(newPriceRegAddr common.Address) error { +func (rf *CommitReportingPluginFactory) UpdateDynamicReaders(ctx context.Context, newPriceRegAddr common.Address) error { rf.readersMu.Lock() defer rf.readersMu.Unlock() // TODO: Investigate use of Close() to cleanup. @@ -65,6 +65,8 @@ func (rf *CommitReportingPluginFactory) UpdateDynamicReaders(newPriceRegAddr com // NewReportingPlugin returns the ccip CommitReportingPlugin and satisfies the ReportingPluginFactory interface. func (rf *CommitReportingPluginFactory) NewReportingPlugin(config types.ReportingPluginConfig) (types.ReportingPlugin, types.ReportingPluginInfo, error) { + ctx := context.Background() // todo: consider adding some timeout + destPriceReg, err := rf.config.commitStore.ChangeConfig(config.OnchainConfig, config.OffchainConfig) if err != nil { return nil, types.ReportingPluginInfo{}, err @@ -74,11 +76,7 @@ func (rf *CommitReportingPluginFactory) NewReportingPlugin(config types.Reportin if err != nil { return nil, types.ReportingPluginInfo{}, err } - if err = rf.UpdateDynamicReaders(priceRegEvmAddr); err != nil { - return nil, types.ReportingPluginInfo{}, err - } - - if err != nil { + if err = rf.UpdateDynamicReaders(ctx, priceRegEvmAddr); err != nil { return nil, types.ReportingPluginInfo{}, err } diff --git a/core/services/ocr2/plugins/ccip/ccipcommit/inflight.go b/core/services/ocr2/plugins/ccip/ccipcommit/inflight.go index 32f76d2abd..a74ce9e591 100644 --- a/core/services/ocr2/plugins/ccip/ccipcommit/inflight.go +++ b/core/services/ocr2/plugins/ccip/ccipcommit/inflight.go @@ -6,8 +6,8 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ) const ( diff --git a/core/services/ocr2/plugins/ccip/ccipcommit/inflight_test.go b/core/services/ocr2/plugins/ccip/ccipcommit/inflight_test.go index 0dd11aca8e..a34d2d3b20 100644 --- a/core/services/ocr2/plugins/ccip/ccipcommit/inflight_test.go +++ b/core/services/ocr2/plugins/ccip/ccipcommit/inflight_test.go @@ -10,9 +10,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" ) diff --git a/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go b/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go index c1166a02a1..2b343e4586 100644 --- a/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go +++ b/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go @@ -16,7 +16,7 @@ import ( commonlogger "github.com/smartcontractkit/chainlink-common/pkg/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/ccipdataprovider" @@ -87,7 +87,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(lggr logger.Logger, jb job.Job, chainSet legacyevm.LegacyChainContainer, qopts ...pg.QOpt) error { +func UnregisterCommitPluginLpFilters(ctx context.Context, lggr logger.Logger, jb job.Job, chainSet legacyevm.LegacyChainContainer, qopts ...pg.QOpt) error { params, err := extractJobSpecParams(jb, chainSet) if err != nil { return err diff --git a/core/services/ocr2/plugins/ccip/ccipcommit/initializers_test.go b/core/services/ocr2/plugins/ccip/ccipcommit/initializers_test.go index d42e1987f9..3e956934a3 100644 --- a/core/services/ocr2/plugins/ccip/ccipcommit/initializers_test.go +++ b/core/services/ocr2/plugins/ccip/ccipcommit/initializers_test.go @@ -9,6 +9,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" legacyEvmORMMocks "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm/mocks" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" ) @@ -53,6 +54,8 @@ func TestGetCommitPluginFilterNamesFromSpec(t *testing.T) { }, } + ctx := testutils.Context(t) + for _, tc := range testCases { t.Run(tc.description, func(t *testing.T) { chainSet := &legacyEvmORMMocks.LegacyChainContainer{} @@ -65,7 +68,7 @@ func TestGetCommitPluginFilterNamesFromSpec(t *testing.T) { } } - err := UnregisterCommitPluginLpFilters(lggr, job.Job{OCR2OracleSpec: tc.spec}, chainSet) + err := UnregisterCommitPluginLpFilters(ctx, lggr, job.Job{OCR2OracleSpec: tc.spec}, chainSet) if tc.expectingErr { assert.Error(t, err) } else { diff --git a/core/services/ocr2/plugins/ccip/ccipcommit/ocr2.go b/core/services/ocr2/plugins/ccip/ccipcommit/ocr2.go index 7fdcbe3fa4..4adede96c9 100644 --- a/core/services/ocr2/plugins/ccip/ccipcommit/ocr2.go +++ b/core/services/ocr2/plugins/ccip/ccipcommit/ocr2.go @@ -16,7 +16,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/utils/mathutil" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/ocr2/plugins/ccip/ccipcommit/ocr2_test.go b/core/services/ocr2/plugins/ccip/ccipcommit/ocr2_test.go index a43b1cb3be..8d6ab25626 100644 --- a/core/services/ocr2/plugins/ccip/ccipcommit/ocr2_test.go +++ b/core/services/ocr2/plugins/ccip/ccipcommit/ocr2_test.go @@ -23,6 +23,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/config" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/mocks" mocks2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" @@ -31,7 +32,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" ccipcachemocks "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache/mocks" diff --git a/core/services/ocr2/plugins/ccip/ccipexec/batching.go b/core/services/ocr2/plugins/ccip/ccipexec/batching.go index e2bb7fb88c..9f36c1488a 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/batching.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/batching.go @@ -6,9 +6,9 @@ import ( "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/hashlib" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/merklemulti" diff --git a/core/services/ocr2/plugins/ccip/ccipexec/batching_test.go b/core/services/ocr2/plugins/ccip/ccipexec/batching_test.go index 11f1198bec..dc3594c820 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/batching_test.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/batching_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" ) func Test_validateSendRequests(t *testing.T) { diff --git a/core/services/ocr2/plugins/ccip/ccipexec/factory.go b/core/services/ocr2/plugins/ccip/ccipexec/factory.go index 4200e39168..2c0dca9e24 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/factory.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/factory.go @@ -2,12 +2,13 @@ package ccipexec import ( "context" + "fmt" "sync" "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" ) @@ -32,7 +33,7 @@ func NewExecutionReportingPluginFactory(config ExecutionPluginStaticConfig) *Exe } } -func (rf *ExecutionReportingPluginFactory) UpdateDynamicReaders(newPriceRegAddr cciptypes.Address) error { +func (rf *ExecutionReportingPluginFactory) UpdateDynamicReaders(ctx context.Context, newPriceRegAddr cciptypes.Address) error { rf.readersMu.Lock() defer rf.readersMu.Unlock() // TODO: Investigate use of Close() to cleanup. @@ -59,23 +60,39 @@ func (rf *ExecutionReportingPluginFactory) UpdateDynamicReaders(newPriceRegAddr } func (rf *ExecutionReportingPluginFactory) NewReportingPlugin(config types.ReportingPluginConfig) (types.ReportingPlugin, types.ReportingPluginInfo, error) { - destPriceRegistry, destWrappedNative, err := rf.config.offRampReader.ChangeConfig(config.OnchainConfig, config.OffchainConfig) + ctx := context.Background() // todo: consider setting a timeout + + destPriceRegistry, destWrappedNative, err := rf.config.offRampReader.ChangeConfig(ctx, config.OnchainConfig, config.OffchainConfig) if err != nil { return nil, types.ReportingPluginInfo{}, err } // Open dynamic readers - err = rf.UpdateDynamicReaders(destPriceRegistry) + err = rf.UpdateDynamicReaders(ctx, destPriceRegistry) if err != nil { return nil, types.ReportingPluginInfo{}, err } - offchainConfig := rf.config.offRampReader.OffchainConfig() + offchainConfig, err := rf.config.offRampReader.OffchainConfig(ctx) + if err != nil { + return nil, types.ReportingPluginInfo{}, fmt.Errorf("get offchain config from offramp: %w", err) + } + + gasPriceEstimator, err := rf.config.offRampReader.GasPriceEstimator(ctx) + if err != nil { + return nil, types.ReportingPluginInfo{}, fmt.Errorf("get gas price estimator from offramp: %w", err) + } + + onchainConfig, err := rf.config.offRampReader.OnchainConfig(ctx) + if err != nil { + return nil, types.ReportingPluginInfo{}, fmt.Errorf("get onchain config from offramp: %w", err) + } + return &ExecutionReportingPlugin{ F: config.F, lggr: rf.config.lggr.Named("ExecutionReportingPlugin"), offchainConfig: offchainConfig, tokenDataWorker: rf.config.tokenDataWorker, - gasPriceEstimator: rf.config.offRampReader.GasPriceEstimator(), + gasPriceEstimator: gasPriceEstimator, sourcePriceRegistryProvider: rf.config.sourcePriceRegistryProvider, sourcePriceRegistryLock: sync.RWMutex{}, sourceWrappedNativeToken: rf.config.sourceWrappedNativeToken, @@ -83,11 +100,11 @@ func (rf *ExecutionReportingPluginFactory) NewReportingPlugin(config types.Repor commitStoreReader: rf.config.commitStoreReader, destPriceRegistry: rf.destPriceRegReader, destWrappedNative: destWrappedNative, - onchainConfig: rf.config.offRampReader.OnchainConfig(), + onchainConfig: onchainConfig, offRampReader: rf.config.offRampReader, tokenPoolBatchedReader: rf.config.tokenPoolBatchedReader, inflightReports: newInflightExecReportsContainer(offchainConfig.InflightCacheExpiry.Duration()), - snoozedRoots: cache.NewSnoozedRoots(rf.config.offRampReader.OnchainConfig().PermissionLessExecutionThresholdSeconds, offchainConfig.RootSnoozeTime.Duration()), + snoozedRoots: cache.NewSnoozedRoots(onchainConfig.PermissionLessExecutionThresholdSeconds, offchainConfig.RootSnoozeTime.Duration()), metricsCollector: rf.config.metricsCollector, chainHealthcheck: rf.config.chainHealthcheck, }, types.ReportingPluginInfo{ diff --git a/core/services/ocr2/plugins/ccip/ccipexec/inflight.go b/core/services/ocr2/plugins/ccip/ccipexec/inflight.go index d108ba5981..c76bfdf778 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/inflight.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/inflight.go @@ -6,8 +6,8 @@ import ( "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ) // InflightInternalExecutionReport serves the same purpose as InflightCommitReport diff --git a/core/services/ocr2/plugins/ccip/ccipexec/inflight_test.go b/core/services/ocr2/plugins/ccip/ccipexec/inflight_test.go index 604ca688a3..2a91457ef4 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/inflight_test.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/inflight_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ) func TestInflightReportsContainer_add(t *testing.T) { diff --git a/core/services/ocr2/plugins/ccip/ccipexec/initializers.go b/core/services/ocr2/plugins/ccip/ccipexec/initializers.go index 45a21dfcb5..5e0b813809 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/initializers.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/initializers.go @@ -18,7 +18,7 @@ import ( commonlogger "github.com/smartcontractkit/chainlink-common/pkg/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" @@ -46,8 +46,8 @@ import ( const numTokenDataWorkers = 5 -func NewExecutionServices(lggr logger.Logger, jb job.Job, chainSet legacyevm.LegacyChainContainer, new bool, argsNoPlugin libocr2.OCR2OracleArgs, logError func(string), qopts ...pg.QOpt) ([]job.ServiceCtx, error) { - execPluginConfig, backfillArgs, chainHealthcheck, tokenWorker, err := jobSpecToExecPluginConfig(lggr, jb, chainSet, qopts...) +func NewExecutionServices(ctx context.Context, lggr logger.Logger, jb job.Job, chainSet legacyevm.LegacyChainContainer, new bool, argsNoPlugin libocr2.OCR2OracleArgs, logError func(string), qopts ...pg.QOpt) ([]job.ServiceCtx, error) { + execPluginConfig, backfillArgs, chainHealthcheck, tokenWorker, err := jobSpecToExecPluginConfig(ctx, lggr, jb, chainSet, qopts...) if err != nil { return nil, err } @@ -87,12 +87,17 @@ func NewExecutionServices(lggr logger.Logger, jb job.Job, chainSet legacyevm.Leg // UnregisterExecPluginLpFilters unregisters all the registered filters for both source and dest chains. // See comment in UnregisterCommitPluginLpFilters // It MUST mirror the filters registered in NewExecutionServices. -func UnregisterExecPluginLpFilters(lggr logger.Logger, jb job.Job, chainSet legacyevm.LegacyChainContainer, qopts ...pg.QOpt) error { +func UnregisterExecPluginLpFilters(ctx context.Context, lggr logger.Logger, jb job.Job, chainSet legacyevm.LegacyChainContainer, qopts ...pg.QOpt) error { params, err := extractJobSpecParams(lggr, jb, chainSet, false, qopts...) if err != nil { return err } + offRampAddress, err := params.offRampReader.Address(ctx) + if err != nil { + return fmt.Errorf("get offramp reader address: %w", err) + } + versionFinder := factory.NewEvmVersionFinder() unregisterFuncs := []func() error{ func() error { @@ -102,7 +107,7 @@ func UnregisterExecPluginLpFilters(lggr logger.Logger, jb job.Job, chainSet lega return factory.CloseOnRampReader(lggr, versionFinder, params.offRampConfig.SourceChainSelector, params.offRampConfig.ChainSelector, params.offRampConfig.OnRamp, params.sourceChain.LogPoller(), params.sourceChain.Client(), qopts...) }, func() error { - return factory.CloseOffRampReader(lggr, versionFinder, params.offRampReader.Address(), params.destChain.Client(), params.destChain.LogPoller(), params.destChain.GasEstimator(), params.destChain.Config().EVM().GasEstimator().PriceMax().ToInt(), qopts...) + return factory.CloseOffRampReader(lggr, versionFinder, offRampAddress, params.destChain.Client(), params.destChain.LogPoller(), params.destChain.GasEstimator(), params.destChain.Config().EVM().GasEstimator().PriceMax().ToInt(), qopts...) }, func() error { // usdc token data reader if usdcDisabled := params.pluginConfig.USDCConfig.AttestationAPI == ""; usdcDisabled { @@ -123,8 +128,8 @@ func UnregisterExecPluginLpFilters(lggr logger.Logger, jb job.Job, chainSet lega // ExecReportToEthTxMeta generates a txmgr.EthTxMeta from the given report. // Only MessageIDs will be populated in the TxMeta. -func ExecReportToEthTxMeta(typ ccipconfig.ContractType, ver semver.Version) (func(report []byte) (*txmgr.TxMeta, error), error) { - return factory.ExecReportToEthTxMeta(typ, ver) +func ExecReportToEthTxMeta(ctx context.Context, typ ccipconfig.ContractType, ver semver.Version) (func(report []byte) (*txmgr.TxMeta, error), error) { + return factory.ExecReportToEthTxMeta(ctx, typ, ver) } func initTokenDataProviders(lggr logger.Logger, jobID string, pluginConfig ccipconfig.ExecutionPluginJobSpecConfig, sourceLP logpoller.LogPoller, qopts ...pg.QOpt) (map[cciptypes.Address]tokendata.Reader, error) { @@ -160,7 +165,7 @@ func initTokenDataProviders(lggr logger.Logger, jobID string, pluginConfig ccipc return tokenDataProviders, nil } -func jobSpecToExecPluginConfig(lggr logger.Logger, jb job.Job, chainSet legacyevm.LegacyChainContainer, qopts ...pg.QOpt) (*ExecutionPluginStaticConfig, *ccipcommon.BackfillArgs, *cache.ObservedChainHealthcheck, *tokendata.BackgroundWorker, error) { +func jobSpecToExecPluginConfig(ctx context.Context, lggr logger.Logger, jb job.Job, chainSet legacyevm.LegacyChainContainer, qopts ...pg.QOpt) (*ExecutionPluginStaticConfig, *ccipcommon.BackfillArgs, *cache.ObservedChainHealthcheck, *tokendata.BackgroundWorker, error) { params, err := extractJobSpecParams(lggr, jb, chainSet, true, qopts...) if err != nil { return nil, nil, nil, nil, err @@ -238,7 +243,12 @@ func jobSpecToExecPluginConfig(lggr logger.Logger, jb job.Job, chainSet legacyev batchCaller := rpclib.NewDynamicLimitedBatchCaller(lggr, params.destChain.Client(), rpclib.DefaultRpcBatchSizeLimit, rpclib.DefaultRpcBatchBackOffMultiplier) - tokenPoolBatchedReader, err := batchreader.NewEVMTokenPoolBatchedReader(execLggr, sourceChainSelector, offRampReader.Address(), batchCaller) + offrampAddress, err := offRampReader.Address(ctx) + if err != nil { + return nil, nil, nil, nil, fmt.Errorf("get offramp reader address: %w", err) + } + + tokenPoolBatchedReader, err := batchreader.NewEVMTokenPoolBatchedReader(execLggr, sourceChainSelector, offrampAddress, batchCaller) if err != nil { return nil, nil, nil, nil, fmt.Errorf("new token pool batched reader: %w", err) } @@ -250,7 +260,7 @@ func jobSpecToExecPluginConfig(lggr logger.Logger, jb job.Job, chainSet legacyev lggr.With( "onramp", params.offRampConfig.OnRamp, "commitStore", params.offRampConfig.CommitStore, - "offramp", params.offRampReader.Address(), + "offramp", offrampAddress, ), onRampReader, commitStoreReader, @@ -261,11 +271,16 @@ func jobSpecToExecPluginConfig(lggr logger.Logger, jb job.Job, chainSet legacyev params.offRampConfig.OnRamp, ) + onchainConfig, err := offRampReader.OnchainConfig(ctx) + if err != nil { + return nil, nil, nil, nil, fmt.Errorf("get onchain config from offramp reader: %w", err) + } + tokenBackgroundWorker := tokendata.NewBackgroundWorker( tokenDataProviders, numTokenDataWorkers, 5*time.Second, - offRampReader.OnchainConfig().PermissionLessExecutionThresholdSeconds, + onchainConfig.PermissionLessExecutionThresholdSeconds, ) return &ExecutionPluginStaticConfig{ lggr: execLggr, diff --git a/core/services/ocr2/plugins/ccip/ccipexec/initializers_test.go b/core/services/ocr2/plugins/ccip/ccipexec/initializers_test.go index 5729d95d66..2498a74189 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/initializers_test.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/initializers_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/assert" legacyEvmORMMocks "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm/mocks" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/job" ) @@ -44,10 +45,12 @@ func TestGetExecutionPluginFilterNamesFromSpec(t *testing.T) { }, } + ctx := testutils.Context(t) + for _, tc := range testCases { chainSet := &legacyEvmORMMocks.LegacyChainContainer{} t.Run(tc.description, func(t *testing.T) { - err := UnregisterExecPluginLpFilters(logger.TestLogger(t), job.Job{OCR2OracleSpec: tc.spec}, chainSet) + err := UnregisterExecPluginLpFilters(ctx, logger.TestLogger(t), job.Job{OCR2OracleSpec: tc.spec}, chainSet) if tc.expectingErr { assert.Error(t, err) } else { diff --git a/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go b/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go index 76eb786825..f27e9507eb 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go @@ -16,9 +16,9 @@ import ( "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcommon" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" @@ -727,7 +727,7 @@ func (r *ExecutionReportingPlugin) buildReport(ctx context.Context, lggr logger. return false } - encoded, err2 := r.offRampReader.EncodeExecutionReport(report) + encoded, err2 := r.offRampReader.EncodeExecutionReport(ctx, report) if err2 != nil { // false makes Search keep looking to the right, always including any "erroring" ObservedMessage and allowing us to detect in the bottom return false @@ -741,7 +741,7 @@ func (r *ExecutionReportingPlugin) buildReport(ctx context.Context, lggr logger. } r.metricsCollector.NumberOfMessagesProcessed(ccip.Report, len(execReport.Messages)) - encodedReport, err := r.offRampReader.EncodeExecutionReport(execReport) + encodedReport, err := r.offRampReader.EncodeExecutionReport(ctx, execReport) if err != nil { return nil, err } @@ -855,7 +855,7 @@ func calculateObservedMessagesConsensus(observations []ccip.ExecutionObservation func (r *ExecutionReportingPlugin) ShouldAcceptFinalizedReport(ctx context.Context, timestamp types.ReportTimestamp, report types.Report) (bool, error) { lggr := r.lggr.Named("ShouldAcceptFinalizedReport") - execReport, err := r.offRampReader.DecodeExecutionReport(report) + execReport, err := r.offRampReader.DecodeExecutionReport(ctx, report) if err != nil { lggr.Errorw("Unable to decode report", "err", err) return false, err @@ -886,7 +886,7 @@ func (r *ExecutionReportingPlugin) ShouldAcceptFinalizedReport(ctx context.Conte func (r *ExecutionReportingPlugin) ShouldTransmitAcceptedReport(ctx context.Context, timestamp types.ReportTimestamp, report types.Report) (bool, error) { lggr := r.lggr.Named("ShouldTransmitAcceptedReport") - execReport, err := r.offRampReader.DecodeExecutionReport(report) + execReport, err := r.offRampReader.DecodeExecutionReport(ctx, report) if err != nil { lggr.Errorw("Unable to decode report", "err", err) return false, nil @@ -991,7 +991,11 @@ func getTokensPrices(ctx context.Context, priceRegistry ccipdata.PriceRegistryRe for i, token := range tokens { // price of a token can never be zero if fetchedPrices[i].Value.BitLen() == 0 { - return nil, fmt.Errorf("price of token %s is zero (price registry=%s)", token, priceRegistry.Address()) + priceRegistryAddress, err := priceRegistry.Address(ctx) + if err != nil { + return nil, fmt.Errorf("get price registry address: %w", err) + } + return nil, fmt.Errorf("price of token %s is zero (price registry=%s)", token, priceRegistryAddress) } // price registry should not report different price for the same token @@ -1130,7 +1134,15 @@ func (r *ExecutionReportingPlugin) ensurePriceRegistrySynchronization(ctx contex return fmt.Errorf("getting price registry from onramp: %w", err) } - needPriceRegistryUpdate = r.sourcePriceRegistry == nil || priceRegistryAddress != r.sourcePriceRegistry.Address() + currentPriceRegistryAddress := cciptypes.Address("") + if r.sourcePriceRegistry != nil { + currentPriceRegistryAddress, err = r.sourcePriceRegistry.Address(ctx) + if err != nil { + return fmt.Errorf("get current priceregistry address: %w", err) + } + } + + needPriceRegistryUpdate = r.sourcePriceRegistry == nil || priceRegistryAddress != currentPriceRegistryAddress r.sourcePriceRegistryLock.RUnlock() if !needPriceRegistryUpdate { return nil diff --git a/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go b/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go index 578d73f9bc..3f82236706 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go @@ -23,11 +23,11 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" lpMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" ccipcachemocks "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache/mocks" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" @@ -171,7 +171,7 @@ func TestExecutionReportingPlugin_Observation(t *testing.T) { mockOffRampReader.On("GetExecutionStateChangesBetweenSeqNums", ctx, mock.Anything, mock.Anything, 0). Return(executionEvents, nil).Maybe() mockOffRampReader.On("CurrentRateLimiterState", mock.Anything).Return(tc.rateLimiterState, nil).Maybe() - mockOffRampReader.On("Address").Return(cciptypes.Address(offRamp.Address().String())).Maybe() + mockOffRampReader.On("Address", ctx).Return(cciptypes.Address(offRamp.Address().String()), nil).Maybe() mockOffRampReader.On("GetSenderNonce", mock.Anything, mock.Anything).Return(offRamp.GetSenderNonce(nil, utils.RandomAddress())).Maybe() mockOffRampReader.On("GetTokenPoolsRateLimits", ctx, []ccipdata.TokenPoolReader{}). Return([]cciptypes.TokenBucketRateLimit{}, nil).Maybe() @@ -199,10 +199,10 @@ func TestExecutionReportingPlugin_Observation(t *testing.T) { destPriceRegReader := ccipdatamocks.NewPriceRegistryReader(t) destPriceRegReader.On("GetTokenPrices", ctx, mock.Anything).Return( []cciptypes.TokenPriceUpdate{{TokenPrice: cciptypes.TokenPrice{Token: ccipcalc.HexToAddress("0x1"), Value: big.NewInt(123)}, TimestampUnixSec: big.NewInt(time.Now().Unix())}}, nil).Maybe() - destPriceRegReader.On("Address").Return(cciptypes.Address(utils.RandomAddress().String())).Maybe() + destPriceRegReader.On("Address", ctx).Return(cciptypes.Address(utils.RandomAddress().String()), nil).Maybe() destPriceRegReader.On("GetFeeTokens", ctx).Return([]cciptypes.Address{}, nil).Maybe() sourcePriceRegReader := ccipdatamocks.NewPriceRegistryReader(t) - sourcePriceRegReader.On("Address").Return(sourcePriceRegistryAddress).Maybe() + sourcePriceRegReader.On("Address", ctx).Return(sourcePriceRegistryAddress, nil).Maybe() sourcePriceRegReader.On("GetFeeTokens", ctx).Return([]cciptypes.Address{}, nil).Maybe() sourcePriceRegReader.On("GetTokenPrices", ctx, mock.Anything).Return( []cciptypes.TokenPriceUpdate{{TokenPrice: cciptypes.TokenPrice{Token: ccipcalc.HexToAddress("0x1"), Value: big.NewInt(123)}, TimestampUnixSec: big.NewInt(time.Now().Unix())}}, nil).Maybe() @@ -310,7 +310,7 @@ func TestExecutionReportingPlugin_ShouldAcceptFinalizedReport(t *testing.T) { encodedReport := encodeExecutionReport(t, report) mockOffRampReader := ccipdatamocks.NewOffRampReader(t) - mockOffRampReader.On("DecodeExecutionReport", encodedReport).Return(report, nil) + mockOffRampReader.On("DecodeExecutionReport", mock.Anything, encodedReport).Return(report, nil) chainHealthcheck := ccipcachemocks.NewChainHealthcheck(t) chainHealthcheck.On("IsHealthy", mock.Anything).Return(true, nil) @@ -359,7 +359,7 @@ func TestExecutionReportingPlugin_ShouldTransmitAcceptedReport(t *testing.T) { mockCommitStoreReader := ccipdatamocks.NewCommitStoreReader(t) mockOffRampReader := ccipdatamocks.NewOffRampReader(t) - mockOffRampReader.On("DecodeExecutionReport", encodedReport).Return(report, nil) + mockOffRampReader.On("DecodeExecutionReport", mock.Anything, encodedReport).Return(report, nil) mockedExecState := mockOffRampReader.On("GetExecutionState", mock.Anything, uint64(12)).Return(uint8(cciptypes.ExecutionStateUntouched), nil).Once() chainHealthcheck := ccipcachemocks.NewChainHealthcheck(t) @@ -1345,7 +1345,7 @@ func Test_getTokensPrices(t *testing.T) { t.Run(tc.name, func(t *testing.T) { priceReg := ccipdatamocks.NewPriceRegistryReader(t) priceReg.On("GetTokenPrices", mock.Anything, mock.Anything).Return(tc.retPrices, nil) - priceReg.On("Address").Return(cciptypes.Address(utils.RandomAddress().String()), nil).Maybe() + priceReg.On("Address", mock.Anything).Return(cciptypes.Address(utils.RandomAddress().String()), nil).Maybe() tokenPrices, err := getTokensPrices(context.Background(), priceReg, append(tc.feeTokens, tc.tokens...)) if tc.expErr { @@ -1881,7 +1881,7 @@ func Test_prepareTokenExecData(t *testing.T) { gasPriceEstimator.On("GetGasPrice", ctx).Return(big.NewInt(1e9), nil).Maybe() offrampReader.On("GetTokens", ctx).Return(cciptypes.OffRampTokens{DestinationTokens: tt.destTokens}, tt.destTokensErr).Maybe() - sourcePriceRegistry.On("Address").Return(sourcePriceRegistryAddress, nil).Maybe() + sourcePriceRegistry.On("Address", mock.Anything).Return(sourcePriceRegistryAddress, nil).Maybe() sourcePriceRegistry.On("GetFeeTokens", ctx).Return(tt.sourceFeeTokens, tt.sourceFeeTokensErr).Maybe() sourcePriceRegistry.On("GetTokenPrices", ctx, mock.Anything).Return(tt.sourcePrices, nil).Maybe() destPriceRegistry.On("GetFeeTokens", ctx).Return(tt.destFeeTokens, tt.destFeeTokensErr).Maybe() @@ -1924,7 +1924,8 @@ func Test_prepareTokenExecData(t *testing.T) { func encodeExecutionReport(t *testing.T, report cciptypes.ExecReport) []byte { reader, err := v1_2_0.NewOffRamp(logger.TestLogger(t), utils.RandomAddress(), nil, nil, nil, nil) require.NoError(t, err) - encodedReport, err := reader.EncodeExecutionReport(report) + ctx := testutils.Context(t) + encodedReport, err := reader.EncodeExecutionReport(ctx, report) require.NoError(t, err) return encodedReport } @@ -1940,10 +1941,10 @@ func TestExecutionReportingPlugin_ensurePriceRegistrySynchronization(t *testing. mockPriceRegistryReader1 := ccipdatamocks.NewPriceRegistryReader(t) mockPriceRegistryReader2 := ccipdatamocks.NewPriceRegistryReader(t) - mockPriceRegistryReader1.On("Address").Return(sourcePriceRegistryAddress1, nil) - mockPriceRegistryReader2.On("Address").Return(sourcePriceRegistryAddress2, nil).Maybe() - mockPriceRegistryReader1.On("Close").Return(nil) - mockPriceRegistryReader2.On("Close").Return(nil).Maybe() + mockPriceRegistryReader1.On("Address", mock.Anything).Return(sourcePriceRegistryAddress1, nil) + mockPriceRegistryReader2.On("Address", mock.Anything).Return(sourcePriceRegistryAddress2, nil).Maybe() + mockPriceRegistryReader1.On("Close", mock.Anything).Return(nil) + mockPriceRegistryReader2.On("Close", mock.Anything).Return(nil).Maybe() mockSourcePriceRegistryProvider := ccipdataprovidermocks.NewPriceRegistry(t) mockSourcePriceRegistryProvider.On("NewPriceRegistryReader", mock.Anything, sourcePriceRegistryAddress1).Return(mockPriceRegistryReader1, nil) diff --git a/core/services/ocr2/plugins/ccip/cciptypes/commitstore.go b/core/services/ocr2/plugins/ccip/cciptypes/commitstore.go deleted file mode 100644 index 536bde8254..0000000000 --- a/core/services/ocr2/plugins/ccip/cciptypes/commitstore.go +++ /dev/null @@ -1,85 +0,0 @@ -package cciptypes - -import ( - "context" - "math/big" - "time" -) - -type CommitStoreReader interface { - GetExpectedNextSequenceNumber(context context.Context) (uint64, error) - - GetLatestPriceEpochAndRound(context context.Context) (uint64, error) - - // GetCommitReportMatchingSeqNum returns accepted commit report that satisfies Interval.Min <= seqNum <= Interval.Max. Returned slice should be empty or have exactly one element - GetCommitReportMatchingSeqNum(ctx context.Context, seqNum uint64, confirmations int) ([]CommitStoreReportWithTxMeta, error) - - // GetAcceptedCommitReportsGteTimestamp returns all the commit reports with timestamp greater than or equal to the provided. - // Returned Commit Reports have to be sorted by Interval.Min/Interval.Max in ascending order. - GetAcceptedCommitReportsGteTimestamp(ctx context.Context, ts time.Time, confirmations int) ([]CommitStoreReportWithTxMeta, error) - - // IsDestChainHealthy returns true if the destination chain is healthy. - IsDestChainHealthy(ctx context.Context) (bool, error) - - IsDown(ctx context.Context) (bool, error) - - IsBlessed(ctx context.Context, root [32]byte) (bool, error) - - // ChangeConfig notifies the reader that the config has changed onchain - ChangeConfig(onchainConfig []byte, offchainConfig []byte) (Address, error) - - OffchainConfig() CommitOffchainConfig - - GasPriceEstimator() GasPriceEstimatorCommit - - EncodeCommitReport(report CommitStoreReport) ([]byte, error) - - DecodeCommitReport(report []byte) (CommitStoreReport, error) - - VerifyExecutionReport(ctx context.Context, report ExecReport) (bool, error) - - GetCommitStoreStaticConfig(ctx context.Context) (CommitStoreStaticConfig, error) -} - -type CommitStoreReportWithTxMeta struct { - TxMeta - CommitStoreReport -} - -type CommitStoreReport struct { - TokenPrices []TokenPrice - GasPrices []GasPrice - Interval CommitStoreInterval - MerkleRoot [32]byte -} - -type TokenPrice struct { - Token Address - Value *big.Int -} - -type GasPrice struct { - DestChainSelector uint64 - Value *big.Int -} - -type CommitOffchainConfig struct { - GasPriceDeviationPPB uint32 - GasPriceHeartBeat time.Duration - TokenPriceDeviationPPB uint32 - TokenPriceHeartBeat time.Duration - InflightCacheExpiry time.Duration - PriceReportingDisabled bool -} - -type CommitStoreStaticConfig struct { - ChainSelector uint64 - SourceChainSelector uint64 - OnRamp Address - ArmProxy Address -} - -type CommitStoreInterval struct { - Min uint64 - Max uint64 -} diff --git a/core/services/ocr2/plugins/ccip/cciptypes/gaspriceestimator.go b/core/services/ocr2/plugins/ccip/cciptypes/gaspriceestimator.go deleted file mode 100644 index 4ddd3b3fb9..0000000000 --- a/core/services/ocr2/plugins/ccip/cciptypes/gaspriceestimator.go +++ /dev/null @@ -1,47 +0,0 @@ -package cciptypes - -import ( - "context" - "math/big" - "time" -) - -type GasPriceEstimator interface { - GasPriceEstimatorCommit - GasPriceEstimatorExec -} - -type GasPriceEstimatorCommit interface { - CommonGasPriceEstimator - - // Deviates checks if p1 gas price diffs from p2 by deviation options. Input prices should not be nil. - Deviates(p1 *big.Int, p2 *big.Int) (bool, error) -} - -// GasPriceEstimatorExec provides gasPriceEstimatorCommon + features needed in exec plugin, e.g. message cost estimation. -type GasPriceEstimatorExec interface { - CommonGasPriceEstimator - - // EstimateMsgCostUSD estimates the costs for msg execution, and converts to USD value scaled by 1e18 (e.g. 5$ = 5e18). - EstimateMsgCostUSD(p *big.Int, wrappedNativePrice *big.Int, msg EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error) -} - -// CommonGasPriceEstimator is abstraction over multi-component gas prices. -type CommonGasPriceEstimator interface { - // GetGasPrice fetches the current gas price. - GetGasPrice(ctx context.Context) (*big.Int, error) - // DenoteInUSD converts the gas price to be in units of USD. Input prices should not be nil. - DenoteInUSD(p *big.Int, wrappedNativePrice *big.Int) (*big.Int, error) - // Median finds the median gas price in slice. If gas price has multiple components, median of each individual component should be taken. Input prices should not contain nil. - Median(gasPrices []*big.Int) (*big.Int, error) -} - -// EVM2EVMOnRampCCIPSendRequestedWithMeta helper struct to hold the send request and some metadata -type EVM2EVMOnRampCCIPSendRequestedWithMeta struct { - EVM2EVMMessage - BlockTimestamp time.Time - Executed bool - Finalized bool - LogIndex uint - TxHash string -} diff --git a/core/services/ocr2/plugins/ccip/cciptypes/models.go b/core/services/ocr2/plugins/ccip/cciptypes/models.go deleted file mode 100644 index 9b5157b9aa..0000000000 --- a/core/services/ocr2/plugins/ccip/cciptypes/models.go +++ /dev/null @@ -1,20 +0,0 @@ -package cciptypes - -import ( - "encoding/hex" -) - -type Address string - -type Hash [32]byte - -func (h Hash) String() string { - return "0x" + hex.EncodeToString(h[:]) -} - -type TxMeta struct { - BlockTimestampUnixMilli int64 - BlockNumber uint64 - TxHash string - LogIndex uint64 -} diff --git a/core/services/ocr2/plugins/ccip/cciptypes/models_test.go b/core/services/ocr2/plugins/ccip/cciptypes/models_test.go deleted file mode 100644 index 337d051931..0000000000 --- a/core/services/ocr2/plugins/ccip/cciptypes/models_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package cciptypes - -import ( - "testing" -) - -func TestHash_String(t *testing.T) { - tests := []struct { - name string - h Hash - want string - }{ - { - name: "empty", - h: Hash{}, - want: "0x0000000000000000000000000000000000000000000000000000000000000000", - }, - { - name: "1..", - h: Hash{1}, - want: "0x0100000000000000000000000000000000000000000000000000000000000000", - }, - { - name: "1..000..1", - h: [32]byte{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, - want: "0x0100000000000000000000000000000000000000000000000000000000000001", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.h.String(); got != tt.want { - t.Errorf("String() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/core/services/ocr2/plugins/ccip/cciptypes/offramp.go b/core/services/ocr2/plugins/ccip/cciptypes/offramp.go deleted file mode 100644 index fbddbce484..0000000000 --- a/core/services/ocr2/plugins/ccip/cciptypes/offramp.go +++ /dev/null @@ -1,124 +0,0 @@ -package cciptypes - -import ( - "context" - "math/big" - "time" - - "github.com/pkg/errors" - - "github.com/smartcontractkit/chainlink-common/pkg/config" -) - -type OffRampReader interface { - // EncodeExecutionReport will error if messages are not a compatible version. - EncodeExecutionReport(report ExecReport) ([]byte, error) - - // DecodeExecutionReport will error if messages are not a compatible version. - DecodeExecutionReport(report []byte) (ExecReport, error) - - // GetExecutionStateChangesBetweenSeqNums returns all the execution state change events for the provided message sequence numbers (inclusive). - GetExecutionStateChangesBetweenSeqNums(ctx context.Context, seqNumMin, seqNumMax uint64, confirmations int) ([]ExecutionStateChangedWithTxMeta, error) - - Address() Address - - // ChangeConfig notifies the reader that the config has changed onchain - ChangeConfig(onchainConfig []byte, offchainConfig []byte) (Address, Address, error) - - OffchainConfig() ExecOffchainConfig - - OnchainConfig() ExecOnchainConfig - - GasPriceEstimator() GasPriceEstimatorExec - - GetSenderNonce(ctx context.Context, sender Address) (uint64, error) - - CurrentRateLimiterState(ctx context.Context) (TokenBucketRateLimit, error) - - GetExecutionState(ctx context.Context, sequenceNumber uint64) (uint8, error) - - GetStaticConfig(ctx context.Context) (OffRampStaticConfig, error) - - GetSourceToDestTokensMapping(ctx context.Context) (map[Address]Address, error) - - GetTokens(ctx context.Context) (OffRampTokens, error) -} - -type ExecReport struct { - Messages []EVM2EVMMessage - OffchainTokenData [][][]byte - Proofs [][32]byte - ProofFlagBits *big.Int -} - -type ExecutionStateChangedWithTxMeta struct { - TxMeta - ExecutionStateChanged -} - -type ExecutionStateChanged struct { - SequenceNumber uint64 - Finalized bool -} - -type TokenBucketRateLimit struct { - Tokens *big.Int - LastUpdated uint32 - IsEnabled bool - Capacity *big.Int - Rate *big.Int -} - -// ExecOffchainConfig specifies configuration for nodes executing committed messages. -type ExecOffchainConfig struct { - // DestOptimisticConfirmations is how many confirmations to wait for the dest chain event before we consider it - // confirmed (optimistically, need not be finalized). - DestOptimisticConfirmations uint32 - // BatchGasLimit is the maximum sum of user callback gas we permit in one execution report. - BatchGasLimit uint32 - // RelativeBoostPerWaitHour indicates how much to increase (artificially) the fee paid on the source chain per hour - // of wait time, such that eventually the fee paid is greater than the execution cost, and we’ll execute it. - // For example: if set to 0.5, that means the fee paid is increased by 50% every hour the message has been waiting. - RelativeBoostPerWaitHour float64 - // InflightCacheExpiry indicates how long we keep a report in the plugin cache before we expire it. - // The caching prevents us from issuing another report while one is already in flight. - InflightCacheExpiry config.Duration - // RootSnoozeTime is the interval at which we check roots for executable messages. - RootSnoozeTime config.Duration -} - -type ExecOnchainConfig struct { - PermissionLessExecutionThresholdSeconds time.Duration -} - -func (c ExecOnchainConfig) Validate() error { - if c.PermissionLessExecutionThresholdSeconds == 0 { - return errors.New("must set PermissionLessExecutionThresholdSeconds") - } - return nil -} - -type OffRampStaticConfig struct { - CommitStore Address - ChainSelector uint64 - SourceChainSelector uint64 - OnRamp Address - PrevOffRamp Address - ArmProxy Address -} - -type OffRampTokens struct { - DestinationTokens []Address - SourceTokens []Address - DestinationPool map[Address]Address -} - -// MessageExecutionState defines the execution states of CCIP messages. -type MessageExecutionState uint8 - -const ( - ExecutionStateUntouched MessageExecutionState = iota - ExecutionStateInProgress - ExecutionStateSuccess - ExecutionStateFailure -) diff --git a/core/services/ocr2/plugins/ccip/cciptypes/onramp.go b/core/services/ocr2/plugins/ccip/cciptypes/onramp.go deleted file mode 100644 index 4cd7a29ca0..0000000000 --- a/core/services/ocr2/plugins/ccip/cciptypes/onramp.go +++ /dev/null @@ -1,71 +0,0 @@ -package cciptypes - -import ( - "context" - "math/big" -) - -type OnRampDynamicConfig struct { - Router Address - MaxNumberOfTokensPerMsg uint16 - DestGasOverhead uint32 - DestGasPerPayloadByte uint16 - DestDataAvailabilityOverheadGas uint32 - DestGasPerDataAvailabilityByte uint16 - DestDataAvailabilityMultiplierBps uint16 - PriceRegistry Address - MaxDataBytes uint32 - MaxPerMsgGasLimit uint32 -} - -// EVM2EVMMessage is the interface for a message sent from the off-ramp to the on-ramp -// Plugin can operate against any lane version which has a message satisfying this interface. -type EVM2EVMMessage struct { - SequenceNumber uint64 - GasLimit *big.Int - Nonce uint64 - MessageID Hash - SourceChainSelector uint64 - Sender Address - Receiver Address - Strict bool - FeeToken Address - FeeTokenAmount *big.Int - Data []byte - TokenAmounts []TokenAmount - SourceTokenData [][]byte - - // Computed - Hash Hash -} - -type EVM2EVMMessageWithTxMeta struct { - TxMeta - EVM2EVMMessage -} - -type TokenAmount struct { - Token Address - Amount *big.Int -} - -type OnRampReader interface { - // GetSendRequestsBetweenSeqNums returns all the finalized message send requests in the provided sequence numbers range (inclusive). - // If some requests do not exist in the provided sequence numbers range they will not be part of the response. - // It's the responsibility of the caller to validate whether all the requests exist or not. - GetSendRequestsBetweenSeqNums(ctx context.Context, seqNumMin, seqNumMax uint64, finalized bool) ([]EVM2EVMMessageWithTxMeta, error) - // IsSourceChainHealthy returns true if the source chain is healthy. - IsSourceChainHealthy(ctx context.Context) (bool, error) - // IsSourceCursed returns true if the source chain is cursed. OnRamp communicates with the underlying RMN - // to verify if source chain was cursed or not. - IsSourceCursed(ctx context.Context) (bool, error) - // RouterAddress returns the router address that is configured on the onRamp - RouterAddress() (Address, error) - - Address() (Address, error) - - GetDynamicConfig() (OnRampDynamicConfig, error) - - // SourcePriceRegistryAddress returns the address of the current price registry configured on the onRamp. - SourcePriceRegistryAddress(ctx context.Context) (Address, error) -} diff --git a/core/services/ocr2/plugins/ccip/cciptypes/pricegetter.go b/core/services/ocr2/plugins/ccip/cciptypes/pricegetter.go deleted file mode 100644 index db1a029583..0000000000 --- a/core/services/ocr2/plugins/ccip/cciptypes/pricegetter.go +++ /dev/null @@ -1,13 +0,0 @@ -package cciptypes - -import ( - "context" - "math/big" -) - -type PriceGetter interface { - // TokenPricesUSD returns token prices in USD. - // Note: The result might contain tokens that are not passed with the 'tokens' param. - // The opposite cannot happen, an error will be returned if a token price was not found. - TokenPricesUSD(ctx context.Context, tokens []Address) (map[Address]*big.Int, error) -} diff --git a/core/services/ocr2/plugins/ccip/cciptypes/priceregistry.go b/core/services/ocr2/plugins/ccip/cciptypes/priceregistry.go deleted file mode 100644 index 19881e198b..0000000000 --- a/core/services/ocr2/plugins/ccip/cciptypes/priceregistry.go +++ /dev/null @@ -1,47 +0,0 @@ -package cciptypes - -import ( - "context" - "math/big" - "time" -) - -type PriceRegistryReader interface { - // GetTokenPriceUpdatesCreatedAfter returns all the token price updates that happened after the provided timestamp. - // The returned updates are sorted by timestamp in ascending order. - GetTokenPriceUpdatesCreatedAfter(ctx context.Context, ts time.Time, confirmations int) ([]TokenPriceUpdateWithTxMeta, error) - - // GetGasPriceUpdatesCreatedAfter returns all the gas price updates that happened after the provided timestamp. - // The returned updates are sorted by timestamp in ascending order. - GetGasPriceUpdatesCreatedAfter(ctx context.Context, chainSelector uint64, ts time.Time, confirmations int) ([]GasPriceUpdateWithTxMeta, error) - - Address() Address - - GetFeeTokens(ctx context.Context) ([]Address, error) - - GetTokenPrices(ctx context.Context, wantedTokens []Address) ([]TokenPriceUpdate, error) - - GetTokensDecimals(ctx context.Context, tokenAddresses []Address) ([]uint8, error) - - Close() error -} - -type TokenPriceUpdateWithTxMeta struct { - TxMeta - TokenPriceUpdate -} - -type TokenPriceUpdate struct { - TokenPrice - TimestampUnixSec *big.Int -} - -type GasPriceUpdateWithTxMeta struct { - TxMeta - GasPriceUpdate -} - -type GasPriceUpdate struct { - GasPrice - TimestampUnixSec *big.Int -} diff --git a/core/services/ocr2/plugins/ccip/cciptypes/tokendata.go b/core/services/ocr2/plugins/ccip/cciptypes/tokendata.go deleted file mode 100644 index 01989c8f59..0000000000 --- a/core/services/ocr2/plugins/ccip/cciptypes/tokendata.go +++ /dev/null @@ -1,9 +0,0 @@ -package cciptypes - -import "context" - -type TokenDataReader interface { - // ReadTokenData returns the attestation bytes if ready, and throws an error if not ready. - // It supports messages with a single token transfer, the returned []byte has the token data for the first token of the msg. - ReadTokenData(ctx context.Context, msg EVM2EVMOnRampCCIPSendRequestedWithMeta, tokenIndex int) (tokenData []byte, err error) -} diff --git a/core/services/ocr2/plugins/ccip/cciptypes/tokenpool.go b/core/services/ocr2/plugins/ccip/cciptypes/tokenpool.go deleted file mode 100644 index eb86494de8..0000000000 --- a/core/services/ocr2/plugins/ccip/cciptypes/tokenpool.go +++ /dev/null @@ -1,7 +0,0 @@ -package cciptypes - -import "context" - -type TokenPoolBatchedReader interface { - GetInboundTokenPoolRateLimits(ctx context.Context, tokenPoolReaders []Address) ([]TokenBucketRateLimit, error) -} diff --git a/core/services/ocr2/plugins/ccip/config/config.go b/core/services/ocr2/plugins/ccip/config/config.go index e226c14cfe..635c47ac2d 100644 --- a/core/services/ocr2/plugins/ccip/config/config.go +++ b/core/services/ocr2/plugins/ccip/config/config.go @@ -9,8 +9,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink-common/pkg/utils/bytes" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" ) 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 d6c165a8e4..941162448a 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 @@ -7,7 +7,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" ) var ( diff --git a/core/services/ocr2/plugins/ccip/internal/cache/observed_chain_health_test.go b/core/services/ocr2/plugins/ccip/internal/cache/observed_chain_health_test.go index 27c6e433a9..19583a37c7 100644 --- a/core/services/ocr2/plugins/ccip/internal/cache/observed_chain_health_test.go +++ b/core/services/ocr2/plugins/ccip/internal/cache/observed_chain_health_test.go @@ -12,7 +12,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache/mocks" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipcalc/addr.go b/core/services/ocr2/plugins/ccip/internal/ccipcalc/addr.go index 1ce755bb13..40cdab6df9 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipcalc/addr.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipcalc/addr.go @@ -5,7 +5,7 @@ import ( "github.com/ethereum/go-ethereum/common" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" ) func EvmAddrsToGeneric(evmAddrs ...common.Address) []cciptypes.Address { diff --git a/core/services/ocr2/plugins/ccip/internal/ccipcommon/shortcuts.go b/core/services/ocr2/plugins/ccip/internal/ccipcommon/shortcuts.go index 9cdb93d49b..0ebe3a59ca 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipcommon/shortcuts.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipcommon/shortcuts.go @@ -7,8 +7,8 @@ import ( "golang.org/x/sync/errgroup" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipcommon/shortcuts_test.go b/core/services/ocr2/plugins/ccip/internal/ccipcommon/shortcuts_test.go index 4ac9fa708b..c3623b7f75 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipcommon/shortcuts_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipcommon/shortcuts_test.go @@ -8,7 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" ) func TestGetMessageIDsAsHexString(t *testing.T) { diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/mocks/token_pool_batched_reader_mock.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/mocks/token_pool_batched_reader_mock.go index 1101aee120..44266d5b35 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/mocks/token_pool_batched_reader_mock.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/mocks/token_pool_batched_reader_mock.go @@ -5,7 +5,7 @@ package mocks import ( context "context" - cciptypes "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + ccip "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" mock "github.com/stretchr/testify/mock" ) @@ -16,27 +16,27 @@ type TokenPoolBatchedReader struct { } // GetInboundTokenPoolRateLimits provides a mock function with given fields: ctx, tokenPoolReaders -func (_m *TokenPoolBatchedReader) GetInboundTokenPoolRateLimits(ctx context.Context, tokenPoolReaders []cciptypes.Address) ([]cciptypes.TokenBucketRateLimit, error) { +func (_m *TokenPoolBatchedReader) GetInboundTokenPoolRateLimits(ctx context.Context, tokenPoolReaders []ccip.Address) ([]ccip.TokenBucketRateLimit, error) { ret := _m.Called(ctx, tokenPoolReaders) if len(ret) == 0 { panic("no return value specified for GetInboundTokenPoolRateLimits") } - var r0 []cciptypes.TokenBucketRateLimit + var r0 []ccip.TokenBucketRateLimit var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []cciptypes.Address) ([]cciptypes.TokenBucketRateLimit, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, []ccip.Address) ([]ccip.TokenBucketRateLimit, error)); ok { return rf(ctx, tokenPoolReaders) } - if rf, ok := ret.Get(0).(func(context.Context, []cciptypes.Address) []cciptypes.TokenBucketRateLimit); ok { + if rf, ok := ret.Get(0).(func(context.Context, []ccip.Address) []ccip.TokenBucketRateLimit); ok { r0 = rf(ctx, tokenPoolReaders) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]cciptypes.TokenBucketRateLimit) + r0 = ret.Get(0).([]ccip.TokenBucketRateLimit) } } - if rf, ok := ret.Get(1).(func(context.Context, []cciptypes.Address) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, []ccip.Address) error); ok { r1 = rf(ctx, tokenPoolReaders) } else { r1 = ret.Error(1) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/token_pool_batch_reader.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/token_pool_batch_reader.go index 4d7e4b59d7..3cea0e5f7e 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/token_pool_batch_reader.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/token_pool_batch_reader.go @@ -9,10 +9,10 @@ import ( "github.com/ethereum/go-ethereum/common" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" type_and_version "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/type_and_version_interface_wrapper" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/token_pool_batch_reader_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/token_pool_batch_reader_test.go index 029bc6c6c2..c63d479f3d 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/token_pool_batch_reader_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader/token_pool_batch_reader_test.go @@ -10,9 +10,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/rpclib" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/ccipdataprovider/mocks/price_registry_mock.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/ccipdataprovider/mocks/price_registry_mock.go index 262f837123..91f2e4326c 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/ccipdataprovider/mocks/price_registry_mock.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/ccipdataprovider/mocks/price_registry_mock.go @@ -3,9 +3,9 @@ package mocks import ( - context "context" + ccip "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" - cciptypes "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + context "context" mock "github.com/stretchr/testify/mock" ) @@ -16,27 +16,27 @@ type PriceRegistry struct { } // NewPriceRegistryReader provides a mock function with given fields: ctx, addr -func (_m *PriceRegistry) NewPriceRegistryReader(ctx context.Context, addr cciptypes.Address) (cciptypes.PriceRegistryReader, error) { +func (_m *PriceRegistry) NewPriceRegistryReader(ctx context.Context, addr ccip.Address) (ccip.PriceRegistryReader, error) { ret := _m.Called(ctx, addr) if len(ret) == 0 { panic("no return value specified for NewPriceRegistryReader") } - var r0 cciptypes.PriceRegistryReader + var r0 ccip.PriceRegistryReader var r1 error - if rf, ok := ret.Get(0).(func(context.Context, cciptypes.Address) (cciptypes.PriceRegistryReader, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, ccip.Address) (ccip.PriceRegistryReader, error)); ok { return rf(ctx, addr) } - if rf, ok := ret.Get(0).(func(context.Context, cciptypes.Address) cciptypes.PriceRegistryReader); ok { + if rf, ok := ret.Get(0).(func(context.Context, ccip.Address) ccip.PriceRegistryReader); ok { r0 = rf(ctx, addr) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(cciptypes.PriceRegistryReader) + r0 = ret.Get(0).(ccip.PriceRegistryReader) } } - if rf, ok := ret.Get(1).(func(context.Context, cciptypes.Address) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, ccip.Address) error); ok { r1 = rf(ctx, addr) } else { r1 = ret.Error(1) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/ccipdataprovider/provider.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/ccipdataprovider/provider.go index 8c5cdac7e1..6697a78e19 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/ccipdataprovider/provider.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/ccipdataprovider/provider.go @@ -3,10 +3,10 @@ package ccipdataprovider import ( "context" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/factory" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/observability" ) @@ -32,8 +32,8 @@ func NewEvmPriceRegistry(lp logpoller.LogPoller, ec client.Client, lggr logger.L } } -func (p *EvmPriceRegistry) NewPriceRegistryReader(_ context.Context, addr cciptypes.Address) (cciptypes.PriceRegistryReader, error) { - destPriceRegistryReader, err := factory.NewPriceRegistryReader(p.lggr, factory.NewEvmVersionFinder(), addr, p.lp, p.ec) +func (p *EvmPriceRegistry) NewPriceRegistryReader(ctx context.Context, addr cciptypes.Address) (cciptypes.PriceRegistryReader, error) { + destPriceRegistryReader, err := factory.NewPriceRegistryReader(ctx, p.lggr, factory.NewEvmVersionFinder(), addr, p.lp, p.ec) if err != nil { return nil, err } diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_reader.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_reader.go index e122dc8002..1284e93420 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_reader.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_reader.go @@ -7,9 +7,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_reader_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_reader_test.go index e2747fda62..5936d8ccf9 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_reader_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/commit_store_reader_test.go @@ -14,6 +14,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/config" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" evmclientmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" @@ -31,7 +32,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/commit_store.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/commit_store.go index b40cff548c..a18d27e525 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/commit_store.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/commit_store.go @@ -6,6 +6,7 @@ import ( "github.com/Masterminds/semver/v3" "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" @@ -14,7 +15,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store_1_0_0" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/commit_store_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/commit_store_test.go index 106f3af13f..2c7f26267a 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/commit_store_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/commit_store_test.go @@ -7,11 +7,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" mocks2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/offramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/offramp.go index e4ff6ae186..c334be92b3 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/offramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/offramp.go @@ -1,12 +1,14 @@ package factory import ( + "context" "math/big" "github.com/Masterminds/semver/v3" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" @@ -15,7 +17,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_offramp_1_0_0" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" @@ -56,7 +57,7 @@ func initOrCloseOffRampReader(lggr logger.Logger, versionFinder VersionFinder, a return nil, err } if closeReader { - return nil, offRamp.Close(pgOpts...) + return nil, offRamp.Close() } return offRamp, offRamp.RegisterFilters(pgOpts...) case ccipdata.V1_2_0, ccipdata.V1_5_0: @@ -65,7 +66,7 @@ func initOrCloseOffRampReader(lggr logger.Logger, versionFinder VersionFinder, a return nil, err } if closeReader { - return nil, offRamp.Close(pgOpts...) + return nil, offRamp.Close() } return offRamp, offRamp.RegisterFilters(pgOpts...) default: @@ -74,7 +75,7 @@ func initOrCloseOffRampReader(lggr logger.Logger, versionFinder VersionFinder, a // TODO can validate it pointing to the correct version } -func ExecReportToEthTxMeta(typ ccipconfig.ContractType, ver semver.Version) (func(report []byte) (*txmgr.TxMeta, error), error) { +func ExecReportToEthTxMeta(ctx context.Context, typ ccipconfig.ContractType, ver semver.Version) (func(report []byte) (*txmgr.TxMeta, error), error) { if typ != ccipconfig.EVM2EVMOffRamp { return nil, errors.Errorf("expected %v got %v", ccipconfig.EVM2EVMOffRamp, typ) } @@ -82,7 +83,7 @@ func ExecReportToEthTxMeta(typ ccipconfig.ContractType, ver semver.Version) (fun case ccipdata.V1_0_0, ccipdata.V1_1_0: offRampABI := abihelpers.MustParseABI(evm_2_evm_offramp_1_0_0.EVM2EVMOffRampABI) return func(report []byte) (*txmgr.TxMeta, error) { - execReport, err := v1_0_0.DecodeExecReport(abihelpers.MustGetMethodInputs(ccipdata.ManuallyExecute, offRampABI)[:1], report) + execReport, err := v1_0_0.DecodeExecReport(ctx, abihelpers.MustGetMethodInputs(ccipdata.ManuallyExecute, offRampABI)[:1], report) if err != nil { return nil, err } @@ -91,7 +92,7 @@ func ExecReportToEthTxMeta(typ ccipconfig.ContractType, ver semver.Version) (fun case ccipdata.V1_2_0, ccipdata.V1_5_0: offRampABI := abihelpers.MustParseABI(evm_2_evm_offramp.EVM2EVMOffRampABI) return func(report []byte) (*txmgr.TxMeta, error) { - execReport, err := v1_2_0.DecodeExecReport(abihelpers.MustGetMethodInputs(ccipdata.ManuallyExecute, offRampABI)[:1], report) + execReport, err := v1_2_0.DecodeExecReport(ctx, abihelpers.MustGetMethodInputs(ccipdata.ManuallyExecute, offRampABI)[:1], report) if err != nil { return nil, err } diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/offramp_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/offramp_test.go index fd9a76d313..7d34748134 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/offramp_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/offramp_test.go @@ -7,11 +7,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" mocks2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/onramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/onramp.go index 369061e58b..a743a5654f 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/onramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/onramp.go @@ -3,10 +3,10 @@ package factory import ( "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/onramp_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/onramp_test.go index c7bd690a04..00ef73ae0f 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/onramp_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/onramp_test.go @@ -7,11 +7,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" mocks2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/price_registry.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/price_registry.go index 93bb5e486f..784bf96cfd 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/price_registry.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/price_registry.go @@ -1,14 +1,15 @@ package factory import ( + "context" "strings" "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" @@ -17,16 +18,16 @@ import ( ) // NewPriceRegistryReader determines the appropriate version of the price registry and returns a reader for it. -func NewPriceRegistryReader(lggr logger.Logger, versionFinder VersionFinder, priceRegistryAddress cciptypes.Address, lp logpoller.LogPoller, cl client.Client) (ccipdata.PriceRegistryReader, error) { - return initOrClosePriceRegistryReader(lggr, versionFinder, priceRegistryAddress, lp, cl, false) +func NewPriceRegistryReader(ctx context.Context, lggr logger.Logger, versionFinder VersionFinder, priceRegistryAddress cciptypes.Address, lp logpoller.LogPoller, cl client.Client) (ccipdata.PriceRegistryReader, error) { + return initOrClosePriceRegistryReader(ctx, lggr, versionFinder, priceRegistryAddress, lp, cl, false) } -func ClosePriceRegistryReader(lggr logger.Logger, versionFinder VersionFinder, priceRegistryAddress cciptypes.Address, lp logpoller.LogPoller, cl client.Client) error { - _, err := initOrClosePriceRegistryReader(lggr, versionFinder, priceRegistryAddress, lp, cl, true) +func ClosePriceRegistryReader(ctx context.Context, lggr logger.Logger, versionFinder VersionFinder, priceRegistryAddress cciptypes.Address, lp logpoller.LogPoller, cl client.Client) error { + _, err := initOrClosePriceRegistryReader(ctx, lggr, versionFinder, priceRegistryAddress, lp, cl, true) return err } -func initOrClosePriceRegistryReader(lggr logger.Logger, versionFinder VersionFinder, priceRegistryAddress cciptypes.Address, lp logpoller.LogPoller, cl client.Client, closeReader bool) (ccipdata.PriceRegistryReader, error) { +func initOrClosePriceRegistryReader(ctx context.Context, lggr logger.Logger, versionFinder VersionFinder, priceRegistryAddress cciptypes.Address, lp logpoller.LogPoller, cl client.Client, closeReader bool) (ccipdata.PriceRegistryReader, error) { registerFilters := !closeReader priceRegistryEvmAddr, err := ccipcalc.GenericAddrToEvm(priceRegistryAddress) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/price_registry_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/price_registry_test.go index b6c0e815d1..d9e99e8bd0 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/price_registry_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/price_registry_test.go @@ -7,16 +7,19 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" mocks2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" ) func TestPriceRegistry(t *testing.T) { + ctx := testutils.Context(t) + for _, versionStr := range []string{ccipdata.V1_0_0, ccipdata.V1_2_0} { lggr := logger.TestLogger(t) addr := cciptypes.Address(utils.RandomAddress().String()) @@ -30,13 +33,13 @@ func TestPriceRegistry(t *testing.T) { versionFinder := newMockVersionFinder(ccipconfig.PriceRegistry, *semver.MustParse(versionStr), nil) lp.On("RegisterFilter", mock.Anything).Return(nil).Times(len(expFilterNames)) - _, err := NewPriceRegistryReader(lggr, versionFinder, addr, lp, nil) + _, err := NewPriceRegistryReader(ctx, lggr, versionFinder, addr, lp, nil) assert.NoError(t, err) for _, f := range expFilterNames { lp.On("UnregisterFilter", f).Return(nil) } - err = ClosePriceRegistryReader(lggr, versionFinder, addr, lp, nil) + err = ClosePriceRegistryReader(ctx, lggr, versionFinder, addr, lp, nil) assert.NoError(t, err) } } diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/versionfinder.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/versionfinder.go index 6bcf29a79f..ac16fc4df2 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/versionfinder.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/versionfinder.go @@ -4,7 +4,7 @@ import ( "github.com/Masterminds/semver/v3" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/commit_store_reader_mock.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/commit_store_reader_mock.go index 4cba684fb6..df91b542fb 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/commit_store_reader_mock.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/commit_store_reader_mock.go @@ -3,9 +3,9 @@ package mocks import ( - context "context" + ccip "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" - cciptypes "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + context "context" mock "github.com/stretchr/testify/mock" @@ -18,22 +18,22 @@ type CommitStoreReader struct { } // ChangeConfig provides a mock function with given fields: onchainConfig, offchainConfig -func (_m *CommitStoreReader) ChangeConfig(onchainConfig []byte, offchainConfig []byte) (cciptypes.Address, error) { +func (_m *CommitStoreReader) ChangeConfig(onchainConfig []byte, offchainConfig []byte) (ccip.Address, error) { ret := _m.Called(onchainConfig, offchainConfig) if len(ret) == 0 { panic("no return value specified for ChangeConfig") } - var r0 cciptypes.Address + var r0 ccip.Address var r1 error - if rf, ok := ret.Get(0).(func([]byte, []byte) (cciptypes.Address, error)); ok { + if rf, ok := ret.Get(0).(func([]byte, []byte) (ccip.Address, error)); ok { return rf(onchainConfig, offchainConfig) } - if rf, ok := ret.Get(0).(func([]byte, []byte) cciptypes.Address); ok { + if rf, ok := ret.Get(0).(func([]byte, []byte) ccip.Address); ok { r0 = rf(onchainConfig, offchainConfig) } else { - r0 = ret.Get(0).(cciptypes.Address) + r0 = ret.Get(0).(ccip.Address) } if rf, ok := ret.Get(1).(func([]byte, []byte) error); ok { @@ -46,22 +46,22 @@ func (_m *CommitStoreReader) ChangeConfig(onchainConfig []byte, offchainConfig [ } // DecodeCommitReport provides a mock function with given fields: report -func (_m *CommitStoreReader) DecodeCommitReport(report []byte) (cciptypes.CommitStoreReport, error) { +func (_m *CommitStoreReader) DecodeCommitReport(report []byte) (ccip.CommitStoreReport, error) { ret := _m.Called(report) if len(ret) == 0 { panic("no return value specified for DecodeCommitReport") } - var r0 cciptypes.CommitStoreReport + var r0 ccip.CommitStoreReport var r1 error - if rf, ok := ret.Get(0).(func([]byte) (cciptypes.CommitStoreReport, error)); ok { + if rf, ok := ret.Get(0).(func([]byte) (ccip.CommitStoreReport, error)); ok { return rf(report) } - if rf, ok := ret.Get(0).(func([]byte) cciptypes.CommitStoreReport); ok { + if rf, ok := ret.Get(0).(func([]byte) ccip.CommitStoreReport); ok { r0 = rf(report) } else { - r0 = ret.Get(0).(cciptypes.CommitStoreReport) + r0 = ret.Get(0).(ccip.CommitStoreReport) } if rf, ok := ret.Get(1).(func([]byte) error); ok { @@ -74,7 +74,7 @@ func (_m *CommitStoreReader) DecodeCommitReport(report []byte) (cciptypes.Commit } // EncodeCommitReport provides a mock function with given fields: report -func (_m *CommitStoreReader) EncodeCommitReport(report cciptypes.CommitStoreReport) ([]byte, error) { +func (_m *CommitStoreReader) EncodeCommitReport(report ccip.CommitStoreReport) ([]byte, error) { ret := _m.Called(report) if len(ret) == 0 { @@ -83,10 +83,10 @@ func (_m *CommitStoreReader) EncodeCommitReport(report cciptypes.CommitStoreRepo var r0 []byte var r1 error - if rf, ok := ret.Get(0).(func(cciptypes.CommitStoreReport) ([]byte, error)); ok { + if rf, ok := ret.Get(0).(func(ccip.CommitStoreReport) ([]byte, error)); ok { return rf(report) } - if rf, ok := ret.Get(0).(func(cciptypes.CommitStoreReport) []byte); ok { + if rf, ok := ret.Get(0).(func(ccip.CommitStoreReport) []byte); ok { r0 = rf(report) } else { if ret.Get(0) != nil { @@ -94,7 +94,7 @@ func (_m *CommitStoreReader) EncodeCommitReport(report cciptypes.CommitStoreRepo } } - if rf, ok := ret.Get(1).(func(cciptypes.CommitStoreReport) error); ok { + if rf, ok := ret.Get(1).(func(ccip.CommitStoreReport) error); ok { r1 = rf(report) } else { r1 = ret.Error(1) @@ -104,19 +104,19 @@ func (_m *CommitStoreReader) EncodeCommitReport(report cciptypes.CommitStoreRepo } // GasPriceEstimator provides a mock function with given fields: -func (_m *CommitStoreReader) GasPriceEstimator() cciptypes.GasPriceEstimatorCommit { +func (_m *CommitStoreReader) GasPriceEstimator() ccip.GasPriceEstimatorCommit { ret := _m.Called() if len(ret) == 0 { panic("no return value specified for GasPriceEstimator") } - var r0 cciptypes.GasPriceEstimatorCommit - if rf, ok := ret.Get(0).(func() cciptypes.GasPriceEstimatorCommit); ok { + var r0 ccip.GasPriceEstimatorCommit + if rf, ok := ret.Get(0).(func() ccip.GasPriceEstimatorCommit); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(cciptypes.GasPriceEstimatorCommit) + r0 = ret.Get(0).(ccip.GasPriceEstimatorCommit) } } @@ -124,23 +124,23 @@ func (_m *CommitStoreReader) GasPriceEstimator() cciptypes.GasPriceEstimatorComm } // GetAcceptedCommitReportsGteTimestamp provides a mock function with given fields: ctx, ts, confirmations -func (_m *CommitStoreReader) GetAcceptedCommitReportsGteTimestamp(ctx context.Context, ts time.Time, confirmations int) ([]cciptypes.CommitStoreReportWithTxMeta, error) { +func (_m *CommitStoreReader) GetAcceptedCommitReportsGteTimestamp(ctx context.Context, ts time.Time, confirmations int) ([]ccip.CommitStoreReportWithTxMeta, error) { ret := _m.Called(ctx, ts, confirmations) if len(ret) == 0 { panic("no return value specified for GetAcceptedCommitReportsGteTimestamp") } - var r0 []cciptypes.CommitStoreReportWithTxMeta + var r0 []ccip.CommitStoreReportWithTxMeta var r1 error - if rf, ok := ret.Get(0).(func(context.Context, time.Time, int) ([]cciptypes.CommitStoreReportWithTxMeta, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, time.Time, int) ([]ccip.CommitStoreReportWithTxMeta, error)); ok { return rf(ctx, ts, confirmations) } - if rf, ok := ret.Get(0).(func(context.Context, time.Time, int) []cciptypes.CommitStoreReportWithTxMeta); ok { + if rf, ok := ret.Get(0).(func(context.Context, time.Time, int) []ccip.CommitStoreReportWithTxMeta); ok { r0 = rf(ctx, ts, confirmations) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]cciptypes.CommitStoreReportWithTxMeta) + r0 = ret.Get(0).([]ccip.CommitStoreReportWithTxMeta) } } @@ -154,23 +154,23 @@ func (_m *CommitStoreReader) GetAcceptedCommitReportsGteTimestamp(ctx context.Co } // GetCommitReportMatchingSeqNum provides a mock function with given fields: ctx, seqNum, confirmations -func (_m *CommitStoreReader) GetCommitReportMatchingSeqNum(ctx context.Context, seqNum uint64, confirmations int) ([]cciptypes.CommitStoreReportWithTxMeta, error) { +func (_m *CommitStoreReader) GetCommitReportMatchingSeqNum(ctx context.Context, seqNum uint64, confirmations int) ([]ccip.CommitStoreReportWithTxMeta, error) { ret := _m.Called(ctx, seqNum, confirmations) if len(ret) == 0 { panic("no return value specified for GetCommitReportMatchingSeqNum") } - var r0 []cciptypes.CommitStoreReportWithTxMeta + var r0 []ccip.CommitStoreReportWithTxMeta var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uint64, int) ([]cciptypes.CommitStoreReportWithTxMeta, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uint64, int) ([]ccip.CommitStoreReportWithTxMeta, error)); ok { return rf(ctx, seqNum, confirmations) } - if rf, ok := ret.Get(0).(func(context.Context, uint64, int) []cciptypes.CommitStoreReportWithTxMeta); ok { + if rf, ok := ret.Get(0).(func(context.Context, uint64, int) []ccip.CommitStoreReportWithTxMeta); ok { r0 = rf(ctx, seqNum, confirmations) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]cciptypes.CommitStoreReportWithTxMeta) + r0 = ret.Get(0).([]ccip.CommitStoreReportWithTxMeta) } } @@ -184,22 +184,22 @@ func (_m *CommitStoreReader) GetCommitReportMatchingSeqNum(ctx context.Context, } // GetCommitStoreStaticConfig provides a mock function with given fields: ctx -func (_m *CommitStoreReader) GetCommitStoreStaticConfig(ctx context.Context) (cciptypes.CommitStoreStaticConfig, error) { +func (_m *CommitStoreReader) GetCommitStoreStaticConfig(ctx context.Context) (ccip.CommitStoreStaticConfig, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetCommitStoreStaticConfig") } - var r0 cciptypes.CommitStoreStaticConfig + var r0 ccip.CommitStoreStaticConfig var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (cciptypes.CommitStoreStaticConfig, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (ccip.CommitStoreStaticConfig, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) cciptypes.CommitStoreStaticConfig); ok { + if rf, ok := ret.Get(0).(func(context.Context) ccip.CommitStoreStaticConfig); ok { r0 = rf(ctx) } else { - r0 = ret.Get(0).(cciptypes.CommitStoreStaticConfig) + r0 = ret.Get(0).(ccip.CommitStoreStaticConfig) } if rf, ok := ret.Get(1).(func(context.Context) error); ok { @@ -352,25 +352,25 @@ func (_m *CommitStoreReader) IsDown(ctx context.Context) (bool, error) { } // OffchainConfig provides a mock function with given fields: -func (_m *CommitStoreReader) OffchainConfig() cciptypes.CommitOffchainConfig { +func (_m *CommitStoreReader) OffchainConfig() ccip.CommitOffchainConfig { ret := _m.Called() if len(ret) == 0 { panic("no return value specified for OffchainConfig") } - var r0 cciptypes.CommitOffchainConfig - if rf, ok := ret.Get(0).(func() cciptypes.CommitOffchainConfig); ok { + var r0 ccip.CommitOffchainConfig + if rf, ok := ret.Get(0).(func() ccip.CommitOffchainConfig); ok { r0 = rf() } else { - r0 = ret.Get(0).(cciptypes.CommitOffchainConfig) + r0 = ret.Get(0).(ccip.CommitOffchainConfig) } return r0 } // VerifyExecutionReport provides a mock function with given fields: ctx, report -func (_m *CommitStoreReader) VerifyExecutionReport(ctx context.Context, report cciptypes.ExecReport) (bool, error) { +func (_m *CommitStoreReader) VerifyExecutionReport(ctx context.Context, report ccip.ExecReport) (bool, error) { ret := _m.Called(ctx, report) if len(ret) == 0 { @@ -379,16 +379,16 @@ func (_m *CommitStoreReader) VerifyExecutionReport(ctx context.Context, report c var r0 bool var r1 error - if rf, ok := ret.Get(0).(func(context.Context, cciptypes.ExecReport) (bool, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, ccip.ExecReport) (bool, error)); ok { return rf(ctx, report) } - if rf, ok := ret.Get(0).(func(context.Context, cciptypes.ExecReport) bool); ok { + if rf, ok := ret.Get(0).(func(context.Context, ccip.ExecReport) bool); ok { r0 = rf(ctx, report) } else { r0 = ret.Get(0).(bool) } - if rf, ok := ret.Get(1).(func(context.Context, cciptypes.ExecReport) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, ccip.ExecReport) error); ok { r1 = rf(ctx, report) } else { r1 = ret.Error(1) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/offramp_reader_mock.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/offramp_reader_mock.go index cf6e6bfbdc..7438cc70a5 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/offramp_reader_mock.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/offramp_reader_mock.go @@ -3,9 +3,9 @@ package mocks import ( - context "context" + ccip "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" - cciptypes "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + context "context" mock "github.com/stretchr/testify/mock" ) @@ -15,52 +15,62 @@ type OffRampReader struct { mock.Mock } -// Address provides a mock function with given fields: -func (_m *OffRampReader) Address() cciptypes.Address { - ret := _m.Called() +// Address provides a mock function with given fields: ctx +func (_m *OffRampReader) Address(ctx context.Context) (ccip.Address, error) { + ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for Address") } - var r0 cciptypes.Address - if rf, ok := ret.Get(0).(func() cciptypes.Address); ok { - r0 = rf() + var r0 ccip.Address + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (ccip.Address, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) ccip.Address); ok { + r0 = rf(ctx) } else { - r0 = ret.Get(0).(cciptypes.Address) + r0 = ret.Get(0).(ccip.Address) } - return r0 + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -// ChangeConfig provides a mock function with given fields: onchainConfig, offchainConfig -func (_m *OffRampReader) ChangeConfig(onchainConfig []byte, offchainConfig []byte) (cciptypes.Address, cciptypes.Address, error) { - ret := _m.Called(onchainConfig, offchainConfig) +// ChangeConfig provides a mock function with given fields: ctx, onchainConfig, offchainConfig +func (_m *OffRampReader) ChangeConfig(ctx context.Context, onchainConfig []byte, offchainConfig []byte) (ccip.Address, ccip.Address, error) { + ret := _m.Called(ctx, onchainConfig, offchainConfig) if len(ret) == 0 { panic("no return value specified for ChangeConfig") } - var r0 cciptypes.Address - var r1 cciptypes.Address + var r0 ccip.Address + var r1 ccip.Address var r2 error - if rf, ok := ret.Get(0).(func([]byte, []byte) (cciptypes.Address, cciptypes.Address, error)); ok { - return rf(onchainConfig, offchainConfig) + if rf, ok := ret.Get(0).(func(context.Context, []byte, []byte) (ccip.Address, ccip.Address, error)); ok { + return rf(ctx, onchainConfig, offchainConfig) } - if rf, ok := ret.Get(0).(func([]byte, []byte) cciptypes.Address); ok { - r0 = rf(onchainConfig, offchainConfig) + if rf, ok := ret.Get(0).(func(context.Context, []byte, []byte) ccip.Address); ok { + r0 = rf(ctx, onchainConfig, offchainConfig) } else { - r0 = ret.Get(0).(cciptypes.Address) + r0 = ret.Get(0).(ccip.Address) } - if rf, ok := ret.Get(1).(func([]byte, []byte) cciptypes.Address); ok { - r1 = rf(onchainConfig, offchainConfig) + if rf, ok := ret.Get(1).(func(context.Context, []byte, []byte) ccip.Address); ok { + r1 = rf(ctx, onchainConfig, offchainConfig) } else { - r1 = ret.Get(1).(cciptypes.Address) + r1 = ret.Get(1).(ccip.Address) } - if rf, ok := ret.Get(2).(func([]byte, []byte) error); ok { - r2 = rf(onchainConfig, offchainConfig) + if rf, ok := ret.Get(2).(func(context.Context, []byte, []byte) error); ok { + r2 = rf(ctx, onchainConfig, offchainConfig) } else { r2 = ret.Error(2) } @@ -68,23 +78,41 @@ func (_m *OffRampReader) ChangeConfig(onchainConfig []byte, offchainConfig []byt return r0, r1, r2 } +// Close provides a mock function with given fields: +func (_m *OffRampReader) Close() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Close") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + // CurrentRateLimiterState provides a mock function with given fields: ctx -func (_m *OffRampReader) CurrentRateLimiterState(ctx context.Context) (cciptypes.TokenBucketRateLimit, error) { +func (_m *OffRampReader) CurrentRateLimiterState(ctx context.Context) (ccip.TokenBucketRateLimit, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for CurrentRateLimiterState") } - var r0 cciptypes.TokenBucketRateLimit + var r0 ccip.TokenBucketRateLimit var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (cciptypes.TokenBucketRateLimit, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (ccip.TokenBucketRateLimit, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) cciptypes.TokenBucketRateLimit); ok { + if rf, ok := ret.Get(0).(func(context.Context) ccip.TokenBucketRateLimit); ok { r0 = rf(ctx) } else { - r0 = ret.Get(0).(cciptypes.TokenBucketRateLimit) + r0 = ret.Get(0).(ccip.TokenBucketRateLimit) } if rf, ok := ret.Get(1).(func(context.Context) error); ok { @@ -96,27 +124,27 @@ func (_m *OffRampReader) CurrentRateLimiterState(ctx context.Context) (cciptypes return r0, r1 } -// DecodeExecutionReport provides a mock function with given fields: report -func (_m *OffRampReader) DecodeExecutionReport(report []byte) (cciptypes.ExecReport, error) { - ret := _m.Called(report) +// DecodeExecutionReport provides a mock function with given fields: ctx, report +func (_m *OffRampReader) DecodeExecutionReport(ctx context.Context, report []byte) (ccip.ExecReport, error) { + ret := _m.Called(ctx, report) if len(ret) == 0 { panic("no return value specified for DecodeExecutionReport") } - var r0 cciptypes.ExecReport + var r0 ccip.ExecReport var r1 error - if rf, ok := ret.Get(0).(func([]byte) (cciptypes.ExecReport, error)); ok { - return rf(report) + if rf, ok := ret.Get(0).(func(context.Context, []byte) (ccip.ExecReport, error)); ok { + return rf(ctx, report) } - if rf, ok := ret.Get(0).(func([]byte) cciptypes.ExecReport); ok { - r0 = rf(report) + if rf, ok := ret.Get(0).(func(context.Context, []byte) ccip.ExecReport); ok { + r0 = rf(ctx, report) } else { - r0 = ret.Get(0).(cciptypes.ExecReport) + r0 = ret.Get(0).(ccip.ExecReport) } - if rf, ok := ret.Get(1).(func([]byte) error); ok { - r1 = rf(report) + if rf, ok := ret.Get(1).(func(context.Context, []byte) error); ok { + r1 = rf(ctx, report) } else { r1 = ret.Error(1) } @@ -124,9 +152,9 @@ func (_m *OffRampReader) DecodeExecutionReport(report []byte) (cciptypes.ExecRep return r0, r1 } -// EncodeExecutionReport provides a mock function with given fields: report -func (_m *OffRampReader) EncodeExecutionReport(report cciptypes.ExecReport) ([]byte, error) { - ret := _m.Called(report) +// EncodeExecutionReport provides a mock function with given fields: ctx, report +func (_m *OffRampReader) EncodeExecutionReport(ctx context.Context, report ccip.ExecReport) ([]byte, error) { + ret := _m.Called(ctx, report) if len(ret) == 0 { panic("no return value specified for EncodeExecutionReport") @@ -134,19 +162,19 @@ func (_m *OffRampReader) EncodeExecutionReport(report cciptypes.ExecReport) ([]b var r0 []byte var r1 error - if rf, ok := ret.Get(0).(func(cciptypes.ExecReport) ([]byte, error)); ok { - return rf(report) + if rf, ok := ret.Get(0).(func(context.Context, ccip.ExecReport) ([]byte, error)); ok { + return rf(ctx, report) } - if rf, ok := ret.Get(0).(func(cciptypes.ExecReport) []byte); ok { - r0 = rf(report) + if rf, ok := ret.Get(0).(func(context.Context, ccip.ExecReport) []byte); ok { + r0 = rf(ctx, report) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]byte) } } - if rf, ok := ret.Get(1).(func(cciptypes.ExecReport) error); ok { - r1 = rf(report) + if rf, ok := ret.Get(1).(func(context.Context, ccip.ExecReport) error); ok { + r1 = rf(ctx, report) } else { r1 = ret.Error(1) } @@ -154,24 +182,34 @@ func (_m *OffRampReader) EncodeExecutionReport(report cciptypes.ExecReport) ([]b return r0, r1 } -// GasPriceEstimator provides a mock function with given fields: -func (_m *OffRampReader) GasPriceEstimator() cciptypes.GasPriceEstimatorExec { - ret := _m.Called() +// GasPriceEstimator provides a mock function with given fields: ctx +func (_m *OffRampReader) GasPriceEstimator(ctx context.Context) (ccip.GasPriceEstimatorExec, error) { + ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GasPriceEstimator") } - var r0 cciptypes.GasPriceEstimatorExec - if rf, ok := ret.Get(0).(func() cciptypes.GasPriceEstimatorExec); ok { - r0 = rf() + var r0 ccip.GasPriceEstimatorExec + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (ccip.GasPriceEstimatorExec, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) ccip.GasPriceEstimatorExec); ok { + r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(cciptypes.GasPriceEstimatorExec) + r0 = ret.Get(0).(ccip.GasPriceEstimatorExec) } } - return r0 + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } // GetExecutionState provides a mock function with given fields: ctx, sequenceNumber @@ -203,23 +241,23 @@ func (_m *OffRampReader) GetExecutionState(ctx context.Context, sequenceNumber u } // GetExecutionStateChangesBetweenSeqNums provides a mock function with given fields: ctx, seqNumMin, seqNumMax, confirmations -func (_m *OffRampReader) GetExecutionStateChangesBetweenSeqNums(ctx context.Context, seqNumMin uint64, seqNumMax uint64, confirmations int) ([]cciptypes.ExecutionStateChangedWithTxMeta, error) { +func (_m *OffRampReader) GetExecutionStateChangesBetweenSeqNums(ctx context.Context, seqNumMin uint64, seqNumMax uint64, confirmations int) ([]ccip.ExecutionStateChangedWithTxMeta, error) { ret := _m.Called(ctx, seqNumMin, seqNumMax, confirmations) if len(ret) == 0 { panic("no return value specified for GetExecutionStateChangesBetweenSeqNums") } - var r0 []cciptypes.ExecutionStateChangedWithTxMeta + var r0 []ccip.ExecutionStateChangedWithTxMeta var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, int) ([]cciptypes.ExecutionStateChangedWithTxMeta, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, int) ([]ccip.ExecutionStateChangedWithTxMeta, error)); ok { return rf(ctx, seqNumMin, seqNumMax, confirmations) } - if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, int) []cciptypes.ExecutionStateChangedWithTxMeta); ok { + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, int) []ccip.ExecutionStateChangedWithTxMeta); ok { r0 = rf(ctx, seqNumMin, seqNumMax, confirmations) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]cciptypes.ExecutionStateChangedWithTxMeta) + r0 = ret.Get(0).([]ccip.ExecutionStateChangedWithTxMeta) } } @@ -233,7 +271,7 @@ func (_m *OffRampReader) GetExecutionStateChangesBetweenSeqNums(ctx context.Cont } // GetSenderNonce provides a mock function with given fields: ctx, sender -func (_m *OffRampReader) GetSenderNonce(ctx context.Context, sender cciptypes.Address) (uint64, error) { +func (_m *OffRampReader) GetSenderNonce(ctx context.Context, sender ccip.Address) (uint64, error) { ret := _m.Called(ctx, sender) if len(ret) == 0 { @@ -242,16 +280,16 @@ func (_m *OffRampReader) GetSenderNonce(ctx context.Context, sender cciptypes.Ad var r0 uint64 var r1 error - if rf, ok := ret.Get(0).(func(context.Context, cciptypes.Address) (uint64, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, ccip.Address) (uint64, error)); ok { return rf(ctx, sender) } - if rf, ok := ret.Get(0).(func(context.Context, cciptypes.Address) uint64); ok { + if rf, ok := ret.Get(0).(func(context.Context, ccip.Address) uint64); ok { r0 = rf(ctx, sender) } else { r0 = ret.Get(0).(uint64) } - if rf, ok := ret.Get(1).(func(context.Context, cciptypes.Address) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, ccip.Address) error); ok { r1 = rf(ctx, sender) } else { r1 = ret.Error(1) @@ -261,23 +299,23 @@ func (_m *OffRampReader) GetSenderNonce(ctx context.Context, sender cciptypes.Ad } // GetSourceToDestTokensMapping provides a mock function with given fields: ctx -func (_m *OffRampReader) GetSourceToDestTokensMapping(ctx context.Context) (map[cciptypes.Address]cciptypes.Address, error) { +func (_m *OffRampReader) GetSourceToDestTokensMapping(ctx context.Context) (map[ccip.Address]ccip.Address, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetSourceToDestTokensMapping") } - var r0 map[cciptypes.Address]cciptypes.Address + var r0 map[ccip.Address]ccip.Address var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (map[cciptypes.Address]cciptypes.Address, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (map[ccip.Address]ccip.Address, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) map[cciptypes.Address]cciptypes.Address); ok { + if rf, ok := ret.Get(0).(func(context.Context) map[ccip.Address]ccip.Address); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(map[cciptypes.Address]cciptypes.Address) + r0 = ret.Get(0).(map[ccip.Address]ccip.Address) } } @@ -291,22 +329,22 @@ func (_m *OffRampReader) GetSourceToDestTokensMapping(ctx context.Context) (map[ } // GetStaticConfig provides a mock function with given fields: ctx -func (_m *OffRampReader) GetStaticConfig(ctx context.Context) (cciptypes.OffRampStaticConfig, error) { +func (_m *OffRampReader) GetStaticConfig(ctx context.Context) (ccip.OffRampStaticConfig, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetStaticConfig") } - var r0 cciptypes.OffRampStaticConfig + var r0 ccip.OffRampStaticConfig var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (cciptypes.OffRampStaticConfig, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (ccip.OffRampStaticConfig, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) cciptypes.OffRampStaticConfig); ok { + if rf, ok := ret.Get(0).(func(context.Context) ccip.OffRampStaticConfig); ok { r0 = rf(ctx) } else { - r0 = ret.Get(0).(cciptypes.OffRampStaticConfig) + r0 = ret.Get(0).(ccip.OffRampStaticConfig) } if rf, ok := ret.Get(1).(func(context.Context) error); ok { @@ -319,22 +357,22 @@ func (_m *OffRampReader) GetStaticConfig(ctx context.Context) (cciptypes.OffRamp } // GetTokens provides a mock function with given fields: ctx -func (_m *OffRampReader) GetTokens(ctx context.Context) (cciptypes.OffRampTokens, error) { +func (_m *OffRampReader) GetTokens(ctx context.Context) (ccip.OffRampTokens, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetTokens") } - var r0 cciptypes.OffRampTokens + var r0 ccip.OffRampTokens var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (cciptypes.OffRampTokens, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (ccip.OffRampTokens, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) cciptypes.OffRampTokens); ok { + if rf, ok := ret.Get(0).(func(context.Context) ccip.OffRampTokens); ok { r0 = rf(ctx) } else { - r0 = ret.Get(0).(cciptypes.OffRampTokens) + r0 = ret.Get(0).(ccip.OffRampTokens) } if rf, ok := ret.Get(1).(func(context.Context) error); ok { @@ -346,40 +384,60 @@ func (_m *OffRampReader) GetTokens(ctx context.Context) (cciptypes.OffRampTokens return r0, r1 } -// OffchainConfig provides a mock function with given fields: -func (_m *OffRampReader) OffchainConfig() cciptypes.ExecOffchainConfig { - ret := _m.Called() +// OffchainConfig provides a mock function with given fields: ctx +func (_m *OffRampReader) OffchainConfig(ctx context.Context) (ccip.ExecOffchainConfig, error) { + ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for OffchainConfig") } - var r0 cciptypes.ExecOffchainConfig - if rf, ok := ret.Get(0).(func() cciptypes.ExecOffchainConfig); ok { - r0 = rf() + var r0 ccip.ExecOffchainConfig + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (ccip.ExecOffchainConfig, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) ccip.ExecOffchainConfig); ok { + r0 = rf(ctx) } else { - r0 = ret.Get(0).(cciptypes.ExecOffchainConfig) + r0 = ret.Get(0).(ccip.ExecOffchainConfig) } - return r0 + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -// OnchainConfig provides a mock function with given fields: -func (_m *OffRampReader) OnchainConfig() cciptypes.ExecOnchainConfig { - ret := _m.Called() +// OnchainConfig provides a mock function with given fields: ctx +func (_m *OffRampReader) OnchainConfig(ctx context.Context) (ccip.ExecOnchainConfig, error) { + ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for OnchainConfig") } - var r0 cciptypes.ExecOnchainConfig - if rf, ok := ret.Get(0).(func() cciptypes.ExecOnchainConfig); ok { - r0 = rf() + var r0 ccip.ExecOnchainConfig + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (ccip.ExecOnchainConfig, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) ccip.ExecOnchainConfig); ok { + r0 = rf(ctx) } else { - r0 = ret.Get(0).(cciptypes.ExecOnchainConfig) + r0 = ret.Get(0).(ccip.ExecOnchainConfig) } - return r0 + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } // NewOffRampReader creates a new instance of OffRampReader. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/onramp_reader_mock.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/onramp_reader_mock.go index 8888c2afa8..dad3fc27f8 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/onramp_reader_mock.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/onramp_reader_mock.go @@ -3,9 +3,9 @@ package mocks import ( - context "context" + ccip "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" - cciptypes "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + context "context" mock "github.com/stretchr/testify/mock" ) @@ -16,22 +16,22 @@ type OnRampReader struct { } // Address provides a mock function with given fields: -func (_m *OnRampReader) Address() (cciptypes.Address, error) { +func (_m *OnRampReader) Address() (ccip.Address, error) { ret := _m.Called() if len(ret) == 0 { panic("no return value specified for Address") } - var r0 cciptypes.Address + var r0 ccip.Address var r1 error - if rf, ok := ret.Get(0).(func() (cciptypes.Address, error)); ok { + if rf, ok := ret.Get(0).(func() (ccip.Address, error)); ok { return rf() } - if rf, ok := ret.Get(0).(func() cciptypes.Address); ok { + if rf, ok := ret.Get(0).(func() ccip.Address); ok { r0 = rf() } else { - r0 = ret.Get(0).(cciptypes.Address) + r0 = ret.Get(0).(ccip.Address) } if rf, ok := ret.Get(1).(func() error); ok { @@ -44,22 +44,22 @@ func (_m *OnRampReader) Address() (cciptypes.Address, error) { } // GetDynamicConfig provides a mock function with given fields: -func (_m *OnRampReader) GetDynamicConfig() (cciptypes.OnRampDynamicConfig, error) { +func (_m *OnRampReader) GetDynamicConfig() (ccip.OnRampDynamicConfig, error) { ret := _m.Called() if len(ret) == 0 { panic("no return value specified for GetDynamicConfig") } - var r0 cciptypes.OnRampDynamicConfig + var r0 ccip.OnRampDynamicConfig var r1 error - if rf, ok := ret.Get(0).(func() (cciptypes.OnRampDynamicConfig, error)); ok { + if rf, ok := ret.Get(0).(func() (ccip.OnRampDynamicConfig, error)); ok { return rf() } - if rf, ok := ret.Get(0).(func() cciptypes.OnRampDynamicConfig); ok { + if rf, ok := ret.Get(0).(func() ccip.OnRampDynamicConfig); ok { r0 = rf() } else { - r0 = ret.Get(0).(cciptypes.OnRampDynamicConfig) + r0 = ret.Get(0).(ccip.OnRampDynamicConfig) } if rf, ok := ret.Get(1).(func() error); ok { @@ -72,23 +72,23 @@ func (_m *OnRampReader) GetDynamicConfig() (cciptypes.OnRampDynamicConfig, error } // GetSendRequestsBetweenSeqNums provides a mock function with given fields: ctx, seqNumMin, seqNumMax, finalized -func (_m *OnRampReader) GetSendRequestsBetweenSeqNums(ctx context.Context, seqNumMin uint64, seqNumMax uint64, finalized bool) ([]cciptypes.EVM2EVMMessageWithTxMeta, error) { +func (_m *OnRampReader) GetSendRequestsBetweenSeqNums(ctx context.Context, seqNumMin uint64, seqNumMax uint64, finalized bool) ([]ccip.EVM2EVMMessageWithTxMeta, error) { ret := _m.Called(ctx, seqNumMin, seqNumMax, finalized) if len(ret) == 0 { panic("no return value specified for GetSendRequestsBetweenSeqNums") } - var r0 []cciptypes.EVM2EVMMessageWithTxMeta + var r0 []ccip.EVM2EVMMessageWithTxMeta var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, bool) ([]cciptypes.EVM2EVMMessageWithTxMeta, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, bool) ([]ccip.EVM2EVMMessageWithTxMeta, error)); ok { return rf(ctx, seqNumMin, seqNumMax, finalized) } - if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, bool) []cciptypes.EVM2EVMMessageWithTxMeta); ok { + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, bool) []ccip.EVM2EVMMessageWithTxMeta); ok { r0 = rf(ctx, seqNumMin, seqNumMax, finalized) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]cciptypes.EVM2EVMMessageWithTxMeta) + r0 = ret.Get(0).([]ccip.EVM2EVMMessageWithTxMeta) } } @@ -158,22 +158,22 @@ func (_m *OnRampReader) IsSourceCursed(ctx context.Context) (bool, error) { } // RouterAddress provides a mock function with given fields: -func (_m *OnRampReader) RouterAddress() (cciptypes.Address, error) { +func (_m *OnRampReader) RouterAddress() (ccip.Address, error) { ret := _m.Called() if len(ret) == 0 { panic("no return value specified for RouterAddress") } - var r0 cciptypes.Address + var r0 ccip.Address var r1 error - if rf, ok := ret.Get(0).(func() (cciptypes.Address, error)); ok { + if rf, ok := ret.Get(0).(func() (ccip.Address, error)); ok { return rf() } - if rf, ok := ret.Get(0).(func() cciptypes.Address); ok { + if rf, ok := ret.Get(0).(func() ccip.Address); ok { r0 = rf() } else { - r0 = ret.Get(0).(cciptypes.Address) + r0 = ret.Get(0).(ccip.Address) } if rf, ok := ret.Get(1).(func() error); ok { @@ -186,22 +186,22 @@ func (_m *OnRampReader) RouterAddress() (cciptypes.Address, error) { } // SourcePriceRegistryAddress provides a mock function with given fields: ctx -func (_m *OnRampReader) SourcePriceRegistryAddress(ctx context.Context) (cciptypes.Address, error) { +func (_m *OnRampReader) SourcePriceRegistryAddress(ctx context.Context) (ccip.Address, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for SourcePriceRegistryAddress") } - var r0 cciptypes.Address + var r0 ccip.Address var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (cciptypes.Address, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (ccip.Address, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) cciptypes.Address); ok { + if rf, ok := ret.Get(0).(func(context.Context) ccip.Address); ok { r0 = rf(ctx) } else { - r0 = ret.Get(0).(cciptypes.Address) + r0 = ret.Get(0).(ccip.Address) } if rf, ok := ret.Get(1).(func(context.Context) error); ok { diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/price_registry_reader_mock.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/price_registry_reader_mock.go index 234a47aa40..b0b8e82411 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/price_registry_reader_mock.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/price_registry_reader_mock.go @@ -3,9 +3,9 @@ package mocks import ( - context "context" + ccip "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" - cciptypes "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + context "context" mock "github.com/stretchr/testify/mock" @@ -17,22 +17,32 @@ type PriceRegistryReader struct { mock.Mock } -// Address provides a mock function with given fields: -func (_m *PriceRegistryReader) Address() cciptypes.Address { - ret := _m.Called() +// Address provides a mock function with given fields: ctx +func (_m *PriceRegistryReader) Address(ctx context.Context) (ccip.Address, error) { + ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for Address") } - var r0 cciptypes.Address - if rf, ok := ret.Get(0).(func() cciptypes.Address); ok { - r0 = rf() + var r0 ccip.Address + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (ccip.Address, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) ccip.Address); ok { + r0 = rf(ctx) } else { - r0 = ret.Get(0).(cciptypes.Address) + r0 = ret.Get(0).(ccip.Address) } - return r0 + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } // Close provides a mock function with given fields: @@ -54,23 +64,23 @@ func (_m *PriceRegistryReader) Close() error { } // GetFeeTokens provides a mock function with given fields: ctx -func (_m *PriceRegistryReader) GetFeeTokens(ctx context.Context) ([]cciptypes.Address, error) { +func (_m *PriceRegistryReader) GetFeeTokens(ctx context.Context) ([]ccip.Address, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetFeeTokens") } - var r0 []cciptypes.Address + var r0 []ccip.Address var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]cciptypes.Address, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) ([]ccip.Address, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) []cciptypes.Address); ok { + if rf, ok := ret.Get(0).(func(context.Context) []ccip.Address); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]cciptypes.Address) + r0 = ret.Get(0).([]ccip.Address) } } @@ -84,23 +94,23 @@ func (_m *PriceRegistryReader) GetFeeTokens(ctx context.Context) ([]cciptypes.Ad } // GetGasPriceUpdatesCreatedAfter provides a mock function with given fields: ctx, chainSelector, ts, confirmations -func (_m *PriceRegistryReader) GetGasPriceUpdatesCreatedAfter(ctx context.Context, chainSelector uint64, ts time.Time, confirmations int) ([]cciptypes.GasPriceUpdateWithTxMeta, error) { +func (_m *PriceRegistryReader) GetGasPriceUpdatesCreatedAfter(ctx context.Context, chainSelector uint64, ts time.Time, confirmations int) ([]ccip.GasPriceUpdateWithTxMeta, error) { ret := _m.Called(ctx, chainSelector, ts, confirmations) if len(ret) == 0 { panic("no return value specified for GetGasPriceUpdatesCreatedAfter") } - var r0 []cciptypes.GasPriceUpdateWithTxMeta + var r0 []ccip.GasPriceUpdateWithTxMeta var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uint64, time.Time, int) ([]cciptypes.GasPriceUpdateWithTxMeta, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uint64, time.Time, int) ([]ccip.GasPriceUpdateWithTxMeta, error)); ok { return rf(ctx, chainSelector, ts, confirmations) } - if rf, ok := ret.Get(0).(func(context.Context, uint64, time.Time, int) []cciptypes.GasPriceUpdateWithTxMeta); ok { + if rf, ok := ret.Get(0).(func(context.Context, uint64, time.Time, int) []ccip.GasPriceUpdateWithTxMeta); ok { r0 = rf(ctx, chainSelector, ts, confirmations) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]cciptypes.GasPriceUpdateWithTxMeta) + r0 = ret.Get(0).([]ccip.GasPriceUpdateWithTxMeta) } } @@ -114,23 +124,23 @@ func (_m *PriceRegistryReader) GetGasPriceUpdatesCreatedAfter(ctx context.Contex } // GetTokenPriceUpdatesCreatedAfter provides a mock function with given fields: ctx, ts, confirmations -func (_m *PriceRegistryReader) GetTokenPriceUpdatesCreatedAfter(ctx context.Context, ts time.Time, confirmations int) ([]cciptypes.TokenPriceUpdateWithTxMeta, error) { +func (_m *PriceRegistryReader) GetTokenPriceUpdatesCreatedAfter(ctx context.Context, ts time.Time, confirmations int) ([]ccip.TokenPriceUpdateWithTxMeta, error) { ret := _m.Called(ctx, ts, confirmations) if len(ret) == 0 { panic("no return value specified for GetTokenPriceUpdatesCreatedAfter") } - var r0 []cciptypes.TokenPriceUpdateWithTxMeta + var r0 []ccip.TokenPriceUpdateWithTxMeta var r1 error - if rf, ok := ret.Get(0).(func(context.Context, time.Time, int) ([]cciptypes.TokenPriceUpdateWithTxMeta, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, time.Time, int) ([]ccip.TokenPriceUpdateWithTxMeta, error)); ok { return rf(ctx, ts, confirmations) } - if rf, ok := ret.Get(0).(func(context.Context, time.Time, int) []cciptypes.TokenPriceUpdateWithTxMeta); ok { + if rf, ok := ret.Get(0).(func(context.Context, time.Time, int) []ccip.TokenPriceUpdateWithTxMeta); ok { r0 = rf(ctx, ts, confirmations) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]cciptypes.TokenPriceUpdateWithTxMeta) + r0 = ret.Get(0).([]ccip.TokenPriceUpdateWithTxMeta) } } @@ -144,27 +154,27 @@ func (_m *PriceRegistryReader) GetTokenPriceUpdatesCreatedAfter(ctx context.Cont } // GetTokenPrices provides a mock function with given fields: ctx, wantedTokens -func (_m *PriceRegistryReader) GetTokenPrices(ctx context.Context, wantedTokens []cciptypes.Address) ([]cciptypes.TokenPriceUpdate, error) { +func (_m *PriceRegistryReader) GetTokenPrices(ctx context.Context, wantedTokens []ccip.Address) ([]ccip.TokenPriceUpdate, error) { ret := _m.Called(ctx, wantedTokens) if len(ret) == 0 { panic("no return value specified for GetTokenPrices") } - var r0 []cciptypes.TokenPriceUpdate + var r0 []ccip.TokenPriceUpdate var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []cciptypes.Address) ([]cciptypes.TokenPriceUpdate, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, []ccip.Address) ([]ccip.TokenPriceUpdate, error)); ok { return rf(ctx, wantedTokens) } - if rf, ok := ret.Get(0).(func(context.Context, []cciptypes.Address) []cciptypes.TokenPriceUpdate); ok { + if rf, ok := ret.Get(0).(func(context.Context, []ccip.Address) []ccip.TokenPriceUpdate); ok { r0 = rf(ctx, wantedTokens) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]cciptypes.TokenPriceUpdate) + r0 = ret.Get(0).([]ccip.TokenPriceUpdate) } } - if rf, ok := ret.Get(1).(func(context.Context, []cciptypes.Address) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, []ccip.Address) error); ok { r1 = rf(ctx, wantedTokens) } else { r1 = ret.Error(1) @@ -174,7 +184,7 @@ func (_m *PriceRegistryReader) GetTokenPrices(ctx context.Context, wantedTokens } // GetTokensDecimals provides a mock function with given fields: ctx, tokenAddresses -func (_m *PriceRegistryReader) GetTokensDecimals(ctx context.Context, tokenAddresses []cciptypes.Address) ([]uint8, error) { +func (_m *PriceRegistryReader) GetTokensDecimals(ctx context.Context, tokenAddresses []ccip.Address) ([]uint8, error) { ret := _m.Called(ctx, tokenAddresses) if len(ret) == 0 { @@ -183,10 +193,10 @@ func (_m *PriceRegistryReader) GetTokensDecimals(ctx context.Context, tokenAddre var r0 []uint8 var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []cciptypes.Address) ([]uint8, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, []ccip.Address) ([]uint8, error)); ok { return rf(ctx, tokenAddresses) } - if rf, ok := ret.Get(0).(func(context.Context, []cciptypes.Address) []uint8); ok { + if rf, ok := ret.Get(0).(func(context.Context, []ccip.Address) []uint8); ok { r0 = rf(ctx, tokenAddresses) } else { if ret.Get(0) != nil { @@ -194,7 +204,7 @@ func (_m *PriceRegistryReader) GetTokensDecimals(ctx context.Context, tokenAddre } } - if rf, ok := ret.Get(1).(func(context.Context, []cciptypes.Address) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, []ccip.Address) error); ok { r1 = rf(ctx, tokenAddresses) } else { r1 = ret.Error(1) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_reader.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_reader.go index d44143ea02..09c4d8af49 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_reader.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_reader.go @@ -1,6 +1,6 @@ package ccipdata -import "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" +import cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" const ( ManuallyExecute = "manuallyExecute" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_reader_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_reader_test.go index 7ec03f7db6..8b8b09795b 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_reader_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/offramp_reader_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" evmclientmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" @@ -26,7 +27,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/factory" @@ -155,6 +155,7 @@ func TestOffRampReaderInit(t *testing.T) { } func setupOffRampReaderTH(t *testing.T, version string) offRampReaderTH { + ctx := testutils.Context(t) user, bc := ccipdata.NewSimulation(t) log := logger.TestLogger(t) orm := logpoller.NewORM(testutils.SimulatedChainID, pgtest.NewSqlxDB(t), log, pgtest.NewQConfig(true)) @@ -190,7 +191,9 @@ func setupOffRampReaderTH(t *testing.T, version string) offRampReaderTH { // Create the version-specific reader. reader, err := factory.NewOffRampReader(log, factory.NewEvmVersionFinder(), ccipcalc.EvmAddrToGeneric(offRampAddress), bc, lp, nil, nil, true) require.NoError(t, err) - require.Equal(t, ccipcalc.EvmAddrToGeneric(offRampAddress), reader.Address()) + addr, err := reader.Address(ctx) + require.NoError(t, err) + require.Equal(t, ccipcalc.EvmAddrToGeneric(offRampAddress), addr) return offRampReaderTH{ user: user, diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/onramp_reader.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/onramp_reader.go index ae5197f172..7625063946 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/onramp_reader.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/onramp_reader.go @@ -3,7 +3,7 @@ package ccipdata import ( "github.com/ethereum/go-ethereum/core/types" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/hashlib" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/onramp_reader_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/onramp_reader_test.go index 8059205140..da7390a431 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/onramp_reader_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/onramp_reader_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" evmclientmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" @@ -24,7 +25,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/factory" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/price_registry_reader.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/price_registry_reader.go index cd1908d6a6..479f07623f 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/price_registry_reader.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/price_registry_reader.go @@ -1,6 +1,6 @@ package ccipdata -import "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" +import cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" const ( COMMIT_PRICE_UPDATES = "Commit price updates" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/price_registry_reader_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/price_registry_reader_test.go index de8cd4dc7c..d93cd6d13c 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/price_registry_reader_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/price_registry_reader_test.go @@ -15,6 +15,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" evmclientmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" @@ -25,7 +26,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/factory" @@ -112,15 +112,16 @@ func setupPriceRegistryReaderTH(t *testing.T) priceRegReaderTH { Value: big.NewInt(12), // Intentionally set a same value different token }, } + ctx := testutils.Context(t) addr, _, _, err := price_registry_1_0_0.DeployPriceRegistry(user, ec, nil, feeTokens, 1000) require.NoError(t, err) addr2, _, _, err := price_registry.DeployPriceRegistry(user, ec, nil, feeTokens, 1000) require.NoError(t, err) commitAndGetBlockTs(ec) // Deploy these - pr10r, err := factory.NewPriceRegistryReader(lggr, factory.NewEvmVersionFinder(), ccipcalc.EvmAddrToGeneric(addr), lp, ec) + pr10r, err := factory.NewPriceRegistryReader(ctx, lggr, factory.NewEvmVersionFinder(), ccipcalc.EvmAddrToGeneric(addr), lp, ec) require.NoError(t, err) assert.Equal(t, reflect.TypeOf(pr10r).String(), reflect.TypeOf(&v1_0_0.PriceRegistry{}).String()) - pr12r, err := factory.NewPriceRegistryReader(lggr, factory.NewEvmVersionFinder(), ccipcalc.EvmAddrToGeneric(addr2), lp, ec) + pr12r, err := factory.NewPriceRegistryReader(ctx, lggr, factory.NewEvmVersionFinder(), ccipcalc.EvmAddrToGeneric(addr2), lp, ec) require.NoError(t, err) assert.Equal(t, reflect.TypeOf(pr12r).String(), reflect.TypeOf(&v1_2_0.PriceRegistry{}).String()) // Apply block1. @@ -249,6 +250,7 @@ func TestNewPriceRegistryReader(t *testing.T) { expectedErr: "unsupported price registry version 2.0.0", }, } + ctx := testutils.Context(t) for _, tc := range tt { t.Run(tc.typeAndVersion, func(t *testing.T) { b, err := utils.ABIEncode(`[{"type":"string"}]`, tc.typeAndVersion) @@ -258,7 +260,7 @@ func TestNewPriceRegistryReader(t *testing.T) { addr := ccipcalc.EvmAddrToGeneric(utils.RandomAddress()) lp := lpmocks.NewLogPoller(t) lp.On("RegisterFilter", mock.Anything).Return(nil).Maybe() - _, err = factory.NewPriceRegistryReader(logger.TestLogger(t), factory.NewEvmVersionFinder(), addr, lp, c) + _, err = factory.NewPriceRegistryReader(ctx, logger.TestLogger(t), factory.NewEvmVersionFinder(), addr, lp, c) if tc.expectedErr != "" { require.EqualError(t, err, tc.expectedErr) } else { diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/reader.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/reader.go index d01bf371a4..bbdeb76182 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/reader.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/reader.go @@ -6,9 +6,9 @@ import ( "github.com/ethereum/go-ethereum/core/types" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ) const ( diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/commit_store.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/commit_store.go index 9de395608b..e855207a5c 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/commit_store.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/commit_store.go @@ -15,13 +15,13 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/config" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store_1_0_0" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/commit_store_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/commit_store_test.go index ce689b381e..b494951422 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/commit_store_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/commit_store_test.go @@ -8,10 +8,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ) func TestCommitReportEncoding(t *testing.T) { diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp.go index c4012f19fc..f2c688d801 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp.go @@ -16,7 +16,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/config" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/logpollerutil" @@ -346,26 +346,26 @@ func (o *OffRamp) getPoolsByDestTokens(ctx context.Context, tokenAddrs []common. return destPools, nil } -func (o *OffRamp) OffchainConfig() cciptypes.ExecOffchainConfig { +func (o *OffRamp) OffchainConfig(ctx context.Context) (cciptypes.ExecOffchainConfig, error) { o.configMu.RLock() defer o.configMu.RUnlock() - return o.offchainConfig + return o.offchainConfig, nil } -func (o *OffRamp) OnchainConfig() cciptypes.ExecOnchainConfig { +func (o *OffRamp) OnchainConfig(ctx context.Context) (cciptypes.ExecOnchainConfig, error) { o.configMu.RLock() defer o.configMu.RUnlock() - return o.onchainConfig + return o.onchainConfig, nil } -func (o *OffRamp) GasPriceEstimator() cciptypes.GasPriceEstimatorExec { +func (o *OffRamp) GasPriceEstimator(ctx context.Context) (cciptypes.GasPriceEstimatorExec, error) { o.configMu.RLock() defer o.configMu.RUnlock() - return o.gasPriceEstimator + return o.gasPriceEstimator, nil } -func (o *OffRamp) Address() cciptypes.Address { - return cciptypes.Address(o.addr.String()) +func (o *OffRamp) Address(ctx context.Context) (cciptypes.Address, error) { + return cciptypes.Address(o.addr.String()), nil } func (o *OffRamp) UpdateDynamicConfig(onchainConfig cciptypes.ExecOnchainConfig, offchainConfig cciptypes.ExecOffchainConfig, gasPriceEstimator prices.GasPriceEstimatorExec) { @@ -376,7 +376,7 @@ func (o *OffRamp) UpdateDynamicConfig(onchainConfig cciptypes.ExecOnchainConfig, o.configMu.Unlock() } -func (o *OffRamp) ChangeConfig(onchainConfigBytes []byte, offchainConfigBytes []byte) (cciptypes.Address, cciptypes.Address, error) { +func (o *OffRamp) ChangeConfig(ctx context.Context, onchainConfigBytes []byte, offchainConfigBytes []byte) (cciptypes.Address, cciptypes.Address, error) { onchainConfigParsed, err := abihelpers.DecodeAbiStruct[ExecOnchainConfig](onchainConfigBytes) if err != nil { return "", "", err @@ -413,8 +413,8 @@ func (o *OffRamp) ChangeConfig(onchainConfigBytes []byte, offchainConfigBytes [] cciptypes.Address(destWrappedNative.String()), nil } -func (o *OffRamp) Close(qopts ...pg.QOpt) error { - return logpollerutil.UnregisterLpFilters(o.lp, o.filters, qopts...) +func (o *OffRamp) Close() error { + return logpollerutil.UnregisterLpFilters(o.lp, o.filters) } func (o *OffRamp) GetExecutionStateChangesBetweenSeqNums(ctx context.Context, seqNumMin, seqNumMax uint64, confs int) ([]cciptypes.ExecutionStateChangedWithTxMeta, error) { @@ -521,11 +521,11 @@ func encodeExecutionReport(args abi.Arguments, report cciptypes.ExecReport) ([]b return args.PackValues([]interface{}{&rep}) } -func (o *OffRamp) EncodeExecutionReport(report cciptypes.ExecReport) ([]byte, error) { +func (o *OffRamp) EncodeExecutionReport(ctx context.Context, report cciptypes.ExecReport) ([]byte, error) { return encodeExecutionReport(o.ExecutionReportArgs, report) } -func DecodeExecReport(args abi.Arguments, report []byte) (cciptypes.ExecReport, error) { +func DecodeExecReport(ctx context.Context, args abi.Arguments, report []byte) (cciptypes.ExecReport, error) { unpacked, err := args.Unpack(report) if err != nil { return cciptypes.ExecReport{}, err @@ -599,8 +599,8 @@ func DecodeExecReport(args abi.Arguments, report []byte) (cciptypes.ExecReport, } -func (o *OffRamp) DecodeExecutionReport(report []byte) (cciptypes.ExecReport, error) { - return DecodeExecReport(o.ExecutionReportArgs, report) +func (o *OffRamp) DecodeExecutionReport(ctx context.Context, report []byte) (cciptypes.ExecReport, error) { + return DecodeExecReport(ctx, o.ExecutionReportArgs, report) } func (o *OffRamp) RegisterFilters(qopts ...pg.QOpt) error { diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp_reader_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp_reader_test.go index 3a9f80f403..d834b792ce 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp_reader_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp_reader_test.go @@ -6,11 +6,11 @@ import ( "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" lpmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0" ) @@ -28,9 +28,10 @@ func TestExecutionReportEncodingV100(t *testing.T) { offRamp, err := v1_0_0.NewOffRamp(logger.TestLogger(t), utils.RandomAddress(), nil, lpmocks.NewLogPoller(t), nil, nil) require.NoError(t, err) - encodeExecutionReport, err := offRamp.EncodeExecutionReport(report) + ctx := testutils.Context(t) + encodeExecutionReport, err := offRamp.EncodeExecutionReport(ctx, report) require.NoError(t, err) - decodeCommitReport, err := offRamp.DecodeExecutionReport(encodeExecutionReport) + decodeCommitReport, err := offRamp.DecodeExecutionReport(ctx, encodeExecutionReport) require.NoError(t, err) require.Equal(t, report.Proofs, decodeCommitReport.Proofs) require.Equal(t, report, decodeCommitReport) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp_reader_unit_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp_reader_unit_test.go index 4836a91781..cfbdd86bb8 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp_reader_unit_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/offramp_reader_unit_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" @@ -18,7 +19,6 @@ import ( mock_contracts "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/mocks/v1_0_0" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/rpclib" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/onramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/onramp.go index 2e5fb348d5..06a066aa46 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/onramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/onramp.go @@ -9,13 +9,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/arm_contract" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_onramp_1_0_0" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/hashlib" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/price_registry.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/price_registry.go index 404d2ed677..a1ff4acb6f 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/price_registry.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/price_registry.go @@ -11,13 +11,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/price_registry_1_0_0" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/erc20" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" @@ -130,8 +130,8 @@ func (p *PriceRegistry) GetTokenPrices(ctx context.Context, wantedTokens []ccipt return tpu, nil } -func (p *PriceRegistry) Address() cciptypes.Address { - return cciptypes.Address(p.address.String()) +func (p *PriceRegistry) Address(ctx context.Context) (cciptypes.Address, error) { + return cciptypes.Address(p.address.String()), nil } func (p *PriceRegistry) GetFeeTokens(ctx context.Context) ([]cciptypes.Address, error) { diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/test_helpers.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/test_helpers.go index 89d3b17e1f..f85a6a1598 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/test_helpers.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0/test_helpers.go @@ -10,13 +10,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_offramp" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/price_registry_1_0_0" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_1_0/onramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_1_0/onramp.go index 5fe52143e7..72e63d8b7d 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_1_0/onramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_1_0/onramp.go @@ -5,11 +5,11 @@ import ( "github.com/ethereum/go-ethereum/common" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_onramp_1_1_0" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/commit_store.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/commit_store.go index 612a90d560..9302fe1c79 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/commit_store.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/commit_store.go @@ -15,13 +15,13 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/config" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/commit_store_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/commit_store_test.go index 1756124425..42609f72c6 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/commit_store_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/commit_store_test.go @@ -11,10 +11,10 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/config" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp.go index 61c45faa4a..76c02de83b 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp.go @@ -13,6 +13,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/config" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" @@ -20,7 +21,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" @@ -139,7 +139,7 @@ func (o *OffRamp) CurrentRateLimiterState(ctx context.Context) (cciptypes.TokenB }, nil } -func (o *OffRamp) ChangeConfig(onchainConfigBytes []byte, offchainConfigBytes []byte) (cciptypes.Address, cciptypes.Address, error) { +func (o *OffRamp) ChangeConfig(ctx context.Context, onchainConfigBytes []byte, offchainConfigBytes []byte) (cciptypes.Address, cciptypes.Address, error) { // Same as the v1.0.0 method, except for the ExecOnchainConfig type. onchainConfigParsed, err := abihelpers.DecodeAbiStruct[ExecOnchainConfig](onchainConfigBytes) if err != nil { @@ -177,7 +177,7 @@ func (o *OffRamp) ChangeConfig(onchainConfigBytes []byte, offchainConfigBytes [] cciptypes.Address(destWrappedNative.String()), nil } -func EncodeExecutionReport(args abi.Arguments, report cciptypes.ExecReport) ([]byte, error) { +func EncodeExecutionReport(ctx context.Context, args abi.Arguments, report cciptypes.ExecReport) ([]byte, error) { var msgs []evm_2_evm_offramp.InternalEVM2EVMMessage for _, msg := range report.Messages { var ta []evm_2_evm_offramp.ClientEVMTokenAmount @@ -224,11 +224,11 @@ func EncodeExecutionReport(args abi.Arguments, report cciptypes.ExecReport) ([]b return args.PackValues([]interface{}{&rep}) } -func (o *OffRamp) EncodeExecutionReport(report cciptypes.ExecReport) ([]byte, error) { - return EncodeExecutionReport(o.ExecutionReportArgs, report) +func (o *OffRamp) EncodeExecutionReport(ctx context.Context, report cciptypes.ExecReport) ([]byte, error) { + return EncodeExecutionReport(ctx, o.ExecutionReportArgs, report) } -func DecodeExecReport(args abi.Arguments, report []byte) (cciptypes.ExecReport, error) { +func DecodeExecReport(ctx context.Context, args abi.Arguments, report []byte) (cciptypes.ExecReport, error) { unpacked, err := args.Unpack(report) if err != nil { return cciptypes.ExecReport{}, err @@ -303,8 +303,8 @@ func DecodeExecReport(args abi.Arguments, report []byte) (cciptypes.ExecReport, } -func (o *OffRamp) DecodeExecutionReport(report []byte) (cciptypes.ExecReport, error) { - return DecodeExecReport(o.ExecutionReportArgs, report) +func (o *OffRamp) DecodeExecutionReport(ctx context.Context, report []byte) (cciptypes.ExecReport, error) { + return DecodeExecReport(ctx, o.ExecutionReportArgs, report) } func NewOffRamp(lggr logger.Logger, addr common.Address, ec client.Client, lp logpoller.LogPoller, estimator gas.EvmFeeEstimator, destMaxGasPrice *big.Int) (*OffRamp, error) { diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp_reader_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp_reader_test.go index 0457f242be..f87fc8842f 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp_reader_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp_reader_test.go @@ -6,11 +6,11 @@ import ( "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" lpmocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0" ) @@ -28,9 +28,10 @@ func TestExecutionReportEncodingV120(t *testing.T) { offRamp, err := v1_2_0.NewOffRamp(logger.TestLogger(t), utils.RandomAddress(), nil, lpmocks.NewLogPoller(t), nil, nil) require.NoError(t, err) - encodeExecutionReport, err := offRamp.EncodeExecutionReport(report) + ctx := testutils.Context(t) + encodeExecutionReport, err := offRamp.EncodeExecutionReport(ctx, report) require.NoError(t, err) - decodeCommitReport, err := offRamp.DecodeExecutionReport(encodeExecutionReport) + decodeCommitReport, err := offRamp.DecodeExecutionReport(ctx, encodeExecutionReport) require.NoError(t, err) require.Equal(t, report.Proofs, decodeCommitReport.Proofs) require.Equal(t, report, decodeCommitReport) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/onramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/onramp.go index 4f8bda1b03..d5c732af01 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/onramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/onramp.go @@ -10,13 +10,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/arm_contract" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_onramp_1_2_0" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/hashlib" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/price_registry.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/price_registry.go index 69cc17f960..5effe58c23 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/price_registry.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/price_registry.go @@ -7,11 +7,11 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/price_registry" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/test_helpers.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/test_helpers.go index 4af51374e5..cd62accfcb 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/test_helpers.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/test_helpers.go @@ -8,9 +8,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/price_registry" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/onramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/onramp.go index 9ce54806cb..3449101ad2 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/onramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/onramp.go @@ -10,13 +10,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/arm_contract" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_onramp" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" diff --git a/core/services/ocr2/plugins/ccip/internal/observability/commit_store.go b/core/services/ocr2/plugins/ccip/internal/observability/commit_store.go index b268274182..6a1fb48f49 100644 --- a/core/services/ocr2/plugins/ccip/internal/observability/commit_store.go +++ b/core/services/ocr2/plugins/ccip/internal/observability/commit_store.go @@ -4,7 +4,7 @@ import ( "context" "time" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" ) diff --git a/core/services/ocr2/plugins/ccip/internal/observability/metrics_test.go b/core/services/ocr2/plugins/ccip/internal/observability/metrics_test.go index 6637e5d74f..3d84acf961 100644 --- a/core/services/ocr2/plugins/ccip/internal/observability/metrics_test.go +++ b/core/services/ocr2/plugins/ccip/internal/observability/metrics_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipdatamocks "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks" ) diff --git a/core/services/ocr2/plugins/ccip/internal/observability/offramp.go b/core/services/ocr2/plugins/ccip/internal/observability/offramp.go index 15bfe20dd6..c73b92c934 100644 --- a/core/services/ocr2/plugins/ccip/internal/observability/offramp.go +++ b/core/services/ocr2/plugins/ccip/internal/observability/offramp.go @@ -3,7 +3,7 @@ package observability import ( "context" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" ) diff --git a/core/services/ocr2/plugins/ccip/internal/observability/onramp.go b/core/services/ocr2/plugins/ccip/internal/observability/onramp.go index 7b726f690f..57d9bcc53d 100644 --- a/core/services/ocr2/plugins/ccip/internal/observability/onramp.go +++ b/core/services/ocr2/plugins/ccip/internal/observability/onramp.go @@ -3,7 +3,7 @@ package observability import ( "context" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" ) diff --git a/core/services/ocr2/plugins/ccip/internal/observability/price_registry.go b/core/services/ocr2/plugins/ccip/internal/observability/price_registry.go index db7f95d7f8..936f439ad0 100644 --- a/core/services/ocr2/plugins/ccip/internal/observability/price_registry.go +++ b/core/services/ocr2/plugins/ccip/internal/observability/price_registry.go @@ -4,7 +4,7 @@ import ( "context" "time" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" ) diff --git a/core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go b/core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go index 7615395cf9..d7d5307c3d 100644 --- a/core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go +++ b/core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go @@ -10,8 +10,8 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/internal/gethwrappers2/generated/offchainaggregator" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/rpclib" diff --git a/core/services/ocr2/plugins/ccip/internal/pricegetter/evm_test.go b/core/services/ocr2/plugins/ccip/internal/pricegetter/evm_test.go index 5a27793050..dedbe25613 100644 --- a/core/services/ocr2/plugins/ccip/internal/pricegetter/evm_test.go +++ b/core/services/ocr2/plugins/ccip/internal/pricegetter/evm_test.go @@ -9,10 +9,10 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/aggregator_v3_interface" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/rpclib" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/rpclib/rpclibmocks" diff --git a/core/services/ocr2/plugins/ccip/internal/pricegetter/mock.go b/core/services/ocr2/plugins/ccip/internal/pricegetter/mock.go index db3e76d7cc..f1b22e50e5 100644 --- a/core/services/ocr2/plugins/ccip/internal/pricegetter/mock.go +++ b/core/services/ocr2/plugins/ccip/internal/pricegetter/mock.go @@ -6,7 +6,7 @@ import ( context "context" big "math/big" - cciptypes "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + ccip "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" mock "github.com/stretchr/testify/mock" ) @@ -17,27 +17,27 @@ type MockPriceGetter struct { } // TokenPricesUSD provides a mock function with given fields: ctx, tokens -func (_m *MockPriceGetter) TokenPricesUSD(ctx context.Context, tokens []cciptypes.Address) (map[cciptypes.Address]*big.Int, error) { +func (_m *MockPriceGetter) TokenPricesUSD(ctx context.Context, tokens []ccip.Address) (map[ccip.Address]*big.Int, error) { ret := _m.Called(ctx, tokens) if len(ret) == 0 { panic("no return value specified for TokenPricesUSD") } - var r0 map[cciptypes.Address]*big.Int + var r0 map[ccip.Address]*big.Int var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []cciptypes.Address) (map[cciptypes.Address]*big.Int, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, []ccip.Address) (map[ccip.Address]*big.Int, error)); ok { return rf(ctx, tokens) } - if rf, ok := ret.Get(0).(func(context.Context, []cciptypes.Address) map[cciptypes.Address]*big.Int); ok { + if rf, ok := ret.Get(0).(func(context.Context, []ccip.Address) map[ccip.Address]*big.Int); ok { r0 = rf(ctx, tokens) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(map[cciptypes.Address]*big.Int) + r0 = ret.Get(0).(map[ccip.Address]*big.Int) } } - if rf, ok := ret.Get(1).(func(context.Context, []cciptypes.Address) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, []ccip.Address) error); ok { r1 = rf(ctx, tokens) } else { r1 = ret.Error(1) diff --git a/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline.go b/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline.go index 4c7d3d2665..cb0ef5e953 100644 --- a/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline.go +++ b/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline.go @@ -9,8 +9,8 @@ import ( "github.com/google/uuid" "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/parseutil" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" diff --git a/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline_test.go b/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline_test.go index c83e28855d..6c427a2a10 100644 --- a/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline_test.go +++ b/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline_test.go @@ -16,9 +16,9 @@ import ( "github.com/stretchr/testify/require" config2 "github.com/smartcontractkit/chainlink-common/pkg/config" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/pricegetter" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" diff --git a/core/services/ocr2/plugins/ccip/internal/pricegetter/pricegetter.go b/core/services/ocr2/plugins/ccip/internal/pricegetter/pricegetter.go index d8910de35f..50d78249c0 100644 --- a/core/services/ocr2/plugins/ccip/internal/pricegetter/pricegetter.go +++ b/core/services/ocr2/plugins/ccip/internal/pricegetter/pricegetter.go @@ -1,6 +1,6 @@ package pricegetter -import "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" +import cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" //go:generate mockery --quiet --name PriceGetter --output . --filename mock.go --inpackage --case=underscore type PriceGetter interface { diff --git a/core/services/ocr2/plugins/ccip/observations.go b/core/services/ocr2/plugins/ccip/observations.go index 6eec8bbd8f..58cf722b9b 100644 --- a/core/services/ocr2/plugins/ccip/observations.go +++ b/core/services/ocr2/plugins/ccip/observations.go @@ -10,8 +10,8 @@ import ( "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" ) diff --git a/core/services/ocr2/plugins/ccip/observations_test.go b/core/services/ocr2/plugins/ccip/observations_test.go index 868258cc8f..c5e9495458 100644 --- a/core/services/ocr2/plugins/ccip/observations_test.go +++ b/core/services/ocr2/plugins/ccip/observations_test.go @@ -15,9 +15,9 @@ import ( "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store_1_0_0" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/testhelpers" @@ -251,16 +251,22 @@ func TestAddressEncodingBackwardsCompatibility(t *testing.T) { // make this test pass or if you removed a field, remove it from the expected fields slice. t.Run("job spec config", func(t *testing.T) { - exp := []string{"cciptypes.Address OffRamp"} + exp := []string{"ccip.Address OffRamp"} - fields := testhelpers.FindStructFieldsOfCertainType("cciptypes.Address", config.CommitPluginJobSpecConfig{PriceGetterConfig: &config.DynamicPriceGetterConfig{}}) + fields := testhelpers.FindStructFieldsOfCertainType( + "ccip.Address", + config.CommitPluginJobSpecConfig{PriceGetterConfig: &config.DynamicPriceGetterConfig{}}, + ) assert.Equal(t, exp, fields) }) t.Run("commit observation", func(t *testing.T) { - exp := []string{"map[cciptypes.Address]*big.Int TokenPricesUSD"} + exp := []string{"map[ccip.Address]*big.Int TokenPricesUSD"} - fields := testhelpers.FindStructFieldsOfCertainType("cciptypes.Address", CommitObservation{SourceGasPriceUSD: big.NewInt(0)}) + fields := testhelpers.FindStructFieldsOfCertainType( + "ccip.Address", + CommitObservation{SourceGasPriceUSD: big.NewInt(0)}, + ) assert.Equal(t, exp, fields) }) diff --git a/core/services/ocr2/plugins/ccip/prices/da_price_estimator.go b/core/services/ocr2/plugins/ccip/prices/da_price_estimator.go index 0e711909a3..83869dc0ef 100644 --- a/core/services/ocr2/plugins/ccip/prices/da_price_estimator.go +++ b/core/services/ocr2/plugins/ccip/prices/da_price_estimator.go @@ -5,9 +5,9 @@ import ( "fmt" "math/big" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/rollups" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" ) diff --git a/core/services/ocr2/plugins/ccip/prices/da_price_estimator_test.go b/core/services/ocr2/plugins/ccip/prices/da_price_estimator_test.go index 97d51bb28f..2f8616a866 100644 --- a/core/services/ocr2/plugins/ccip/prices/da_price_estimator_test.go +++ b/core/services/ocr2/plugins/ccip/prices/da_price_estimator_test.go @@ -8,9 +8,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/rollups/mocks" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ) func encodeGasPrice(daPrice, execPrice *big.Int) *big.Int { diff --git a/core/services/ocr2/plugins/ccip/prices/exec_price_estimator.go b/core/services/ocr2/plugins/ccip/prices/exec_price_estimator.go index b36630119a..56e1ddb583 100644 --- a/core/services/ocr2/plugins/ccip/prices/exec_price_estimator.go +++ b/core/services/ocr2/plugins/ccip/prices/exec_price_estimator.go @@ -5,9 +5,9 @@ import ( "fmt" "math/big" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" ) diff --git a/core/services/ocr2/plugins/ccip/prices/exec_price_estimator_test.go b/core/services/ocr2/plugins/ccip/prices/exec_price_estimator_test.go index 0ac7f2cbc3..e1c2fa0398 100644 --- a/core/services/ocr2/plugins/ccip/prices/exec_price_estimator_test.go +++ b/core/services/ocr2/plugins/ccip/prices/exec_price_estimator_test.go @@ -8,10 +8,10 @@ import ( "github.com/pkg/errors" "github.com/stretchr/testify/assert" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/mocks" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ) func TestExecPriceEstimator_GetGasPrice(t *testing.T) { diff --git a/core/services/ocr2/plugins/ccip/prices/gas_price_estimator.go b/core/services/ocr2/plugins/ccip/prices/gas_price_estimator.go index ae5a7b0bdf..610dc3b3da 100644 --- a/core/services/ocr2/plugins/ccip/prices/gas_price_estimator.go +++ b/core/services/ocr2/plugins/ccip/prices/gas_price_estimator.go @@ -6,8 +6,8 @@ import ( "github.com/Masterminds/semver/v3" "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ) const ( diff --git a/core/services/ocr2/plugins/ccip/prices/gas_price_estimator_exec_mock.go b/core/services/ocr2/plugins/ccip/prices/gas_price_estimator_exec_mock.go index 06fc8aaca2..b9e9816e25 100644 --- a/core/services/ocr2/plugins/ccip/prices/gas_price_estimator_exec_mock.go +++ b/core/services/ocr2/plugins/ccip/prices/gas_price_estimator_exec_mock.go @@ -6,7 +6,7 @@ import ( context "context" big "math/big" - cciptypes "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + ccip "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" mock "github.com/stretchr/testify/mock" ) @@ -47,7 +47,7 @@ func (_m *MockGasPriceEstimatorExec) DenoteInUSD(p *big.Int, wrappedNativePrice } // EstimateMsgCostUSD provides a mock function with given fields: p, wrappedNativePrice, msg -func (_m *MockGasPriceEstimatorExec) EstimateMsgCostUSD(p *big.Int, wrappedNativePrice *big.Int, msg cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error) { +func (_m *MockGasPriceEstimatorExec) EstimateMsgCostUSD(p *big.Int, wrappedNativePrice *big.Int, msg ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error) { ret := _m.Called(p, wrappedNativePrice, msg) if len(ret) == 0 { @@ -56,10 +56,10 @@ func (_m *MockGasPriceEstimatorExec) EstimateMsgCostUSD(p *big.Int, wrappedNativ var r0 *big.Int var r1 error - if rf, ok := ret.Get(0).(func(*big.Int, *big.Int, cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error)); ok { + if rf, ok := ret.Get(0).(func(*big.Int, *big.Int, ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error)); ok { return rf(p, wrappedNativePrice, msg) } - if rf, ok := ret.Get(0).(func(*big.Int, *big.Int, cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) *big.Int); ok { + if rf, ok := ret.Get(0).(func(*big.Int, *big.Int, ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta) *big.Int); ok { r0 = rf(p, wrappedNativePrice, msg) } else { if ret.Get(0) != nil { @@ -67,7 +67,7 @@ func (_m *MockGasPriceEstimatorExec) EstimateMsgCostUSD(p *big.Int, wrappedNativ } } - if rf, ok := ret.Get(1).(func(*big.Int, *big.Int, cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) error); ok { + if rf, ok := ret.Get(1).(func(*big.Int, *big.Int, ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta) error); ok { r1 = rf(p, wrappedNativePrice, msg) } else { r1 = ret.Error(1) diff --git a/core/services/ocr2/plugins/ccip/prices/gas_price_estimator_mock.go b/core/services/ocr2/plugins/ccip/prices/gas_price_estimator_mock.go index 09dc0a7152..7e69c7082b 100644 --- a/core/services/ocr2/plugins/ccip/prices/gas_price_estimator_mock.go +++ b/core/services/ocr2/plugins/ccip/prices/gas_price_estimator_mock.go @@ -6,7 +6,7 @@ import ( context "context" big "math/big" - cciptypes "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + ccip "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" mock "github.com/stretchr/testify/mock" ) @@ -75,7 +75,7 @@ func (_m *MockGasPriceEstimator) Deviates(p1 *big.Int, p2 *big.Int) (bool, error } // EstimateMsgCostUSD provides a mock function with given fields: p, wrappedNativePrice, msg -func (_m *MockGasPriceEstimator) EstimateMsgCostUSD(p *big.Int, wrappedNativePrice *big.Int, msg cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error) { +func (_m *MockGasPriceEstimator) EstimateMsgCostUSD(p *big.Int, wrappedNativePrice *big.Int, msg ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error) { ret := _m.Called(p, wrappedNativePrice, msg) if len(ret) == 0 { @@ -84,10 +84,10 @@ func (_m *MockGasPriceEstimator) EstimateMsgCostUSD(p *big.Int, wrappedNativePri var r0 *big.Int var r1 error - if rf, ok := ret.Get(0).(func(*big.Int, *big.Int, cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error)); ok { + if rf, ok := ret.Get(0).(func(*big.Int, *big.Int, ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta) (*big.Int, error)); ok { return rf(p, wrappedNativePrice, msg) } - if rf, ok := ret.Get(0).(func(*big.Int, *big.Int, cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) *big.Int); ok { + if rf, ok := ret.Get(0).(func(*big.Int, *big.Int, ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta) *big.Int); ok { r0 = rf(p, wrappedNativePrice, msg) } else { if ret.Get(0) != nil { @@ -95,7 +95,7 @@ func (_m *MockGasPriceEstimator) EstimateMsgCostUSD(p *big.Int, wrappedNativePri } } - if rf, ok := ret.Get(1).(func(*big.Int, *big.Int, cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta) error); ok { + if rf, ok := ret.Get(1).(func(*big.Int, *big.Int, ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta) error); ok { r1 = rf(p, wrappedNativePrice, msg) } else { r1 = ret.Error(1) diff --git a/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go b/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go index bfed37ad49..39e5c73b98 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go @@ -22,6 +22,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/config" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/arm_proxy_contract" @@ -43,7 +44,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/burn_mint_erc677" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0" diff --git a/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go b/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go index 2bd1eb7a8c..b82ea3bbe2 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go @@ -35,7 +35,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/loop" "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" v2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" diff --git a/core/services/ocr2/plugins/ccip/testhelpers/offramp.go b/core/services/ocr2/plugins/ccip/testhelpers/offramp.go index 064fed618e..d10e693325 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/offramp.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/offramp.go @@ -8,10 +8,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_offramp" mock_contracts "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/mocks" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" ) diff --git a/core/services/ocr2/plugins/ccip/tokendata/bgworker.go b/core/services/ocr2/plugins/ccip/tokendata/bgworker.go index 3814978f45..bf67cc1bd9 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/bgworker.go +++ b/core/services/ocr2/plugins/ccip/tokendata/bgworker.go @@ -11,8 +11,8 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/services" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" ) type msgResult struct { diff --git a/core/services/ocr2/plugins/ccip/tokendata/bgworker_test.go b/core/services/ocr2/plugins/ccip/tokendata/bgworker_test.go index c55548ce6d..5d505363ac 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/bgworker_test.go +++ b/core/services/ocr2/plugins/ccip/tokendata/bgworker_test.go @@ -11,9 +11,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/tokendata" ) diff --git a/core/services/ocr2/plugins/ccip/tokendata/observability/usdc_client_test.go b/core/services/ocr2/plugins/ccip/tokendata/observability/usdc_client_test.go index 811adc8851..47fb22fff5 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/observability/usdc_client_test.go +++ b/core/services/ocr2/plugins/ccip/tokendata/observability/usdc_client_test.go @@ -16,8 +16,8 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks" http2 "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/tokendata/http" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/tokendata/usdc" diff --git a/core/services/ocr2/plugins/ccip/tokendata/reader.go b/core/services/ocr2/plugins/ccip/tokendata/reader.go index 8d12129627..82c21ebc26 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/reader.go +++ b/core/services/ocr2/plugins/ccip/tokendata/reader.go @@ -3,7 +3,7 @@ package tokendata import ( "errors" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" ) var ( diff --git a/core/services/ocr2/plugins/ccip/tokendata/reader_mock.go b/core/services/ocr2/plugins/ccip/tokendata/reader_mock.go index 0cdfb25ace..2b284dc2f4 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/reader_mock.go +++ b/core/services/ocr2/plugins/ccip/tokendata/reader_mock.go @@ -5,7 +5,7 @@ package tokendata import ( context "context" - cciptypes "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" + ccip "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" mock "github.com/stretchr/testify/mock" ) @@ -16,7 +16,7 @@ type MockReader struct { } // ReadTokenData provides a mock function with given fields: ctx, msg, tokenIndex -func (_m *MockReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta, tokenIndex int) ([]byte, error) { +func (_m *MockReader) ReadTokenData(ctx context.Context, msg ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta, tokenIndex int) ([]byte, error) { ret := _m.Called(ctx, msg, tokenIndex) if len(ret) == 0 { @@ -25,10 +25,10 @@ func (_m *MockReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2EVMOn var r0 []byte var r1 error - if rf, ok := ret.Get(0).(func(context.Context, cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta, int) ([]byte, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta, int) ([]byte, error)); ok { return rf(ctx, msg, tokenIndex) } - if rf, ok := ret.Get(0).(func(context.Context, cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta, int) []byte); ok { + if rf, ok := ret.Get(0).(func(context.Context, ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta, int) []byte); ok { r0 = rf(ctx, msg, tokenIndex) } else { if ret.Get(0) != nil { @@ -36,7 +36,7 @@ func (_m *MockReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2EVMOn } } - if rf, ok := ret.Get(1).(func(context.Context, cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta, int) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, ccip.EVM2EVMOnRampCCIPSendRequestedWithMeta, int) error); ok { r1 = rf(ctx, msg, tokenIndex) } else { r1 = ret.Error(1) diff --git a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go index 7d6adea384..e4ca430d0d 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go +++ b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go @@ -14,10 +14,10 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/pkg/errors" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/tokendata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/tokendata/http" diff --git a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_blackbox_test.go b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_blackbox_test.go index f3c9022aa8..eb969294d6 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_blackbox_test.go +++ b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_blackbox_test.go @@ -14,9 +14,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" ccipdatamocks "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/tokendata" diff --git a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go index 107ff4a618..8c9fa22af9 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go +++ b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go @@ -14,10 +14,10 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/cciptypes" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" ccipdatamocks "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/tokendata"