diff --git a/core/services/ocr2/plugins/ccip/ccipexec/factory.go b/core/services/ocr2/plugins/ccip/ccipexec/factory.go index 04a5a159b7..5f13ff5c6b 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/factory.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/factory.go @@ -112,7 +112,7 @@ func (rf *ExecutionReportingPluginFactory) NewReportingPluginFn(config types.Rep return reportingPluginAndInfo{}, fmt.Errorf("get onchain config from offramp: %w", err) } - batchingStrategy, err := NewBatchingStrategy(offchainConfig.BatchingStrategyID, statuschecker.NewTxmStatusChecker(rf.config.txManager)) + batchingStrategy, err := NewBatchingStrategy(offchainConfig.BatchingStrategyID, statuschecker.NewTxmStatusChecker(rf.config.getTransactionStatus)) if err != nil { return reportingPluginAndInfo{}, fmt.Errorf("get batching strategy: %w", err) } diff --git a/core/services/ocr2/plugins/ccip/ccipexec/initializers.go b/core/services/ocr2/plugins/ccip/ccipexec/initializers.go index 632e7e875c..2aa641f07b 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/initializers.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/initializers.go @@ -165,7 +165,7 @@ func NewExecServices(ctx context.Context, lggr logger.Logger, jb job.Job, srcPro metricsCollector: metricsCollector, chainHealthcheck: chainHealthcheck, newReportingPluginRetryConfig: defaultNewReportingPluginRetryConfig, - txManager: dstChain.TxManager(), + getTransactionStatus: dstProvider.GetTransactionStatus, }) argsNoPlugin.ReportingPluginFactory = promwrapper.NewPromFactory(wrappedPluginFactory, "CCIPExecution", jb.OCR2OracleSpec.Relay, big.NewInt(0).SetInt64(dstChainID)) diff --git a/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go b/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go index 5065a4a4f3..252889ffb8 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/ocr2.go @@ -16,9 +16,8 @@ import ( "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/smartcontractkit/chainlink-common/pkg/hashutil" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" - - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" "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/internal/cache" @@ -50,6 +49,8 @@ var ( _ types.ReportingPlugin = &ExecutionReportingPlugin{} ) +type GetTransactionStatusFunc func(ctx context.Context, transactionID string) (commontypes.TransactionStatus, error) + type ExecutionPluginStaticConfig struct { lggr logger.Logger onRampReader ccipdata.OnRampReader @@ -64,7 +65,7 @@ type ExecutionPluginStaticConfig struct { metricsCollector ccip.PluginMetricsCollector chainHealthcheck cache.ChainHealthcheck newReportingPluginRetryConfig ccipdata.RetryConfig - txManager txmgr.TxManager + getTransactionStatus GetTransactionStatusFunc } type ExecutionReportingPlugin struct { diff --git a/core/services/relay/evm/evm.go b/core/services/relay/evm/evm.go index 06da8f5e7d..d534b10bd7 100644 --- a/core/services/relay/evm/evm.go +++ b/core/services/relay/evm/evm.go @@ -841,7 +841,7 @@ func generateTransmitterFrom(ctx context.Context, rargs commontypes.RelayArgs, e checker, configWatcher.chain.ID(), ethKeystore, - statuschecker.NewTxmStatusChecker(configWatcher.chain.TxManager()), + statuschecker.NewTxmStatusChecker(configWatcher.chain.TxManager().GetTransactionStatus), ) default: transmitter, err = ocrcommon.NewTransmitter( diff --git a/core/services/relay/evm/statuschecker/txm_status_checker.go b/core/services/relay/evm/statuschecker/txm_status_checker.go index 918087074b..183f154230 100644 --- a/core/services/relay/evm/statuschecker/txm_status_checker.go +++ b/core/services/relay/evm/statuschecker/txm_status_checker.go @@ -6,7 +6,6 @@ import ( "strings" "github.com/smartcontractkit/chainlink-common/pkg/types" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" ) // CCIPTransactionStatusChecker is an interface that defines the method for checking the status of a transaction. @@ -19,11 +18,11 @@ type CCIPTransactionStatusChecker interface { } type TxmStatusChecker struct { - txManager txmgr.TxManager + getTransactionStatus func(ctx context.Context, transactionID string) (types.TransactionStatus, error) } -func NewTxmStatusChecker(txManager txmgr.TxManager) *TxmStatusChecker { - return &TxmStatusChecker{txManager: txManager} +func NewTxmStatusChecker(getTransactionStatus func(ctx context.Context, transactionID string) (types.TransactionStatus, error)) *TxmStatusChecker { + return &TxmStatusChecker{getTransactionStatus: getTransactionStatus} } // CheckMessageStatus checks the status of a message by checking the status of all transactions associated with the message ID. @@ -37,7 +36,7 @@ func (tsc *TxmStatusChecker) CheckMessageStatus(ctx context.Context, msgID strin for { transactionID := fmt.Sprintf("%s-%d", msgID, counter) - status, err := tsc.txManager.GetTransactionStatus(ctx, transactionID) + status, err := tsc.getTransactionStatus(ctx, transactionID) if err != nil { if strings.Contains(err.Error(), fmt.Sprintf("failed to find transaction with IdempotencyKey %s", transactionID)) { break diff --git a/core/services/relay/evm/statuschecker/txm_status_checker_test.go b/core/services/relay/evm/statuschecker/txm_status_checker_test.go index 21c8775175..576aa4fbc0 100644 --- a/core/services/relay/evm/statuschecker/txm_status_checker_test.go +++ b/core/services/relay/evm/statuschecker/txm_status_checker_test.go @@ -18,7 +18,7 @@ func Test_CheckMessageStatus(t *testing.T) { testutils.SkipShort(t, "") ctx := context.Background() mockTxManager := mocks.NewMockEvmTxManager(t) - checker := NewTxmStatusChecker(mockTxManager) + checker := NewTxmStatusChecker(mockTxManager.GetTransactionStatus) msgID := "test-message-id" @@ -111,7 +111,7 @@ func Test_CheckMessageStatus(t *testing.T) { func Test_FailForMoreThan1000Retries(t *testing.T) { ctx := context.Background() mockTxManager := mocks.NewMockEvmTxManager(t) - checker := NewTxmStatusChecker(mockTxManager) + checker := NewTxmStatusChecker(mockTxManager.GetTransactionStatus) for i := 0; i < 1000; i++ { mockTxManager.On("GetTransactionStatus", ctx, fmt.Sprintf("test-message-id-%d", i)).Return(types.Finalized, nil)