diff --git a/.mockery.yaml b/.mockery.yaml index 7fd4ff242bb..b7dbb8a1e85 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -490,12 +490,20 @@ packages: PriceRegistryReader: config: filename: price_registry_reader_mock.go + FeeEstimatorConfigReader: + config: + filename: fee_estimator_config_mock.go TokenPoolReader: config: filename: token_pool_reader_mock.go USDCReader: config: filename: usdc_reader_mock.go + github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/estimatorconfig: + interfaces: + GasPriceInterceptor: + config: + filename: gas_price_interceptor_mock.go github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/batchreader: config: filename: token_pool_batched_reader_mock.go diff --git a/core/chains/evm/client/config_builder_test.go b/core/chains/evm/client/config_builder_test.go index ce64d63d6d2..856242edada 100644 --- a/core/chains/evm/client/config_builder_test.go +++ b/core/chains/evm/client/config_builder_test.go @@ -55,7 +55,10 @@ func TestClientConfigBuilder(t *testing.T) { require.Equal(t, deathDeclarationDelay, nodePool.DeathDeclarationDelay()) require.Equal(t, pollInterval, nodePool.FinalizedBlockPollInterval()) require.Equal(t, newHeadsPollInterval, nodePool.NewHeadsPollInterval()) + + // Validate node configs require.Equal(t, *nodeConfigs[0].Name, *nodes[0].Name) + require.Equal(t, *nodeConfigs[0].WSURL, (*nodes[0].WSURL).String()) require.Equal(t, *nodeConfigs[0].HTTPURL, (*nodes[0].HTTPURL).String()) // Validate chain config diff --git a/core/chains/evm/config/config_test.go b/core/chains/evm/config/config_test.go index 2a38b43d5c0..ab0d600efe0 100644 --- a/core/chains/evm/config/config_test.go +++ b/core/chains/evm/config/config_test.go @@ -269,8 +269,8 @@ func TestChainScopedConfig_GasEstimator(t *testing.T) { assert.Equal(t, assets.GWei(20), ge.PriceDefault()) assert.Equal(t, assets.GWei(500), ge.PriceMax()) assert.Equal(t, assets.GWei(1), ge.PriceMin()) - assert.Equal(t, uint64(8_000_000), ge.LimitDefault()) - assert.Equal(t, uint64(8_000_000), ge.LimitMax()) + assert.Equal(t, uint64(500000), ge.LimitDefault()) + assert.Equal(t, uint64(500000), ge.LimitMax()) assert.Equal(t, float32(1), ge.LimitMultiplier()) assert.Equal(t, uint64(21000), ge.LimitTransfer()) assert.Equal(t, assets.GWei(5), ge.BumpMin()) @@ -305,23 +305,23 @@ func TestChainScopedConfig_Profiles(t *testing.T) { expectedGasLimitDefault uint64 expectedMinimumContractPayment string }{ - {"default", 0, 8_000_000, "0.00001"}, - {"mainnet", 1, 8_000_000, "0.1"}, - {"kovan", 42, 8_000_000, "0.1"}, - - {"optimism", 10, 8_000_000, "0.00001"}, - {"optimism", 69, 8_000_000, "0.00001"}, - {"optimism", 420, 8_000_000, "0.00001"}, - - {"bscMainnet", 56, 8_000_000, "0.00001"}, - {"hecoMainnet", 128, 8_000_000, "0.00001"}, - {"fantomMainnet", 250, 8_000_000, "0.00001"}, - {"fantomTestnet", 4002, 8_000_000, "0.00001"}, - {"polygonMatic", 800001, 8_000_000, "0.00001"}, - {"harmonyMainnet", 1666600000, 8_000_000, "0.00001"}, - {"harmonyTestnet", 1666700000, 8_000_000, "0.00001"}, - - {"gnosisMainnet", 100, 8_000_000, "0.00001"}, + {"default", 0, 500000, "0.00001"}, + {"mainnet", 1, 500000, "0.1"}, + {"kovan", 42, 500000, "0.1"}, + + {"optimism", 10, 500000, "0.00001"}, + {"optimism", 69, 500000, "0.00001"}, + {"optimism", 420, 500000, "0.00001"}, + + {"bscMainnet", 56, 500000, "0.00001"}, + {"hecoMainnet", 128, 500000, "0.00001"}, + {"fantomMainnet", 250, 500000, "0.00001"}, + {"fantomTestnet", 4002, 500000, "0.00001"}, + {"polygonMatic", 800001, 500000, "0.00001"}, + {"harmonyMainnet", 1666600000, 500000, "0.00001"}, + {"harmonyTestnet", 1666700000, 500000, "0.00001"}, + + {"gnosisMainnet", 100, 500000, "0.00001"}, } for _, test := range tests { tt := test diff --git a/core/chains/evm/gas/block_history_estimator_test.go b/core/chains/evm/gas/block_history_estimator_test.go index 265f7d8f354..b754132d7c7 100644 --- a/core/chains/evm/gas/block_history_estimator_test.go +++ b/core/chains/evm/gas/block_history_estimator_test.go @@ -1453,12 +1453,6 @@ func TestBlockHistoryEstimator_IsUsable(t *testing.T) { assert.Equal(t, false, bhe.IsUsable(tx, block, chaintype.ChainWeMix, geCfg.PriceMin(), logger.Test(t))) }) - t.Run("returns false if transaction is of type 0x16 only on WeMix", func(t *testing.T) { - cfg.ChainTypeF = "wemix" - tx := evmtypes.Transaction{Type: 0x16, GasPrice: assets.NewWeiI(10), GasLimit: 42, Hash: utils.NewHash()} - assert.Equal(t, false, bhe.IsUsable(tx, block, cfg.ChainType(), geCfg.PriceMin(), logger.Test(t))) - }) - t.Run("returns false if transaction has base fee higher than the gas price only on Celo", func(t *testing.T) { tx := evmtypes.Transaction{Type: 0x0, GasPrice: assets.NewWeiI(10), GasLimit: 42, Hash: utils.NewHash()} assert.Equal(t, false, bhe.IsUsable(tx, block, chaintype.ChainCelo, geCfg.PriceMin(), logger.Test(t))) diff --git a/core/chains/evm/gas/chain_specific.go b/core/chains/evm/gas/chain_specific.go index 4ad45f45bf3..a647f2ad272 100644 --- a/core/chains/evm/gas/chain_specific.go +++ b/core/chains/evm/gas/chain_specific.go @@ -49,7 +49,6 @@ func chainSpecificIsUsable(tx evmtypes.Transaction, baseFee *assets.Wei, chainTy return false } } - if chainType == chaintype.ChainZkSync { // zKSync specific type for contract deployment & priority transactions // https://era.zksync.io/docs/reference/concepts/transactions.html#eip-712-0x71 diff --git a/core/chains/evm/gas/rollups/l1_oracle.go b/core/chains/evm/gas/rollups/l1_oracle.go index 587b3b1d7a5..80c1e04988a 100644 --- a/core/chains/evm/gas/rollups/l1_oracle.go +++ b/core/chains/evm/gas/rollups/l1_oracle.go @@ -95,7 +95,7 @@ func NewL1GasOracle(lggr logger.Logger, ethClient l1OracleClient, chainType chai switch chainType { // FIXME Merge conflict, is it still valid? - //case chaintype.ChainOptimismBedrock, chaintype.ChainKroma, chaintype.ChainScroll, chaintype.ChainMantle, chaintype.ChainZircuit: + // case chaintype.ChainOptimismBedrock, chaintype.ChainKroma, chaintype.ChainScroll, chaintype.ChainMantle, chaintype.ChainZircuit: // l1Oracle, err = NewOpStackL1GasOracle(lggr, ethClient, chainType) case chaintype.ChainArbitrum: l1Oracle, err = NewArbitrumL1GasOracle(lggr, ethClient) diff --git a/core/chains/evm/gas/rollups/op_l1_oracle.go b/core/chains/evm/gas/rollups/op_l1_oracle.go index abe9c590278..daf67ded259 100644 --- a/core/chains/evm/gas/rollups/op_l1_oracle.go +++ b/core/chains/evm/gas/rollups/op_l1_oracle.go @@ -27,7 +27,7 @@ import ( // Reads L2-specific precompiles and caches the l1GasPrice set by the L2. // -//nolint:unused +//nolint:unused // backported from CCIP type optimismL1Oracle struct { services.StateMachine client l1OracleClient diff --git a/core/chains/evm/logpoller/disabled.go b/core/chains/evm/logpoller/disabled.go index a04b4fdb199..a29dd5ea11a 100644 --- a/core/chains/evm/logpoller/disabled.go +++ b/core/chains/evm/logpoller/disabled.go @@ -22,12 +22,12 @@ func (disabled) Name() string { return "disabledLogPoller" } func (disabled) Start(ctx context.Context) error { return ErrDisabled } +func (disabled) Close() error { return ErrDisabled } + func (disabled) Healthy() error { return ErrDisabled } -func (disabled) Close() error { return ErrDisabled } - func (disabled) Ready() error { return ErrDisabled } func (disabled) HealthReport() map[string]error { diff --git a/core/chains/evm/logpoller/observability_test.go b/core/chains/evm/logpoller/observability_test.go index e50bc331a12..6ebc5b0cce0 100644 --- a/core/chains/evm/logpoller/observability_test.go +++ b/core/chains/evm/logpoller/observability_test.go @@ -2,7 +2,6 @@ package logpoller import ( "fmt" - "math" "math/big" "testing" "time" @@ -149,41 +148,6 @@ func TestCountersAreProperlyPopulatedForWrites(t *testing.T) { assert.Equal(t, float64(2), testutil.ToFloat64(orm.blocksInserted.WithLabelValues("420"))) } -func TestCounterAreProperlyPopulatedForDeletes(t *testing.T) { - ctx := testutils.Context(t) - orm := createObservedORM(t, 420) - logs := generateRandomLogs(420, 20) - - for _, log := range logs { - err := orm.InsertLogsWithBlock(ctx, []Log{log}, NewLogPollerBlock(utils.RandomBytes32(), log.BlockNumber, time.Now(), 0)) - require.NoError(t, err) - } - - // Delete 5 logs - removed, err := orm.DeleteBlocksBefore(ctx, logs[4].BlockNumber, 100) - require.NoError(t, err) - assert.Equal(t, int64(5), removed) - assert.Equal(t, float64(5), testutil.ToFloat64(orm.datasetSize.WithLabelValues("420", "DeleteBlocksBefore", "delete"))) - - // Delete 1 more log - removed, err = orm.DeleteBlocksBefore(ctx, logs[5].BlockNumber, 100) - require.NoError(t, err) - assert.Equal(t, int64(1), removed) - assert.Equal(t, float64(1), testutil.ToFloat64(orm.datasetSize.WithLabelValues("420", "DeleteBlocksBefore", "delete"))) - - // Delete all - removed, err = orm.DeleteBlocksBefore(ctx, logs[len(logs)-1].BlockNumber, 0) - require.NoError(t, err) - assert.Equal(t, int64(14), removed) - assert.Equal(t, float64(14), testutil.ToFloat64(orm.datasetSize.WithLabelValues("420", "DeleteBlocksBefore", "delete"))) - - // Nothing to be deleted - removed, err = orm.DeleteBlocksBefore(ctx, math.MaxInt, 0) - require.NoError(t, err) - assert.Equal(t, int64(0), removed) - assert.Equal(t, float64(0), testutil.ToFloat64(orm.datasetSize.WithLabelValues("420", "DeleteBlocksBefore", "delete"))) -} - func generateRandomLogs(chainId, count int) []Log { logs := make([]Log, count) for i := range logs { diff --git a/core/chains/evm/txmgr/client.go b/core/chains/evm/txmgr/client.go index 25b8556e049..adb70b8c9ef 100644 --- a/core/chains/evm/txmgr/client.go +++ b/core/chains/evm/txmgr/client.go @@ -145,7 +145,6 @@ func (c *evmTxmClient) BatchGetReceipts(ctx context.Context, attempts []TxAttemp for _, req := range reqs { txErr = append(txErr, req.Error) } - return txReceipt, txErr, nil } diff --git a/core/chains/evm/txmgr/stuck_tx_detector_test.go b/core/chains/evm/txmgr/stuck_tx_detector_test.go index fd4d8edbe36..c6a0f5a7a41 100644 --- a/core/chains/evm/txmgr/stuck_tx_detector_test.go +++ b/core/chains/evm/txmgr/stuck_tx_detector_test.go @@ -301,7 +301,7 @@ func TestStuckTxDetector_DetectStuckTransactionsZircuit(t *testing.T) { feeEstimator := gasmocks.NewEvmFeeEstimator(t) // Return 10 gwei as market gas price marketGasPrice := tenGwei - fee := gas.EvmFee{Legacy: marketGasPrice} + fee := gas.EvmFee{GasPrice: marketGasPrice} feeEstimator.On("GetFee", mock.Anything, []byte{}, uint64(0), mock.Anything, mock.Anything, mock.Anything).Return(fee, uint64(0), nil) ethClient := testutils.NewEthClientMockWithDefaultChain(t) autoPurgeThreshold := uint32(5) @@ -563,23 +563,6 @@ func mustInsertUnconfirmedTxWithBroadcastAttemptsContainsEmptyBroadcastBeforeBlo return etx } -// helper function for edge case where broadcast attempt contains empty pointer -func mustInsertUnconfirmedTxWithBroadcastAttemptsContainsEmptyBroadcastBeforeBlockNum(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, numAttempts uint32, latestGasPrice *assets.Wei) txmgr.Tx { - ctx := tests.Context(t) - etx := cltest.MustInsertUnconfirmedEthTx(t, txStore, nonce, fromAddress) - // Insert attempts from oldest to newest - for i := int64(numAttempts - 1); i >= 0; i-- { - attempt := cltest.NewLegacyEthTxAttempt(t, etx.ID) - attempt.State = txmgrtypes.TxAttemptBroadcast - attempt.BroadcastBeforeBlockNum = nil - attempt.TxFee = gas.EvmFee{Legacy: latestGasPrice.Sub(assets.NewWeiI(i))} - require.NoError(t, txStore.InsertTxAttempt(ctx, &attempt)) - } - etx, err := txStore.FindTxWithAttempts(ctx, etx.ID) - require.NoError(t, err) - return etx -} - func mustInsertFatalErrorTxWithError(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, blockNum int64) txmgr.Tx { etx := cltest.NewEthTx(fromAddress) etx.State = txmgrcommon.TxFatalError diff --git a/core/chains/evm/types/models_test.go b/core/chains/evm/types/models_test.go index 1fe206d6dc0..a3f40a8bc2d 100644 --- a/core/chains/evm/types/models_test.go +++ b/core/chains/evm/types/models_test.go @@ -954,7 +954,7 @@ func TestBlock_UnmarshalJSON(t *testing.T) { t.Run("unmarshals geth block", func(t *testing.T) { b := new(evmtypes.Block) err := b.UnmarshalJSON([]byte(gethSampleBlock)) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, int64(15051090), b.Number) assert.Equal(t, "0x45eb0a650b6b0b9fd1ee676b870e43fa7614f1034f7404070327a332faed05c0", b.Hash.Hex()) @@ -966,14 +966,14 @@ func TestBlock_UnmarshalJSON(t *testing.T) { t.Run("handles empty result", func(t *testing.T) { b := new(evmtypes.Block) err := b.UnmarshalJSON([]byte("null")) - assert.Error(t, err) + require.Error(t, err) assert.Equal(t, pkgerrors.Cause(err), evmtypes.ErrMissingBlock) assert.True(t, pkgerrors.Is(err, evmtypes.ErrMissingBlock)) }) t.Run("unmarshals EIP-4844 block", func(t *testing.T) { b := new(evmtypes.Block) err := b.UnmarshalJSON([]byte(eip4844Block)) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, int64(5300694), b.Number) assert.Equal(t, "0x3edd900025edab70dde26a52377c3d0a9474c3f540bd0131d58f508711272590", b.Hash.Hex()) assert.Equal(t, "0x077c1d68b52f8203cb90a71759a09b11c2a6577f97ea1fd4a8686a387fbedac8", b.ParentHash.Hex()) @@ -984,7 +984,7 @@ func TestBlock_UnmarshalJSON(t *testing.T) { t.Run("unmarshals EIP-4844 block", func(t *testing.T) { b := new(evmtypes.Block) err := b.UnmarshalJSON([]byte(eip4844Block)) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, int64(5300694), b.Number) assert.Equal(t, "0x3edd900025edab70dde26a52377c3d0a9474c3f540bd0131d58f508711272590", b.Hash.Hex()) assert.Equal(t, "0x077c1d68b52f8203cb90a71759a09b11c2a6577f97ea1fd4a8686a387fbedac8", b.ParentHash.Hex()) diff --git a/core/chains/evm/utils/ethabi.go b/core/chains/evm/utils/ethabi.go index d54d0526314..08dfd54f430 100644 --- a/core/chains/evm/utils/ethabi.go +++ b/core/chains/evm/utils/ethabi.go @@ -45,7 +45,7 @@ func ABIEncode(abiStr string, values ...interface{}) ([]byte, error) { return res[4:], nil } -// ABIDecode is the equivalent of abi.decode. +// ABIEncode is the equivalent of abi.decode. // See a full set of examples https://github.com/ethereum/go-ethereum/blob/420b78659bef661a83c5c442121b13f13288c09f/accounts/abi/packing_test.go#L31 func ABIDecode(abiStr string, data []byte) ([]interface{}, error) { inDef := fmt.Sprintf(`[{ "name" : "method", "type": "function", "outputs": %s}]`, abiStr) diff --git a/core/gethwrappers/go_generate.go b/core/gethwrappers/go_generate.go index 561410f321d..ab610f01d67 100644 --- a/core/gethwrappers/go_generate.go +++ b/core/gethwrappers/go_generate.go @@ -156,9 +156,6 @@ package gethwrappers //go:generate go generate ./liquiditymanager //go:generate go generate ./workflow -// CCIP -//go:generate go generate ./ccip - // Mocks that contain only events and functions to emit them // These contracts are used in testing Atlas flows. The contracts contain no logic, only events, structures, and functions to emit them. // The flow is as follows: diff --git a/core/services/blockheaderfeeder/delegate.go b/core/services/blockheaderfeeder/delegate.go index c2458ff4510..046941aa154 100644 --- a/core/services/blockheaderfeeder/delegate.go +++ b/core/services/blockheaderfeeder/delegate.go @@ -10,7 +10,6 @@ import ( "go.uber.org/multierr" "github.com/smartcontractkit/chainlink-common/pkg/services" - "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/batch_blockhash_store" diff --git a/core/services/chainlink/application.go b/core/services/chainlink/application.go index d217832a3bc..4004b86c341 100644 --- a/core/services/chainlink/application.go +++ b/core/services/chainlink/application.go @@ -30,6 +30,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/build" "github.com/smartcontractkit/chainlink/v2/core/capabilities" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip" gatewayconnector "github.com/smartcontractkit/chainlink/v2/core/capabilities/gateway_connector" "github.com/smartcontractkit/chainlink/v2/core/capabilities/remote" remotetypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/remote/types" diff --git a/core/services/chainlink/config_feature.go b/core/services/chainlink/config_feature.go index c69d8cf795a..f5cc8786411 100644 --- a/core/services/chainlink/config_feature.go +++ b/core/services/chainlink/config_feature.go @@ -18,10 +18,6 @@ func (f *featureConfig) UICSAKeys() bool { return *f.c.UICSAKeys } -func (f *featureConfig) CCIP() bool { - return *f.c.CCIP -} - func (f *featureConfig) MultiFeedsManagers() bool { return *f.c.MultiFeedsManagers } diff --git a/core/services/chainlink/config_test.go b/core/services/chainlink/config_test.go index 94682571f52..eb467835b6f 100644 --- a/core/services/chainlink/config_test.go +++ b/core/services/chainlink/config_test.go @@ -641,7 +641,7 @@ func TestConfig_Marshal(t *testing.T) { LogBackfillBatchSize: ptr[uint32](17), LogPollInterval: &minute, LogKeepBlocksDepth: ptr[uint32](100000), - LogPrunePageSize: ptr[uint32](10000), + LogPrunePageSize: ptr[uint32](0), BackupLogPollerBlockDelay: ptr[uint64](532), MinContractPayment: commonassets.NewLinkFromJuels(math.MaxInt64), MinIncomingConfirmations: ptr[uint32](13), @@ -1106,7 +1106,7 @@ LinkContractAddress = '0x538aAaB4ea120b2bC2fe5D296852D948F07D849e' LogBackfillBatchSize = 17 LogPollInterval = '1m0s' LogKeepBlocksDepth = 100000 -LogPrunePageSize = 10000 +LogPrunePageSize = 0 BackupLogPollerBlockDelay = 532 MinIncomingConfirmations = 13 MinContractPayment = '9.223372036854775807 link' diff --git a/core/services/chainlink/testdata/config-full.toml b/core/services/chainlink/testdata/config-full.toml index de5db5c355a..6878e09c911 100644 --- a/core/services/chainlink/testdata/config-full.toml +++ b/core/services/chainlink/testdata/config-full.toml @@ -323,7 +323,7 @@ LinkContractAddress = '0x538aAaB4ea120b2bC2fe5D296852D948F07D849e' LogBackfillBatchSize = 17 LogPollInterval = '1m0s' LogKeepBlocksDepth = 100000 -LogPrunePageSize = 10000 +LogPrunePageSize = 0 BackupLogPollerBlockDelay = 532 MinIncomingConfirmations = 13 MinContractPayment = '9.223372036854775807 link' diff --git a/core/services/chainlink/testdata/config-multi-chain-effective.toml b/core/services/chainlink/testdata/config-multi-chain-effective.toml index 3399d95e9cc..ba7538cac04 100644 --- a/core/services/chainlink/testdata/config-multi-chain-effective.toml +++ b/core/services/chainlink/testdata/config-multi-chain-effective.toml @@ -306,7 +306,7 @@ LinkContractAddress = '0x514910771AF9Ca656af840dff83E8264EcF986CA' LogBackfillBatchSize = 1000 LogPollInterval = '15s' LogKeepBlocksDepth = 100000 -LogPrunePageSize = 10000 +LogPrunePageSize = 0 BackupLogPollerBlockDelay = 100 MinIncomingConfirmations = 3 MinContractPayment = '0.1 link' @@ -339,8 +339,8 @@ Mode = 'BlockHistory' PriceDefault = '20 gwei' PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether' PriceMin = '1 gwei' -LimitDefault = 8000000 -LimitMax = 8000000 +LimitDefault = 500000 +LimitMax = 500000 LimitMultiplier = '1' LimitTransfer = 21000 EstimateLimit = false @@ -417,7 +417,7 @@ LinkContractAddress = '0xa36085F69e2889c224210F603D836748e7dC0088' LogBackfillBatchSize = 1000 LogPollInterval = '15s' LogKeepBlocksDepth = 100000 -LogPrunePageSize = 10000 +LogPrunePageSize = 0 BackupLogPollerBlockDelay = 100 MinIncomingConfirmations = 3 MinContractPayment = '0.1 link' @@ -450,8 +450,8 @@ Mode = 'BlockHistory' PriceDefault = '9.223372036854775807 ether' PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether' PriceMin = '1 gwei' -LimitDefault = 8000000 -LimitMax = 8000000 +LimitDefault = 500000 +LimitMax = 500000 LimitMultiplier = '1' LimitTransfer = 21000 EstimateLimit = false @@ -523,7 +523,7 @@ LinkContractAddress = '0xb0897686c545045aFc77CF20eC7A532E3120E0F1' LogBackfillBatchSize = 1000 LogPollInterval = '1s' LogKeepBlocksDepth = 100000 -LogPrunePageSize = 10000 +LogPrunePageSize = 0 BackupLogPollerBlockDelay = 100 MinIncomingConfirmations = 5 MinContractPayment = '0.00001 link' @@ -555,8 +555,8 @@ Mode = 'FixedPrice' PriceDefault = '30 gwei' PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether' PriceMin = '30 gwei' -LimitDefault = 8000000 -LimitMax = 8000000 +LimitDefault = 500000 +LimitMax = 500000 LimitMultiplier = '1' LimitTransfer = 21000 EstimateLimit = false diff --git a/core/services/feeds/models.go b/core/services/feeds/models.go index c3859cdd950..a6cf103b4e9 100644 --- a/core/services/feeds/models.go +++ b/core/services/feeds/models.go @@ -25,12 +25,12 @@ const ( type PluginType string const ( - PluginTypeCommit PluginType = "COMMIT" - PluginTypeExecute PluginType = "EXECUTE" - PluginTypeMedian PluginType = "MEDIAN" - PluginTypeMercury PluginType = "MERCURY" - PluginTypeLiquidityManager PluginType = "LIQUIDITYMANAGER" - PluginTypeUnknown PluginType = "UNKNOWN" + PluginTypeCommit PluginType = "COMMIT" + PluginTypeExecute PluginType = "EXECUTE" + PluginTypeMedian PluginType = "MEDIAN" + PluginTypeMercury PluginType = "MERCURY" + PluginTypeRebalancer PluginType = "REBALANCER" + PluginTypeUnknown PluginType = "UNKNOWN" ) func FromPluginTypeInput(pt PluginType) string { @@ -47,19 +47,19 @@ func ToPluginType(s string) (PluginType, error) { return PluginTypeMedian, nil case "mercury": return PluginTypeMercury, nil - case "liquiditymanager": - return PluginTypeLiquidityManager, nil + case "rebalancer": + return PluginTypeRebalancer, nil default: return PluginTypeUnknown, errors.New("unknown plugin type") } } type Plugins struct { - Commit bool `json:"commit"` - Execute bool `json:"execute"` - Median bool `json:"median"` - Mercury bool `json:"mercury"` - LiquidityManager bool `json:"liquiditymanager"` + Commit bool `json:"commit"` + Execute bool `json:"execute"` + Median bool `json:"median"` + Mercury bool `json:"mercury"` + Rebalancer bool `json:"rebalancer"` } func (p Plugins) Value() (driver.Value, error) { diff --git a/core/services/feeds/models_test.go b/core/services/feeds/models_test.go index 44d2003f53e..d0d4382b055 100644 --- a/core/services/feeds/models_test.go +++ b/core/services/feeds/models_test.go @@ -74,9 +74,9 @@ func Test_ToPluginType(t *testing.T) { require.NoError(t, err) assert.Equal(t, pt, PluginTypeMercury) - pt, err = ToPluginType("liquiditymanager") + pt, err = ToPluginType("rebalancer") require.NoError(t, err) - assert.Equal(t, pt, PluginTypeLiquidityManager) + assert.Equal(t, pt, PluginTypeRebalancer) pt, err = ToPluginType("xxx") require.Error(t, err) @@ -91,7 +91,7 @@ func Test_FromPluginType(t *testing.T) { assert.Equal(t, "execute", FromPluginTypeInput(PluginTypeExecute)) assert.Equal(t, "median", FromPluginTypeInput(PluginTypeMedian)) assert.Equal(t, "mercury", FromPluginTypeInput(PluginTypeMercury)) - assert.Equal(t, "liquiditymanager", FromPluginTypeInput(PluginTypeLiquidityManager)) + assert.Equal(t, "rebalancer", FromPluginTypeInput(PluginTypeRebalancer)) assert.Equal(t, "unknown", FromPluginTypeInput(PluginTypeUnknown)) } @@ -256,13 +256,13 @@ func Test_Plugins_Value(t *testing.T) { var ( give = Plugins{ - Commit: true, - Execute: true, - Median: false, - Mercury: true, - LiquidityManager: false, + Commit: true, + Execute: true, + Median: false, + Mercury: true, + Rebalancer: false, } - want = `{"commit":true,"execute":true,"median":false,"mercury":true,"liquiditymanager":false}` + want = `{"commit":true,"execute":true,"median":false,"mercury":true,"rebalancer":false}` ) val, err := give.Value() @@ -278,13 +278,13 @@ func Test_Plugins_Scan(t *testing.T) { t.Parallel() var ( - give = `{"commit":true,"execute":true,"median":false,"mercury":true,"liquiditymanager":false}` + give = `{"commit":true,"execute":true,"median":false,"mercury":true,"rebalancer":false}` want = Plugins{ - Commit: true, - Execute: true, - Median: false, - Mercury: true, - LiquidityManager: false, + Commit: true, + Execute: true, + Median: false, + Mercury: true, + Rebalancer: false, } ) @@ -307,14 +307,14 @@ func Test_OCR2Config_Value(t *testing.T) { P2PPeerID: null.StringFrom("peerid"), KeyBundleID: null.StringFrom("ocrkeyid"), Plugins: Plugins{ - Commit: true, - Execute: true, - Median: false, - Mercury: true, - LiquidityManager: false, + Commit: true, + Execute: true, + Median: false, + Mercury: true, + Rebalancer: false, }, } - want = `{"enabled":true,"is_bootstrap":false,"multiaddr":"multiaddr","forwarder_address":"forwarderaddress","p2p_peer_id":"peerid","key_bundle_id":"ocrkeyid","plugins":{"commit":true,"execute":true,"median":false,"mercury":true,"liquiditymanager":false}}` + want = `{"enabled":true,"is_bootstrap":false,"multiaddr":"multiaddr","forwarder_address":"forwarderaddress","p2p_peer_id":"peerid","key_bundle_id":"ocrkeyid","plugins":{"commit":true,"execute":true,"median":false,"mercury":true,"rebalancer":false}}` ) val, err := give.Value() @@ -330,7 +330,7 @@ func Test_OCR2Config_Scan(t *testing.T) { t.Parallel() var ( - give = `{"enabled":true,"is_bootstrap":false,"multiaddr":"multiaddr","forwarder_address":"forwarderaddress","p2p_peer_id":"peerid","key_bundle_id":"ocrkeyid","plugins":{"commit":true,"execute":true,"median":false,"mercury":true,"liquiditymanager":false}}` + give = `{"enabled":true,"is_bootstrap":false,"multiaddr":"multiaddr","forwarder_address":"forwarderaddress","p2p_peer_id":"peerid","key_bundle_id":"ocrkeyid","plugins":{"commit":true,"execute":true,"median":false,"mercury":true,"rebalancer":false}}` want = OCR2ConfigModel{ Enabled: true, IsBootstrap: false, @@ -339,11 +339,11 @@ func Test_OCR2Config_Scan(t *testing.T) { P2PPeerID: null.StringFrom("peerid"), KeyBundleID: null.StringFrom("ocrkeyid"), Plugins: Plugins{ - Commit: true, - Execute: true, - Median: false, - Mercury: true, - LiquidityManager: false, + Commit: true, + Execute: true, + Median: false, + Mercury: true, + Rebalancer: false, }, } ) diff --git a/core/services/job/job_orm_test.go b/core/services/job/job_orm_test.go index f0d06f25e1a..7a310d6f791 100644 --- a/core/services/job/job_orm_test.go +++ b/core/services/job/job_orm_test.go @@ -1567,7 +1567,7 @@ func Test_FindPipelineRunIDsByJobID(t *testing.T) { runIDs, err := orm.FindPipelineRunIDsByJobID(ctx, jobs[3].ID, 95, 10) require.NoError(t, err) require.Len(t, runIDs, 10) - //assert.Equal(t, int64(4*(len(jobs)-1)), runIDs[3]-runIDs[7]) + assert.Equal(t, int64(4*(len(jobs)-1)), runIDs[3]-runIDs[7]) }) // Internally these queries are batched by 1000, this tests case requiring concatenation @@ -1577,7 +1577,7 @@ func Test_FindPipelineRunIDsByJobID(t *testing.T) { runIDs, err := orm.FindPipelineRunIDsByJobID(ctx, jobs[3].ID, 95, 100) require.NoError(t, err) require.Len(t, runIDs, 100) - //assert.Equal(t, int64(67*(len(jobs)-1)), runIDs[12]-runIDs[79]) + assert.Equal(t, int64(67*(len(jobs)-1)), runIDs[12]-runIDs[79]) }) for i := 0; i < 2100; i++ { @@ -1592,7 +1592,7 @@ func Test_FindPipelineRunIDsByJobID(t *testing.T) { runIDs, err := orm.FindPipelineRunIDsByJobID(ctx, jobs[3].ID, 0, 25) require.NoError(t, err) require.Len(t, runIDs, 25) - //assert.Equal(t, int64(16*(len(jobs)-1)), runIDs[7]-runIDs[23]) + assert.Equal(t, int64(16*(len(jobs)-1)), runIDs[7]-runIDs[23]) }) // Same as previous, but where there are fewer matching jobs than the limit @@ -1601,7 +1601,7 @@ func Test_FindPipelineRunIDsByJobID(t *testing.T) { runIDs, err := orm.FindPipelineRunIDsByJobID(ctx, jobs[3].ID, 143, 190) require.NoError(t, err) require.Len(t, runIDs, 107) - //assert.Equal(t, int64(16*(len(jobs)-1)), runIDs[7]-runIDs[23]) + assert.Equal(t, int64(16*(len(jobs)-1)), runIDs[7]-runIDs[23]) }) } diff --git a/core/services/job/spawner_test.go b/core/services/job/spawner_test.go index f2288cf9224..b8144ef86f8 100644 --- a/core/services/job/spawner_test.go +++ b/core/services/job/spawner_test.go @@ -71,13 +71,6 @@ func (g *relayGetter) Get(id types.RelayID) (loop.Relayer, error) { return evmrelayer.NewLOOPRelayAdapter(g.r), nil } -func (g *relayGetter) List(...types.RelayID) (map[types.RelayID]loop.Relayer, error) { - relayMap := make(map[types.RelayID]loop.Relayer, 1) - r := evmrelayer.NewLoopRelayServerAdapter(g.r, g.e) - relayMap[types.RelayID{Network: "dummy", ChainID: "dummy"}] = r - return relayMap, nil -} - func (g *relayGetter) GetIDToRelayerMap() (map[types.RelayID]loop.Relayer, error) { return map[types.RelayID]loop.Relayer{}, nil } diff --git a/core/services/keeper/delegate.go b/core/services/keeper/delegate.go index a399ade1b03..c9d189b30c5 100644 --- a/core/services/keeper/delegate.go +++ b/core/services/keeper/delegate.go @@ -7,7 +7,6 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox" - "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/logger" diff --git a/core/services/llo/evm/report_codec_premium_legacy.go b/core/services/llo/evm/report_codec_premium_legacy.go index ee981b08f0e..fdbad6aead9 100644 --- a/core/services/llo/evm/report_codec_premium_legacy.go +++ b/core/services/llo/evm/report_codec_premium_legacy.go @@ -114,11 +114,11 @@ func (r ReportCodecPremiumLegacy) Pack(digest types.ConfigDigest, seqNr uint64, var ss [][32]byte var vs [32]byte for i, as := range sigs { - rr, s, v, err := evmutil.SplitSignature(as.Signature) + r, s, v, err := evmutil.SplitSignature(as.Signature) if err != nil { return nil, fmt.Errorf("eventTransmit(ev): error in SplitSignature: %w", err) } - rs = append(rs, rr) + rs = append(rs, r) ss = append(ss, s) vs[i] = v } diff --git a/core/services/llo/onchain_channel_definition_cache.go b/core/services/llo/onchain_channel_definition_cache.go index e7e8a77a264..461c309a73a 100644 --- a/core/services/llo/onchain_channel_definition_cache.go +++ b/core/services/llo/onchain_channel_definition_cache.go @@ -174,7 +174,7 @@ func (c *channelDefinitionCache) Start(ctx context.Context) error { } else if pd != nil { c.definitions = pd.Definitions c.initialBlockNum = pd.BlockNum + 1 - c.definitionsVersion = pd.Version + c.definitionsVersion = uint32(pd.Version) } else { // ensure non-nil map ready for assignment later c.definitions = make(llotypes.ChannelDefinitions) @@ -475,7 +475,6 @@ func (c *channelDefinitionCache) persist(ctx context.Context) (memoryVersion, pe return } -// nolint:revive // Checks persisted version and tries to save if necessary on a periodic timer // Simple backup in case database persistence fails func (c *channelDefinitionCache) failedPersistLoop() { diff --git a/core/services/ocr/contract_tracker.go b/core/services/ocr/contract_tracker.go index 4ccb8ae8ede..f2cf1fee9d3 100644 --- a/core/services/ocr/contract_tracker.go +++ b/core/services/ocr/contract_tracker.go @@ -391,7 +391,6 @@ func (t *OCRContractTracker) ConfigFromLogs(ctx context.Context, changedInBlock return confighelper.ContractConfigFromConfigSetEvent(*latest), err } -// nolint:exhaustive // LatestBlockHeight queries the eth node for the most recent header func (t *OCRContractTracker) LatestBlockHeight(ctx context.Context) (blockheight uint64, err error) { switch t.cfg.ChainType() { diff --git a/core/services/ocr2/delegate.go b/core/services/ocr2/delegate.go index 5d6cf21dd9f..f6b08cf46a3 100644 --- a/core/services/ocr2/delegate.go +++ b/core/services/ocr2/delegate.go @@ -1655,6 +1655,7 @@ func (d *Delegate) newServicesCCIPCommit(ctx context.Context, lggr logger.Sugare if err != nil { return nil, fmt.Errorf("failed to create price getter: %w", err) } + //nolint:gosec // safe to cast return ccipcommit.NewCommitServices(ctx, d.ds, srcProvider, dstProvider, priceGetter, jb, lggr, d.pipelineRunner, oracleArgsNoPlugin, d.isNewlyCreatedJob, int64(srcChainID), dstChainID, logError) } @@ -1669,7 +1670,7 @@ func (d *Delegate) ccipCommitPriceGetter(ctx context.Context, lggr logger.Sugare } else { // Use dynamic price getter. if pluginJobSpecConfig.PriceGetterConfig == nil { - return nil, fmt.Errorf("priceGetterConfig is nil") + return nil, errors.New("priceGetterConfig is nil") } // Configure contract readers for all chains specified in the aggregator configurations. @@ -1694,7 +1695,7 @@ func (d *Delegate) ccipCommitPriceGetter(ctx context.Context, lggr logger.Sugare contractsConfig := make(map[string]evmrelaytypes.ChainContractReader, len(aggregatorContracts)) for i := range aggregatorContracts { - contractsConfig[fmt.Sprintf("%v_%v", ccip.OFFCHAIN_AGGREGATOR, i)] = evmrelaytypes.ChainContractReader{ + contractsConfig[fmt.Sprintf("%v_%v", ccip.OffchainAggregator, i)] = evmrelaytypes.ChainContractReader{ ContractABI: ccip.OffChainAggregatorABI, Configs: map[string]*evmrelaytypes.ChainReaderDefinition{ "decimals": { // CR consumers choose an alias @@ -1710,12 +1711,12 @@ func (d *Delegate) ccipCommitPriceGetter(ctx context.Context, lggr logger.Sugare Contracts: contractsConfig, } - contractReaderConfigJsonBytes, jerr := json.Marshal(contractReaderConfig) + contractReaderConfigJSONBytes, jerr := json.Marshal(contractReaderConfig) if jerr != nil { return nil, fmt.Errorf("marshal contract reader config: %w", jerr) } - contractReader, cerr := relay.NewContractReader(ctx, contractReaderConfigJsonBytes) + contractReader, cerr := relay.NewContractReader(ctx, contractReaderConfigJSONBytes) if cerr != nil { return nil, fmt.Errorf("new ccip commit contract reader %w", cerr) } diff --git a/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go b/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go index 9872aa6b6e5..3a6148d1b8a 100644 --- a/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go +++ b/core/services/ocr2/plugins/ccip/ccipcommit/initializers.go @@ -42,7 +42,21 @@ var defaultNewReportingPluginRetryConfig = ccipdata.RetryConfig{ MaxRetries: (6 * 4) + 10, } -func NewCommitServices(ctx context.Context, ds sqlutil.DataSource, srcProvider commontypes.CCIPCommitProvider, dstProvider commontypes.CCIPCommitProvider, priceGetter ccip.AllTokensPriceGetter, jb job.Job, lggr logger.Logger, pr pipeline.Runner, argsNoPlugin libocr2.OCR2OracleArgs, new bool, sourceChainID int64, destChainID int64, logError func(string)) ([]job.ServiceCtx, error) { +func NewCommitServices( + ctx context.Context, + ds sqlutil.DataSource, + srcProvider commontypes.CCIPCommitProvider, + dstProvider commontypes.CCIPCommitProvider, + priceGetter ccip.AllTokensPriceGetter, + jb job.Job, + lggr logger.Logger, + pr pipeline.Runner, + argsNoPlugin libocr2.OCR2OracleArgs, + newInstance bool, + sourceChainID int64, + destChainID int64, + logError func(string), +) ([]job.ServiceCtx, error) { spec := jb.OCR2OracleSpec var pluginConfig ccipconfig.CommitPluginJobSpecConfig @@ -154,7 +168,7 @@ func NewCommitServices(ctx context.Context, ds sqlutil.DataSource, srcProvider c return nil, err } // If this is a brand-new job, then we make use of the start blocks. If not then we're rebooting and log poller will pick up where we left off. - if new { + if newInstance { return []job.ServiceCtx{ oraclelib.NewChainAgnosticBackFilledOracle( lggr, diff --git a/core/services/ocr2/plugins/ccip/ccipexec/batching_test.go b/core/services/ocr2/plugins/ccip/ccipexec/batching_test.go index 321bf3ef065..e57bc3aa86e 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/batching_test.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/batching_test.go @@ -871,9 +871,9 @@ func runAssertions(t *testing.T, tc testCase, seqNrs []ccip.ObservedMessage, exe batchingStratID := strategy.GetBatchingStrategyID() if strategyType := reflect.TypeOf(strategy); strategyType == reflect.TypeOf(&BestEffortBatchingStrategy{}) { - assert.Equal(t, batchingStratID, uint32(0)) + assert.Equal(t, uint32(0), batchingStratID) } else { - assert.Equal(t, batchingStratID, uint32(1)) + assert.Equal(t, uint32(1), batchingStratID) } } diff --git a/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go b/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go index b169aa48315..73a1f431399 100644 --- a/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go +++ b/core/services/ocr2/plugins/ccip/ccipexec/ocr2_test.go @@ -234,7 +234,7 @@ func TestExecutionReportingPlugin_Report(t *testing.T) { testCases := []struct { name string f int - batchingStrategyId uint32 + batchingStrategyID uint32 committedSeqNum uint64 observations []ccip.ExecutionObservation @@ -245,7 +245,7 @@ func TestExecutionReportingPlugin_Report(t *testing.T) { { name: "not enough observations to form consensus - best effort batching", f: 5, - batchingStrategyId: 0, + batchingStrategyID: 0, committedSeqNum: 5, observations: []ccip.ExecutionObservation{ {Messages: map[uint64]ccip.MsgData{3: {}, 4: {}}}, @@ -257,7 +257,7 @@ func TestExecutionReportingPlugin_Report(t *testing.T) { { name: "not enough observaitons to form consensus - zk batching", f: 5, - batchingStrategyId: 1, + batchingStrategyID: 1, committedSeqNum: 5, observations: []ccip.ExecutionObservation{ {Messages: map[uint64]ccip.MsgData{3: {}, 4: {}}}, @@ -285,8 +285,8 @@ func TestExecutionReportingPlugin_Report(t *testing.T) { p := ExecutionReportingPlugin{} p.lggr = logger.TestLogger(t) p.F = tc.f - bs, err := NewBatchingStrategy(tc.batchingStrategyId, &statuschecker.TxmStatusChecker{}) - assert.NoError(t, err) + bs, err := NewBatchingStrategy(tc.batchingStrategyID, &statuschecker.TxmStatusChecker{}) + require.NoError(t, err) p.batchingStrategy = bs p.commitStoreReader = ccipdatamocks.NewCommitStoreReader(t) @@ -1469,9 +1469,8 @@ func TestExecutionReportingPlugin_getConsensusThreshold(t *testing.T) { p := &ExecutionReportingPlugin{} p.F = tc.F bs, err := NewBatchingStrategy(tc.batchingStrategyID, &statuschecker.TxmStatusChecker{}) - assert.NoError(t, err) + require.NoError(t, err) p.batchingStrategy = bs - require.Equal(t, tc.expectedConsensusThreshold, p.getConsensusThreshold()) }) } diff --git a/core/services/ocr2/plugins/ccip/config/type_and_version_test.go b/core/services/ocr2/plugins/ccip/config/type_and_version_test.go index f626389dcdc..807bb59f3be 100644 --- a/core/services/ocr2/plugins/ccip/config/type_and_version_test.go +++ b/core/services/ocr2/plugins/ccip/config/type_and_version_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestParseTypeAndVersion(t *testing.T) { @@ -38,9 +39,9 @@ func TestParseTypeAndVersion(t *testing.T) { actualType, actualVersion, err := ParseTypeAndVersion(tc.input) if tc.expectedError != "" { - assert.EqualError(t, err, tc.expectedError) + require.EqualError(t, err, tc.expectedError) } else { - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, tc.expectedType, actualType) assert.Equal(t, tc.expectedVersion, actualVersion) } diff --git a/core/services/ocr2/plugins/ccip/estimatorconfig/interceptors/mantle/interceptor.go b/core/services/ocr2/plugins/ccip/estimatorconfig/interceptors/mantle/interceptor.go index 8d5d3bb6c2f..359f32e13a5 100644 --- a/core/services/ocr2/plugins/ccip/estimatorconfig/interceptors/mantle/interceptor.go +++ b/core/services/ocr2/plugins/ccip/estimatorconfig/interceptors/mantle/interceptor.go @@ -12,7 +12,6 @@ import ( "github.com/ethereum/go-ethereum/common" evmClient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/rollups" ) const ( @@ -34,11 +33,11 @@ func NewInterceptor(_ context.Context, client evmClient.Client) (*Interceptor, e // Encode calldata for tokenRatio method tokenRatioMethodAbi, err := abi.JSON(strings.NewReader(mantleTokenRatioAbiString)) if err != nil { - return nil, fmt.Errorf("failed to parse GasPriceOracle %s() method ABI for Mantle; %v", tokenRatioMethod, err) + return nil, fmt.Errorf("failed to parse GasPriceOracle %s() method ABI for Mantle; %w", tokenRatioMethod, err) } tokenRatioCallData, err := tokenRatioMethodAbi.Pack(tokenRatioMethod) if err != nil { - return nil, fmt.Errorf("failed to parse GasPriceOracle %s() calldata for Mantle; %v", tokenRatioMethod, err) + return nil, fmt.Errorf("failed to parse GasPriceOracle %s() calldata for Mantle; %w", tokenRatioMethod, err) } return &Interceptor{ @@ -66,7 +65,10 @@ func (i *Interceptor) ModifyGasPriceComponents(ctx context.Context, execGasPrice // getMantleTokenRatio Requests and returns a token ratio value for the Mantle chain. func (i *Interceptor) getMantleTokenRatio(ctx context.Context) (*big.Int, error) { - precompile := common.HexToAddress(rollups.OPGasOracleAddress) + // FIXME it's removed from chainlink repo + // precompile := common.HexToAddress(rollups.OPGasOracleAddress) + precompile := common.Address{} + tokenRatio, err := i.client.CallContract(ctx, ethereum.CallMsg{ To: &precompile, Data: i.tokenRatioCallData, diff --git a/core/services/ocr2/plugins/ccip/estimatorconfig/mocks/gas_price_interceptor_mock.go b/core/services/ocr2/plugins/ccip/estimatorconfig/mocks/gas_price_interceptor_mock.go index 62ec5a2207b..78d7fa7bb35 100644 --- a/core/services/ocr2/plugins/ccip/estimatorconfig/mocks/gas_price_interceptor_mock.go +++ b/core/services/ocr2/plugins/ccip/estimatorconfig/mocks/gas_price_interceptor_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.50.0. DO NOT EDIT. package mocks diff --git a/core/services/ocr2/plugins/ccip/exportinternal.go b/core/services/ocr2/plugins/ccip/exportinternal.go index 970a8d626dc..10b802eeabc 100644 --- a/core/services/ocr2/plugins/ccip/exportinternal.go +++ b/core/services/ocr2/plugins/ccip/exportinternal.go @@ -10,12 +10,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "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/internal/gethwrappers2/generated/offchainaggregator" - "github.com/smartcontractkit/chainlink/v2/core/logger" "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" @@ -28,9 +28,9 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" ) -const OFFCHAIN_AGGREGATOR = "OffchainAggregator" -const DECIMALS_METHOD_NAME = "decimals" -const LATEST_ROUND_DATA_METHOD_NAME = "latestRoundData" +const OffchainAggregator = "OffchainAggregator" +const DecimalsMethodName = "decimals" +const LatestRoundDataMethodName = "latestRoundData" func GenericAddrToEvm(addr ccip.Address) (common.Address, error) { return ccipcalc.GenericAddrToEvm(addr) diff --git a/core/services/ocr2/plugins/ccip/integration_test.go b/core/services/ocr2/plugins/ccip/integration_test.go index cf5d4f1c247..6a1aef98d0c 100644 --- a/core/services/ocr2/plugins/ccip/integration_test.go +++ b/core/services/ocr2/plugins/ccip/integration_test.go @@ -695,6 +695,7 @@ func TestReorg(t *testing.T) { require.NoError(t, ccipTH.Dest.Chain.Fork(forkBlock.Hash()), "Error while forking the chain") // Make sure that fork is longer than the canonical chain to enforce switch + //nolint:gosec // not a problem in tests noOfBlocks := int(currentBlock.NumberU64() - forkBlock.NumberU64()) for i := 0; i < noOfBlocks+1; i++ { ccipTH.Dest.Chain.Commit() 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 da9c81de7ee..d298eecbbf3 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipcommon/shortcuts_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipcommon/shortcuts_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" ) @@ -146,19 +147,19 @@ func TestRetryUntilSuccess(t *testing.T) { // Assert that RetryUntilSuccess returns the expected value when fn returns success on the 5th attempt numCalls, err := RetryUntilSuccess(fn, initialDelay, maxDelay, 10) - assert.Nil(t, err) + require.NoError(t, err) assert.Equal(t, 5, numCalls) // Assert that RetryUntilSuccess returns the expected value when fn returns success on the 8th attempt numAttempts = 8 numCalls = 0 numCalls, err = RetryUntilSuccess(fn, initialDelay, maxDelay, 10) - assert.Nil(t, err) + require.NoError(t, err) assert.Equal(t, 8, numCalls) // Assert that RetryUntilSuccess exhausts retries numAttempts = 8 numCalls = 0 numCalls, err = RetryUntilSuccess(fn, initialDelay, maxDelay, 2) - assert.NotNil(t, err) + require.Error(t, err) } 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 d1666d548ae..42a7369c7e5 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" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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/internal/ccipdata/factory" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/observability" ) 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 80ecc1b6f10..30e74d89e36 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 @@ -1,6 +1,7 @@ package ccipdata_test import ( + "context" "math/big" "reflect" "testing" @@ -36,7 +37,6 @@ import ( "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" ccipdatamocks "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0" ) @@ -184,7 +184,7 @@ func TestCommitStoreReaders(t *testing.T) { feeEstimatorConfig := ccipdatamocks.NewFeeEstimatorConfigReader(t) feeEstimatorConfig.On( "ModifyGasPriceComponents", - mock.AnythingOfType("context.backgroundCtx"), + mock.Anything, mock.AnythingOfType("*big.Int"), mock.AnythingOfType("*big.Int"), ).Return(func(ctx context.Context, x, y *big.Int) (*big.Int, *big.Int, error) { 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 2ce5d4930be..85eee70e296 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/onramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/onramp.go @@ -5,11 +5,11 @@ import ( "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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" 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/price_registry.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/factory/price_registry.go index 611da1c4dd5..90a40eee1a5 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 @@ -5,11 +5,11 @@ import ( "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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" 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/mocks/fee_estimator_config_mock.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/fee_estimator_config_mock.go index e62cdec87a8..9ce400406d4 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/fee_estimator_config_mock.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks/fee_estimator_config_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.50.0. DO NOT EDIT. package mocks 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 cb3a7d11138..420cd5bf64c 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 @@ -33,7 +33,6 @@ import ( "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" ccipdatamocks "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/mocks" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_0_0" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0" ) 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 92d36f381cf..6340eb21682 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 @@ -71,7 +71,7 @@ func TestOnRampReaderInit(t *testing.T) { func setupOnRampReaderTH(t *testing.T, version string) onRampReaderTH { ctx := tests.Context(t) user, bc := ccipdata.NewSimulation(t) - log := logger.TestLogger(t) + log := logger.Test(t) orm := logpoller.NewORM(testutils.SimulatedChainID, pgtest.NewSqlxDB(t), log) lpOpts := logpoller.Opts{ PollPeriod: 100 * time.Millisecond, @@ -320,7 +320,7 @@ func TestNewOnRampReader(t *testing.T) { addr := ccipcalc.EvmAddrToGeneric(utils.RandomAddress()) lp := lpmocks.NewLogPoller(t) lp.On("RegisterFilter", mock.Anything, mock.Anything).Return(nil).Maybe() - _, err = factory.NewOnRampReader(ctx, logger.TestLogger(t), factory.NewEvmVersionFinder(), 1, 2, addr, lp, c) + _, err = factory.NewOnRampReader(ctx, logger.Test(t), factory.NewEvmVersionFinder(), 1, 2, addr, lp, c) if tc.expectedErr != "" { require.EqualError(t, err, tc.expectedErr) } else { 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 92190f35ec3..1b9ecc128a7 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 @@ -29,7 +29,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/price_registry_1_2_0" "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/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" @@ -72,7 +71,7 @@ func newSim(t *testing.T) (*bind.TransactOpts, *client.SimulatedBackendClient) { // with a snapshot of data so reader tests can do multi-version assertions. func setupPriceRegistryReaderTH(t *testing.T) priceRegReaderTH { user, ec := newSim(t) - lggr := logger.TestLogger(t) + lggr := logger.Test(t) lpOpts := logpoller.Opts{ PollPeriod: 100 * time.Millisecond, FinalityDepth: 2, @@ -280,7 +279,7 @@ func TestNewPriceRegistryReader(t *testing.T) { addr := ccipcalc.EvmAddrToGeneric(utils.RandomAddress()) lp := lpmocks.NewLogPoller(t) lp.On("RegisterFilter", mock.Anything, mock.Anything).Return(nil).Maybe() - _, err = factory.NewPriceRegistryReader(ctx, logger.TestLogger(t), factory.NewEvmVersionFinder(), addr, lp, c) + _, err = factory.NewPriceRegistryReader(ctx, logger.Test(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 3f57d419e16..8655bc98acc 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/reader.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/reader.go @@ -6,10 +6,10 @@ import ( "github.com/ethereum/go-ethereum/core/types" + "github.com/smartcontractkit/chainlink-common/pkg/logger" cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" - "github.com/smartcontractkit/chainlink/v2/core/logger" ) const ( diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/usdc_reader.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/usdc_reader.go index a75bcd03e63..792e2eb7253 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/usdc_reader.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/usdc_reader.go @@ -10,9 +10,10 @@ import ( "github.com/patrickmn/go-cache" "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "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" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/usdc_reader_internal_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/usdc_reader_internal_test.go index 81da724e0d4..a54a1ad09a0 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/usdc_reader_internal_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/usdc_reader_internal_test.go @@ -142,7 +142,7 @@ func TestParse(t *testing.T) { func TestFilters(t *testing.T) { t.Run("filters of different jobs should be distinct", func(t *testing.T) { ctx := tests.Context(t) - lggr := logger.TestLogger(t) + lggr := logger.Test(t) chainID := testutils.NewRandomEVMChainID() db := pgtest.NewSqlxDB(t) o := logpoller.NewORM(chainID, db, lggr) 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 c191c211b86..78f60653668 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 @@ -14,6 +14,7 @@ import ( "github.com/pkg/errors" "github.com/smartcontractkit/chainlink-common/pkg/config" + "github.com/smartcontractkit/chainlink-common/pkg/logger" cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink-common/pkg/types/query" "github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives" @@ -23,7 +24,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store_1_2_0" - "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" ccipconfig "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/v1_2_0/offramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp.go index 92e4de0e3af..881755d3f3c 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 @@ -15,6 +15,7 @@ import ( "github.com/pkg/errors" "github.com/smartcontractkit/chainlink-common/pkg/config" + "github.com/smartcontractkit/chainlink-common/pkg/logger" cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" @@ -23,7 +24,6 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_offramp_1_2_0" "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" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" @@ -155,12 +155,11 @@ type OffRamp struct { // Dynamic config // configMu guards all the dynamic config fields. - configMu sync.RWMutex - gasPriceEstimator prices.GasPriceEstimatorExec - offchainConfig cciptypes.ExecOffchainConfig - onchainConfig cciptypes.ExecOnchainConfig + configMu sync.RWMutex + gasPriceEstimator prices.GasPriceEstimatorExec + offchainConfig cciptypes.ExecOffchainConfig + onchainConfig cciptypes.ExecOnchainConfig feeEstimatorConfig ccipdata.FeeEstimatorConfigReader - } func (o *OffRamp) GetStaticConfig(ctx context.Context) (cciptypes.OffRampStaticConfig, error) { @@ -671,9 +670,9 @@ func NewOffRamp(lggr logger.Logger, addr common.Address, ec client.Client, lp lo offRamp.Address(), ), // values set on the fly after ChangeConfig is called - gasPriceEstimator: prices.ExecGasPriceEstimator{}, - offchainConfig: cciptypes.ExecOffchainConfig{}, - onchainConfig: cciptypes.ExecOnchainConfig{}, + gasPriceEstimator: prices.ExecGasPriceEstimator{}, + offchainConfig: cciptypes.ExecOffchainConfig{}, + onchainConfig: cciptypes.ExecOnchainConfig{}, feeEstimatorConfig: feeEstimatorConfig, }, nil } diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp_reader_unit_test.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp_reader_unit_test.go index 15c91235b92..a1e7f9e6346 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp_reader_unit_test.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0/offramp_reader_unit_test.go @@ -197,7 +197,7 @@ func Test_LogsAreProperlyMarkedAsFinalized(t *testing.T) { lp.On("IndexedLogsTopicRange", mock.Anything, ExecutionStateChangedEvent, offrampAddress, 1, logpoller.EvmWord(minSeqNr), logpoller.EvmWord(maxSeqNr), evmtypes.Confirmations(0)). Return(inputLogs, nil) - offRamp, err := NewOffRamp(logger.Test(t), offrampAddress, evmclimocks.NewClient(t), lp, nil, nil) + offRamp, err := NewOffRamp(logger.Test(t), offrampAddress, evmclimocks.NewClient(t), lp, nil, nil, nil) require.NoError(t, err) logs, err := offRamp.GetExecutionStateChangesBetweenSeqNums(testutils.Context(t), minSeqNr, maxSeqNr, 0) require.NoError(t, err) 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 b6877ab2fac..4ae4eeb0d3e 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 @@ -2,6 +2,7 @@ package v1_2_0 import ( "context" + "errors" "fmt" "strings" @@ -11,12 +12,12 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/smartcontractkit/chainlink-common/pkg/hashutil" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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_2_0" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_contract" - "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/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" @@ -124,7 +125,7 @@ func (o *OnRamp) Address(context.Context) (cciptypes.Address, error) { func (o *OnRamp) GetDynamicConfig(ctx context.Context) (cciptypes.OnRampDynamicConfig, error) { return o.cachedOnRampDynamicConfig.Get(ctx, func(ctx context.Context) (cciptypes.OnRampDynamicConfig, error) { if o.onRamp == nil { - return cciptypes.OnRampDynamicConfig{}, fmt.Errorf("onramp not initialized") + return cciptypes.OnRampDynamicConfig{}, errors.New("onramp not initialized") } config, err := o.onRamp.GetDynamicConfig(&bind.CallOpts{Context: ctx}) if err != nil { 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 1147dc2b8b5..5818f095ea0 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 @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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" diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/commit_store.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/commit_store.go index d5545174cb8..a403139a015 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/commit_store.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/commit_store.go @@ -10,10 +10,10 @@ import ( cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "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/commit_store" - "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0" ) diff --git a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/offramp.go b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/offramp.go index 11e7be1a55c..d5e220c27b1 100644 --- a/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/offramp.go +++ b/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_5_0/offramp.go @@ -9,13 +9,13 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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/evm_2_evm_offramp" "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" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/cache" 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 fe37e64648a..b8cec9aea1f 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 @@ -11,13 +11,13 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/smartcontractkit/chainlink-common/pkg/hashutil" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_contract" - "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/internal/cache" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc" diff --git a/core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go b/core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go index 2d27dd19198..732bbb6be4c 100644 --- a/core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go +++ b/core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go @@ -13,7 +13,8 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types" cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/aggregator_v3_interface" + + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/aggregator_v3_interface" "github.com/smartcontractkit/chainlink/v2/core/internal/gethwrappers2/generated/offchainaggregator" "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/pricegetter/evm_test.go b/core/services/ocr2/plugins/ccip/internal/pricegetter/evm_test.go index b22f99034e6..ada59d68573 100644 --- a/core/services/ocr2/plugins/ccip/internal/pricegetter/evm_test.go +++ b/core/services/ocr2/plugins/ccip/internal/pricegetter/evm_test.go @@ -1,17 +1,15 @@ package pricegetter import ( + "context" "fmt" "math/big" "testing" - "github.com/smartcontractkit/chainlink/v2/core/capabilities/targets/mocks" - "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" @@ -198,10 +196,10 @@ func testParamAggregatorOnly(t *testing.T) testParameters { AnsweredInRound: big.NewInt(4000), } contractReaders := map[uint64]types.ContractReader{ - uint64(101): mockCR(t, []uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), - uint64(102): mockCR(t, []uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), - uint64(103): mockCR(t, []uint8{18}, cfg, []common.Address{TK3}, []aggregator_v3_interface.LatestRoundData{round3}), - uint64(104): mockCR(t, []uint8{20}, cfg, []common.Address{TK4}, []aggregator_v3_interface.LatestRoundData{round4}), + uint64(101): mockCR([]uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), + uint64(102): mockCR([]uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), + uint64(103): mockCR([]uint8{18}, cfg, []common.Address{TK3}, []aggregator_v3_interface.LatestRoundData{round3}), + uint64(104): mockCR([]uint8{20}, cfg, []common.Address{TK4}, []aggregator_v3_interface.LatestRoundData{round4}), } expectedTokenPrices := map[common.Address]big.Int{ TK1: *multExp(round1.Answer, 10), // expected in 1e18 format. @@ -261,8 +259,8 @@ func testParamAggregatorOnlyMulti(t *testing.T) testParameters { AnsweredInRound: big.NewInt(3000), } contractReaders := map[uint64]types.ContractReader{ - uint64(101): mockCR(t, []uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), - uint64(102): mockCR(t, []uint8{8, 8}, cfg, []common.Address{TK2, TK3}, []aggregator_v3_interface.LatestRoundData{round2, round3}), + uint64(101): mockCR([]uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), + uint64(102): mockCR([]uint8{8, 8}, cfg, []common.Address{TK2, TK3}, []aggregator_v3_interface.LatestRoundData{round2, round3}), } expectedTokenPrices := map[common.Address]big.Int{ TK1: *multExp(round1.Answer, 10), @@ -347,8 +345,8 @@ func testParamNoAggregatorForToken(t *testing.T) testParameters { AnsweredInRound: big.NewInt(2000), } contractReaders := map[uint64]types.ContractReader{ - uint64(101): mockCR(t, []uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), - uint64(102): mockCR(t, []uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), + uint64(101): mockCR([]uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), + uint64(102): mockCR([]uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), } expectedTokenPrices := map[common.Address]big.Int{ TK1: *round1.Answer, @@ -401,8 +399,8 @@ func testParamAggregatorAndStaticValid(t *testing.T) testParameters { AnsweredInRound: big.NewInt(2000), } contractReaders := map[uint64]types.ContractReader{ - uint64(101): mockCR(t, []uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), - uint64(102): mockCR(t, []uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), + uint64(101): mockCR([]uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), + uint64(102): mockCR([]uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), } expectedTokenPrices := map[common.Address]big.Int{ TK1: *multExp(round1.Answer, 10), @@ -464,9 +462,9 @@ func testParamAggregatorAndStaticTokenCollision(t *testing.T) testParameters { AnsweredInRound: big.NewInt(3000), } contractReaders := map[uint64]types.ContractReader{ - uint64(101): mockCR(t, []uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), - uint64(102): mockCR(t, []uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), - uint64(103): mockCR(t, []uint8{8}, cfg, []common.Address{TK3}, []aggregator_v3_interface.LatestRoundData{round3}), + uint64(101): mockCR([]uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), + uint64(102): mockCR([]uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), + uint64(103): mockCR([]uint8{8}, cfg, []common.Address{TK3}, []aggregator_v3_interface.LatestRoundData{round3}), } return testParameters{ cfg: cfg, @@ -504,8 +502,8 @@ func testParamBatchCallReturnsErr(t *testing.T) testParameters { AnsweredInRound: big.NewInt(1000), } contractReaders := map[uint64]types.ContractReader{ - uint64(101): mockCR(t, []uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), - uint64(102): mockErrCR(t), + uint64(101): mockCR([]uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), + uint64(102): mockErrCR(), } return testParameters{ cfg: cfg, @@ -563,9 +561,9 @@ func testLessInputsThanDefinedPrices(t *testing.T) testParameters { AnsweredInRound: big.NewInt(3000), } contractReaders := map[uint64]types.ContractReader{ - uint64(101): mockCR(t, []uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), - uint64(102): mockCR(t, []uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), - uint64(103): mockCR(t, []uint8{8}, cfg, []common.Address{TK3}, []aggregator_v3_interface.LatestRoundData{round3}), + uint64(101): mockCR([]uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), + uint64(102): mockCR([]uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), + uint64(103): mockCR([]uint8{8}, cfg, []common.Address{TK3}, []aggregator_v3_interface.LatestRoundData{round3}), } expectedTokenPrices := map[common.Address]big.Int{ TK1: *multExp(round1.Answer, 10), @@ -627,10 +625,11 @@ func testGetAllTokensAggregatorAndStatic(t *testing.T) testParameters { UpdatedAt: big.NewInt(1715743907), AnsweredInRound: big.NewInt(3000), } + contractReaders := map[uint64]types.ContractReader{ - uint64(101): mockCR(t, []uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), - uint64(102): mockCR(t, []uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), - uint64(103): mockCR(t, []uint8{8}, cfg, []common.Address{TK3}, []aggregator_v3_interface.LatestRoundData{round3}), + uint64(101): mockCR([]uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), + uint64(102): mockCR([]uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), + uint64(103): mockCR([]uint8{8}, cfg, []common.Address{TK3}, []aggregator_v3_interface.LatestRoundData{round3}), } expectedTokenPricesForAll := map[common.Address]big.Int{ TK1: *multExp(round1.Answer, 10), @@ -688,9 +687,9 @@ func testGetAllTokensAggregatorOnly(t *testing.T) testParameters { AnsweredInRound: big.NewInt(3000), } contractReaders := map[uint64]types.ContractReader{ - uint64(101): mockCR(t, []uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), - uint64(102): mockCR(t, []uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), - uint64(103): mockCR(t, []uint8{8}, cfg, []common.Address{TK3}, []aggregator_v3_interface.LatestRoundData{round3}), + uint64(101): mockCR([]uint8{8}, cfg, []common.Address{TK1}, []aggregator_v3_interface.LatestRoundData{round1}), + uint64(102): mockCR([]uint8{8}, cfg, []common.Address{TK2}, []aggregator_v3_interface.LatestRoundData{round2}), + uint64(103): mockCR([]uint8{8}, cfg, []common.Address{TK3}, []aggregator_v3_interface.LatestRoundData{round3}), } expectedTokenPricesForAll := map[common.Address]big.Int{ @@ -737,9 +736,7 @@ func testGetAllTokensStaticOnly(t *testing.T) testParameters { } } -func mockCR(t *testing.T, decimals []uint8, cfg config.DynamicPriceGetterConfig, addr []common.Address, rounds []aggregator_v3_interface.LatestRoundData) *mocks.ContractReader { - caller := mocks.NewContractReader(t) - +func mockCR(decimals []uint8, cfg config.DynamicPriceGetterConfig, addr []common.Address, rounds []aggregator_v3_interface.LatestRoundData) *mockContractReader { // Mock batch calls per chain: all decimals calls then all latestRoundData calls. bGLVR := make(types.BatchGetLatestValuesResult) @@ -776,19 +773,31 @@ func mockCR(t *testing.T, decimals []uint8, cfg config.DynamicPriceGetterConfig, bGLVR[boundContract] = append(bGLVR[boundContract], readRes) } - caller.On("Bind", mock.Anything, mock.Anything).Return(nil).Maybe() - caller.On("BatchGetLatestValues", mock.Anything, mock.Anything).Return(bGLVR, nil).Maybe() - return caller + return &mockContractReader{result: bGLVR} } -func mockErrCR(t *testing.T) *mocks.ContractReader { - caller := mocks.NewContractReader(t) - caller.On("Bind", mock.Anything, mock.Anything).Return(nil).Maybe() - caller.On("BatchGetLatestValues", mock.Anything, mock.Anything).Return(nil, assert.AnError).Maybe() - return caller +func mockErrCR() *mockContractReader { + return &mockContractReader{err: assert.AnError} } // multExp returns the result of multiplying x by 10^e. func multExp(x *big.Int, e int64) *big.Int { return big.NewInt(0).Mul(x, big.NewInt(0).Exp(big.NewInt(10), big.NewInt(e), nil)) } + +type mockContractReader struct { + types.UnimplementedContractReader + result types.BatchGetLatestValuesResult + err error +} + +func (m *mockContractReader) Bind(context.Context, []types.BoundContract) error { + return nil +} + +func (m *mockContractReader) BatchGetLatestValues(context.Context, types.BatchGetLatestValuesRequest) (types.BatchGetLatestValuesResult, error) { + if m.err != nil { + return nil, m.err + } + return m.result, nil +} diff --git a/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline.go b/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline.go index 34977eda9f1..b9effffda15 100644 --- a/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline.go +++ b/core/services/ocr2/plugins/ccip/internal/pricegetter/pipeline.go @@ -10,8 +10,8 @@ import ( "github.com/google/uuid" "github.com/pkg/errors" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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/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/rpclib/evm.go b/core/services/ocr2/plugins/ccip/internal/rpclib/evm.go index 876d9fa7821..9fac4595464 100644 --- a/core/services/ocr2/plugins/ccip/internal/rpclib/evm.go +++ b/core/services/ocr2/plugins/ccip/internal/rpclib/evm.go @@ -13,7 +13,7 @@ import ( "github.com/pkg/errors" "golang.org/x/sync/errgroup" - "github.com/smartcontractkit/chainlink/v2/core/logger" + "github.com/smartcontractkit/chainlink-common/pkg/logger" ) var ErrEmptyOutput = errors.New("rpc call output is empty (make sure that the contract method exists and rpc is healthy)") 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 3ca3a53f78c..04002002f5c 100644 --- a/core/services/ocr2/plugins/ccip/prices/da_price_estimator.go +++ b/core/services/ocr2/plugins/ccip/prices/da_price_estimator.go @@ -60,7 +60,7 @@ func (g DAGasPriceEstimator) GetGasPrice(ctx context.Context) (*big.Int, error) gasPrice, daGasPrice, err = g.feeEstimatorConfig.ModifyGasPriceComponents(ctx, gasPrice, daGasPrice) if err != nil { - return nil, fmt.Errorf("gasPrice modification failed: %v", err) + return nil, fmt.Errorf("gasPrice modification failed: %w", err) } if daGasPrice.Cmp(big.NewInt(0)) > 0 { 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 4106d5beed5..aadf969eadd 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,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" @@ -489,7 +490,7 @@ func TestDAPriceEstimator_EstimateMsgCostUSD(t *testing.T) { ctx := tests.Context(t) execEstimator := NewMockGasPriceEstimator(t) - execEstimator.On("EstimateMsgCostUSD", mock.Anything, tc.wrappedNativePrice, tc.msg). + execEstimator.On("EstimateMsgCostUSD", mock.Anything, mock.Anything, tc.wrappedNativePrice, tc.msg). Return(execCostUSD, tc.execEstimatorErr) feeEstimatorConfig := ccipdatamocks.NewFeeEstimatorConfigReader(t) @@ -510,9 +511,9 @@ func TestDAPriceEstimator_EstimateMsgCostUSD(t *testing.T) { switch { case len(tc.execEstimatorResponse) == 4 && tc.execEstimatorResponse[3] != nil, tc.execEstimatorErr != nil: - assert.Error(t, err) + require.Error(t, err) default: - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, tc.expUSD, costUSD) } }) diff --git a/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go b/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go index 6364cc67b79..9238d453966 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/ccip_contracts.go @@ -149,20 +149,20 @@ func (c ExecOffchainConfig) Encode() ([]byte, error) { } func NewExecOffchainConfig( - DestOptimisticConfirmations uint32, - BatchGasLimit uint32, - RelativeBoostPerWaitHour float64, - InflightCacheExpiry config.Duration, - RootSnoozeTime config.Duration, - BatchingStrategyID uint32, // 0 = Standard, 1 = Out of Order + destOptimisticConfirmations uint32, + batchGasLimit uint32, + relativeBoostPerWaitHour float64, + inflightCacheExpiry config.Duration, + rootSnoozeTime config.Duration, + batchingStrategyID uint32, // 0 = Standard, 1 = Out of Order ) ExecOffchainConfig { return ExecOffchainConfig{v1_2_0.JSONExecOffchainConfig{ - DestOptimisticConfirmations: DestOptimisticConfirmations, - BatchGasLimit: BatchGasLimit, - RelativeBoostPerWaitHour: RelativeBoostPerWaitHour, - InflightCacheExpiry: InflightCacheExpiry, - RootSnoozeTime: RootSnoozeTime, - BatchingStrategyID: BatchingStrategyID, + DestOptimisticConfirmations: destOptimisticConfirmations, + BatchGasLimit: batchGasLimit, + RelativeBoostPerWaitHour: relativeBoostPerWaitHour, + InflightCacheExpiry: inflightCacheExpiry, + RootSnoozeTime: rootSnoozeTime, + BatchingStrategyID: batchingStrategyID, }} } diff --git a/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go b/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go index e15a221a5db..b1c3677e497 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go @@ -532,12 +532,12 @@ func setupNodeCCIP( return app, peerID.Raw(), transmitter, kb } -func createConfigV2Chain(chainId *big.Int, finalityDepth uint32) *v2.EVMConfig { +func createConfigV2Chain(chainID *big.Int, finalityDepth uint32) *v2.EVMConfig { // NOTE: For the executor jobs, the default of 500k is insufficient for a 3 message batch defaultGasLimit := uint64(5000000) tr := true - sourceC := v2.Defaults((*evmUtils.Big)(chainId)) + sourceC := v2.Defaults((*evmUtils.Big)(chainID)) sourceC.GasEstimator.LimitDefault = &defaultGasLimit fixedPrice := "FixedPrice" sourceC.GasEstimator.Mode = &fixedPrice @@ -545,7 +545,7 @@ func createConfigV2Chain(chainId *big.Int, finalityDepth uint32) *v2.EVMConfig { sourceC.LogPollInterval = &d sourceC.FinalityDepth = &finalityDepth return &v2.EVMConfig{ - ChainID: (*evmUtils.Big)(chainId), + ChainID: (*evmUtils.Big)(chainID), Enabled: &tr, Chain: sourceC, Nodes: v2.EVMNodes{&v2.Node{}}, @@ -558,10 +558,10 @@ type CCIPIntegrationTestHarness struct { Bootstrap Node } -func SetupCCIPIntegrationTH(t *testing.T, sourceChainID, sourceChainSelector, destChainId, destChainSelector uint64, +func SetupCCIPIntegrationTH(t *testing.T, sourceChainID, sourceChainSelector, destChainID, destChainSelector uint64, sourceFinalityDepth, destFinalityDepth uint32) CCIPIntegrationTestHarness { return CCIPIntegrationTestHarness{ - CCIPContracts: testhelpers.SetupCCIPContracts(t, sourceChainID, sourceChainSelector, destChainId, + CCIPContracts: testhelpers.SetupCCIPContracts(t, sourceChainID, sourceChainSelector, destChainID, destChainSelector, sourceFinalityDepth, destFinalityDepth), } } diff --git a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/ccip_contracts_1_4_0.go b/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/ccip_contracts_1_4_0.go index 9906a7b365a..2c414908f4c 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/ccip_contracts_1_4_0.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/ccip_contracts_1_4_0.go @@ -91,20 +91,21 @@ func (c CommitOffchainConfig) Encode() ([]byte, error) { } func NewCommitOffchainConfig( - GasPriceHeartBeat config.Duration, - DAGasPriceDeviationPPB uint32, - ExecGasPriceDeviationPPB uint32, - TokenPriceHeartBeat config.Duration, - TokenPriceDeviationPPB uint32, - InflightCacheExpiry config.Duration, - priceReportingDisabled bool) CommitOffchainConfig { + gasPriceHeartBeat config.Duration, + daGasPriceDeviationPPB uint32, + execGasPriceDeviationPPB uint32, + tokenPriceHeartBeat config.Duration, + tokenPriceDeviationPPB uint32, + inflightCacheExpiry config.Duration, + priceReportingDisabled bool, +) CommitOffchainConfig { return CommitOffchainConfig{v1_2_0.JSONCommitOffchainConfig{ - GasPriceHeartBeat: GasPriceHeartBeat, - DAGasPriceDeviationPPB: DAGasPriceDeviationPPB, - ExecGasPriceDeviationPPB: ExecGasPriceDeviationPPB, - TokenPriceHeartBeat: TokenPriceHeartBeat, - TokenPriceDeviationPPB: TokenPriceDeviationPPB, - InflightCacheExpiry: InflightCacheExpiry, + GasPriceHeartBeat: gasPriceHeartBeat, + DAGasPriceDeviationPPB: daGasPriceDeviationPPB, + ExecGasPriceDeviationPPB: execGasPriceDeviationPPB, + TokenPriceHeartBeat: tokenPriceHeartBeat, + TokenPriceDeviationPPB: tokenPriceDeviationPPB, + InflightCacheExpiry: inflightCacheExpiry, PriceReportingDisabled: priceReportingDisabled, }} } @@ -114,10 +115,10 @@ type CommitOnchainConfig struct { } func NewCommitOnchainConfig( - PriceRegistry common.Address, + priceRegistry common.Address, ) CommitOnchainConfig { return CommitOnchainConfig{ccipdata.CommitOnchainConfig{ - PriceRegistry: PriceRegistry, + PriceRegistry: priceRegistry, }} } @@ -126,20 +127,20 @@ type ExecOnchainConfig struct { } func NewExecOnchainConfig( - PermissionLessExecutionThresholdSeconds uint32, - Router common.Address, - PriceRegistry common.Address, - MaxNumberOfTokensPerMsg uint16, - MaxDataBytes uint32, - MaxPoolReleaseOrMintGas uint32, + permissionLessExecutionThresholdSeconds uint32, + router common.Address, + priceRegistry common.Address, + maxNumberOfTokensPerMsg uint16, + maxDataBytes uint32, + maxPoolReleaseOrMintGas uint32, ) ExecOnchainConfig { return ExecOnchainConfig{v1_2_0.ExecOnchainConfig{ - PermissionLessExecutionThresholdSeconds: PermissionLessExecutionThresholdSeconds, - Router: Router, - PriceRegistry: PriceRegistry, - MaxNumberOfTokensPerMsg: MaxNumberOfTokensPerMsg, - MaxDataBytes: MaxDataBytes, - MaxPoolReleaseOrMintGas: MaxPoolReleaseOrMintGas, + PermissionLessExecutionThresholdSeconds: permissionLessExecutionThresholdSeconds, + Router: router, + PriceRegistry: priceRegistry, + MaxNumberOfTokensPerMsg: maxNumberOfTokensPerMsg, + MaxDataBytes: maxDataBytes, + MaxPoolReleaseOrMintGas: maxPoolReleaseOrMintGas, }} } @@ -152,20 +153,20 @@ func (c ExecOffchainConfig) Encode() ([]byte, error) { } func NewExecOffchainConfig( - DestOptimisticConfirmations uint32, - BatchGasLimit uint32, - RelativeBoostPerWaitHour float64, - InflightCacheExpiry config.Duration, - RootSnoozeTime config.Duration, - BatchingStrategyID uint32, + destOptimisticConfirmations uint32, + batchGasLimit uint32, + relativeBoostPerWaitHour float64, + inflightCacheExpiry config.Duration, + rootSnoozeTime config.Duration, + batchingStrategyID uint32, ) ExecOffchainConfig { return ExecOffchainConfig{v1_2_0.JSONExecOffchainConfig{ - DestOptimisticConfirmations: DestOptimisticConfirmations, - BatchGasLimit: BatchGasLimit, - RelativeBoostPerWaitHour: RelativeBoostPerWaitHour, - InflightCacheExpiry: InflightCacheExpiry, - RootSnoozeTime: RootSnoozeTime, - BatchingStrategyID: BatchingStrategyID, + DestOptimisticConfirmations: destOptimisticConfirmations, + BatchGasLimit: batchGasLimit, + RelativeBoostPerWaitHour: relativeBoostPerWaitHour, + InflightCacheExpiry: inflightCacheExpiry, + RootSnoozeTime: rootSnoozeTime, + BatchingStrategyID: batchingStrategyID, }} } @@ -185,7 +186,7 @@ type Common struct { WrappedNative *weth9.WETH9 WrappedNativePool *lock_release_token_pool_1_0_0.LockReleaseTokenPool ARM *mock_rmn_contract.MockRMNContract - ARMProxy *rmn_proxy_contract.RMNProxyContract + ARMProxy *rmn_proxy_contract.RMNProxy PriceRegistry *price_registry_1_2_0.PriceRegistry } @@ -516,6 +517,7 @@ func (c *CCIPContracts) DeriveOCR2Config(t *testing.T, oracles []confighelper.Or []int{1, 1, 1, 1}, oracles, rawOffchainConfig, + nil, 50*time.Millisecond, // Max duration query 1*time.Second, // Max duration observation 100*time.Millisecond, @@ -688,7 +690,7 @@ func (c *CCIPContracts) SetupLockAndMintTokenPool( return [20]byte{}, nil, err } - //native token is used as fee token + // native token is used as fee token _, err = c.Source.PriceRegistry.UpdatePrices(c.Source.User, price_registry_1_2_0.InternalPriceUpdates{ TokenPriceUpdates: []price_registry_1_2_0.InternalTokenPriceUpdate{ { @@ -793,60 +795,60 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh armSourceAddress, _, _, err := mock_rmn_contract.DeployMockRMNContract( sourceUser, - sourceChain, + sourceChain.Client(), ) require.NoError(t, err) - sourceARM, err := mock_rmn_contract.NewMockRMNContract(armSourceAddress, sourceChain) + sourceARM, err := mock_rmn_contract.NewMockRMNContract(armSourceAddress, sourceChain.Client()) require.NoError(t, err) - armProxySourceAddress, _, _, err := rmn_proxy_contract.DeployRMNProxyContract( + armProxySourceAddress, _, _, err := rmn_proxy_contract.DeployRMNProxy( sourceUser, - sourceChain, + sourceChain.Client(), armSourceAddress, ) require.NoError(t, err) - sourceARMProxy, err := rmn_proxy_contract.NewRMNProxyContract(armProxySourceAddress, sourceChain) + sourceARMProxy, err := rmn_proxy_contract.NewRMNProxy(armProxySourceAddress, sourceChain.Client()) require.NoError(t, err) sourceChain.Commit() armDestAddress, _, _, err := mock_rmn_contract.DeployMockRMNContract( destUser, - destChain, + destChain.Client(), ) require.NoError(t, err) - armProxyDestAddress, _, _, err := rmn_proxy_contract.DeployRMNProxyContract( + armProxyDestAddress, _, _, err := rmn_proxy_contract.DeployRMNProxy( destUser, - destChain, + destChain.Client(), armDestAddress, ) require.NoError(t, err) destChain.Commit() - destARM, err := mock_rmn_contract.NewMockRMNContract(armDestAddress, destChain) + destARM, err := mock_rmn_contract.NewMockRMNContract(armDestAddress, destChain.Client()) require.NoError(t, err) - destARMProxy, err := rmn_proxy_contract.NewRMNProxyContract(armProxyDestAddress, destChain) + destARMProxy, err := rmn_proxy_contract.NewRMNProxy(armProxyDestAddress, destChain.Client()) require.NoError(t, err) // Deploy link token and pool on source chain - sourceLinkTokenAddress, _, _, err := link_token_interface.DeployLinkToken(sourceUser, sourceChain) + sourceLinkTokenAddress, _, _, err := link_token_interface.DeployLinkToken(sourceUser, sourceChain.Client()) require.NoError(t, err) sourceChain.Commit() - sourceLinkToken, err := link_token_interface.NewLinkToken(sourceLinkTokenAddress, sourceChain) + sourceLinkToken, err := link_token_interface.NewLinkToken(sourceLinkTokenAddress, sourceChain.Client()) require.NoError(t, err) // Create router - sourceWeth9addr, _, _, err := weth9.DeployWETH9(sourceUser, sourceChain) + sourceWeth9addr, _, _, err := weth9.DeployWETH9(sourceUser, sourceChain.Client()) require.NoError(t, err) - sourceWrapped, err := weth9.NewWETH9(sourceWeth9addr, sourceChain) + sourceWrapped, err := weth9.NewWETH9(sourceWeth9addr, sourceChain.Client()) require.NoError(t, err) - sourceRouterAddress, _, _, err := router.DeployRouter(sourceUser, sourceChain, sourceWeth9addr, armProxySourceAddress) + sourceRouterAddress, _, _, err := router.DeployRouter(sourceUser, sourceChain.Client(), sourceWeth9addr, armProxySourceAddress) require.NoError(t, err) - sourceRouter, err := router.NewRouter(sourceRouterAddress, sourceChain) + sourceRouter, err := router.NewRouter(sourceRouterAddress, sourceChain.Client()) require.NoError(t, err) sourceChain.Commit() sourceWeth9PoolAddress, _, _, err := lock_release_token_pool_1_0_0.DeployLockReleaseTokenPool( sourceUser, - sourceChain, + sourceChain.Client(), sourceWeth9addr, []common.Address{}, armProxySourceAddress, @@ -854,12 +856,12 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh require.NoError(t, err) sourceChain.Commit() - sourceWeth9Pool, err := lock_release_token_pool_1_0_0.NewLockReleaseTokenPool(sourceWeth9PoolAddress, sourceChain) + sourceWeth9Pool, err := lock_release_token_pool_1_0_0.NewLockReleaseTokenPool(sourceWeth9PoolAddress, sourceChain.Client()) require.NoError(t, err) sourcePoolAddress, _, _, err := lock_release_token_pool.DeployLockReleaseTokenPool( sourceUser, - sourceChain, + sourceChain.Client(), sourceLinkTokenAddress, []common.Address{}, armProxySourceAddress, @@ -868,34 +870,34 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh ) require.NoError(t, err) sourceChain.Commit() - sourcePool, err := lock_release_token_pool.NewLockReleaseTokenPool(sourcePoolAddress, sourceChain) + sourcePool, err := lock_release_token_pool.NewLockReleaseTokenPool(sourcePoolAddress, sourceChain.Client()) require.NoError(t, err) // Deploy custom token pool source - sourceCustomTokenAddress, _, _, err := link_token_interface.DeployLinkToken(sourceUser, sourceChain) // Just re-use this, it's an ERC20. + sourceCustomTokenAddress, _, _, err := link_token_interface.DeployLinkToken(sourceUser, sourceChain.Client()) // Just re-use this, it's an ERC20. require.NoError(t, err) - sourceCustomToken, err := link_token_interface.NewLinkToken(sourceCustomTokenAddress, sourceChain) + sourceCustomToken, err := link_token_interface.NewLinkToken(sourceCustomTokenAddress, sourceChain.Client()) require.NoError(t, err) destChain.Commit() // Deploy custom token pool dest - destCustomTokenAddress, _, _, err := link_token_interface.DeployLinkToken(destUser, destChain) // Just re-use this, it's an ERC20. + destCustomTokenAddress, _, _, err := link_token_interface.DeployLinkToken(destUser, destChain.Client()) // Just re-use this, it's an ERC20. require.NoError(t, err) - destCustomToken, err := link_token_interface.NewLinkToken(destCustomTokenAddress, destChain) + destCustomToken, err := link_token_interface.NewLinkToken(destCustomTokenAddress, destChain.Client()) require.NoError(t, err) destChain.Commit() // Deploy and configure onramp sourcePricesAddress, _, _, err := price_registry_1_2_0.DeployPriceRegistry( sourceUser, - sourceChain, + sourceChain.Client(), nil, []common.Address{sourceLinkTokenAddress, sourceWeth9addr}, 60*60*24*14, // two weeks ) require.NoError(t, err) - srcPriceRegistry, err := price_registry_1_2_0.NewPriceRegistry(sourcePricesAddress, sourceChain) + srcPriceRegistry, err := price_registry_1_2_0.NewPriceRegistry(sourcePricesAddress, sourceChain.Client()) require.NoError(t, err) _, err = srcPriceRegistry.UpdatePrices(sourceUser, price_registry_1_2_0.InternalPriceUpdates{ @@ -919,8 +921,8 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh require.NoError(t, err) onRampAddress, _, _, err := evm_2_evm_onramp.DeployEVM2EVMOnRamp( - sourceUser, // user - sourceChain, // client + sourceUser, // user + sourceChain.Client(), // client evm_2_evm_onramp.EVM2EVMOnRampStaticConfig{ LinkToken: sourceLinkTokenAddress, ChainSelector: sourceChainSelector, @@ -986,7 +988,7 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh []evm_2_evm_onramp.EVM2EVMOnRampNopAndWeight{}, ) require.NoError(t, err) - onRamp, err := evm_2_evm_onramp.NewEVM2EVMOnRamp(onRampAddress, sourceChain) + onRamp, err := evm_2_evm_onramp.NewEVM2EVMOnRamp(onRampAddress, sourceChain.Client()) require.NoError(t, err) _, err = sourcePool.ApplyChainUpdates( sourceUser, @@ -1022,27 +1024,27 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh require.NoError(t, err) sourceChain.Commit() - destWethaddr, _, _, err := weth9.DeployWETH9(destUser, destChain) + destWethaddr, _, _, err := weth9.DeployWETH9(destUser, destChain.Client()) require.NoError(t, err) - destWrapped, err := weth9.NewWETH9(destWethaddr, destChain) + destWrapped, err := weth9.NewWETH9(destWethaddr, destChain.Client()) require.NoError(t, err) // Create dest router - destRouterAddress, _, _, err := router.DeployRouter(destUser, destChain, destWethaddr, armProxyDestAddress) + destRouterAddress, _, _, err := router.DeployRouter(destUser, destChain.Client(), destWethaddr, armProxyDestAddress) require.NoError(t, err) destChain.Commit() - destRouter, err := router.NewRouter(destRouterAddress, destChain) + destRouter, err := router.NewRouter(destRouterAddress, destChain.Client()) require.NoError(t, err) // Deploy link token and pool on destination chain - destLinkTokenAddress, _, _, err := link_token_interface.DeployLinkToken(destUser, destChain) + destLinkTokenAddress, _, _, err := link_token_interface.DeployLinkToken(destUser, destChain.Client()) require.NoError(t, err) destChain.Commit() - destLinkToken, err := link_token_interface.NewLinkToken(destLinkTokenAddress, destChain) + destLinkToken, err := link_token_interface.NewLinkToken(destLinkTokenAddress, destChain.Client()) require.NoError(t, err) destPoolAddress, _, _, err := lock_release_token_pool.DeployLockReleaseTokenPool( destUser, - destChain, + destChain.Client(), destLinkTokenAddress, []common.Address{}, armProxyDestAddress, @@ -1051,7 +1053,7 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh ) require.NoError(t, err) destChain.Commit() - destPool, err := lock_release_token_pool.NewLockReleaseTokenPool(destPoolAddress, destChain) + destPool, err := lock_release_token_pool.NewLockReleaseTokenPool(destPoolAddress, destChain.Client()) require.NoError(t, err) destChain.Commit() @@ -1069,13 +1071,13 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh destWrappedPoolAddress, _, _, err := lock_release_token_pool_1_0_0.DeployLockReleaseTokenPool( destUser, - destChain, + destChain.Client(), destWethaddr, []common.Address{}, armProxyDestAddress, ) require.NoError(t, err) - destWrappedPool, err := lock_release_token_pool_1_0_0.NewLockReleaseTokenPool(destWrappedPoolAddress, destChain) + destWrappedPool, err := lock_release_token_pool_1_0_0.NewLockReleaseTokenPool(destWrappedPoolAddress, destChain.Client()) require.NoError(t, err) poolFloatValue := big.NewInt(1e18) @@ -1093,19 +1095,19 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh // Deploy and configure ge offramp. destPricesAddress, _, _, err := price_registry_1_2_0.DeployPriceRegistry( destUser, - destChain, + destChain.Client(), nil, []common.Address{destLinkTokenAddress}, 60*60*24*14, // two weeks ) require.NoError(t, err) - destPriceRegistry, err := price_registry_1_2_0.NewPriceRegistry(destPricesAddress, destChain) + destPriceRegistry, err := price_registry_1_2_0.NewPriceRegistry(destPricesAddress, destChain.Client()) require.NoError(t, err) // Deploy commit store. commitStoreAddress, _, _, err := commit_store_1_2_0.DeployCommitStore( - destUser, // user - destChain, // client + destUser, // user + destChain.Client(), // client commit_store_1_2_0.CommitStoreStaticConfig{ ChainSelector: destChainSelector, SourceChainSelector: sourceChainSelector, @@ -1115,12 +1117,12 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh ) require.NoError(t, err) destChain.Commit() - commitStore, err := commit_store_1_2_0.NewCommitStore(commitStoreAddress, destChain) + commitStore, err := commit_store_1_2_0.NewCommitStore(commitStoreAddress, destChain.Client()) require.NoError(t, err) offRampAddress, _, _, err := evm_2_evm_offramp.DeployEVM2EVMOffRamp( destUser, - destChain, + destChain.Client(), evm_2_evm_offramp.EVM2EVMOffRampStaticConfig{ CommitStore: commitStore.Address(), ChainSelector: destChainSelector, @@ -1138,7 +1140,7 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh }, ) require.NoError(t, err) - offRamp, err := evm_2_evm_offramp.NewEVM2EVMOffRamp(offRampAddress, destChain) + offRamp, err := evm_2_evm_offramp.NewEVM2EVMOffRamp(offRampAddress, destChain.Client()) require.NoError(t, err) _, err = destPool.ApplyChainUpdates(destUser, []lock_release_token_pool.TokenPoolChainUpdate{{ @@ -1180,12 +1182,12 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh require.NoError(t, err) // Deploy 2 revertable (one SS one non-SS) - revertingMessageReceiver1Address, _, _, err := maybe_revert_message_receiver.DeployMaybeRevertMessageReceiver(destUser, destChain, false) + revertingMessageReceiver1Address, _, _, err := maybe_revert_message_receiver.DeployMaybeRevertMessageReceiver(destUser, destChain.Client(), false) require.NoError(t, err) - revertingMessageReceiver1, _ := maybe_revert_message_receiver.NewMaybeRevertMessageReceiver(revertingMessageReceiver1Address, destChain) - revertingMessageReceiver2Address, _, _, err := maybe_revert_message_receiver.DeployMaybeRevertMessageReceiver(destUser, destChain, false) + revertingMessageReceiver1, _ := maybe_revert_message_receiver.NewMaybeRevertMessageReceiver(revertingMessageReceiver1Address, destChain.Client()) + revertingMessageReceiver2Address, _, _, err := maybe_revert_message_receiver.DeployMaybeRevertMessageReceiver(destUser, destChain.Client(), false) require.NoError(t, err) - revertingMessageReceiver2, _ := maybe_revert_message_receiver.NewMaybeRevertMessageReceiver(revertingMessageReceiver2Address, destChain) + revertingMessageReceiver2, _ := maybe_revert_message_receiver.NewMaybeRevertMessageReceiver(revertingMessageReceiver2Address, destChain.Client()) // Need to commit here, or we will hit the block gas limit when deploying the executor sourceChain.Commit() destChain.Commit() @@ -1198,10 +1200,11 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh source := SourceChain{ Common: Common{ - ChainID: sourceChainID, - ChainSelector: sourceChainSelector, - User: sourceUser, - Chain: sourceChain, + ChainID: sourceChainID, + ChainSelector: sourceChainSelector, + User: sourceUser, + // FIXME + //Chain: sourceChain, LinkToken: sourceLinkToken, LinkTokenPool: sourcePool, CustomToken: sourceCustomToken, @@ -1216,10 +1219,11 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh } dest := DestinationChain{ Common: Common{ - ChainID: destChainID, - ChainSelector: destChainSelector, - User: destUser, - Chain: destChain, + ChainID: destChainID, + ChainSelector: destChainSelector, + User: destUser, + // FIXME + //Chain: destChain, LinkToken: destLinkToken, LinkTokenPool: destPool, CustomToken: destCustomToken, @@ -1244,7 +1248,8 @@ func SetupCCIPContracts(t *testing.T, sourceChainID, sourceChainSelector, destCh func (c *CCIPContracts) SendRequest(t *testing.T, msg router.ClientEVM2AnyMessage) *types.Transaction { tx, err := c.Source.Router.CcipSend(c.Source.User, c.Dest.ChainSelector, msg) require.NoError(t, err) - testhelpers.ConfirmTxs(t, []*types.Transaction{tx}, c.Source.Chain) + // FIXME + // testhelpers.ConfirmTxs(t, []*types.Transaction{tx}, c.Source.Chain) return tx } @@ -1314,6 +1319,7 @@ func (args *ManualExecArgs) ApproxDestStartBlock() error { minBlockNum := args.DestDeployedAt closestBlockNum := uint64(math.Floor((float64(maxBlockNum) + float64(minBlockNum)) / 2)) var closestBlockHdr *types.Header + //nolint:gosec // safe to casts in tests closestBlockHdr, err = args.DestChain.HeaderByNumber(context.Background(), big.NewInt(int64(closestBlockNum))) if err != nil { return err @@ -1327,6 +1333,7 @@ func (args *ManualExecArgs) ApproxDestStartBlock() error { } timeDiff := math.Abs(float64(closestBlockHdr.Time - sendTxTime)) // break if the difference in timestamp is lesser than 1 minute + //nolint:gocritic // tests if timeDiff < 60 { break } else if closestBlockHdr.Time > sendTxTime { @@ -1342,10 +1349,11 @@ func (args *ManualExecArgs) ApproxDestStartBlock() error { } for closestBlockHdr.Time > sendTxTime { - closestBlockNum = closestBlockNum - blockOffset + closestBlockNum -= blockOffset if closestBlockNum <= 0 { - return fmt.Errorf("approx destination blocknumber not found") + return errors.New("approx destination blocknumber not found") } + //nolint:gosec // safe to casts in tests closestBlockHdr, err = args.DestChain.HeaderByNumber(context.Background(), big.NewInt(int64(closestBlockNum))) if err != nil { return err @@ -1386,22 +1394,22 @@ func (args *ManualExecArgs) ExecuteManually() (*types.Transaction, error) { if args.SourceChainID == 0 || args.DestChainID == 0 || args.DestUser == nil { - return nil, fmt.Errorf("chain ids and owners are mandatory for source and dest chain") + return nil, errors.New("chain ids and owners are mandatory for source and dest chain") } if !common.IsHexAddress(args.CommitStore) || !common.IsHexAddress(args.OffRamp) || !common.IsHexAddress(args.OnRamp) { - return nil, fmt.Errorf("contract addresses must be valid hex address") + return nil, errors.New("contract addresses must be valid hex address") } if args.SendReqTxHash == "" { - return nil, fmt.Errorf("tx hash of ccip-send request are required") + return nil, errors.New("tx hash of ccip-send request are required") } if args.SourceStartBlock == nil { - return nil, fmt.Errorf("must provide the value of source block in/after which ccip-send tx was included") + return nil, errors.New("must provide the value of source block in/after which ccip-send tx was included") } if args.SeqNr == 0 { if args.SendReqLogIndex == 0 { - return nil, fmt.Errorf("must provide the value of log index of ccip-send request") + return nil, errors.New("must provide the value of log index of ccip-send request") } // locate seq nr from CCIPSendRequested log seqNr, err := args.FindSeqNrFromCCIPSendRequested() @@ -1451,7 +1459,7 @@ func (args *ManualExecArgs) execute(report *commit_store_1_2_0.CommitStoreCommit } leafHasher := v1_2_0.NewLeafHasher(args.SourceChainID, args.DestChainID, common.HexToAddress(args.OnRamp), mctx, onRampContract) if leafHasher == nil { - return nil, fmt.Errorf("unable to create leaf hasher") + return nil, errors.New("unable to create leaf hasher") } var leaves [][32]byte @@ -1523,7 +1531,7 @@ func (args *ManualExecArgs) execute(report *commit_store_1_2_0.CommitStoreCommit return nil, err } if tree.Root() != report.MerkleRoot { - return nil, fmt.Errorf("root doesn't match") + return nil, errors.New("root doesn't match") } proof, err := tree.Prove([]int{prove}) @@ -1555,19 +1563,21 @@ func (c *CCIPContracts) ExecuteMessage( sendReqReceipt, err := c.Source.Chain.TransactionReceipt(context.Background(), txHash) require.NoError(t, err) args := ManualExecArgs{ - SourceChainID: c.Source.ChainID, - DestChainID: c.Dest.ChainID, - DestUser: c.Dest.User, - SourceChain: c.Source.Chain, - DestChain: c.Dest.Chain, - SourceStartBlock: sendReqReceipt.BlockNumber, - DestStartBlock: destStartBlock, - DestLatestBlockNum: c.Dest.Chain.Blockchain().CurrentBlock().Number.Uint64(), - SendReqLogIndex: uint(req.LogIndex), - SendReqTxHash: txHash.String(), - CommitStore: c.Dest.CommitStore.Address().String(), - OnRamp: c.Source.OnRamp.Address().String(), - OffRamp: c.Dest.OffRamp.Address().String(), + SourceChainID: c.Source.ChainID, + DestChainID: c.Dest.ChainID, + DestUser: c.Dest.User, + SourceChain: c.Source.Chain, + DestChain: c.Dest.Chain, + SourceStartBlock: sendReqReceipt.BlockNumber, + DestStartBlock: destStartBlock, + // FIXME + //DestLatestBlockNum: c.Dest.Chain.Blockchain().CurrentBlock().Number.Uint64(), + //nolint:gosec // safe to casts in tests + SendReqLogIndex: uint(req.LogIndex), + SendReqTxHash: txHash.String(), + CommitStore: c.Dest.CommitStore.Address().String(), + OnRamp: c.Source.OnRamp.Address().String(), + OffRamp: c.Dest.OffRamp.Address().String(), } tx, err := args.ExecuteManually() require.NoError(t, err) diff --git a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go b/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go index 769874c6e41..9e53145a37d 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/chainlink.go @@ -37,6 +37,8 @@ import ( cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" + pb "github.com/smartcontractkit/chainlink-protos/orchestrator/feedsmanager" + evmcapabilities "github.com/smartcontractkit/chainlink/v2/core/capabilities" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" v2 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" @@ -54,7 +56,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" feeds2 "github.com/smartcontractkit/chainlink/v2/core/services/feeds" feedsMocks "github.com/smartcontractkit/chainlink/v2/core/services/feeds/mocks" - pb "github.com/smartcontractkit/chainlink/v2/core/services/feeds/proto" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" @@ -63,7 +64,6 @@ import ( ksMocks "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" "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" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/testhelpers" integrationtesthelpers "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/testhelpers/integration" @@ -183,7 +183,7 @@ func (node *Node) EventuallyNodeUsesUpdatedPriceRegistry(t *testing.T, ccipContr ccipContracts.Dest.Chain.Commit() log, err := c.LogPoller().LatestLogByEventSigWithConfs( testutils.Context(t), - v1_0_0.UsdPerUnitGasUpdated, + v1_2_0.UsdPerUnitGasUpdated, ccipContracts.Dest.PriceRegistry.Address(), 0, ) @@ -282,9 +282,9 @@ func (node *Node) EventuallyHasExecutedSeqNums(t *testing.T, ccipContracts *CCIP ccipContracts.Dest.Chain.Commit() lgs, err := c.LogPoller().IndexedLogsTopicRange( testutils.Context(t), - v1_0_0.ExecutionStateChangedEvent, + v1_2_0.ExecutionStateChangedEvent, offRamp, - v1_0_0.ExecutionStateChangedSeqNrIndex, + v1_2_0.ExecutionStateChangedSeqNrIndex, abihelpers.EvmWord(uint64(minSeqNum)), abihelpers.EvmWord(uint64(maxSeqNum)), 1, @@ -310,9 +310,9 @@ func (node *Node) ConsistentlySeqNumHasNotBeenExecuted(t *testing.T, ccipContrac ccipContracts.Dest.Chain.Commit() lgs, err := c.LogPoller().IndexedLogsTopicRange( testutils.Context(t), - v1_0_0.ExecutionStateChangedEvent, + v1_2_0.ExecutionStateChangedEvent, offRamp, - v1_0_0.ExecutionStateChangedSeqNrIndex, + v1_2_0.ExecutionStateChangedSeqNrIndex, abihelpers.EvmWord(uint64(seqNum)), abihelpers.EvmWord(uint64(seqNum)), 1, @@ -425,8 +425,8 @@ func setupNodeCCIP( // test, we fake different chainIDs using the wrapped sim cltest.SimulatedBackend so the RPC // appears to operate on different chainIDs and we use an EthKeyStoreSim wrapper which always // signs 1337 see https://github.com/smartcontractkit/chainlink-ccip/blob/a24dd436810250a458d27d8bb3fb78096afeb79c/core/services/ocr2/plugins/ccip/testhelpers/simulated_backend.go#L35 - sourceClient := client.NewSimulatedBackendClient(t, sourceChain, sourceChainID) - destClient := client.NewSimulatedBackendClient(t, destChain, destChainID) + sourceClient := client.NewSimulatedBackendClient(t, sourceChain.Backend, sourceChainID) + destClient := client.NewSimulatedBackendClient(t, destChain.Backend, destChainID) csaKeyStore := ksMocks.NewCSA(t) key, err := csakey.NewV2() @@ -456,7 +456,7 @@ func setupNodeCCIP( }, CSAETHKeystore: simEthKeyStore, } - loopRegistry := plugins.NewLoopRegistry(lggr.Named("LoopRegistry"), config.Tracing(), config.Telemetry()) + loopRegistry := plugins.NewLoopRegistry(lggr.Named("LoopRegistry"), config.Tracing(), config.Telemetry(), nil, "") relayerFactory := chainlink.RelayerFactory{ Logger: lggr, LoopRegistry: loopRegistry, @@ -486,7 +486,7 @@ func setupNodeCCIP( RestrictedHTTPClient: &http.Client{}, AuditLogger: audit.NoopLogger, MailMon: mailMon, - LoopRegistry: plugins.NewLoopRegistry(lggr, config.Tracing(), config.Telemetry()), + LoopRegistry: plugins.NewLoopRegistry(lggr, config.Tracing(), config.Telemetry(), nil, ""), }) ctx := testutils.Context(t) require.NoError(t, err) diff --git a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/config_1_4_0.go b/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/config_1_4_0.go index 087c21e9333..adfdfd9283e 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/config_1_4_0.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/testhelpers_1_4_0/config_1_4_0.go @@ -1,5 +1,6 @@ -// Package with set of configs that should be used only within tests suites - +// Package testhelpers_1_4_0 pkg with set of configs that should be used only within tests suites +// +//nolint:revive // used in tests package testhelpers_1_4_0 import ( diff --git a/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc.go b/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc.go index 86d3c71e621..f0ddcbd9dce 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc.go +++ b/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc.go @@ -14,8 +14,8 @@ import ( "github.com/pkg/errors" "golang.org/x/time/rate" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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/abihelpers" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/tokendata" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/tokendata/http" @@ -57,8 +57,8 @@ var ( type TokenDataReader struct { lggr logger.Logger httpClient http.IHttpClient - attestationApi *url.URL - attestationApiTimeout time.Duration + attestationAPI *url.URL + attestationAPITimeout time.Duration lbtcTokenAddress common.Address rate *rate.Limiter @@ -117,13 +117,13 @@ var _ tokendata.Reader = &TokenDataReader{} func NewLBTCTokenDataReader( lggr logger.Logger, - lbtcAttestationApi *url.URL, - lbtcAttestationApiTimeoutSeconds int, + lbtcAttestationAPI *url.URL, + lbtcAttestationAPITimeoutSeconds int, lbtcTokenAddress common.Address, requestInterval time.Duration, ) *TokenDataReader { - timeout := time.Duration(lbtcAttestationApiTimeoutSeconds) * time.Second - if lbtcAttestationApiTimeoutSeconds == 0 { + timeout := time.Duration(lbtcAttestationAPITimeoutSeconds) * time.Second + if lbtcAttestationAPITimeoutSeconds == 0 { timeout = defaultAttestationTimeout } @@ -136,15 +136,15 @@ func NewLBTCTokenDataReader( return &TokenDataReader{ lggr: lggr, httpClient: http.NewObservedLbtcIHttpClient(&http.HttpClient{}), - attestationApi: lbtcAttestationApi, - attestationApiTimeout: timeout, + attestationAPI: lbtcAttestationAPI, + attestationAPITimeout: timeout, lbtcTokenAddress: lbtcTokenAddress, coolDownMu: &sync.RWMutex{}, rate: rate.NewLimiter(rate.Every(requestInterval), 1), } } -func NewLBTCTokenDataReaderWithHttpClient( +func NewLBTCTokenDataReaderWithHTTPClient( origin TokenDataReader, httpClient http.IHttpClient, lbtcTokenAddress common.Address, @@ -153,8 +153,8 @@ func NewLBTCTokenDataReaderWithHttpClient( return &TokenDataReader{ lggr: origin.lggr, httpClient: httpClient, - attestationApi: origin.attestationApi, - attestationApiTimeout: origin.attestationApiTimeout, + attestationAPI: origin.attestationAPI, + attestationAPITimeout: origin.attestationAPITimeout, coolDownMu: origin.coolDownMu, lbtcTokenAddress: lbtcTokenAddress, rate: rate.NewLimiter(rate.Every(requestInterval), 1), @@ -199,11 +199,11 @@ func (s *TokenDataReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2E payloadHashHex := hexutil.Encode(payloadHash[:]) s.lggr.Infow("Calling attestation API", "messageBodyHash", payloadHashHex, "messageID", msgID) - attestationResp, err := s.callAttestationApi(ctx, payloadHash) + attestationResp, err := s.callAttestationAPI(ctx, payloadHash) if err != nil { return nil, errors.Wrap(err, "failed calling lbtc attestation API") } - if attestationResp.Attestations == nil || len(attestationResp.Attestations) == 0 { + if len(attestationResp.Attestations) == 0 { return nil, errors.New("attestation response is empty") } if len(attestationResp.Attestations) > 1 { @@ -237,15 +237,15 @@ func (s *TokenDataReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2E } } -func (s *TokenDataReader) callAttestationApi(ctx context.Context, lbtcMessageHash [32]byte) (attestationResponse, error) { - attestationUrl := fmt.Sprintf("%s/bridge/%s/%s", s.attestationApi.String(), apiVersion, attestationPath) +func (s *TokenDataReader) callAttestationAPI(ctx context.Context, lbtcMessageHash [32]byte) (attestationResponse, error) { + attestationURL := fmt.Sprintf("%s/bridge/%s/%s", s.attestationAPI.String(), apiVersion, attestationPath) request := attestationRequest{PayloadHashes: []string{hexutil.Encode(lbtcMessageHash[:])}} encodedRequest, err := json.Marshal(request) requestBuffer := bytes.NewBuffer(encodedRequest) if err != nil { return attestationResponse{}, err } - respRaw, _, _, err := s.httpClient.Post(ctx, attestationUrl, requestBuffer, s.attestationApiTimeout) + respRaw, _, _, err := s.httpClient.Post(ctx, attestationURL, requestBuffer, s.attestationAPITimeout) switch { case errors.Is(err, tokendata.ErrRateLimit): s.setCoolDownPeriod(defaultCoolDownDuration) diff --git a/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc_test.go b/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc_test.go index 8b65685faa1..b68aea37ace 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc_test.go +++ b/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc_test.go @@ -38,6 +38,7 @@ func getMockLBTCEndpoint(t *testing.T, response attestationResponse) *httptest.S return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { _, err := w.Write(responseBytes) + //nolint:testifylint // we need to use require here require.NoError(t, err) })) } @@ -49,7 +50,7 @@ func TestLBTCReader_callAttestationApi(t *testing.T) { lggr := logger.TestLogger(t) lbtcService := NewLBTCTokenDataReader(lggr, attestationURI, 0, common.Address{}, APIIntervalRateLimitDisabled) - attestation, err := lbtcService.callAttestationApi(context.Background(), [32]byte(common.FromHex(lbtcMessageHash))) + attestation, err := lbtcService.callAttestationAPI(context.Background(), [32]byte(common.FromHex(lbtcMessageHash))) require.NoError(t, err) require.Equal(t, lbtcMessageHash, attestation.Attestations[0].MessageHash) @@ -75,7 +76,7 @@ func TestLBTCReader_callAttestationApiMock(t *testing.T) { lggr := logger.TestLogger(t) lbtcService := NewLBTCTokenDataReader(lggr, attestationURI, 0, common.Address{}, APIIntervalRateLimitDisabled) - attestation, err := lbtcService.callAttestationApi(context.Background(), [32]byte(common.FromHex(lbtcMessageHash))) + attestation, err := lbtcService.callAttestationAPI(context.Background(), [32]byte(common.FromHex(lbtcMessageHash))) require.NoError(t, err) require.Equal(t, response.Attestations[0].Status, attestation.Attestations[0].Status) @@ -177,7 +178,7 @@ func TestLBTCReader_callAttestationApiMockError(t *testing.T) { parentCtx, cancel := context.WithTimeout(context.Background(), time.Duration(test.parentTimeoutSeconds)*time.Second) defer cancel() - _, err = lbtcService.callAttestationApi(parentCtx, [32]byte(common.FromHex(lbtcMessageHash))) + _, err = lbtcService.callAttestationAPI(parentCtx, [32]byte(common.FromHex(lbtcMessageHash))) require.Error(t, err) if test.expectedError != nil { @@ -269,7 +270,7 @@ func TestLBTCReader_rateLimiting(t *testing.T) { trigger := make(chan struct{}) errorChan := make(chan error, tc.requests) wg := sync.WaitGroup{} - for i := 0; i < int(tc.requests); i++ { + for i := uint64(0); i < tc.requests; i++ { wg.Add(1) go func() { defer wg.Done() @@ -298,6 +299,7 @@ func TestLBTCReader_rateLimiting(t *testing.T) { // Collect errors errorFound := false for err := range errorChan { + //nolint:gocritic // easier to read using ifElse instead of switch if tc.err != "" && strings.Contains(err.Error(), tc.err) { errorFound = true } else if tc.additionalErr != "" && strings.Contains(err.Error(), tc.additionalErr) { @@ -469,7 +471,7 @@ func TestLBTCReader_expectedOutput(t *testing.T) { if tc.expectedReturn != nil { require.EqualValues(t, tc.expectedReturn, payloadAndProof) } else if tc.expectedError != nil { - require.True(t, strings.Contains(err.Error(), tc.expectedError.Error())) + require.Contains(t, err.Error(), tc.expectedError.Error()) } }) } diff --git a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go index 89bb17e8448..9e27ebcc59e 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go +++ b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go @@ -17,10 +17,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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/internal/ccipcalc" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata" diff --git a/core/services/ocr2/validate/validate.go b/core/services/ocr2/validate/validate.go index 7b951cbce8f..27a5a885369 100644 --- a/core/services/ocr2/validate/validate.go +++ b/core/services/ocr2/validate/validate.go @@ -21,7 +21,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/config/env" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" - liquiditymanagermodels "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/liquiditymanager/models" lloconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/llo/config" mercuryconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/mercury/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon" @@ -33,11 +32,11 @@ import ( // ValidatedOracleSpecToml validates an oracle spec that came from TOML func ValidatedOracleSpecToml(ctx context.Context, config OCR2Config, insConf InsecureConfig, tomlString string, rc plugins.RegistrarConfig) (job.Job, error) { - jb := job.Job{} + var jb = job.Job{} var spec job.OCR2OracleSpec tree, err := toml.Load(tomlString) if err != nil { - return jb, pkgerrors.Wrapf(err, "toml error on load %v", tomlString) + return jb, pkgerrors.Wrap(err, "toml error on load") } // Note this validates all the fields which implement an UnmarshalText // i.e. TransmitterAddress, PeerID... @@ -127,8 +126,6 @@ func validateSpec(ctx context.Context, tree *toml.Tree, spec job.Job, rc plugins return validateOCR2LLOSpec(spec.OCR2OracleSpec.PluginConfig) case types.GenericPlugin: return validateGenericPluginSpec(ctx, spec.OCR2OracleSpec, rc) - case "liquiditymanager": - return validateLiquidityManagerSpec(spec.OCR2OracleSpec.PluginConfig) case "": return errors.New("no plugin specified") default: @@ -296,27 +293,6 @@ func validateGenericPluginSpec(ctx context.Context, spec *job.OCR2OracleSpec, rc return plugin.ValidateConfig(ctx, spec.PluginConfig) } -func validateLiquidityManagerSpec(jsonConfig job.JSONConfig) error { - if jsonConfig == nil { - return errors.New("pluginConfig is empty") - } - var pluginConfig liquiditymanagermodels.PluginConfig - err := json.Unmarshal(jsonConfig.Bytes(), &pluginConfig) - if err != nil { - return pkgerrors.Wrap(err, "error while unmarshalling plugin config") - } - if pluginConfig.LiquidityManagerNetwork == 0 { - return errors.New("liquidityManagerNetwork must be provided") - } - if pluginConfig.ClosePluginTimeoutSec <= 0 { - return errors.New("closePluginTimeoutSec must be positive") - } - if err := liquiditymanagermodels.ValidateRebalancerConfig(pluginConfig.RebalancerConfig); err != nil { - return fmt.Errorf("rebalancer config invalid: %w", err) - } - return nil -} - func validateOCR2KeeperSpec(jsonConfig job.JSONConfig) error { return nil } @@ -325,7 +301,7 @@ func validateOCR2MercurySpec(spec *job.OCR2OracleSpec, feedID [32]byte) error { var relayConfig evmtypes.RelayConfig err := json.Unmarshal(spec.RelayConfig.Bytes(), &relayConfig) if err != nil { - return pkgerrors.Wrap(err, "error while unmarshalling plugin config") + return pkgerrors.Wrap(err, "error while unmarshalling relay config") } if len(spec.PluginConfig) == 0 { diff --git a/core/services/ocr2/validate/validate_test.go b/core/services/ocr2/validate/validate_test.go index 7f511c27061..1356e0db628 100644 --- a/core/services/ocr2/validate/validate_test.go +++ b/core/services/ocr2/validate/validate_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/require" commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" + "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" diff --git a/core/services/relay/evm/ccip.go b/core/services/relay/evm/ccip.go index a5374daf5bb..9fc6ae8b1a0 100644 --- a/core/services/relay/evm/ccip.go +++ b/core/services/relay/evm/ccip.go @@ -6,12 +6,12 @@ import ( "math/big" "time" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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/logger" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" diff --git a/core/services/relay/evm/commit_provider.go b/core/services/relay/evm/commit_provider.go index b431f14ea8a..6be639674e2 100644 --- a/core/services/relay/evm/commit_provider.go +++ b/core/services/relay/evm/commit_provider.go @@ -11,13 +11,13 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + "github.com/smartcontractkit/chainlink-common/pkg/logger" 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/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/router" - "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/estimatorconfig" ) @@ -179,13 +179,13 @@ func (p *DstCommitProvider) Close() error { if p.seenCommitStoreAddress == nil { return nil } - return ccip.CloseCommitStoreReader(ctx, p.lggr, versionFinder, *p.seenCommitStoreAddress, p.client, p.lp, P.feeEstimatorConfig) + return ccip.CloseCommitStoreReader(ctx, p.lggr, versionFinder, *p.seenCommitStoreAddress, p.client, p.lp, p.feeEstimatorConfig) }) unregisterFuncs = append(unregisterFuncs, func(ctx context.Context) error { if p.seenOffRampAddress == nil { return nil } - return ccip.CloseOffRampReader(ctx, p.lggr, versionFinder, *p.seenOffRampAddress, p.client, p.lp, nil, big.NewInt(0), P.feeEstimatorConfig) + return ccip.CloseOffRampReader(ctx, p.lggr, versionFinder, *p.seenOffRampAddress, p.client, p.lp, nil, big.NewInt(0), p.feeEstimatorConfig) }) var multiErr error @@ -256,7 +256,7 @@ func (p *DstCommitProvider) NewPriceGetter(ctx context.Context) (priceGetter cci } func (p *SrcCommitProvider) NewCommitStoreReader(ctx context.Context, commitStoreAddress cciptypes.Address) (commitStoreReader cciptypes.CommitStoreReader, err error) { - commitStoreReader = NewIncompleteSourceCommitStoreReader(p.estimator, p.maxGasPrice, P.feeEstimatorConfig) + commitStoreReader = NewIncompleteSourceCommitStoreReader(p.estimator, p.maxGasPrice, p.feeEstimatorConfig) return } @@ -264,7 +264,7 @@ func (p *DstCommitProvider) NewCommitStoreReader(ctx context.Context, commitStor p.seenCommitStoreAddress = &commitStoreAddress versionFinder := ccip.NewEvmVersionFinder() - commitStoreReader, err = NewIncompleteDestCommitStoreReader(ctx, p.lggr, versionFinder, commitStoreAddress, p.client, p.lp, P.feeEstimatorConfig) + commitStoreReader, err = NewIncompleteDestCommitStoreReader(ctx, p.lggr, versionFinder, commitStoreAddress, p.client, p.lp, p.feeEstimatorConfig) return } @@ -279,7 +279,7 @@ func (p *SrcCommitProvider) NewOnRampReader(ctx context.Context, onRampAddress c if err != nil { return nil, err } - P.feeEstimatorConfig.SetOnRampReader(onRampReader) + p.feeEstimatorConfig.SetOnRampReader(onRampReader) return } @@ -292,7 +292,7 @@ func (p *SrcCommitProvider) NewOffRampReader(ctx context.Context, offRampAddr cc } func (p *DstCommitProvider) NewOffRampReader(ctx context.Context, offRampAddr cciptypes.Address) (offRampReader cciptypes.OffRampReader, err error) { - offRampReader, err = ccip.NewOffRampReader(ctx, p.lggr, p.versionFinder, offRampAddr, p.client, p.lp, p.gasEstimator, &p.maxGasPrice, true, P.feeEstimatorConfig) + offRampReader, err = ccip.NewOffRampReader(ctx, p.lggr, p.versionFinder, offRampAddr, p.client, p.lp, p.gasEstimator, &p.maxGasPrice, true, p.feeEstimatorConfig) return } diff --git a/core/services/relay/evm/evm.go b/core/services/relay/evm/evm.go index 4fc747ac972..cf79d2aea59 100644 --- a/core/services/relay/evm/evm.go +++ b/core/services/relay/evm/evm.go @@ -14,8 +14,6 @@ import ( "sync" "time" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/estimatorconfig/interceptors/mantle" - "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" @@ -32,12 +30,12 @@ import ( ocr3capability "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3" "github.com/smartcontractkit/chainlink-common/pkg/capabilities/triggers" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/services" "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" coretypes "github.com/smartcontractkit/chainlink-common/pkg/types/core" - "github.com/smartcontractkit/chainlink/v2/core/logger" txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" txm "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" @@ -53,6 +51,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/ccipexec" ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/estimatorconfig" + "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/estimatorconfig/interceptors/mantle" cciptransmitter "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/transmitter" lloconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/llo/config" mercuryconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/mercury/config" @@ -632,6 +631,7 @@ func (r *Relayer) NewCCIPExecProvider(ctx context.Context, rargs commontypes.Rel // bail early. if execPluginConfig.IsSourceProvider { return NewSrcExecProvider( + ctx, r.lggr, versionFinder, r.chain.Client(), diff --git a/core/services/relay/evm/exec_provider.go b/core/services/relay/evm/exec_provider.go index 5c81ac0c65c..e5b00205caa 100644 --- a/core/services/relay/evm/exec_provider.go +++ b/core/services/relay/evm/exec_provider.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/types" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" @@ -23,7 +24,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" "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" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/estimatorconfig" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/tokendata/usdc" @@ -209,6 +209,7 @@ func (s *SrcExecProvider) NewTokenDataReader(ctx context.Context, tokenAddress c s.lggr, s.usdcReader, attestationURI, + //nolint:gosec // integer overflow int(s.usdcConfig.AttestationAPITimeoutSeconds), tokenAddr, time.Duration(s.usdcConfig.AttestationAPIIntervalMilliseconds)*time.Millisecond, @@ -221,6 +222,7 @@ func (s *SrcExecProvider) NewTokenDataReader(ctx context.Context, tokenAddress c return lbtc.NewLBTCTokenDataReader( s.lggr, attestationURI, + //nolint:gosec // integer overflow int(s.lbtcConfig.AttestationAPITimeoutSeconds), tokenAddr, time.Duration(s.lbtcConfig.AttestationAPIIntervalMilliseconds)*time.Millisecond, diff --git a/core/services/relay/evm/functions.go b/core/services/relay/evm/functions.go index 74a133edd17..98928241fde 100644 --- a/core/services/relay/evm/functions.go +++ b/core/services/relay/evm/functions.go @@ -10,14 +10,13 @@ import ( ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - commonlogger "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/services" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" txm "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" - "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/functions/config" functionsRelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/functions" @@ -41,7 +40,7 @@ func newFunctionsProvider(lggr logger.Logger, cw *configWatcher, ct ContractTran } p.Service, p.eng = services.Config{ Name: "FunctionsProvider", - NewSubServices: func(lggr commonlogger.Logger) []services.Service { + NewSubServices: func(lggr logger.Logger) []services.Service { return []services.Service{p.configWatcher, p.logPollerWrapper} }, }.NewServiceEngine(lggr) diff --git a/core/services/relay/evm/interceptors/mantle/interceptor.go b/core/services/relay/evm/interceptors/mantle/interceptor.go index 8d5d3bb6c2f..c1520652d67 100644 --- a/core/services/relay/evm/interceptors/mantle/interceptor.go +++ b/core/services/relay/evm/interceptors/mantle/interceptor.go @@ -9,10 +9,9 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/common" evmClient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/rollups" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" ) const ( @@ -34,11 +33,11 @@ func NewInterceptor(_ context.Context, client evmClient.Client) (*Interceptor, e // Encode calldata for tokenRatio method tokenRatioMethodAbi, err := abi.JSON(strings.NewReader(mantleTokenRatioAbiString)) if err != nil { - return nil, fmt.Errorf("failed to parse GasPriceOracle %s() method ABI for Mantle; %v", tokenRatioMethod, err) + return nil, fmt.Errorf("failed to parse GasPriceOracle %s() method ABI for Mantle; %w", tokenRatioMethod, err) } tokenRatioCallData, err := tokenRatioMethodAbi.Pack(tokenRatioMethod) if err != nil { - return nil, fmt.Errorf("failed to parse GasPriceOracle %s() calldata for Mantle; %v", tokenRatioMethod, err) + return nil, fmt.Errorf("failed to parse GasPriceOracle %s() calldata for Mantle; %w", tokenRatioMethod, err) } return &Interceptor{ @@ -66,7 +65,9 @@ func (i *Interceptor) ModifyGasPriceComponents(ctx context.Context, execGasPrice // getMantleTokenRatio Requests and returns a token ratio value for the Mantle chain. func (i *Interceptor) getMantleTokenRatio(ctx context.Context) (*big.Int, error) { - precompile := common.HexToAddress(rollups.OPGasOracleAddress) + // FIXME it's removed from chainlink repo + // precompile := common.HexToAddress(rollups.OPGasOracleAddress) + precompile := utils.RandomAddress() tokenRatio, err := i.client.CallContract(ctx, ethereum.CallMsg{ To: &precompile, Data: i.tokenRatioCallData, diff --git a/core/services/relay/evm/median_test.go b/core/services/relay/evm/median_test.go index ae4546ce6a8..9fa612dabcd 100644 --- a/core/services/relay/evm/median_test.go +++ b/core/services/relay/evm/median_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-common/pkg/logger" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" - "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm/mocks" @@ -17,7 +17,7 @@ import ( ) func TestNewMedianProvider(t *testing.T) { - lggr := logger.TestLogger(t) + lggr := logger.Test(t) chain := mocks.NewChain(t) chainID := testutils.NewRandomEVMChainID() diff --git a/core/services/relay/evm/mercury_config_provider.go b/core/services/relay/evm/mercury_config_provider.go index 443c82ab2c5..53bf8e22d24 100644 --- a/core/services/relay/evm/mercury_config_provider.go +++ b/core/services/relay/evm/mercury_config_provider.go @@ -9,10 +9,10 @@ import ( ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + "github.com/smartcontractkit/chainlink-common/pkg/logger" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" - "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/types" ) @@ -33,7 +33,7 @@ func newMercuryConfigProvider(ctx context.Context, lggr logger.Logger, chain leg } cp, err := mercury.NewConfigPoller( ctx, - lggr.Named(relayConfig.FeedID.String()), + logger.Named(lggr, relayConfig.FeedID.String()), chain.LogPoller(), aggregatorAddress, *relayConfig.FeedID, diff --git a/core/services/relay/evm/ocr2keeper.go b/core/services/relay/evm/ocr2keeper.go index a4a0cd0265c..db96afee7d7 100644 --- a/core/services/relay/evm/ocr2keeper.go +++ b/core/services/relay/evm/ocr2keeper.go @@ -13,6 +13,7 @@ import ( ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/smartcontractkit/chainlink-automation/pkg/v3/plugin" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink-common/pkg/types/automation" @@ -20,7 +21,6 @@ import ( evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" ac "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_v21_plus_common" - "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" evm "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/encoding" @@ -215,7 +215,7 @@ func newOCR2KeeperConfigProvider(ctx context.Context, lggr logger.Logger, chain configPoller, err := NewConfigPoller( ctx, - lggr.With("contractID", rargs.ContractID), + logger.With(lggr, "contractID", rargs.ContractID), CPConfig{ chain.Client(), chain.LogPoller(), diff --git a/core/services/relay/evm/standard_config_provider.go b/core/services/relay/evm/standard_config_provider.go index 59f91c52f4a..91ca25413fa 100644 --- a/core/services/relay/evm/standard_config_provider.go +++ b/core/services/relay/evm/standard_config_provider.go @@ -10,8 +10,9 @@ import ( "github.com/smartcontractkit/libocr/offchainreporting2plus/chains/evmutil" ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" - "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/types" ) diff --git a/core/services/relay/evm/types/codec_entry.go b/core/services/relay/evm/types/codec_entry.go index 0043db526eb..6a39f9d226f 100644 --- a/core/services/relay/evm/types/codec_entry.go +++ b/core/services/relay/evm/types/codec_entry.go @@ -212,12 +212,6 @@ func getNativeAndCheckedTypesForArg(arg *abi.Argument) (reflect.Type, reflect.Ty if arg.Type.Elem.GetType() == u8.native { return reflect.TypeOf(common.Hash{}), reflect.TypeOf(common.Hash{}), nil } - return nil, nil, fmt.Errorf("%w: unsupported array type: %v", commontypes.ErrInvalidConfig, arg.Type) - case abi.FixedBytesTy: - typ, ok := GetAbiEncodingType(fmt.Sprintf("bytes%d", arg.Type.Size)) - if ok { - return typ.native, typ.checked, nil - } fallthrough case abi.SliceTy, abi.TupleTy, abi.FixedPointTy, abi.FunctionTy: // https://github.com/ethereum/go-ethereum/blob/release/1.12/accounts/abi/topics.go#L78 diff --git a/core/services/relay/evm/types/types.go b/core/services/relay/evm/types/types.go index 0832663e792..2b56aee6379 100644 --- a/core/services/relay/evm/types/types.go +++ b/core/services/relay/evm/types/types.go @@ -218,10 +218,6 @@ type RelayConfig struct { TriggerCapabilityName string `json:"triggerCapabilityName"` TriggerCapabilityVersion string `json:"triggerCapabilityVersion"` - // Rebalancer specific - // FromBlocks specifies the block numbers to replay from for each chain. - FromBlocks map[string]int64 `json:"fromBlocks"` - // LLO-specific LLODONID uint32 `json:"lloDonID" toml:"lloDonID"` LLOConfigMode LLOConfigMode `json:"lloConfigMode" toml:"lloConfigMode"` diff --git a/core/services/synchronization/telem/telem.pb.go b/core/services/synchronization/telem/telem.pb.go index 0396fd462d0..8ededa8ce1c 100644 --- a/core/services/synchronization/telem/telem.pb.go +++ b/core/services/synchronization/telem/telem.pb.go @@ -7,11 +7,10 @@ package telem import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/core/services/synchronization/telem/telem_automation_custom.pb.go b/core/services/synchronization/telem/telem_automation_custom.pb.go index 1000ee0131b..7c498be9fde 100644 --- a/core/services/synchronization/telem/telem_automation_custom.pb.go +++ b/core/services/synchronization/telem/telem_automation_custom.pb.go @@ -7,11 +7,10 @@ package telem import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/core/services/synchronization/telem/telem_enhanced_ea.pb.go b/core/services/synchronization/telem/telem_enhanced_ea.pb.go index d239ebe6ffa..687ff7ab4e9 100644 --- a/core/services/synchronization/telem/telem_enhanced_ea.pb.go +++ b/core/services/synchronization/telem/telem_enhanced_ea.pb.go @@ -7,11 +7,10 @@ package telem import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/core/services/synchronization/telem/telem_enhanced_ea_mercury.pb.go b/core/services/synchronization/telem/telem_enhanced_ea_mercury.pb.go index ec4292ccb7c..34f4b3e349b 100644 --- a/core/services/synchronization/telem/telem_enhanced_ea_mercury.pb.go +++ b/core/services/synchronization/telem/telem_enhanced_ea_mercury.pb.go @@ -7,11 +7,10 @@ package telem import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/core/services/synchronization/telem/telem_functions_request.pb.go b/core/services/synchronization/telem/telem_functions_request.pb.go index b2b3427f852..1a67d1223a8 100644 --- a/core/services/synchronization/telem/telem_functions_request.pb.go +++ b/core/services/synchronization/telem/telem_functions_request.pb.go @@ -7,11 +7,10 @@ package telem import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/core/services/vrf/delegate.go b/core/services/vrf/delegate.go index 545bdc43440..ec2139c014f 100644 --- a/core/services/vrf/delegate.go +++ b/core/services/vrf/delegate.go @@ -14,7 +14,6 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox" - "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" diff --git a/core/web/resolver/mutation.go b/core/web/resolver/mutation.go index f40f880c54d..92d30ca65af 100644 --- a/core/web/resolver/mutation.go +++ b/core/web/resolver/mutation.go @@ -17,6 +17,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/auth" "github.com/smartcontractkit/chainlink/v2/core/bridges" + ccip "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/validate" "github.com/smartcontractkit/chainlink/v2/core/logger/audit" "github.com/smartcontractkit/chainlink/v2/core/services/blockhashstore" "github.com/smartcontractkit/chainlink/v2/core/services/blockheaderfeeder" @@ -1112,7 +1113,7 @@ func (r *Resolver) CreateJob(ctx context.Context, args struct { case job.Stream: jb, err = streams.ValidatedStreamSpec(args.Input.TOML) case job.CCIP: - return nil, errors.New("CCIP job type is not supported in this version") + jb, err = ccip.ValidatedCCIPSpec(args.Input.TOML) default: return NewCreateJobPayload(r.App, nil, map[string]string{ "Job Type": fmt.Sprintf("unknown job type: %s", jbt), diff --git a/core/web/resolver/plugins.go b/core/web/resolver/plugins.go index c4a6f0366d8..187bd7977b7 100644 --- a/core/web/resolver/plugins.go +++ b/core/web/resolver/plugins.go @@ -28,7 +28,7 @@ func (r PluginsResolver) Mercury() bool { return r.plugins.Mercury } -// LiquidityManager returns the the status of the liquidity manager plugin. +// Rebalancer returns the the status of the rebalancer plugin. func (r PluginsResolver) Rebalancer() bool { - return r.plugins.LiquidityManager + return r.plugins.Rebalancer }