From ba841a51666daeb8252d034c5f64da2f637f5f7d Mon Sep 17 00:00:00 2001 From: Dylan Tinianov Date: Wed, 10 Jan 2024 13:18:10 -0500 Subject: [PATCH] Extract core/store/models (#11626) * Extract URL * tidy * Extract duration tests * Generate * update imports * Extract duration to common * tidy * fix imports * tidy * remove unused import * Remove unused mock file * fix imports * Use commonconfig Duration * Use commonconfig * Use commonconfig * Use MustNewDuration * use commonconfig * fix imports * fix imports * fmt * Use common url * fix imports --- core/chains/evm/config/config_test.go | 6 +- core/chains/evm/config/toml/config.go | 31 +- .../evm/headtracker/head_broadcaster_test.go | 4 +- .../evm/headtracker/head_listener_test.go | 6 +- .../evm/headtracker/head_tracker_test.go | 6 +- core/chains/evm/txmgr/evm_tx_store_test.go | 4 +- core/chains/evm/txmgr/resender_test.go | 6 +- core/cmd/evm_node_commands_test.go | 10 +- core/cmd/evm_transaction_commands_test.go | 6 +- core/cmd/jobs_commands_test.go | 5 +- core/cmd/shell_local_test.go | 9 +- core/cmd/shell_remote_test.go | 4 +- core/config/audit_logger_config.go | 3 +- core/config/auto_pprof_config.go | 8 +- core/config/docs/docs_test.go | 4 +- core/config/job_pipeline_config.go | 4 +- core/config/p2p_v2_config.go | 8 +- core/config/toml/types.go | 103 +++--- core/config/toml/types_test.go | 7 +- core/config/web_config.go | 14 +- core/internal/features/features_test.go | 13 +- .../features/ocr2/features_ocr2_test.go | 7 +- .../testutils/configtest/general_config.go | 19 +- core/logger/audit/audit_logger.go | 4 +- core/logger/audit/audit_logger_test.go | 7 +- core/scripts/go.mod | 2 +- core/scripts/go.sum | 4 +- core/services/chainlink/config.go | 2 +- .../services/chainlink/config_audit_logger.go | 3 +- core/services/chainlink/config_auto_pprof.go | 12 +- core/services/chainlink/config_general.go | 10 +- .../services/chainlink/config_job_pipeline.go | 4 +- .../chainlink/config_job_pipeline_test.go | 4 +- core/services/chainlink/config_p2p.go | 14 +- core/services/chainlink/config_test.go | 117 +++---- core/services/chainlink/config_web_server.go | 20 +- .../chainlink/config_web_server_test.go | 8 +- .../relayer_chain_interoperators_test.go | 31 +- core/services/feeds/config.go | 4 +- core/services/feeds/mocks/config.go | 292 ------------------ core/services/feeds/service_test.go | 86 +++--- core/services/fluxmonitorv2/config.go | 4 +- .../fluxmonitorv2/integrations_test.go | 21 +- core/services/fluxmonitorv2/validate.go | 4 +- core/services/fluxmonitorv2/validate_test.go | 6 +- .../job/job_pipeline_orm_integration_test.go | 3 +- core/services/job/runner_integration_test.go | 9 +- core/services/keeper/integration_test.go | 16 +- core/services/nurse.go | 8 +- core/services/nurse_test.go | 20 +- core/services/ocr/validate_test.go | 4 +- .../v1/internal/testutils.go | 7 +- .../ocr2/plugins/mercury/helpers_test.go | 6 +- .../plugins/ocr2keeper/integration_test.go | 5 +- .../internal/ocr2vrf_integration_test.go | 10 +- core/services/ocr2/validate/validate_test.go | 4 +- core/services/ocrcommon/peer_wrapper_test.go | 6 +- core/services/pg/locked_db_test.go | 6 +- core/services/pipeline/common.go | 4 +- core/services/pipeline/mocks/config.go | 10 +- core/services/pipeline/task.bridge_test.go | 5 +- core/services/telemetry/manager_test.go | 4 +- core/services/vrf/v1/integration_test.go | 4 +- core/services/vrf/v2/bhs_feeder_test.go | 8 +- .../vrf/v2/integration_helpers_test.go | 30 +- .../vrf/v2/integration_v2_plus_test.go | 4 +- core/services/vrf/v2/integration_v2_test.go | 12 +- core/sessions/ldapauth/helpers_test.go | 18 +- core/sessions/localauth/reaper.go | 6 +- core/sessions/localauth/reaper_test.go | 19 +- core/store/models/common.go | 167 ---------- core/store/models/common_test.go | 64 ---- core/store/models/secrets.go | 12 +- core/web/evm_transfer_controller_test.go | 3 +- core/web/pipeline_runs_controller_test.go | 10 +- core/web/presenters/job.go | 17 +- core/web/resolver/node_test.go | 6 +- go.mod | 2 +- go.sum | 4 +- integration-tests/go.mod | 4 +- integration-tests/go.sum | 8 +- integration-tests/load/functions/config.go | 46 +-- integration-tests/load/ocr/config.go | 28 +- integration-tests/load/vrfv2/config.go | 10 +- integration-tests/load/vrfv2plus/config.go | 10 +- integration-tests/smoke/automation_test.go | 11 +- integration-tests/smoke/keeper_test.go | 5 +- integration-tests/types/config/node/core.go | 15 +- .../universal/log_poller/config.go | 14 +- .../universal/log_poller/helpers.go | 19 +- integration-tests/utils/common.go | 6 +- 91 files changed, 564 insertions(+), 1071 deletions(-) delete mode 100644 core/services/feeds/mocks/config.go diff --git a/core/chains/evm/config/config_test.go b/core/chains/evm/config/config_test.go index 0127328239a..a8cbf6667f3 100644 --- a/core/chains/evm/config/config_test.go +++ b/core/chains/evm/config/config_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + configurl "github.com/smartcontractkit/chainlink-common/pkg/config" commonconfig "github.com/smartcontractkit/chainlink/v2/common/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" @@ -21,7 +22,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func TestChainScopedConfig(t *testing.T) { @@ -383,8 +383,8 @@ func Test_chainScopedConfig_Validate(t *testing.T) { c.EVM[0] = &toml.EVMConfig{ChainID: chainID, Enabled: ptr(true), Chain: toml.Defaults(chainID, chains...), Nodes: toml.EVMNodes{{ Name: ptr("fake"), - WSURL: models.MustParseURL("wss://foo.test/ws"), - HTTPURL: models.MustParseURL("http://foo.test"), + WSURL: configurl.MustParseURL("wss://foo.test/ws"), + HTTPURL: configurl.MustParseURL("http://foo.test"), }}} }) } diff --git a/core/chains/evm/config/toml/config.go b/core/chains/evm/config/toml/config.go index 292db56f817..e5b774edd17 100644 --- a/core/chains/evm/config/toml/config.go +++ b/core/chains/evm/config/toml/config.go @@ -22,7 +22,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) type HasEVMConfigs interface { @@ -351,12 +350,12 @@ type Chain struct { FlagsContractAddress *ethkey.EIP55Address LinkContractAddress *ethkey.EIP55Address LogBackfillBatchSize *uint32 - LogPollInterval *models.Duration + LogPollInterval *commonconfig.Duration LogKeepBlocksDepth *uint32 MinIncomingConfirmations *uint32 MinContractPayment *commonassets.Link NonceAutoSync *bool - NoNewHeadsThreshold *models.Duration + NoNewHeadsThreshold *commonconfig.Duration OperatorFactoryAddress *ethkey.EIP55Address RPCDefaultBatchSize *uint32 RPCBlockQueryDelay *uint16 @@ -404,9 +403,9 @@ type Transactions struct { ForwardersEnabled *bool MaxInFlight *uint32 MaxQueued *uint32 - ReaperInterval *models.Duration - ReaperThreshold *models.Duration - ResendAfterThreshold *models.Duration + ReaperInterval *commonconfig.Duration + ReaperThreshold *commonconfig.Duration + ResendAfterThreshold *commonconfig.Duration } func (t *Transactions) setFrom(f *Transactions) { @@ -669,7 +668,7 @@ func (e *KeySpecificGasEstimator) setFrom(f *KeySpecificGasEstimator) { type HeadTracker struct { HistoryDepth *uint32 MaxBufferSize *uint32 - SamplingInterval *models.Duration + SamplingInterval *commonconfig.Duration } func (t *HeadTracker) setFrom(f *HeadTracker) { @@ -686,10 +685,10 @@ func (t *HeadTracker) setFrom(f *HeadTracker) { type NodePool struct { PollFailureThreshold *uint32 - PollInterval *models.Duration + PollInterval *commonconfig.Duration SelectionMode *string SyncThreshold *uint32 - LeaseDuration *models.Duration + LeaseDuration *commonconfig.Duration } func (p *NodePool) setFrom(f *NodePool) { @@ -712,11 +711,11 @@ func (p *NodePool) setFrom(f *NodePool) { type OCR struct { ContractConfirmations *uint16 - ContractTransmitterTransmitTimeout *models.Duration - DatabaseTimeout *models.Duration - DeltaCOverride *models.Duration - DeltaCJitterOverride *models.Duration - ObservationGracePeriod *models.Duration + ContractTransmitterTransmitTimeout *commonconfig.Duration + DatabaseTimeout *commonconfig.Duration + DeltaCOverride *commonconfig.Duration + DeltaCJitterOverride *commonconfig.Duration + ObservationGracePeriod *commonconfig.Duration } func (o *OCR) setFrom(f *OCR) { @@ -742,8 +741,8 @@ func (o *OCR) setFrom(f *OCR) { type Node struct { Name *string - WSURL *models.URL - HTTPURL *models.URL + WSURL *commonconfig.URL + HTTPURL *commonconfig.URL SendOnly *bool Order *int32 } diff --git a/core/chains/evm/headtracker/head_broadcaster_test.go b/core/chains/evm/headtracker/head_broadcaster_test.go index eb4daa6fde4..dcbb9bd0396 100644 --- a/core/chains/evm/headtracker/head_broadcaster_test.go +++ b/core/chains/evm/headtracker/head_broadcaster_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/services/servicetest" "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox/mailboxtest" @@ -26,7 +27,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func waitHeadBroadcasterToStart(t *testing.T, hb types.HeadBroadcaster) { @@ -46,7 +46,7 @@ func TestHeadBroadcaster_Subscribe(t *testing.T) { g := gomega.NewWithT(t) cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.EVM[0].HeadTracker.SamplingInterval = &models.Duration{} + c.EVM[0].HeadTracker.SamplingInterval = &commonconfig.Duration{} }) evmCfg := evmtest.NewChainScopedConfig(t, cfg) db := pgtest.NewSqlxDB(t) diff --git a/core/chains/evm/headtracker/head_listener_test.go b/core/chains/evm/headtracker/head_listener_test.go index 8bb761bdfaa..3ba9c0863da 100644 --- a/core/chains/evm/headtracker/head_listener_test.go +++ b/core/chains/evm/headtracker/head_listener_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/logger" commonmocks "github.com/smartcontractkit/chainlink/v2/common/types/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker" @@ -21,7 +22,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func Test_HeadListener_HappyPath(t *testing.T) { @@ -39,7 +39,7 @@ func Test_HeadListener_HappyPath(t *testing.T) { ethClient := evmtest.NewEthClientMockWithDefaultChain(t) cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { // no need to test head timeouts here - c.EVM[0].NoNewHeadsThreshold = &models.Duration{} + c.EVM[0].NoNewHeadsThreshold = &commonconfig.Duration{} }) evmcfg := evmtest.NewChainScopedConfig(t, cfg) chStop := make(chan struct{}) @@ -100,7 +100,7 @@ func Test_HeadListener_NotReceivingHeads(t *testing.T) { ethClient := evmtest.NewEthClientMockWithDefaultChain(t) cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.EVM[0].NoNewHeadsThreshold = models.MustNewDuration(time.Second) + c.EVM[0].NoNewHeadsThreshold = commonconfig.MustNewDuration(time.Second) }) evmcfg := evmtest.NewChainScopedConfig(t, cfg) chStop := make(chan struct{}) diff --git a/core/chains/evm/headtracker/head_tracker_test.go b/core/chains/evm/headtracker/head_tracker_test.go index 38cbe1fbfe4..22e931d6d0f 100644 --- a/core/chains/evm/headtracker/head_tracker_test.go +++ b/core/chains/evm/headtracker/head_tracker_test.go @@ -20,6 +20,7 @@ import ( "github.com/jmoiron/sqlx" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/services" "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox" @@ -38,7 +39,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func firstHead(t *testing.T, db *sqlx.DB) (h evmtypes.Head) { @@ -426,7 +426,7 @@ func TestHeadTracker_SwitchesToLongestChainWithHeadSamplingEnabled(t *testing.T) c.EVM[0].FinalityDepth = ptr[uint32](50) // Need to set the buffer to something large since we inject a lot of heads at once and otherwise they will be dropped c.EVM[0].HeadTracker.MaxBufferSize = ptr[uint32](100) - c.EVM[0].HeadTracker.SamplingInterval = models.MustNewDuration(2500 * time.Millisecond) + c.EVM[0].HeadTracker.SamplingInterval = commonconfig.MustNewDuration(2500 * time.Millisecond) }) ethClient := evmtest.NewEthClientMockWithDefaultChain(t) @@ -554,7 +554,7 @@ func TestHeadTracker_SwitchesToLongestChainWithHeadSamplingDisabled(t *testing.T c.EVM[0].FinalityDepth = ptr[uint32](50) // Need to set the buffer to something large since we inject a lot of heads at once and otherwise they will be dropped c.EVM[0].HeadTracker.MaxBufferSize = ptr[uint32](100) - c.EVM[0].HeadTracker.SamplingInterval = models.MustNewDuration(0) + c.EVM[0].HeadTracker.SamplingInterval = commonconfig.MustNewDuration(0) }) ethClient := evmtest.NewEthClientMockWithDefaultChain(t) diff --git a/core/chains/evm/txmgr/evm_tx_store_test.go b/core/chains/evm/txmgr/evm_tx_store_test.go index 1a1ee1bcd3a..b5da5527448 100644 --- a/core/chains/evm/txmgr/evm_tx_store_test.go +++ b/core/chains/evm/txmgr/evm_tx_store_test.go @@ -7,6 +7,7 @@ import ( "testing" "time" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/logger" txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types" @@ -23,7 +24,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/pg" "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/google/uuid" "github.com/stretchr/testify/assert" @@ -1379,7 +1379,7 @@ func TestORM_UpdateTxUnstartedToInProgress(t *testing.T) { etx := mustInsertInProgressEthTxWithAttempt(t, txStore, nonce, fromAddress) require.Len(t, etx.TxAttempts, 1) - zero := models.MustNewDuration(time.Duration(0)) + zero := commonconfig.MustNewDuration(time.Duration(0)) evmCfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0].Chain.Transactions.ReaperInterval = zero c.EVM[0].Chain.Transactions.ReaperThreshold = zero diff --git a/core/chains/evm/txmgr/resender_test.go b/core/chains/evm/txmgr/resender_test.go index f6b0e3e29c7..fd3d1745010 100644 --- a/core/chains/evm/txmgr/resender_test.go +++ b/core/chains/evm/txmgr/resender_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" @@ -23,7 +24,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func Test_EthResender_resendUnconfirmed(t *testing.T) { @@ -106,7 +106,7 @@ func Test_EthResender_alertUnconfirmed(t *testing.T) { ethKeyStore := cltest.NewKeyStore(t, db, logCfg).Eth() ethClient := evmtest.NewEthClientMockWithDefaultChain(t) // Set this to the smallest non-zero value possible for the attempt to be eligible for resend - delay := models.MustNewDuration(1 * time.Nanosecond) + delay := commonconfig.MustNewDuration(1 * time.Nanosecond) cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0] = &toml.EVMConfig{ Chain: toml.Defaults(ubig.New(big.NewInt(0)), &toml.Chain{ @@ -144,7 +144,7 @@ func Test_EthResender_Start(t *testing.T) { db := pgtest.NewSqlxDB(t) cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { // This can be anything as long as it isn't zero - c.EVM[0].Transactions.ResendAfterThreshold = models.MustNewDuration(42 * time.Hour) + c.EVM[0].Transactions.ResendAfterThreshold = commonconfig.MustNewDuration(42 * time.Hour) // Set batch size low to test batching c.EVM[0].RPCDefaultBatchSize = ptr[uint32](1) }) diff --git a/core/cmd/evm_node_commands_test.go b/core/cmd/evm_node_commands_test.go index 869ef1b9b3e..dae950fce01 100644 --- a/core/cmd/evm_node_commands_test.go +++ b/core/cmd/evm_node_commands_test.go @@ -9,11 +9,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/cmd" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func assertTableRenders(t *testing.T, r *cltest.RendererMock) { @@ -31,15 +31,15 @@ func TestShell_IndexEVMNodes(t *testing.T) { chainID := newRandChainID() node1 := evmcfg.Node{ Name: ptr("Test node 1"), - WSURL: models.MustParseURL("ws://localhost:8546"), - HTTPURL: models.MustParseURL("http://localhost:8546"), + WSURL: commonconfig.MustParseURL("ws://localhost:8546"), + HTTPURL: commonconfig.MustParseURL("http://localhost:8546"), SendOnly: ptr(false), Order: ptr(int32(15)), } node2 := evmcfg.Node{ Name: ptr("Test node 2"), - WSURL: models.MustParseURL("ws://localhost:8547"), - HTTPURL: models.MustParseURL("http://localhost:8547"), + WSURL: commonconfig.MustParseURL("ws://localhost:8547"), + HTTPURL: commonconfig.MustParseURL("http://localhost:8547"), SendOnly: ptr(false), Order: ptr(int32(36)), } diff --git a/core/cmd/evm_transaction_commands_test.go b/core/cmd/evm_transaction_commands_test.go index 5c80a7d74a0..588e65027f2 100644 --- a/core/cmd/evm_transaction_commands_test.go +++ b/core/cmd/evm_transaction_commands_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/require" "github.com/urfave/cli" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -22,7 +23,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func TestShell_IndexTransactions(t *testing.T) { @@ -151,7 +151,7 @@ func TestShell_SendEther_From_Txm(t *testing.T) { // NOTE: FallbackPollInterval is used in this test to quickly create TxAttempts // Testing triggers requires committing transactions and does not work with transactional tests - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(time.Second) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(time.Second) }, withKey(), withMocks(ethMock, key), @@ -217,7 +217,7 @@ func TestShell_SendEther_From_Txm_WEI(t *testing.T) { // NOTE: FallbackPollInterval is used in this test to quickly create TxAttempts // Testing triggers requires committing transactions and does not work with transactional tests - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(time.Second) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(time.Second) }, withKey(), withMocks(ethMock, key), diff --git a/core/cmd/jobs_commands_test.go b/core/cmd/jobs_commands_test.go index 5d9b3cb3f1a..75e95db84ca 100644 --- a/core/cmd/jobs_commands_test.go +++ b/core/cmd/jobs_commands_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/require" "github.com/urfave/cli" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/cmd" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" @@ -367,7 +368,7 @@ func TestShell_CreateJobV2(t *testing.T) { t.Parallel() app := startNewApplicationV2(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(100 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(100 * time.Millisecond) c.OCR.Enabled = ptr(true) c.P2P.V2.Enabled = ptr(true) c.P2P.V2.ListenAddresses = &[]string{fmt.Sprintf("127.0.0.1:%d", freeport.GetOne(t))} @@ -405,7 +406,7 @@ func TestShell_DeleteJob(t *testing.T) { t.Parallel() app := startNewApplicationV2(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(100 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(100 * time.Millisecond) c.EVM[0].Enabled = ptr(true) c.EVM[0].NonceAutoSync = ptr(false) c.EVM[0].BalanceMonitor.Enabled = ptr(false) diff --git a/core/cmd/shell_local_test.go b/core/cmd/shell_local_test.go index 5bdcbb180ef..72c2f2b5bbd 100644 --- a/core/cmd/shell_local_test.go +++ b/core/cmd/shell_local_test.go @@ -8,6 +8,7 @@ import ( "testing" "time" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox" "github.com/smartcontractkit/chainlink/v2/common/client" @@ -73,8 +74,8 @@ func TestShell_RunNodeWithPasswords(t *testing.T) { cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { s.Password.Keystore = models.NewSecret("dummy") c.EVM[0].Nodes[0].Name = ptr("fake") - c.EVM[0].Nodes[0].HTTPURL = models.MustParseURL("http://fake.com") - c.EVM[0].Nodes[0].WSURL = models.MustParseURL("WSS://fake.com/ws") + c.EVM[0].Nodes[0].HTTPURL = commonconfig.MustParseURL("http://fake.com") + c.EVM[0].Nodes[0].WSURL = commonconfig.MustParseURL("WSS://fake.com/ws") // seems to be needed for config validate c.Insecure.OCRDevelopmentMode = nil }) @@ -166,8 +167,8 @@ func TestShell_RunNodeWithAPICredentialsFile(t *testing.T) { cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { s.Password.Keystore = models.NewSecret("16charlengthp4SsW0rD1!@#_") c.EVM[0].Nodes[0].Name = ptr("fake") - c.EVM[0].Nodes[0].WSURL = models.MustParseURL("WSS://fake.com/ws") - c.EVM[0].Nodes[0].HTTPURL = models.MustParseURL("http://fake.com") + c.EVM[0].Nodes[0].WSURL = commonconfig.MustParseURL("WSS://fake.com/ws") + c.EVM[0].Nodes[0].HTTPURL = commonconfig.MustParseURL("http://fake.com") // seems to be needed for config validate c.Insecure.OCRDevelopmentMode = nil }) diff --git a/core/cmd/shell_remote_test.go b/core/cmd/shell_remote_test.go index 6c8b46eda4c..ed675d8ee9e 100644 --- a/core/cmd/shell_remote_test.go +++ b/core/cmd/shell_remote_test.go @@ -20,6 +20,7 @@ import ( "github.com/stretchr/testify/require" "github.com/urfave/cli" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/auth" "github.com/smartcontractkit/chainlink/v2/core/bridges" evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" @@ -33,7 +34,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/sessions" "github.com/smartcontractkit/chainlink/v2/core/static" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/testdata/testspecs" "github.com/smartcontractkit/chainlink/v2/core/web" ) @@ -60,7 +60,7 @@ func startNewApplicationV2(t *testing.T, overrideFn func(c *chainlink.Config, s } config := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.JobPipeline.HTTPRequest.DefaultTimeout = models.MustNewDuration(30 * time.Millisecond) + c.JobPipeline.HTTPRequest.DefaultTimeout = commonconfig.MustNewDuration(30 * time.Millisecond) f := false c.EVM[0].Enabled = &f c.P2P.V2.Enabled = &f diff --git a/core/config/audit_logger_config.go b/core/config/audit_logger_config.go index e5078897722..b83ca5b00d0 100644 --- a/core/config/audit_logger_config.go +++ b/core/config/audit_logger_config.go @@ -1,12 +1,13 @@ package config import ( + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/store/models" ) type AuditLogger interface { Enabled() bool - ForwardToUrl() (models.URL, error) + ForwardToUrl() (commonconfig.URL, error) Environment() string JsonWrapperKey() string Headers() (models.ServiceHeaders, error) diff --git a/core/config/auto_pprof_config.go b/core/config/auto_pprof_config.go index f87777cbbd0..c69ff2c86af 100644 --- a/core/config/auto_pprof_config.go +++ b/core/config/auto_pprof_config.go @@ -1,7 +1,7 @@ package config import ( - "github.com/smartcontractkit/chainlink/v2/core/store/models" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -9,13 +9,13 @@ type AutoPprof interface { BlockProfileRate() int CPUProfileRate() int Enabled() bool - GatherDuration() models.Duration - GatherTraceDuration() models.Duration + GatherDuration() commonconfig.Duration + GatherTraceDuration() commonconfig.Duration GoroutineThreshold() int MaxProfileSize() utils.FileSize MemProfileRate() int MemThreshold() utils.FileSize MutexProfileFraction() int - PollInterval() models.Duration + PollInterval() commonconfig.Duration ProfileRoot() string } diff --git a/core/config/docs/docs_test.go b/core/config/docs/docs_test.go index 30688c38879..508bd62e338 100644 --- a/core/config/docs/docs_test.go +++ b/core/config/docs/docs_test.go @@ -15,13 +15,13 @@ import ( stkcfg "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/config" "github.com/smartcontractkit/chainlink-common/pkg/config" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/config/docs" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink/cfgtest" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func TestDoc(t *testing.T) { @@ -42,7 +42,7 @@ func TestDoc(t *testing.T) { // and its only use is to signal to NOPs that these fields are no longer allowed emptyString := "" c.TelemetryIngress.ServerPubKey = &emptyString - c.TelemetryIngress.URL = new(models.URL) + c.TelemetryIngress.URL = new(commonconfig.URL) cfgtest.AssertFieldsNotNil(t, c) diff --git a/core/config/job_pipeline_config.go b/core/config/job_pipeline_config.go index 65010fc48c7..d4a01dbed03 100644 --- a/core/config/job_pipeline_config.go +++ b/core/config/job_pipeline_config.go @@ -3,12 +3,12 @@ package config import ( "time" - "github.com/smartcontractkit/chainlink/v2/core/store/models" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" ) type JobPipeline interface { DefaultHTTPLimit() int64 - DefaultHTTPTimeout() models.Duration + DefaultHTTPTimeout() commonconfig.Duration MaxRunDuration() time.Duration MaxSuccessfulRuns() uint64 ReaperInterval() time.Duration diff --git a/core/config/p2p_v2_config.go b/core/config/p2p_v2_config.go index 7b4a3c05fc4..ff640786ed2 100644 --- a/core/config/p2p_v2_config.go +++ b/core/config/p2p_v2_config.go @@ -1,16 +1,16 @@ package config import ( - ocrcommontypes "github.com/smartcontractkit/libocr/commontypes" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" - "github.com/smartcontractkit/chainlink/v2/core/store/models" + ocrcommontypes "github.com/smartcontractkit/libocr/commontypes" ) type V2 interface { Enabled() bool AnnounceAddresses() []string DefaultBootstrappers() (locators []ocrcommontypes.BootstrapperLocator) - DeltaDial() models.Duration - DeltaReconcile() models.Duration + DeltaDial() commonconfig.Duration + DeltaReconcile() commonconfig.Duration ListenAddresses() []string } diff --git a/core/config/toml/types.go b/core/config/toml/types.go index 93fcef32611..eae5b2f533a 100644 --- a/core/config/toml/types.go +++ b/core/config/toml/types.go @@ -14,6 +14,7 @@ import ( ocrcommontypes "github.com/smartcontractkit/libocr/commontypes" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/build" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/config/parse" @@ -34,7 +35,7 @@ type Core struct { AppID uuid.UUID `toml:"-"` // random or test InsecureFastScrypt *bool RootDir *string - ShutdownGracePeriod *models.Duration + ShutdownGracePeriod *commonconfig.Duration Feature Feature `toml:",omitempty"` Database Database `toml:",omitempty"` @@ -310,9 +311,9 @@ func (f *Feature) setFrom(f2 *Feature) { } type Database struct { - DefaultIdleInTxSessionTimeout *models.Duration - DefaultLockTimeout *models.Duration - DefaultQueryTimeout *models.Duration + DefaultIdleInTxSessionTimeout *commonconfig.Duration + DefaultLockTimeout *commonconfig.Duration + DefaultQueryTimeout *commonconfig.Duration Dialect dialects.DialectName `toml:"-"` LogQueries *bool MaxIdleConns *int64 @@ -353,9 +354,9 @@ func (d *Database) setFrom(f *Database) { } type DatabaseListener struct { - MaxReconnectDuration *models.Duration - MinReconnectInterval *models.Duration - FallbackPollInterval *models.Duration + MaxReconnectDuration *commonconfig.Duration + MinReconnectInterval *commonconfig.Duration + FallbackPollInterval *commonconfig.Duration } func (d *DatabaseListener) setFrom(f *DatabaseListener) { @@ -372,8 +373,8 @@ func (d *DatabaseListener) setFrom(f *DatabaseListener) { type DatabaseLock struct { Enabled *bool - LeaseDuration *models.Duration - LeaseRefreshInterval *models.Duration + LeaseDuration *commonconfig.Duration + LeaseRefreshInterval *commonconfig.Duration } func (l *DatabaseLock) Mode() string { @@ -408,7 +409,7 @@ func (l *DatabaseLock) setFrom(f *DatabaseLock) { // Note: url is stored in Secrets.DatabaseBackupURL type DatabaseBackup struct { Dir *string - Frequency *models.Duration + Frequency *commonconfig.Duration Mode *config.DatabaseBackupMode OnVersionUpgrade *bool } @@ -433,19 +434,19 @@ type TelemetryIngress struct { Logging *bool BufferSize *uint16 MaxBatchSize *uint16 - SendInterval *models.Duration - SendTimeout *models.Duration + SendInterval *commonconfig.Duration + SendTimeout *commonconfig.Duration UseBatchSend *bool Endpoints []TelemetryIngressEndpoint `toml:",omitempty"` - URL *models.URL `toml:",omitempty"` // Deprecated: Use TelemetryIngressEndpoint.URL instead, this field will be removed in future versions - ServerPubKey *string `toml:",omitempty"` // Deprecated: Use TelemetryIngressEndpoint.ServerPubKey instead, this field will be removed in future versions + URL *commonconfig.URL `toml:",omitempty"` // Deprecated: Use TelemetryIngressEndpoint.URL instead, this field will be removed in future versions + ServerPubKey *string `toml:",omitempty"` // Deprecated: Use TelemetryIngressEndpoint.ServerPubKey instead, this field will be removed in future versions } type TelemetryIngressEndpoint struct { Network *string ChainID *string - URL *models.URL + URL *commonconfig.URL ServerPubKey *string } @@ -498,7 +499,7 @@ func (t *TelemetryIngress) ValidateConfig() (err error) { type AuditLogger struct { Enabled *bool - ForwardToUrl *models.URL + ForwardToUrl *commonconfig.URL JsonWrapperKey *string Headers *[]models.ServiceHeader } @@ -597,15 +598,15 @@ func (l *LogFile) setFrom(f *LogFile) { type WebServer struct { AuthenticationMethod *string AllowOrigins *string - BridgeResponseURL *models.URL - BridgeCacheTTL *models.Duration - HTTPWriteTimeout *models.Duration + BridgeResponseURL *commonconfig.URL + BridgeCacheTTL *commonconfig.Duration + HTTPWriteTimeout *commonconfig.Duration HTTPPort *uint16 SecureCookies *bool - SessionTimeout *models.Duration - SessionReaperExpiration *models.Duration + SessionTimeout *commonconfig.Duration + SessionReaperExpiration *commonconfig.Duration HTTPMaxSize *utils.FileSize - StartTimeout *models.Duration + StartTimeout *commonconfig.Duration ListenIP *net.IP LDAP WebServerLDAP `toml:",omitempty"` @@ -708,9 +709,9 @@ func (w *WebServerMFA) setFrom(f *WebServerMFA) { type WebServerRateLimit struct { Authenticated *int64 - AuthenticatedPeriod *models.Duration + AuthenticatedPeriod *commonconfig.Duration Unauthenticated *int64 - UnauthenticatedPeriod *models.Duration + UnauthenticatedPeriod *commonconfig.Duration } func (w *WebServerRateLimit) setFrom(f *WebServerRateLimit) { @@ -760,8 +761,8 @@ func (w *WebServerTLS) setFrom(f *WebServerTLS) { type WebServerLDAP struct { ServerTLS *bool - SessionTimeout *models.Duration - QueryTimeout *models.Duration + SessionTimeout *commonconfig.Duration + QueryTimeout *commonconfig.Duration BaseUserAttr *string BaseDN *string UsersDN *string @@ -773,9 +774,9 @@ type WebServerLDAP struct { RunUserGroupCN *string ReadUserGroupCN *string UserApiTokenEnabled *bool - UserAPITokenDuration *models.Duration - UpstreamSyncInterval *models.Duration - UpstreamSyncRateLimit *models.Duration + UserAPITokenDuration *commonconfig.Duration + UpstreamSyncInterval *commonconfig.Duration + UpstreamSyncRateLimit *commonconfig.Duration } func (w *WebServerLDAP) setFrom(f *WebServerLDAP) { @@ -864,10 +865,10 @@ func (w *WebServerSecrets) SetFrom(f *WebServerSecrets) error { type JobPipeline struct { ExternalInitiatorsEnabled *bool - MaxRunDuration *models.Duration + MaxRunDuration *commonconfig.Duration MaxSuccessfulRuns *uint64 - ReaperInterval *models.Duration - ReaperThreshold *models.Duration + ReaperInterval *commonconfig.Duration + ReaperThreshold *commonconfig.Duration ResultWriteQueueDepth *uint32 HTTPRequest JobPipelineHTTPRequest `toml:",omitempty"` @@ -897,7 +898,7 @@ func (j *JobPipeline) setFrom(f *JobPipeline) { } type JobPipelineHTTPRequest struct { - DefaultTimeout *models.Duration + DefaultTimeout *commonconfig.Duration MaxSize *utils.FileSize } @@ -927,11 +928,11 @@ func (m *FluxMonitor) setFrom(f *FluxMonitor) { type OCR2 struct { Enabled *bool ContractConfirmations *uint32 - BlockchainTimeout *models.Duration - ContractPollInterval *models.Duration - ContractSubscribeInterval *models.Duration - ContractTransmitterTransmitTimeout *models.Duration - DatabaseTimeout *models.Duration + BlockchainTimeout *commonconfig.Duration + ContractPollInterval *commonconfig.Duration + ContractSubscribeInterval *commonconfig.Duration + ContractTransmitterTransmitTimeout *commonconfig.Duration + DatabaseTimeout *commonconfig.Duration KeyBundleID *models.Sha256Hash CaptureEATelemetry *bool CaptureAutomationCustomTelemetry *bool @@ -984,10 +985,10 @@ func (o *OCR2) setFrom(f *OCR2) { type OCR struct { Enabled *bool - ObservationTimeout *models.Duration - BlockchainTimeout *models.Duration - ContractPollInterval *models.Duration - ContractSubscribeInterval *models.Duration + ObservationTimeout *commonconfig.Duration + BlockchainTimeout *commonconfig.Duration + ContractPollInterval *commonconfig.Duration + ContractSubscribeInterval *commonconfig.Duration DefaultTransactionQueueDepth *uint32 // Optional KeyBundleID *models.Sha256Hash @@ -1063,8 +1064,8 @@ type P2PV2 struct { Enabled *bool AnnounceAddresses *[]string DefaultBootstrappers *[]ocrcommontypes.BootstrapperLocator - DeltaDial *models.Duration - DeltaReconcile *models.Duration + DeltaDial *commonconfig.Duration + DeltaReconcile *commonconfig.Duration ListenAddresses *[]string } @@ -1128,7 +1129,7 @@ type KeeperRegistry struct { CheckGasOverhead *uint32 PerformGasOverhead *uint32 MaxPerformDataSize *uint32 - SyncInterval *models.Duration + SyncInterval *commonconfig.Duration SyncUpkeepQueueSize *uint32 } @@ -1153,9 +1154,9 @@ func (k *KeeperRegistry) setFrom(f *KeeperRegistry) { type AutoPprof struct { Enabled *bool ProfileRoot *string - PollInterval *models.Duration - GatherDuration *models.Duration - GatherTraceDuration *models.Duration + PollInterval *commonconfig.Duration + GatherDuration *commonconfig.Duration + GatherTraceDuration *commonconfig.Duration MaxProfileSize *utils.FileSize CPUProfileRate *int64 // runtime.SetCPUProfileRate MemProfileRate *int64 // runtime.MemProfileRate @@ -1287,9 +1288,9 @@ func (ins *Insecure) setFrom(f *Insecure) { } type MercuryCache struct { - LatestReportTTL *models.Duration - MaxStaleAge *models.Duration - LatestReportDeadline *models.Duration + LatestReportTTL *commonconfig.Duration + MaxStaleAge *commonconfig.Duration + LatestReportDeadline *commonconfig.Duration } func (mc *MercuryCache) setFrom(f *MercuryCache) { diff --git a/core/config/toml/types_test.go b/core/config/toml/types_test.go index d29da688e33..9c3fd1d02df 100644 --- a/core/config/toml/types_test.go +++ b/core/config/toml/types_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/build" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/store/models" @@ -109,13 +110,13 @@ func Test_validateDBURL(t *testing.T) { } func TestDatabaseSecrets_ValidateConfig(t *testing.T) { - validUrl := models.URL(url.URL{Scheme: "https", Host: "localhost"}) + validUrl := commonconfig.URL(url.URL{Scheme: "https", Host: "localhost"}) validSecretURL := *models.NewSecretURL(&validUrl) - invalidEmptyUrl := models.URL(url.URL{}) + invalidEmptyUrl := commonconfig.URL(url.URL{}) invalidEmptySecretURL := *models.NewSecretURL(&invalidEmptyUrl) - invalidBackupURL := models.URL(url.URL{Scheme: "http", Host: "localhost"}) + invalidBackupURL := commonconfig.URL(url.URL{Scheme: "http", Host: "localhost"}) invalidBackupSecretURL := *models.NewSecretURL(&invalidBackupURL) tests := []struct { diff --git a/core/config/web_config.go b/core/config/web_config.go index 429a31e7e82..1f1adc47f5d 100644 --- a/core/config/web_config.go +++ b/core/config/web_config.go @@ -7,7 +7,7 @@ import ( "github.com/gin-contrib/sessions" - "github.com/smartcontractkit/chainlink/v2/core/store/models" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" ) type TLS interface { @@ -37,7 +37,7 @@ type LDAP interface { ReadOnlyUserLogin() string ReadOnlyUserPass() string ServerTLS() bool - SessionTimeout() models.Duration + SessionTimeout() commonconfig.Duration QueryTimeout() time.Duration BaseUserAttr() string BaseDN() string @@ -50,9 +50,9 @@ type LDAP interface { RunUserGroupCN() string ReadUserGroupCN() string UserApiTokenEnabled() bool - UserAPITokenDuration() models.Duration - UpstreamSyncInterval() models.Duration - UpstreamSyncRateLimit() models.Duration + UserAPITokenDuration() commonconfig.Duration + UpstreamSyncInterval() commonconfig.Duration + UpstreamSyncRateLimit() commonconfig.Duration } type WebServer interface { @@ -64,10 +64,10 @@ type WebServer interface { StartTimeout() time.Duration HTTPWriteTimeout() time.Duration HTTPPort() uint16 - SessionReaperExpiration() models.Duration + SessionReaperExpiration() commonconfig.Duration SecureCookies() bool SessionOptions() sessions.Options - SessionTimeout() models.Duration + SessionTimeout() commonconfig.Duration ListenIP() net.IP TLS() TLS diff --git a/core/internal/features/features_test.go b/core/internal/features/features_test.go index a0588f6abdc..8ae6a28a873 100644 --- a/core/internal/features/features_test.go +++ b/core/internal/features/features_test.go @@ -39,6 +39,7 @@ import ( "github.com/smartcontractkit/libocr/offchainreporting/confighelper" ocrtypes "github.com/smartcontractkit/libocr/offchainreporting/types" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/auth" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" @@ -85,7 +86,7 @@ func TestIntegration_ExternalInitiatorV2(t *testing.T) { cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.JobPipeline.ExternalInitiatorsEnabled = ptr(true) - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(10 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(10 * time.Millisecond) }) app := cltest.NewApplicationWithConfig(t, cfg, ethClient, cltest.UseRealExternalInitiatorManager) @@ -362,7 +363,7 @@ func TestIntegration_DirectRequest(t *testing.T) { // Simulate a consumer contract calling to obtain ETH quotes in 3 different currencies // in a single callback. config := configtest.NewGeneralConfigSimulated(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(100 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(100 * time.Millisecond) c.EVM[0].GasEstimator.EIP1559DynamicFees = ptr(true) }) operatorContracts := setupOperatorContracts(t) @@ -467,7 +468,7 @@ func setupAppForEthTx(t *testing.T, operatorContracts OperatorContracts) (app *c lggr, o := logger.TestLoggerObserved(t, zapcore.DebugLevel) cfg := configtest.NewGeneralConfigSimulated(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(100 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(100 * time.Millisecond) }) app = cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, cfg, b, lggr) b.Commit() @@ -689,10 +690,10 @@ func setupNode(t *testing.T, owner *bind.TransactOpts, portV2 int, c.P2P.V2.Enabled = ptr(true) c.P2P.V2.ListenAddresses = &[]string{fmt.Sprintf("127.0.0.1:%d", portV2)} - c.P2P.V2.DeltaReconcile = models.MustNewDuration(5 * time.Second) + c.P2P.V2.DeltaReconcile = commonconfig.MustNewDuration(5 * time.Second) // GracePeriod < ObservationTimeout - c.EVM[0].OCR.ObservationGracePeriod = models.MustNewDuration(100 * time.Millisecond) + c.EVM[0].OCR.ObservationGracePeriod = commonconfig.MustNewDuration(100 * time.Millisecond) if overrides != nil { overrides(c, s) @@ -732,7 +733,7 @@ func setupForwarderEnabledNode(t *testing.T, owner *bind.TransactOpts, portV2 in c.P2P.PeerID = ptr(p2pKey.PeerID()) c.P2P.V2.Enabled = ptr(true) c.P2P.V2.ListenAddresses = &[]string{fmt.Sprintf("127.0.0.1:%d", portV2)} - c.P2P.V2.DeltaReconcile = models.MustNewDuration(5 * time.Second) + c.P2P.V2.DeltaReconcile = commonconfig.MustNewDuration(5 * time.Second) c.EVM[0].Transactions.ForwardersEnabled = ptr(true) diff --git a/core/internal/features/ocr2/features_ocr2_test.go b/core/internal/features/ocr2/features_ocr2_test.go index e3b6c1a24d1..863451de733 100644 --- a/core/internal/features/ocr2/features_ocr2_test.go +++ b/core/internal/features/ocr2/features_ocr2_test.go @@ -34,6 +34,7 @@ import ( confighelper2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" ocrtypes2 "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/forwarders" @@ -120,14 +121,14 @@ func setupNodeOCR2( c.P2P.PeerID = ptr(p2pKey.PeerID()) c.P2P.V2.Enabled = ptr(true) - c.P2P.V2.DeltaDial = models.MustNewDuration(500 * time.Millisecond) - c.P2P.V2.DeltaReconcile = models.MustNewDuration(5 * time.Second) + c.P2P.V2.DeltaDial = commonconfig.MustNewDuration(500 * time.Millisecond) + c.P2P.V2.DeltaReconcile = commonconfig.MustNewDuration(5 * time.Second) c.P2P.V2.ListenAddresses = &[]string{fmt.Sprintf("127.0.0.1:%d", port)} if len(p2pV2Bootstrappers) > 0 { c.P2P.V2.DefaultBootstrappers = &p2pV2Bootstrappers } - c.EVM[0].LogPollInterval = models.MustNewDuration(5 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(5 * time.Second) c.EVM[0].Transactions.ForwardersEnabled = &useForwarder }) diff --git a/core/internal/testutils/configtest/general_config.go b/core/internal/testutils/configtest/general_config.go index c414c973160..d2851035855 100644 --- a/core/internal/testutils/configtest/general_config.go +++ b/core/internal/testutils/configtest/general_config.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" @@ -45,21 +46,21 @@ func overrides(c *chainlink.Config, s *chainlink.Secrets) { c.Insecure.OCRDevelopmentMode = ptr(true) c.InsecureFastScrypt = ptr(true) - c.ShutdownGracePeriod = models.MustNewDuration(testutils.DefaultWaitTimeout) + c.ShutdownGracePeriod = commonconfig.MustNewDuration(testutils.DefaultWaitTimeout) c.Database.Dialect = dialects.TransactionWrappedPostgres c.Database.Lock.Enabled = ptr(false) c.Database.MaxIdleConns = ptr[int64](20) c.Database.MaxOpenConns = ptr[int64](20) c.Database.MigrateOnStartup = ptr(false) - c.Database.DefaultLockTimeout = models.MustNewDuration(1 * time.Minute) + c.Database.DefaultLockTimeout = commonconfig.MustNewDuration(1 * time.Minute) - c.JobPipeline.ReaperInterval = models.MustNewDuration(0) + c.JobPipeline.ReaperInterval = commonconfig.MustNewDuration(0) c.P2P.V2.Enabled = ptr(false) - c.WebServer.SessionTimeout = models.MustNewDuration(2 * time.Minute) - c.WebServer.BridgeResponseURL = models.MustParseURL("http://localhost:6688") + c.WebServer.SessionTimeout = commonconfig.MustNewDuration(2 * time.Minute) + c.WebServer.BridgeResponseURL = commonconfig.MustParseURL("http://localhost:6688") testIP := net.ParseIP("127.0.0.1") c.WebServer.ListenIP = &testIP c.WebServer.TLS.ListenIP = &testIP @@ -71,8 +72,8 @@ func overrides(c *chainlink.Config, s *chainlink.Secrets) { Nodes: evmcfg.EVMNodes{ &evmcfg.Node{ Name: ptr("test"), - WSURL: &models.URL{}, - HTTPURL: &models.URL{}, + WSURL: &commonconfig.URL{}, + HTTPURL: &commonconfig.URL{}, SendOnly: new(bool), Order: ptr[int32](100), }, @@ -112,8 +113,8 @@ func simulated(c *chainlink.Config, s *chainlink.Secrets) { var validTestNode = evmcfg.Node{ Name: ptr("simulated-node"), - WSURL: models.MustParseURL("WSS://simulated-wss.com/ws"), - HTTPURL: models.MustParseURL("http://simulated.com"), + WSURL: commonconfig.MustParseURL("WSS://simulated-wss.com/ws"), + HTTPURL: commonconfig.MustParseURL("http://simulated.com"), SendOnly: nil, Order: ptr(int32(1)), } diff --git a/core/logger/audit/audit_logger.go b/core/logger/audit/audit_logger.go index ef66a063a55..2f96c40586f 100644 --- a/core/logger/audit/audit_logger.go +++ b/core/logger/audit/audit_logger.go @@ -13,8 +13,8 @@ import ( "os" "time" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/services" - "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/store/models" @@ -38,7 +38,7 @@ type HTTPAuditLoggerInterface interface { type AuditLoggerService struct { logger logger.Logger // The standard logger configured in the node enabled bool // Whether the audit logger is enabled or not - forwardToUrl models.URL // Location we are going to send logs to + forwardToUrl commonconfig.URL // Location we are going to send logs to headers []models.ServiceHeader // Headers to be sent along with logs for identification/authentication jsonWrapperKey string // Wrap audit data as a map under this key if present environmentName string // Decorate the environment this is coming from diff --git a/core/logger/audit/audit_logger_test.go b/core/logger/audit/audit_logger_test.go index 576d11df3a4..a28c35b129d 100644 --- a/core/logger/audit/audit_logger_test.go +++ b/core/logger/audit/audit_logger_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/require" "github.com/urfave/cli" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" @@ -65,10 +66,10 @@ func (c Config) Environment() string { return "test" } -func (c Config) ForwardToUrl() (models.URL, error) { - url, err := models.ParseURL("http://localhost:9898") +func (c Config) ForwardToUrl() (commonconfig.URL, error) { + url, err := commonconfig.ParseURL("http://localhost:9898") if err != nil { - return models.URL{}, err + return commonconfig.URL{}, err } return *url, nil } diff --git a/core/scripts/go.mod b/core/scripts/go.mod index 98ab5cbfaf9..8cd50b08541 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -19,7 +19,7 @@ require ( github.com/pelletier/go-toml/v2 v2.1.1 github.com/shopspring/decimal v1.3.1 github.com/smartcontractkit/chainlink-automation v1.0.1 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20231222010926-795676d23c7a + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240104174432-88b0f2a535a6 github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20231130143053-c5102a9c0fb7 diff --git a/core/scripts/go.sum b/core/scripts/go.sum index 170e36ad2cc..eb5bbb9cdf7 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1164,8 +1164,8 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.1 h1:vVjBFq2Zsz21kPy1Pb0wpjF9zrbJX+zjXphDeeR4XZk= github.com/smartcontractkit/chainlink-automation v1.0.1/go.mod h1:INSchkV3ntyDdlZKGWA030MPDpp6pbeuiRkRKYFCm2k= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231222010926-795676d23c7a h1:ViX8kP1/WYW1dLG85Frqpvus1nRGif/1QiK7qeyS+Rc= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231222010926-795676d23c7a/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240104174432-88b0f2a535a6 h1:zFupIn0S1JYnKUJffFS+m4k+9BUlBG4IHsOpu6kkqKM= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240104174432-88b0f2a535a6/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231218175426-6e0427c661e5 h1:kBnmjv3fxU7krVIqZFvo1m4F6qBc4vPURQFX/mcChhI= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231218175426-6e0427c661e5/go.mod h1:EoM7wQ81mov7wsUzG4zEnnr0EH0POEo/I0hRDg433TU= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 h1:xYqRgZO0nMSO8CBCMR0r3WA+LZ4kNL8a6bnbyk/oBtQ= diff --git a/core/services/chainlink/config.go b/core/services/chainlink/config.go index 192fbb311d3..6cd2732ece8 100644 --- a/core/services/chainlink/config.go +++ b/core/services/chainlink/config.go @@ -30,7 +30,7 @@ import ( // - TOML is limited to int64/float64, so fields requiring greater range/precision must use non-standard types // implementing encoding.TextMarshaler/TextUnmarshaler, like big.Big and decimal.Decimal // - std lib types that don't implement encoding.TextMarshaler/TextUnmarshaler (time.Duration, url.URL, big.Int) won't -// work as expected, and require wrapper types. See models.Duration, models.URL, big.Big. +// work as expected, and require wrapper types. See commonconfig.Duration, commonconfig.URL, big.Big. type Config struct { toml.Core diff --git a/core/services/chainlink/config_audit_logger.go b/core/services/chainlink/config_audit_logger.go index 1593f3887fb..5d8c00f771d 100644 --- a/core/services/chainlink/config_audit_logger.go +++ b/core/services/chainlink/config_audit_logger.go @@ -1,6 +1,7 @@ package chainlink import ( + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/build" "github.com/smartcontractkit/chainlink/v2/core/config/toml" "github.com/smartcontractkit/chainlink/v2/core/store/models" @@ -14,7 +15,7 @@ func (a auditLoggerConfig) Enabled() bool { return *a.c.Enabled } -func (a auditLoggerConfig) ForwardToUrl() (models.URL, error) { +func (a auditLoggerConfig) ForwardToUrl() (commonconfig.URL, error) { return *a.c.ForwardToUrl, nil } diff --git a/core/services/chainlink/config_auto_pprof.go b/core/services/chainlink/config_auto_pprof.go index 8cc5f2dd3e8..48ec7749b79 100644 --- a/core/services/chainlink/config_auto_pprof.go +++ b/core/services/chainlink/config_auto_pprof.go @@ -3,9 +3,9 @@ package chainlink import ( "path/filepath" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/config/toml" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -28,12 +28,12 @@ func (a *autoPprofConfig) CPUProfileRate() int { return int(*a.c.CPUProfileRate) } -func (a *autoPprofConfig) GatherDuration() models.Duration { - return models.MustMakeDuration(a.c.GatherDuration.Duration()) +func (a *autoPprofConfig) GatherDuration() commonconfig.Duration { + return *commonconfig.MustNewDuration(a.c.GatherDuration.Duration()) } -func (a *autoPprofConfig) GatherTraceDuration() models.Duration { - return models.MustMakeDuration(a.c.GatherTraceDuration.Duration()) +func (a *autoPprofConfig) GatherTraceDuration() commonconfig.Duration { + return *commonconfig.MustNewDuration(a.c.GatherTraceDuration.Duration()) } func (a *autoPprofConfig) GoroutineThreshold() int { @@ -56,7 +56,7 @@ func (a *autoPprofConfig) MutexProfileFraction() int { return int(*a.c.MutexProfileFraction) } -func (a *autoPprofConfig) PollInterval() models.Duration { +func (a *autoPprofConfig) PollInterval() commonconfig.Duration { return *a.c.PollInterval } diff --git a/core/services/chainlink/config_general.go b/core/services/chainlink/config_general.go index cb68ed0e72d..97243926973 100644 --- a/core/services/chainlink/config_general.go +++ b/core/services/chainlink/config_general.go @@ -357,12 +357,12 @@ func (g *generalConfig) AutoPprofCPUProfileRate() int { return int(*g.c.AutoPprof.CPUProfileRate) } -func (g *generalConfig) AutoPprofGatherDuration() models.Duration { - return models.MustMakeDuration(g.c.AutoPprof.GatherDuration.Duration()) +func (g *generalConfig) AutoPprofGatherDuration() commonconfig.Duration { + return *commonconfig.MustNewDuration(g.c.AutoPprof.GatherDuration.Duration()) } -func (g *generalConfig) AutoPprofGatherTraceDuration() models.Duration { - return models.MustMakeDuration(g.c.AutoPprof.GatherTraceDuration.Duration()) +func (g *generalConfig) AutoPprofGatherTraceDuration() commonconfig.Duration { + return *commonconfig.MustNewDuration(g.c.AutoPprof.GatherTraceDuration.Duration()) } func (g *generalConfig) AutoPprofGoroutineThreshold() int { @@ -385,7 +385,7 @@ func (g *generalConfig) AutoPprofMutexProfileFraction() int { return int(*g.c.AutoPprof.MutexProfileFraction) } -func (g *generalConfig) AutoPprofPollInterval() models.Duration { +func (g *generalConfig) AutoPprofPollInterval() commonconfig.Duration { return *g.c.AutoPprof.PollInterval } diff --git a/core/services/chainlink/config_job_pipeline.go b/core/services/chainlink/config_job_pipeline.go index 1586cbb3574..95106b84199 100644 --- a/core/services/chainlink/config_job_pipeline.go +++ b/core/services/chainlink/config_job_pipeline.go @@ -3,9 +3,9 @@ package chainlink import ( "time" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/config/toml" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) var _ config.JobPipeline = (*jobPipelineConfig)(nil) @@ -18,7 +18,7 @@ func (j *jobPipelineConfig) DefaultHTTPLimit() int64 { return int64(*j.c.HTTPRequest.MaxSize) } -func (j *jobPipelineConfig) DefaultHTTPTimeout() models.Duration { +func (j *jobPipelineConfig) DefaultHTTPTimeout() commonconfig.Duration { return *j.c.HTTPRequest.DefaultTimeout } diff --git a/core/services/chainlink/config_job_pipeline_test.go b/core/services/chainlink/config_job_pipeline_test.go index 58c94067f25..0b771a18fb7 100644 --- a/core/services/chainlink/config_job_pipeline_test.go +++ b/core/services/chainlink/config_job_pipeline_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink/v2/core/store/models" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -21,7 +21,7 @@ func TestJobPipelineConfigTest(t *testing.T) { jp := cfg.JobPipeline() assert.Equal(t, int64(100*utils.MB), jp.DefaultHTTPLimit()) - d, err := models.MakeDuration(1 * time.Minute) + d, err := commonconfig.MakeDuration(1 * time.Minute) require.NoError(t, err) assert.Equal(t, d, jp.DefaultHTTPTimeout()) assert.Equal(t, 1*time.Hour, jp.MaxRunDuration()) diff --git a/core/services/chainlink/config_p2p.go b/core/services/chainlink/config_p2p.go index 596a4fe0cae..4197358b148 100644 --- a/core/services/chainlink/config_p2p.go +++ b/core/services/chainlink/config_p2p.go @@ -1,12 +1,12 @@ package chainlink import ( - "github.com/smartcontractkit/libocr/commontypes" - + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/config/toml" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" - "github.com/smartcontractkit/chainlink/v2/core/store/models" + + "github.com/smartcontractkit/libocr/commontypes" ) type p2p struct { @@ -59,19 +59,19 @@ func (v *p2pv2) DefaultBootstrappers() (locators []commontypes.BootstrapperLocat return nil } -func (v *p2pv2) DeltaDial() models.Duration { +func (v *p2pv2) DeltaDial() commonconfig.Duration { if d := v.c.DeltaDial; d != nil { return *d } - return models.Duration{} + return commonconfig.Duration{} } -func (v *p2pv2) DeltaReconcile() models.Duration { +func (v *p2pv2) DeltaReconcile() commonconfig.Duration { if d := v.c.DeltaReconcile; d != nil { return *d } - return models.Duration{} + return commonconfig.Duration{} } func (v *p2pv2) ListenAddresses() []string { diff --git a/core/services/chainlink/config_test.go b/core/services/chainlink/config_test.go index 10ab00e8bd0..a7ac1e86d84 100644 --- a/core/services/chainlink/config_test.go +++ b/core/services/chainlink/config_test.go @@ -20,6 +20,7 @@ import ( commonassets "github.com/smartcontractkit/chainlink-common/pkg/assets" "github.com/smartcontractkit/chainlink-common/pkg/config" commoncfg "github.com/smartcontractkit/chainlink-common/pkg/config" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/utils/hex" coscfg "github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/config" "github.com/smartcontractkit/chainlink-solana/pkg/solana" @@ -66,7 +67,7 @@ var ( }, Database: toml.Database{ Listener: toml.DatabaseListener{ - FallbackPollInterval: models.MustNewDuration(2 * time.Minute), + FallbackPollInterval: commonconfig.MustNewDuration(2 * time.Minute), }, }, Log: toml.Log{ @@ -75,16 +76,16 @@ var ( }, JobPipeline: toml.JobPipeline{ HTTPRequest: toml.JobPipelineHTTPRequest{ - DefaultTimeout: models.MustNewDuration(30 * time.Second), + DefaultTimeout: commonconfig.MustNewDuration(30 * time.Second), }, }, OCR2: toml.OCR2{ Enabled: ptr(true), - DatabaseTimeout: models.MustNewDuration(20 * time.Second), + DatabaseTimeout: commonconfig.MustNewDuration(20 * time.Second), }, OCR: toml.OCR{ Enabled: ptr(true), - BlockchainTimeout: models.MustNewDuration(5 * time.Second), + BlockchainTimeout: commonconfig.MustNewDuration(5 * time.Second), }, P2P: toml.P2P{ IncomingMessageBufferSize: ptr[int64](999), @@ -194,10 +195,10 @@ var ( ) func TestConfig_Marshal(t *testing.T) { - zeroSeconds := models.MustMakeDuration(time.Second * 0) - second := models.MustMakeDuration(time.Second) - minute := models.MustMakeDuration(time.Minute) - hour := models.MustMakeDuration(time.Hour) + zeroSeconds := *commonconfig.MustNewDuration(time.Second * 0) + second := *commonconfig.MustNewDuration(time.Second) + minute := *commonconfig.MustNewDuration(time.Minute) + hour := *commonconfig.MustNewDuration(time.Hour) mustPeerID := func(s string) *p2pkey.PeerID { id, err := p2pkey.MakePeerID(s) require.NoError(t, err) @@ -219,7 +220,7 @@ func TestConfig_Marshal(t *testing.T) { Core: toml.Core{ InsecureFastScrypt: ptr(true), RootDir: ptr("test/root/dir"), - ShutdownGracePeriod: models.MustNewDuration(10 * time.Second), + ShutdownGracePeriod: commonconfig.MustNewDuration(10 * time.Second), Insecure: toml.Insecure{ DevWebServer: ptr(false), OCRDevelopmentMode: ptr(false), @@ -260,17 +261,17 @@ func TestConfig_Marshal(t *testing.T) { UICSAKeys: ptr(true), } full.Database = toml.Database{ - DefaultIdleInTxSessionTimeout: models.MustNewDuration(time.Minute), - DefaultLockTimeout: models.MustNewDuration(time.Hour), - DefaultQueryTimeout: models.MustNewDuration(time.Second), + DefaultIdleInTxSessionTimeout: commonconfig.MustNewDuration(time.Minute), + DefaultLockTimeout: commonconfig.MustNewDuration(time.Hour), + DefaultQueryTimeout: commonconfig.MustNewDuration(time.Second), LogQueries: ptr(true), MigrateOnStartup: ptr(true), MaxIdleConns: ptr[int64](7), MaxOpenConns: ptr[int64](13), Listener: toml.DatabaseListener{ - MaxReconnectDuration: models.MustNewDuration(time.Minute), - MinReconnectInterval: models.MustNewDuration(5 * time.Minute), - FallbackPollInterval: models.MustNewDuration(2 * time.Minute), + MaxReconnectDuration: commonconfig.MustNewDuration(time.Minute), + MinReconnectInterval: commonconfig.MustNewDuration(5 * time.Minute), + FallbackPollInterval: commonconfig.MustNewDuration(2 * time.Minute), }, Lock: toml.DatabaseLock{ Enabled: ptr(false), @@ -289,10 +290,10 @@ func TestConfig_Marshal(t *testing.T) { Logging: ptr(true), BufferSize: ptr[uint16](1234), MaxBatchSize: ptr[uint16](4321), - SendInterval: models.MustNewDuration(time.Minute), - SendTimeout: models.MustNewDuration(5 * time.Second), + SendInterval: commonconfig.MustNewDuration(time.Minute), + SendTimeout: commonconfig.MustNewDuration(5 * time.Second), UseBatchSend: ptr(true), - URL: ptr(models.URL{}), + URL: ptr(commonconfig.URL{}), ServerPubKey: ptr(""), Endpoints: []toml.TelemetryIngressEndpoint{{ Network: ptr("EVM"), @@ -317,14 +318,14 @@ func TestConfig_Marshal(t *testing.T) { AuthenticationMethod: ptr("local"), AllowOrigins: ptr("*"), BridgeResponseURL: mustURL("https://bridge.response"), - BridgeCacheTTL: models.MustNewDuration(10 * time.Second), - HTTPWriteTimeout: models.MustNewDuration(time.Minute), + BridgeCacheTTL: commonconfig.MustNewDuration(10 * time.Second), + HTTPWriteTimeout: commonconfig.MustNewDuration(time.Minute), HTTPPort: ptr[uint16](56), SecureCookies: ptr(true), - SessionTimeout: models.MustNewDuration(time.Hour), - SessionReaperExpiration: models.MustNewDuration(7 * 24 * time.Hour), + SessionTimeout: commonconfig.MustNewDuration(time.Hour), + SessionReaperExpiration: commonconfig.MustNewDuration(7 * 24 * time.Hour), HTTPMaxSize: ptr(utils.FileSize(uint64(32770))), - StartTimeout: models.MustNewDuration(15 * time.Second), + StartTimeout: commonconfig.MustNewDuration(15 * time.Second), ListenIP: mustIP("192.158.1.37"), MFA: toml.WebServerMFA{ RPID: ptr("test-rpid"), @@ -332,8 +333,8 @@ func TestConfig_Marshal(t *testing.T) { }, LDAP: toml.WebServerLDAP{ ServerTLS: ptr(true), - SessionTimeout: models.MustNewDuration(15 * time.Minute), - QueryTimeout: models.MustNewDuration(2 * time.Minute), + SessionTimeout: commonconfig.MustNewDuration(15 * time.Minute), + QueryTimeout: commonconfig.MustNewDuration(2 * time.Minute), BaseUserAttr: ptr("uid"), BaseDN: ptr("dc=custom,dc=example,dc=com"), UsersDN: ptr("ou=users"), @@ -345,15 +346,15 @@ func TestConfig_Marshal(t *testing.T) { RunUserGroupCN: ptr("NodeRunners"), ReadUserGroupCN: ptr("NodeReadOnly"), UserApiTokenEnabled: ptr(false), - UserAPITokenDuration: models.MustNewDuration(240 * time.Hour), - UpstreamSyncInterval: models.MustNewDuration(0 * time.Second), - UpstreamSyncRateLimit: models.MustNewDuration(2 * time.Minute), + UserAPITokenDuration: commonconfig.MustNewDuration(240 * time.Hour), + UpstreamSyncInterval: commonconfig.MustNewDuration(0 * time.Second), + UpstreamSyncRateLimit: commonconfig.MustNewDuration(2 * time.Minute), }, RateLimit: toml.WebServerRateLimit{ Authenticated: ptr[int64](42), - AuthenticatedPeriod: models.MustNewDuration(time.Second), + AuthenticatedPeriod: commonconfig.MustNewDuration(time.Second), Unauthenticated: ptr[int64](7), - UnauthenticatedPeriod: models.MustNewDuration(time.Minute), + UnauthenticatedPeriod: commonconfig.MustNewDuration(time.Minute), }, TLS: toml.WebServerTLS{ CertPath: ptr("tls/cert/path"), @@ -366,14 +367,14 @@ func TestConfig_Marshal(t *testing.T) { } full.JobPipeline = toml.JobPipeline{ ExternalInitiatorsEnabled: ptr(true), - MaxRunDuration: models.MustNewDuration(time.Hour), + MaxRunDuration: commonconfig.MustNewDuration(time.Hour), MaxSuccessfulRuns: ptr[uint64](123456), - ReaperInterval: models.MustNewDuration(4 * time.Hour), - ReaperThreshold: models.MustNewDuration(7 * 24 * time.Hour), + ReaperInterval: commonconfig.MustNewDuration(4 * time.Hour), + ReaperThreshold: commonconfig.MustNewDuration(7 * 24 * time.Hour), ResultWriteQueueDepth: ptr[uint32](10), HTTPRequest: toml.JobPipelineHTTPRequest{ MaxSize: ptr[utils.FileSize](100 * utils.MB), - DefaultTimeout: models.MustNewDuration(time.Minute), + DefaultTimeout: commonconfig.MustNewDuration(time.Minute), }, } full.FluxMonitor = toml.FluxMonitor{ @@ -383,11 +384,11 @@ func TestConfig_Marshal(t *testing.T) { full.OCR2 = toml.OCR2{ Enabled: ptr(true), ContractConfirmations: ptr[uint32](11), - BlockchainTimeout: models.MustNewDuration(3 * time.Second), - ContractPollInterval: models.MustNewDuration(time.Hour), - ContractSubscribeInterval: models.MustNewDuration(time.Minute), - ContractTransmitterTransmitTimeout: models.MustNewDuration(time.Minute), - DatabaseTimeout: models.MustNewDuration(8 * time.Second), + BlockchainTimeout: commonconfig.MustNewDuration(3 * time.Second), + ContractPollInterval: commonconfig.MustNewDuration(time.Hour), + ContractSubscribeInterval: commonconfig.MustNewDuration(time.Minute), + ContractTransmitterTransmitTimeout: commonconfig.MustNewDuration(time.Minute), + DatabaseTimeout: commonconfig.MustNewDuration(8 * time.Second), KeyBundleID: ptr(models.MustSha256HashFromHex("7a5f66bbe6594259325bf2b4f5b1a9c9")), CaptureEATelemetry: ptr(false), CaptureAutomationCustomTelemetry: ptr(true), @@ -397,10 +398,10 @@ func TestConfig_Marshal(t *testing.T) { } full.OCR = toml.OCR{ Enabled: ptr(true), - ObservationTimeout: models.MustNewDuration(11 * time.Second), - BlockchainTimeout: models.MustNewDuration(3 * time.Second), - ContractPollInterval: models.MustNewDuration(time.Hour), - ContractSubscribeInterval: models.MustNewDuration(time.Minute), + ObservationTimeout: commonconfig.MustNewDuration(11 * time.Second), + BlockchainTimeout: commonconfig.MustNewDuration(3 * time.Second), + ContractPollInterval: commonconfig.MustNewDuration(time.Hour), + ContractSubscribeInterval: commonconfig.MustNewDuration(time.Minute), DefaultTransactionQueueDepth: ptr[uint32](12), KeyBundleID: ptr(models.MustSha256HashFromHex("acdd42797a8b921b2910497badc50006")), SimulateTransactions: ptr(true), @@ -420,8 +421,8 @@ func TestConfig_Marshal(t *testing.T) { {PeerID: "12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw", Addrs: []string{"foo:42", "bar:10"}}, {PeerID: "12D3KooWMoejJznyDuEk5aX6GvbjaG12UzeornPCBNzMRqdwrFJw", Addrs: []string{"test:99"}}, }, - DeltaDial: models.MustNewDuration(time.Minute), - DeltaReconcile: models.MustNewDuration(time.Second), + DeltaDial: commonconfig.MustNewDuration(time.Minute), + DeltaReconcile: commonconfig.MustNewDuration(time.Second), ListenAddresses: &[]string{"foo", "bar"}, }, } @@ -435,7 +436,7 @@ func TestConfig_Marshal(t *testing.T) { Registry: toml.KeeperRegistry{ CheckGasOverhead: ptr[uint32](90), PerformGasOverhead: ptr[uint32](math.MaxUint32), - SyncInterval: models.MustNewDuration(time.Hour), + SyncInterval: commonconfig.MustNewDuration(time.Hour), SyncUpkeepQueueSize: ptr[uint32](31), MaxPerformDataSize: ptr[uint32](5000), }, @@ -443,9 +444,9 @@ func TestConfig_Marshal(t *testing.T) { full.AutoPprof = toml.AutoPprof{ Enabled: ptr(true), ProfileRoot: ptr("prof/root"), - PollInterval: models.MustNewDuration(time.Minute), - GatherDuration: models.MustNewDuration(12 * time.Second), - GatherTraceDuration: models.MustNewDuration(13 * time.Second), + PollInterval: commonconfig.MustNewDuration(time.Minute), + GatherDuration: commonconfig.MustNewDuration(12 * time.Second), + GatherTraceDuration: commonconfig.MustNewDuration(13 * time.Second), MaxProfileSize: ptr[utils.FileSize](utils.GB), CPUProfileRate: ptr[int64](7), MemProfileRate: ptr[int64](9), @@ -564,8 +565,8 @@ func TestConfig_Marshal(t *testing.T) { ContractConfirmations: ptr[uint16](11), ContractTransmitterTransmitTimeout: &minute, DatabaseTimeout: &second, - DeltaCOverride: models.MustNewDuration(time.Hour), - DeltaCJitterOverride: models.MustNewDuration(time.Second), + DeltaCOverride: commonconfig.MustNewDuration(time.Hour), + DeltaCJitterOverride: commonconfig.MustNewDuration(time.Second), ObservationGracePeriod: &second, }, OCR2: evmcfg.OCR2{ @@ -662,9 +663,9 @@ func TestConfig_Marshal(t *testing.T) { } full.Mercury = toml.Mercury{ Cache: toml.MercuryCache{ - LatestReportTTL: models.MustNewDuration(100 * time.Second), - MaxStaleAge: models.MustNewDuration(101 * time.Second), - LatestReportDeadline: models.MustNewDuration(102 * time.Second), + LatestReportTTL: commonconfig.MustNewDuration(100 * time.Second), + MaxStaleAge: commonconfig.MustNewDuration(101 * time.Second), + LatestReportDeadline: commonconfig.MustNewDuration(102 * time.Second), }, TLS: toml.MercuryTLS{ CertFile: ptr("/path/to/cert.pem"), @@ -1129,7 +1130,7 @@ func TestConfig_full(t *testing.T) { for c := range got.EVM { for n := range got.EVM[c].Nodes { if got.EVM[c].Nodes[n].WSURL == nil { - got.EVM[c].Nodes[n].WSURL = new(models.URL) + got.EVM[c].Nodes[n].WSURL = new(commonconfig.URL) } if got.EVM[c].Nodes[n].SendOnly == nil { got.EVM[c].Nodes[n].SendOnly = ptr(true) @@ -1148,7 +1149,7 @@ func TestConfig_full(t *testing.T) { // Except for TelemetryIngress.URL as this will be removed in the future // and its only use is to signal to NOPs that these fields are no longer allowed if got.TelemetryIngress.URL == nil { - got.TelemetryIngress.URL = new(models.URL) + got.TelemetryIngress.URL = new(commonconfig.URL) } cfgtest.AssertFieldsNotNil(t, got) @@ -1261,8 +1262,8 @@ func TestConfig_Validate(t *testing.T) { } } -func mustURL(s string) *models.URL { - var u models.URL +func mustURL(s string) *commonconfig.URL { + var u commonconfig.URL if err := u.UnmarshalText([]byte(s)); err != nil { panic(err) } diff --git a/core/services/chainlink/config_web_server.go b/core/services/chainlink/config_web_server.go index 06db398e2ea..473f70a4c9c 100644 --- a/core/services/chainlink/config_web_server.go +++ b/core/services/chainlink/config_web_server.go @@ -9,9 +9,9 @@ import ( "github.com/gin-contrib/sessions" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/config/toml" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) var _ config.WebServer = (*webServerConfig)(nil) @@ -153,7 +153,7 @@ func (w *webServerConfig) HTTPPort() uint16 { return *w.c.HTTPPort } -func (w *webServerConfig) SessionReaperExpiration() models.Duration { +func (w *webServerConfig) SessionReaperExpiration() commonconfig.Duration { return *w.c.SessionReaperExpiration } @@ -170,8 +170,8 @@ func (w *webServerConfig) SessionOptions() sessions.Options { } } -func (w *webServerConfig) SessionTimeout() models.Duration { - return models.MustMakeDuration(w.c.SessionTimeout.Duration()) +func (w *webServerConfig) SessionTimeout() commonconfig.Duration { + return *commonconfig.MustNewDuration(w.c.SessionTimeout.Duration()) } func (w *webServerConfig) ListenIP() net.IP { @@ -211,7 +211,7 @@ func (l *ldapConfig) ServerTLS() bool { return *l.c.ServerTLS } -func (l *ldapConfig) SessionTimeout() models.Duration { +func (l *ldapConfig) SessionTimeout() commonconfig.Duration { return *l.c.SessionTimeout } @@ -219,7 +219,7 @@ func (l *ldapConfig) QueryTimeout() time.Duration { return l.c.QueryTimeout.Duration() } -func (l *ldapConfig) UserAPITokenDuration() models.Duration { +func (l *ldapConfig) UserAPITokenDuration() commonconfig.Duration { return *l.c.UserAPITokenDuration } @@ -300,16 +300,16 @@ func (l *ldapConfig) UserApiTokenEnabled() bool { return *l.c.UserApiTokenEnabled } -func (l *ldapConfig) UpstreamSyncInterval() models.Duration { +func (l *ldapConfig) UpstreamSyncInterval() commonconfig.Duration { if l.c.UpstreamSyncInterval == nil { - return models.Duration{} + return commonconfig.Duration{} } return *l.c.UpstreamSyncInterval } -func (l *ldapConfig) UpstreamSyncRateLimit() models.Duration { +func (l *ldapConfig) UpstreamSyncRateLimit() commonconfig.Duration { if l.c.UpstreamSyncRateLimit == nil { - return models.Duration{} + return commonconfig.Duration{} } return *l.c.UpstreamSyncRateLimit } diff --git a/core/services/chainlink/config_web_server_test.go b/core/services/chainlink/config_web_server_test.go index 92e8dde460a..946e0b0c12b 100644 --- a/core/services/chainlink/config_web_server_test.go +++ b/core/services/chainlink/config_web_server_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func TestWebServerConfig(t *testing.T) { @@ -24,8 +24,8 @@ func TestWebServerConfig(t *testing.T) { assert.Equal(t, 1*time.Minute, ws.HTTPWriteTimeout()) assert.Equal(t, uint16(56), ws.HTTPPort()) assert.True(t, ws.SecureCookies()) - assert.Equal(t, *models.MustNewDuration(1 * time.Hour), ws.SessionTimeout()) - assert.Equal(t, *models.MustNewDuration(168 * time.Hour), ws.SessionReaperExpiration()) + assert.Equal(t, *commonconfig.MustNewDuration(1 * time.Hour), ws.SessionTimeout()) + assert.Equal(t, *commonconfig.MustNewDuration(168 * time.Hour), ws.SessionReaperExpiration()) assert.Equal(t, int64(32770), ws.HTTPMaxSize()) assert.Equal(t, 15*time.Second, ws.StartTimeout()) tls := ws.TLS() diff --git a/core/services/chainlink/relayer_chain_interoperators_test.go b/core/services/chainlink/relayer_chain_interoperators_test.go index 6f6e3afce31..499eca9748a 100644 --- a/core/services/chainlink/relayer_chain_interoperators_test.go +++ b/core/services/chainlink/relayer_chain_interoperators_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - commoncfg "github.com/smartcontractkit/chainlink-common/pkg/config" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/loop" "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox" @@ -26,7 +26,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/relay" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/plugins" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" @@ -45,22 +44,22 @@ func TestCoreRelayerChainInteroperators(t *testing.T) { cfg := evmcfg.Defaults(evmChainID1) node1_1 := evmcfg.Node{ Name: ptr("Test node chain1:1"), - WSURL: models.MustParseURL("ws://localhost:8546"), - HTTPURL: models.MustParseURL("http://localhost:8546"), + WSURL: commonconfig.MustParseURL("ws://localhost:8546"), + HTTPURL: commonconfig.MustParseURL("http://localhost:8546"), SendOnly: ptr(false), Order: ptr(int32(15)), } node1_2 := evmcfg.Node{ Name: ptr("Test node chain1:2"), - WSURL: models.MustParseURL("ws://localhost:8547"), - HTTPURL: models.MustParseURL("http://localhost:8547"), + WSURL: commonconfig.MustParseURL("ws://localhost:8547"), + HTTPURL: commonconfig.MustParseURL("http://localhost:8547"), SendOnly: ptr(false), Order: ptr(int32(36)), } node2_1 := evmcfg.Node{ Name: ptr("Test node chain2:1"), - WSURL: models.MustParseURL("ws://localhost:8547"), - HTTPURL: models.MustParseURL("http://localhost:8547"), + WSURL: commonconfig.MustParseURL("ws://localhost:8547"), + HTTPURL: commonconfig.MustParseURL("http://localhost:8547"), SendOnly: ptr(false), Order: ptr(int32(11)), } @@ -85,7 +84,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) { Chain: solcfg.Chain{}, Nodes: []*solcfg.Node{{ Name: ptr("solana chain 1 node 1"), - URL: ((*commoncfg.URL)(models.MustParseURL("http://localhost:8547").URL())), + URL: ((*commonconfig.URL)(commonconfig.MustParseURL("http://localhost:8547").URL())), }}, }, &solana.TOMLConfig{ @@ -94,7 +93,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) { Chain: solcfg.Chain{}, Nodes: []*solcfg.Node{{ Name: ptr("solana chain 2 node 1"), - URL: ((*commoncfg.URL)(models.MustParseURL("http://localhost:8527").URL())), + URL: ((*commonconfig.URL)(commonconfig.MustParseURL("http://localhost:8527").URL())), }}, }, } @@ -107,15 +106,15 @@ func TestCoreRelayerChainInteroperators(t *testing.T) { Nodes: []*stkcfg.Node{ { Name: ptr("starknet chain 1 node 1"), - URL: ((*commoncfg.URL)(models.MustParseURL("http://localhost:8547").URL())), + URL: ((*commonconfig.URL)(commonconfig.MustParseURL("http://localhost:8547").URL())), }, { Name: ptr("starknet chain 1 node 2"), - URL: ((*commoncfg.URL)(models.MustParseURL("http://localhost:8548").URL())), + URL: ((*commonconfig.URL)(commonconfig.MustParseURL("http://localhost:8548").URL())), }, { Name: ptr("starknet chain 1 node 3"), - URL: ((*commoncfg.URL)(models.MustParseURL("http://localhost:8549").URL())), + URL: ((*commonconfig.URL)(commonconfig.MustParseURL("http://localhost:8549").URL())), }, }, }, @@ -126,7 +125,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) { Nodes: []*stkcfg.Node{ { Name: ptr("starknet chain 2 node 1"), - URL: ((*commoncfg.URL)(models.MustParseURL("http://localhost:3547").URL())), + URL: ((*commonconfig.URL)(commonconfig.MustParseURL("http://localhost:3547").URL())), }, }, }, @@ -144,7 +143,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) { Nodes: coscfg.Nodes{ &coscfg.Node{ Name: ptr("cosmos chain 1 node 1"), - TendermintURL: (*commoncfg.URL)(models.MustParseURL("http://localhost:9548").URL()), + TendermintURL: (*commonconfig.URL)(commonconfig.MustParseURL("http://localhost:9548").URL()), }, }, }, @@ -159,7 +158,7 @@ func TestCoreRelayerChainInteroperators(t *testing.T) { Nodes: coscfg.Nodes{ &coscfg.Node{ Name: ptr("cosmos chain 2 node 1"), - TendermintURL: (*commoncfg.URL)(models.MustParseURL("http://localhost:9598").URL()), + TendermintURL: (*commonconfig.URL)(commonconfig.MustParseURL("http://localhost:9598").URL()), }, }, }, diff --git a/core/services/feeds/config.go b/core/services/feeds/config.go index 605e70c24c9..141e4910960 100644 --- a/core/services/feeds/config.go +++ b/core/services/feeds/config.go @@ -3,11 +3,11 @@ package feeds import ( "time" - "github.com/smartcontractkit/chainlink/v2/core/store/models" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" ) type JobConfig interface { - DefaultHTTPTimeout() models.Duration + DefaultHTTPTimeout() commonconfig.Duration } type InsecureConfig interface { diff --git a/core/services/feeds/mocks/config.go b/core/services/feeds/mocks/config.go deleted file mode 100644 index f2e4dcaa883..00000000000 --- a/core/services/feeds/mocks/config.go +++ /dev/null @@ -1,292 +0,0 @@ -// Code generated by mockery v2.22.1. DO NOT EDIT. - -package mocks - -import ( - time "time" - - models "github.com/smartcontractkit/chainlink/v2/core/store/models" - mock "github.com/stretchr/testify/mock" -) - -// Config is an autogenerated mock type for the Config type -type Config struct { - mock.Mock -} - -// DatabaseDefaultQueryTimeout provides a mock function with given fields: -func (_m *Config) DatabaseDefaultQueryTimeout() time.Duration { - ret := _m.Called() - - var r0 time.Duration - if rf, ok := ret.Get(0).(func() time.Duration); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(time.Duration) - } - - return r0 -} - -// DefaultHTTPTimeout provides a mock function with given fields: -func (_m *Config) DefaultHTTPTimeout() models.Duration { - ret := _m.Called() - - var r0 models.Duration - if rf, ok := ret.Get(0).(func() models.Duration); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(models.Duration) - } - - return r0 -} - -// Dev provides a mock function with given fields: -func (_m *Config) Dev() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// FeatureOffchainReporting provides a mock function with given fields: -func (_m *Config) FeatureOffchainReporting() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// FeatureOffchainReporting2 provides a mock function with given fields: -func (_m *Config) FeatureOffchainReporting2() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// JobPipelineMaxSuccessfulRuns provides a mock function with given fields: -func (_m *Config) JobPipelineMaxSuccessfulRuns() uint64 { - ret := _m.Called() - - var r0 uint64 - if rf, ok := ret.Get(0).(func() uint64); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(uint64) - } - - return r0 -} - -// JobPipelineResultWriteQueueDepth provides a mock function with given fields: -func (_m *Config) JobPipelineResultWriteQueueDepth() uint64 { - ret := _m.Called() - - var r0 uint64 - if rf, ok := ret.Get(0).(func() uint64); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(uint64) - } - - return r0 -} - -// LogSQL provides a mock function with given fields: -func (_m *Config) LogSQL() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// OCR2BlockchainTimeout provides a mock function with given fields: -func (_m *Config) OCR2BlockchainTimeout() time.Duration { - ret := _m.Called() - - var r0 time.Duration - if rf, ok := ret.Get(0).(func() time.Duration); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(time.Duration) - } - - return r0 -} - -// OCR2CaptureEATelemetry provides a mock function with given fields: -func (_m *Config) OCR2CaptureEATelemetry() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// OCR2ContractConfirmations provides a mock function with given fields: -func (_m *Config) OCR2ContractConfirmations() uint16 { - ret := _m.Called() - - var r0 uint16 - if rf, ok := ret.Get(0).(func() uint16); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(uint16) - } - - return r0 -} - -// OCR2ContractPollInterval provides a mock function with given fields: -func (_m *Config) OCR2ContractPollInterval() time.Duration { - ret := _m.Called() - - var r0 time.Duration - if rf, ok := ret.Get(0).(func() time.Duration); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(time.Duration) - } - - return r0 -} - -// OCR2ContractSubscribeInterval provides a mock function with given fields: -func (_m *Config) OCR2ContractSubscribeInterval() time.Duration { - ret := _m.Called() - - var r0 time.Duration - if rf, ok := ret.Get(0).(func() time.Duration); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(time.Duration) - } - - return r0 -} - -// OCR2ContractTransmitterTransmitTimeout provides a mock function with given fields: -func (_m *Config) OCR2ContractTransmitterTransmitTimeout() time.Duration { - ret := _m.Called() - - var r0 time.Duration - if rf, ok := ret.Get(0).(func() time.Duration); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(time.Duration) - } - - return r0 -} - -// OCR2DatabaseTimeout provides a mock function with given fields: -func (_m *Config) OCR2DatabaseTimeout() time.Duration { - ret := _m.Called() - - var r0 time.Duration - if rf, ok := ret.Get(0).(func() time.Duration); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(time.Duration) - } - - return r0 -} - -// OCR2KeyBundleID provides a mock function with given fields: -func (_m *Config) OCR2KeyBundleID() (string, error) { - ret := _m.Called() - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func() (string, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// OCR2TraceLogging provides a mock function with given fields: -func (_m *Config) OCR2TraceLogging() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// OCRDevelopmentMode provides a mock function with given fields: -func (_m *Config) OCRDevelopmentMode() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -type mockConstructorTestingTNewConfig interface { - mock.TestingT - Cleanup(func()) -} - -// NewConfig creates a new instance of Config. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewConfig(t mockConstructorTestingTNewConfig) *Config { - mock := &Config{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/services/feeds/service_test.go b/core/services/feeds/service_test.go index d37393eba9e..d822cd9787d 100644 --- a/core/services/feeds/service_test.go +++ b/core/services/feeds/service_test.go @@ -17,6 +17,7 @@ import ( "github.com/stretchr/testify/require" "gopkg.in/guregu/null.v4" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/services/servicetest" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" @@ -41,7 +42,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/pipeline" evmrelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" "github.com/smartcontractkit/chainlink/v2/core/services/versioning" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/utils/crypto" ) @@ -626,7 +626,7 @@ func Test_Service_ProposeJob(t *testing.T) { JobProposalID: idBootstrap, } - httpTimeout = models.MustMakeDuration(1 * time.Second) + httpTimeout = *commonconfig.MustNewDuration(1 * time.Second) ) testCases := []struct { @@ -806,7 +806,7 @@ func Test_Service_DeleteJob(t *testing.T) { Status: feeds.JobProposalStatusApproved, } - httpTimeout = models.MustMakeDuration(1 * time.Second) + httpTimeout = *commonconfig.MustNewDuration(1 * time.Second) ) testCases := []struct { @@ -946,7 +946,7 @@ answer1 [type=median index=0]; Definition: defn, } - httpTimeout = models.MustMakeDuration(1 * time.Second) + httpTimeout = *commonconfig.MustNewDuration(1 * time.Second) ) testCases := []struct { @@ -1610,7 +1610,7 @@ answer1 [type=median index=0]; testCases := []struct { name string - httpTimeout *models.Duration + httpTimeout *commonconfig.Duration before func(svc *TestService) id int64 force bool @@ -1618,7 +1618,7 @@ answer1 [type=median index=0]; }{ { name: "pending job success for new proposals", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.EXPECT().GetSpec(spec.ID, mock.Anything).Return(spec, nil) @@ -1656,7 +1656,7 @@ answer1 [type=median index=0]; }, { name: "cancelled spec success when it is the latest spec", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", cancelledSpec.ID, mock.Anything).Return(cancelledSpec, nil) @@ -1695,7 +1695,7 @@ answer1 [type=median index=0]; }, { name: "pending job fail due to spec missing external job id", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.EXPECT().GetSpec(spec.ID, mock.Anything).Return(spec2, nil) @@ -1775,7 +1775,7 @@ answer1 [type=median index=0]; }, { name: "already existing job replacement (found via external job id) error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -1790,7 +1790,7 @@ answer1 [type=median index=0]; }, { name: "already existing job replacement error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -1806,7 +1806,7 @@ answer1 [type=median index=0]; }, { name: "already existing self managed job replacement success if forced (via external job id)", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.EXPECT().GetSpec(spec.ID, mock.Anything).Return(spec, nil) @@ -1845,7 +1845,7 @@ answer1 [type=median index=0]; }, { name: "already existing self managed job replacement success if forced", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.EXPECT().GetSpec(spec.ID, mock.Anything).Return(spec, nil) @@ -1885,7 +1885,7 @@ answer1 [type=median index=0]; }, { name: "already existing FMS managed job replacement success if forced", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.EXPECT().GetSpec(spec.ID, mock.Anything).Return(spec, nil) @@ -1944,7 +1944,7 @@ answer1 [type=median index=0]; }, { name: "bridges do not exist", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -1967,7 +1967,7 @@ answer1 [type=median index=0]; }, { name: "Fetching the approved spec fails (via external job id)", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.EXPECT().GetSpec(spec.ID, mock.Anything).Return(spec, nil) @@ -1982,7 +1982,7 @@ answer1 [type=median index=0]; }, { name: "Fetching the approved spec fails", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.EXPECT().GetSpec(spec.ID, mock.Anything).Return(spec, nil) @@ -1998,7 +1998,7 @@ answer1 [type=median index=0]; }, { name: "spec cancellation fails (via external job id)", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.EXPECT().GetSpec(spec.ID, mock.Anything).Return(spec, nil) @@ -2014,7 +2014,7 @@ answer1 [type=median index=0]; }, { name: "spec cancellation fails", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.EXPECT().GetSpec(spec.ID, mock.Anything).Return(spec, nil) @@ -2031,7 +2031,7 @@ answer1 [type=median index=0]; }, { name: "create job error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) svc.orm.On("GetJobProposal", jp.ID, mock.Anything).Return(jp, nil) @@ -2056,7 +2056,7 @@ answer1 [type=median index=0]; }, { name: "approve spec orm error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) svc.orm.On("GetJobProposal", jp.ID, mock.Anything).Return(jp, nil) @@ -2087,7 +2087,7 @@ answer1 [type=median index=0]; }, { name: "fms call error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) svc.orm.On("GetJobProposal", jp.ID, mock.Anything).Return(jp, nil) @@ -2250,7 +2250,7 @@ answer1 [type=median index=0]; testCases := []struct { name string - httpTimeout *models.Duration + httpTimeout *commonconfig.Duration before func(svc *TestService) id int64 force bool @@ -2258,7 +2258,7 @@ answer1 [type=median index=0]; }{ { name: "pending job success", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -2295,7 +2295,7 @@ answer1 [type=median index=0]; }, { name: "cancelled spec success when it is the latest spec", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", cancelledSpec.ID, mock.Anything).Return(cancelledSpec, nil) @@ -2361,7 +2361,7 @@ answer1 [type=median index=0]; }, { name: "already existing job replacement error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -2376,7 +2376,7 @@ answer1 [type=median index=0]; }, { name: "already existing self managed job replacement success if forced without feedID", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -2415,7 +2415,7 @@ answer1 [type=median index=0]; }, { name: "already existing self managed job replacement success if forced with feedID", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(&feeds.JobProposalSpec{ @@ -2460,7 +2460,7 @@ answer1 [type=median index=0]; }, { name: "already existing FMS managed job replacement success if forced", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -2548,7 +2548,7 @@ answer1 [type=median index=0]; }, { name: "bridges do not exist", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -2571,7 +2571,7 @@ answer1 [type=median index=0]; }, { name: "create job error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) svc.orm.On("GetJobProposal", jp.ID, mock.Anything).Return(jp, nil) @@ -2596,7 +2596,7 @@ answer1 [type=median index=0]; }, { name: "approve spec orm error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) svc.orm.On("GetJobProposal", jp.ID, mock.Anything).Return(jp, nil) @@ -2627,7 +2627,7 @@ answer1 [type=median index=0]; }, { name: "fms call error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) svc.orm.On("GetJobProposal", jp.ID, mock.Anything).Return(jp, nil) @@ -2756,7 +2756,7 @@ chainID = 0 testCases := []struct { name string - httpTimeout *models.Duration + httpTimeout *commonconfig.Duration before func(svc *TestService) id int64 force bool @@ -2764,7 +2764,7 @@ chainID = 0 }{ { name: "pending job success", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -2801,7 +2801,7 @@ chainID = 0 }, { name: "cancelled spec success when it is the latest spec", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", cancelledSpec.ID, mock.Anything).Return(cancelledSpec, nil) @@ -2867,7 +2867,7 @@ chainID = 0 }, { name: "already existing job replacement error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -2882,7 +2882,7 @@ chainID = 0 }, { name: "already existing self managed job replacement success if forced without feedID", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -2921,7 +2921,7 @@ chainID = 0 }, { name: "already existing self managed job replacement success if forced with feedID", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(&feeds.JobProposalSpec{ @@ -2966,7 +2966,7 @@ chainID = 0 }, { name: "already existing FMS managed job replacement success if forced", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -3054,7 +3054,7 @@ chainID = 0 }, { name: "bridges do not exist", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.connMgr.On("GetClient", jp.FeedsManagerID).Return(svc.fmsClient, nil) svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) @@ -3077,7 +3077,7 @@ chainID = 0 }, { name: "create job error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) svc.orm.On("GetJobProposal", jp.ID, mock.Anything).Return(jp, nil) @@ -3102,7 +3102,7 @@ chainID = 0 }, { name: "approve spec orm error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) svc.orm.On("GetJobProposal", jp.ID, mock.Anything).Return(jp, nil) @@ -3133,7 +3133,7 @@ chainID = 0 }, { name: "fms call error", - httpTimeout: models.MustNewDuration(1 * time.Minute), + httpTimeout: commonconfig.MustNewDuration(1 * time.Minute), before: func(svc *TestService) { svc.orm.On("GetSpec", spec.ID, mock.Anything).Return(spec, nil) svc.orm.On("GetJobProposal", jp.ID, mock.Anything).Return(jp, nil) diff --git a/core/services/fluxmonitorv2/config.go b/core/services/fluxmonitorv2/config.go index 2680f30a777..18fdf72798b 100644 --- a/core/services/fluxmonitorv2/config.go +++ b/core/services/fluxmonitorv2/config.go @@ -4,8 +4,8 @@ import ( "time" "github.com/smartcontractkit/chainlink-common/pkg/assets" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) // Config defines the Flux Monitor configuration. @@ -28,7 +28,7 @@ type FluxMonitorConfig interface { } type JobPipelineConfig interface { - DefaultHTTPTimeout() models.Duration + DefaultHTTPTimeout() commonconfig.Duration } // MinimumPollingInterval returns the minimum duration between polling ticks diff --git a/core/services/fluxmonitorv2/integrations_test.go b/core/services/fluxmonitorv2/integrations_test.go index 48c9ca24ac3..580e7a1d086 100644 --- a/core/services/fluxmonitorv2/integrations_test.go +++ b/core/services/fluxmonitorv2/integrations_test.go @@ -26,6 +26,7 @@ import ( "github.com/jmoiron/sqlx" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/log" @@ -448,8 +449,8 @@ func TestFluxMonitor_Deviation(t *testing.T) { // Set up chainlink app app := startApplication(t, fa, func(c *chainlink.Config, s *chainlink.Secrets) { - c.JobPipeline.HTTPRequest.DefaultTimeout = models.MustNewDuration(100 * time.Millisecond) - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(1 * time.Second) + c.JobPipeline.HTTPRequest.DefaultTimeout = commonconfig.MustNewDuration(100 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(1 * time.Second) c.EVM[0].GasEstimator.EIP1559DynamicFees = &test.eip1559 }) @@ -620,8 +621,8 @@ func TestFluxMonitor_NewRound(t *testing.T) { // Set up chainlink app app := startApplication(t, fa, func(c *chainlink.Config, s *chainlink.Secrets) { - c.JobPipeline.HTTPRequest.DefaultTimeout = models.MustNewDuration(100 * time.Millisecond) - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(1 * time.Second) + c.JobPipeline.HTTPRequest.DefaultTimeout = commonconfig.MustNewDuration(100 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(1 * time.Second) flags := ethkey.EIP55AddressFromAddress(fa.flagsContractAddress) c.EVM[0].FlagsContractAddress = &flags }) @@ -731,8 +732,8 @@ func TestFluxMonitor_HibernationMode(t *testing.T) { // Start chainlink app app := startApplication(t, fa, func(c *chainlink.Config, s *chainlink.Secrets) { - c.JobPipeline.HTTPRequest.DefaultTimeout = models.MustNewDuration(100 * time.Millisecond) - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(1 * time.Second) + c.JobPipeline.HTTPRequest.DefaultTimeout = commonconfig.MustNewDuration(100 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(1 * time.Second) flags := ethkey.EIP55AddressFromAddress(fa.flagsContractAddress) c.EVM[0].FlagsContractAddress = &flags }) @@ -848,8 +849,8 @@ func TestFluxMonitor_InvalidSubmission(t *testing.T) { // Set up chainlink app app := startApplication(t, fa, func(c *chainlink.Config, s *chainlink.Secrets) { - c.JobPipeline.HTTPRequest.DefaultTimeout = models.MustNewDuration(100 * time.Millisecond) - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(1 * time.Second) + c.JobPipeline.HTTPRequest.DefaultTimeout = commonconfig.MustNewDuration(100 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) // Report a price that is above the maximum allowed value, @@ -925,8 +926,8 @@ func TestFluxMonitorAntiSpamLogic(t *testing.T) { // Set up chainlink app app := startApplication(t, fa, func(c *chainlink.Config, s *chainlink.Secrets) { - c.JobPipeline.HTTPRequest.DefaultTimeout = models.MustNewDuration(100 * time.Millisecond) - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(1 * time.Second) + c.JobPipeline.HTTPRequest.DefaultTimeout = commonconfig.MustNewDuration(100 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) answer := int64(1) // Answer the nodes give on the first round diff --git a/core/services/fluxmonitorv2/validate.go b/core/services/fluxmonitorv2/validate.go index 02dbfb01284..fc531fc7cb4 100644 --- a/core/services/fluxmonitorv2/validate.go +++ b/core/services/fluxmonitorv2/validate.go @@ -8,13 +8,13 @@ import ( "github.com/pelletier/go-toml" "github.com/pkg/errors" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/utils" ) type ValidationConfig interface { - DefaultHTTPTimeout() models.Duration + DefaultHTTPTimeout() commonconfig.Duration } func ValidatedFluxMonitorSpec(config ValidationConfig, ts string) (job.Job, error) { diff --git a/core/services/fluxmonitorv2/validate_test.go b/core/services/fluxmonitorv2/validate_test.go index 94dc8b6b709..40efd1d724d 100644 --- a/core/services/fluxmonitorv2/validate_test.go +++ b/core/services/fluxmonitorv2/validate_test.go @@ -6,8 +6,8 @@ import ( "time" "github.com/smartcontractkit/chainlink-common/pkg/assets" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/utils/tomlutils" "github.com/stretchr/testify/assert" @@ -16,7 +16,9 @@ import ( type testcfg struct{} -func (testcfg) DefaultHTTPTimeout() models.Duration { return models.MustMakeDuration(2 * time.Second) } +func (testcfg) DefaultHTTPTimeout() commonconfig.Duration { + return *commonconfig.MustNewDuration(2 * time.Second) +} func TestValidate(t *testing.T) { var tt = []struct { diff --git a/core/services/job/job_pipeline_orm_integration_test.go b/core/services/job/job_pipeline_orm_integration_test.go index f1307753d29..dd3062fa14b 100644 --- a/core/services/job/job_pipeline_orm_integration_test.go +++ b/core/services/job/job_pipeline_orm_integration_test.go @@ -9,6 +9,7 @@ import ( "github.com/jmoiron/sqlx" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" @@ -46,7 +47,7 @@ func TestPipelineORM_Integration(t *testing.T) { ` config := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.JobPipeline.HTTPRequest.DefaultTimeout = models.MustNewDuration(30 * time.Millisecond) + c.JobPipeline.HTTPRequest.DefaultTimeout = commonconfig.MustNewDuration(30 * time.Millisecond) }) db := pgtest.NewSqlxDB(t) keyStore := cltest.NewKeyStore(t, db, config.Database()) diff --git a/core/services/job/runner_integration_test.go b/core/services/job/runner_integration_test.go index 27c0e0e8515..fb671982ec5 100644 --- a/core/services/job/runner_integration_test.go +++ b/core/services/job/runner_integration_test.go @@ -23,6 +23,7 @@ import ( "github.com/stretchr/testify/require" "gopkg.in/guregu/null.v4" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/services/servicetest" "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox/mailboxtest" @@ -68,8 +69,8 @@ func TestRunner(t *testing.T) { c.OCR.KeyBundleID = &kbid taddress := ethkey.EIP55AddressFromAddress(transmitterAddress) c.OCR.TransmitterAddress = &taddress - c.OCR2.DatabaseTimeout = models.MustNewDuration(time.Second) - c.OCR2.ContractTransmitterTransmitTimeout = models.MustNewDuration(time.Second) + c.OCR2.DatabaseTimeout = commonconfig.MustNewDuration(time.Second) + c.OCR2.ContractTransmitterTransmitTimeout = commonconfig.MustNewDuration(time.Second) c.Insecure.OCRDevelopmentMode = ptr(true) }) @@ -746,7 +747,7 @@ func TestRunner_Success_Callback_AsyncJob(t *testing.T) { cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { t := true c.JobPipeline.ExternalInitiatorsEnabled = &t - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(10 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(10 * time.Millisecond) }) app := cltest.NewApplicationWithConfig(t, cfg, ethClient, cltest.UseRealExternalInitiatorManager) @@ -925,7 +926,7 @@ func TestRunner_Error_Callback_AsyncJob(t *testing.T) { cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { t := true c.JobPipeline.ExternalInitiatorsEnabled = &t - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(10 * time.Millisecond) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(10 * time.Millisecond) }) app := cltest.NewApplicationWithConfig(t, cfg, ethClient, cltest.UseRealExternalInitiatorManager) diff --git a/core/services/keeper/integration_test.go b/core/services/keeper/integration_test.go index c35ebc81b7f..af95788029f 100644 --- a/core/services/keeper/integration_test.go +++ b/core/services/keeper/integration_test.go @@ -16,6 +16,7 @@ import ( "github.com/smartcontractkit/libocr/gethwrappers/link_token_interface" "github.com/stretchr/testify/require" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/forwarders" @@ -36,7 +37,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keeper" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" - "github.com/smartcontractkit/chainlink/v2/core/store/models" webpresenters "github.com/smartcontractkit/chainlink/v2/core/web/presenters" ) @@ -238,8 +238,8 @@ func TestKeeperEthIntegration(t *testing.T) { // setup app config, db := heavyweight.FullTestDBV2(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.EVM[0].GasEstimator.EIP1559DynamicFees = &test.eip1559 - c.Keeper.MaxGracePeriod = ptr[int64](0) // avoid waiting to re-submit for upkeeps - c.Keeper.Registry.SyncInterval = models.MustNewDuration(24 * time.Hour) // disable full sync ticker for test + c.Keeper.MaxGracePeriod = ptr[int64](0) // avoid waiting to re-submit for upkeeps + c.Keeper.Registry.SyncInterval = commonconfig.MustNewDuration(24 * time.Hour) // disable full sync ticker for test c.Keeper.TurnLookBack = ptr[int64](0) // testing doesn't need to do far look back @@ -396,8 +396,8 @@ func TestKeeperForwarderEthIntegration(t *testing.T) { config, db := heavyweight.FullTestDBV2(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.Feature.LogPoller = ptr(true) c.EVM[0].GasEstimator.EIP1559DynamicFees = ptr(true) - c.Keeper.MaxGracePeriod = ptr[int64](0) // avoid waiting to re-submit for upkeeps - c.Keeper.Registry.SyncInterval = models.MustNewDuration(24 * time.Hour) // disable full sync ticker for test + c.Keeper.MaxGracePeriod = ptr[int64](0) // avoid waiting to re-submit for upkeeps + c.Keeper.Registry.SyncInterval = commonconfig.MustNewDuration(24 * time.Hour) // disable full sync ticker for test c.Keeper.TurnLookBack = ptr[int64](0) // testing doesn't need to do far look back @@ -541,9 +541,9 @@ func TestMaxPerformDataSize(t *testing.T) { // setup app config, db := heavyweight.FullTestDBV2(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.Keeper.MaxGracePeriod = ptr[int64](0) // avoid waiting to re-submit for upkeeps - c.Keeper.Registry.SyncInterval = models.MustNewDuration(24 * time.Hour) // disable full sync ticker for test - c.Keeper.Registry.MaxPerformDataSize = ptr(uint32(maxPerformDataSize)) // set the max perform data size + c.Keeper.MaxGracePeriod = ptr[int64](0) // avoid waiting to re-submit for upkeeps + c.Keeper.Registry.SyncInterval = commonconfig.MustNewDuration(24 * time.Hour) // disable full sync ticker for test + c.Keeper.Registry.MaxPerformDataSize = ptr(uint32(maxPerformDataSize)) // set the max perform data size c.Keeper.TurnLookBack = ptr[int64](0) // testing doesn't need to do far look back diff --git a/core/services/nurse.go b/core/services/nurse.go index 3d896a80ff3..1b44beea21c 100644 --- a/core/services/nurse.go +++ b/core/services/nurse.go @@ -17,9 +17,9 @@ import ( "github.com/google/pprof/profile" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/services" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -40,14 +40,14 @@ type Nurse struct { type Config interface { BlockProfileRate() int CPUProfileRate() int - GatherDuration() models.Duration - GatherTraceDuration() models.Duration + GatherDuration() commonconfig.Duration + GatherTraceDuration() commonconfig.Duration GoroutineThreshold() int MaxProfileSize() utils.FileSize MemProfileRate() int MemThreshold() utils.FileSize MutexProfileFraction() int - PollInterval() models.Duration + PollInterval() commonconfig.Duration ProfileRoot() string } diff --git a/core/services/nurse_test.go b/core/services/nurse_test.go index 79f57d91235..46ebd749036 100644 --- a/core/services/nurse_test.go +++ b/core/services/nurse_test.go @@ -9,18 +9,18 @@ import ( "github.com/stretchr/testify/assert" "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/logger" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/utils" ) type mockConfig struct { t *testing.T root string - pollInterval *models.Duration - gatherDuration *models.Duration - traceDuration *models.Duration + pollInterval *commonconfig.Duration + gatherDuration *commonconfig.Duration + traceDuration *commonconfig.Duration profileSize utils.FileSize cpuProfileRate int memProfileRate int @@ -40,9 +40,9 @@ var ( func newMockConfig(t *testing.T) *mockConfig { return &mockConfig{ root: t.TempDir(), - pollInterval: models.MustNewDuration(testInterval), - gatherDuration: models.MustNewDuration(testDuration), - traceDuration: models.MustNewDuration(testDuration), + pollInterval: commonconfig.MustNewDuration(testInterval), + gatherDuration: commonconfig.MustNewDuration(testDuration), + traceDuration: commonconfig.MustNewDuration(testDuration), profileSize: utils.FileSize(testSize), memProfileRate: runtime.MemProfileRate, blockProfileRate: testRate, @@ -57,15 +57,15 @@ func (c mockConfig) ProfileRoot() string { return c.root } -func (c mockConfig) PollInterval() models.Duration { +func (c mockConfig) PollInterval() commonconfig.Duration { return *c.pollInterval } -func (c mockConfig) GatherDuration() models.Duration { +func (c mockConfig) GatherDuration() commonconfig.Duration { return *c.gatherDuration } -func (c mockConfig) GatherTraceDuration() models.Duration { +func (c mockConfig) GatherTraceDuration() commonconfig.Duration { return *c.traceDuration } diff --git a/core/services/ocr/validate_test.go b/core/services/ocr/validate_test.go index 4d8a9ae26c8..e55c5d1a484 100644 --- a/core/services/ocr/validate_test.go +++ b/core/services/ocr/validate_test.go @@ -11,13 +11,13 @@ import ( "github.com/stretchr/testify/require" "gopkg.in/guregu/null.v4" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" evmconfig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/ocr" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func TestValidateOracleSpec(t *testing.T) { @@ -359,7 +359,7 @@ answer1 [type=median index=0]; require.Contains(t, err.Error(), "data source timeout must be between 1s and 20s, but is currently 20m0s") }, overrides: func(c *chainlink.Config, s *chainlink.Secrets) { - c.OCR.ObservationTimeout = models.MustNewDuration(20 * time.Minute) + c.OCR.ObservationTimeout = commonconfig.MustNewDuration(20 * time.Minute) }, }, } diff --git a/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go b/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go index 9388b93329b..5ea1d3e4030 100644 --- a/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go +++ b/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go @@ -28,6 +28,7 @@ import ( confighelper2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" ocrtypes2 "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" @@ -318,14 +319,14 @@ func StartNewNode( c.P2P.PeerID = ptr(p2pKey.PeerID()) c.P2P.V2.Enabled = ptr(true) - c.P2P.V2.DeltaDial = models.MustNewDuration(500 * time.Millisecond) - c.P2P.V2.DeltaReconcile = models.MustNewDuration(5 * time.Second) + c.P2P.V2.DeltaDial = commonconfig.MustNewDuration(500 * time.Millisecond) + c.P2P.V2.DeltaReconcile = commonconfig.MustNewDuration(5 * time.Second) c.P2P.V2.ListenAddresses = &[]string{fmt.Sprintf("127.0.0.1:%d", port)} if len(p2pV2Bootstrappers) > 0 { c.P2P.V2.DefaultBootstrappers = &p2pV2Bootstrappers } - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) c.EVM[0].Transactions.ForwardersEnabled = ptr(false) c.EVM[0].GasEstimator.LimitDefault = ptr(maxGas) c.EVM[0].GasEstimator.Mode = ptr("FixedPrice") diff --git a/core/services/ocr2/plugins/mercury/helpers_test.go b/core/services/ocr2/plugins/mercury/helpers_test.go index 68fb27fa82e..473db53bc6f 100644 --- a/core/services/ocr2/plugins/mercury/helpers_test.go +++ b/core/services/ocr2/plugins/mercury/helpers_test.go @@ -25,6 +25,7 @@ import ( "github.com/smartcontractkit/libocr/offchainreporting2/chains/evmutil" ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest/heavyweight" @@ -40,7 +41,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/ocrbootstrap" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc/pb" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) var _ pb.MercuryServer = &mercuryServer{} @@ -199,8 +199,8 @@ func setupNode( c.P2P.V2.Enabled = ptr(true) c.P2P.V2.AnnounceAddresses = &p2paddresses c.P2P.V2.ListenAddresses = &p2paddresses - c.P2P.V2.DeltaDial = models.MustNewDuration(500 * time.Millisecond) - c.P2P.V2.DeltaReconcile = models.MustNewDuration(5 * time.Second) + c.P2P.V2.DeltaDial = commonconfig.MustNewDuration(500 * time.Millisecond) + c.P2P.V2.DeltaReconcile = commonconfig.MustNewDuration(5 * time.Second) }) lggr, observedLogs := logger.TestLoggerObserved(t, zapcore.DebugLevel) diff --git a/core/services/ocr2/plugins/ocr2keeper/integration_test.go b/core/services/ocr2/plugins/ocr2keeper/integration_test.go index d0a93f77631..56467c60abb 100644 --- a/core/services/ocr2/plugins/ocr2keeper/integration_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/integration_test.go @@ -32,6 +32,7 @@ import ( ocrTypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/smartcontractkit/chainlink-automation/pkg/v2/config" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" @@ -123,8 +124,8 @@ func setupNode( c.P2P.PeerID = ptr(p2pKey.PeerID()) c.P2P.V2.Enabled = ptr(true) - c.P2P.V2.DeltaDial = models.MustNewDuration(500 * time.Millisecond) - c.P2P.V2.DeltaReconcile = models.MustNewDuration(5 * time.Second) + c.P2P.V2.DeltaDial = commonconfig.MustNewDuration(500 * time.Millisecond) + c.P2P.V2.DeltaReconcile = commonconfig.MustNewDuration(5 * time.Second) c.P2P.V2.AnnounceAddresses = &p2paddresses c.P2P.V2.ListenAddresses = &p2paddresses if len(p2pV2Bootstrappers) > 0 { diff --git a/core/services/ocr2/plugins/ocr2vrf/internal/ocr2vrf_integration_test.go b/core/services/ocr2/plugins/ocr2vrf/internal/ocr2vrf_integration_test.go index 55517d5719d..4a01ee7904f 100644 --- a/core/services/ocr2/plugins/ocr2vrf/internal/ocr2vrf_integration_test.go +++ b/core/services/ocr2/plugins/ocr2vrf/internal/ocr2vrf_integration_test.go @@ -30,6 +30,7 @@ import ( "github.com/smartcontractkit/chainlink-vrf/ocr2vrf" ocr2vrftypes "github.com/smartcontractkit/chainlink-vrf/types" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" commonutils "github.com/smartcontractkit/chainlink-common/pkg/utils" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/forwarders" @@ -55,7 +56,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate" "github.com/smartcontractkit/chainlink/v2/core/services/ocrbootstrap" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) type ocr2vrfUniverse struct { @@ -234,8 +234,8 @@ func setupNodeOCR2( c.P2P.PeerID = ptr(p2pKey.PeerID()) c.P2P.V2.Enabled = ptr(true) - c.P2P.V2.DeltaDial = models.MustNewDuration(500 * time.Millisecond) - c.P2P.V2.DeltaReconcile = models.MustNewDuration(5 * time.Second) + c.P2P.V2.DeltaDial = commonconfig.MustNewDuration(500 * time.Millisecond) + c.P2P.V2.DeltaReconcile = commonconfig.MustNewDuration(5 * time.Second) c.P2P.V2.ListenAddresses = &[]string{fmt.Sprintf("127.0.0.1:%d", port)} if len(p2pV2Bootstrappers) > 0 { c.P2P.V2.DefaultBootstrappers = &p2pV2Bootstrappers @@ -244,10 +244,10 @@ func setupNodeOCR2( c.OCR.Enabled = ptr(false) c.OCR2.Enabled = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(500 * time.Millisecond) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(500 * time.Millisecond) c.EVM[0].GasEstimator.LimitDefault = ptr[uint32](3_500_000) c.EVM[0].Transactions.ForwardersEnabled = &useForwarders - c.OCR2.ContractPollInterval = models.MustNewDuration(10 * time.Second) + c.OCR2.ContractPollInterval = commonconfig.MustNewDuration(10 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, b, p2pKey) diff --git a/core/services/ocr2/validate/validate_test.go b/core/services/ocr2/validate/validate_test.go index b03f08f6b08..52dbe5f0042 100644 --- a/core/services/ocr2/validate/validate_test.go +++ b/core/services/ocr2/validate/validate_test.go @@ -11,13 +11,13 @@ import ( "github.com/stretchr/testify/assert" "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" "github.com/smartcontractkit/chainlink/v2/core/services/job" medianconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/median/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func TestValidateOracleSpec(t *testing.T) { @@ -308,7 +308,7 @@ chainID = 1337 require.Contains(t, err.Error(), "database timeout must be between 100ms and 10s, but is currently 20m0s") }, overrides: func(c *chainlink.Config, s *chainlink.Secrets) { - c.OCR2.DatabaseTimeout = models.MustNewDuration(20 * time.Minute) + c.OCR2.DatabaseTimeout = commonconfig.MustNewDuration(20 * time.Minute) }, }, { diff --git a/core/services/ocrcommon/peer_wrapper_test.go b/core/services/ocrcommon/peer_wrapper_test.go index 278e0684fd2..f46b2af27c5 100644 --- a/core/services/ocrcommon/peer_wrapper_test.go +++ b/core/services/ocrcommon/peer_wrapper_test.go @@ -9,6 +9,7 @@ import ( ragep2ptypes "github.com/smartcontractkit/libocr/ragep2p/types" "github.com/stretchr/testify/require" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/services/servicetest" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" @@ -18,7 +19,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" "github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func Test_SingletonPeerWrapper_Start(t *testing.T) { @@ -123,8 +123,8 @@ func Test_SingletonPeerWrapper_Close(t *testing.T) { cfg = configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { c.P2P.V2.Enabled = ptr(true) c.P2P.PeerID = ptr(k.PeerID()) - c.P2P.V2.DeltaDial = models.MustNewDuration(100 * time.Millisecond) - c.P2P.V2.DeltaReconcile = models.MustNewDuration(1 * time.Second) + c.P2P.V2.DeltaDial = commonconfig.MustNewDuration(100 * time.Millisecond) + c.P2P.V2.DeltaReconcile = commonconfig.MustNewDuration(1 * time.Second) p2paddresses := []string{ "127.0.0.1:17193", diff --git a/core/services/pg/locked_db_test.go b/core/services/pg/locked_db_test.go index a2aebcd57f4..ed0935c1411 100644 --- a/core/services/pg/locked_db_test.go +++ b/core/services/pg/locked_db_test.go @@ -5,12 +5,12 @@ import ( "testing" "time" + 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/logger" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/pg" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/stretchr/testify/require" ) @@ -18,8 +18,8 @@ import ( func lease(c *chainlink.Config, s *chainlink.Secrets) { t := true c.Database.Lock.Enabled = &t - c.Database.Lock.LeaseDuration = models.MustNewDuration(10 * time.Second) - c.Database.Lock.LeaseRefreshInterval = models.MustNewDuration(time.Second) + c.Database.Lock.LeaseDuration = commonconfig.MustNewDuration(10 * time.Second) + c.Database.Lock.LeaseRefreshInterval = commonconfig.MustNewDuration(time.Second) } func TestLockedDB_HappyPath(t *testing.T) { diff --git a/core/services/pipeline/common.go b/core/services/pipeline/common.go index 0e72bed4226..ae82e5b3b81 100644 --- a/core/services/pipeline/common.go +++ b/core/services/pipeline/common.go @@ -20,11 +20,11 @@ import ( pkgerrors "github.com/pkg/errors" "gopkg.in/guregu/null.v4" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" cutils "github.com/smartcontractkit/chainlink-common/pkg/utils" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" "github.com/smartcontractkit/chainlink/v2/core/logger" cnull "github.com/smartcontractkit/chainlink/v2/core/null" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -65,7 +65,7 @@ type ( Config interface { DefaultHTTPLimit() int64 - DefaultHTTPTimeout() models.Duration + DefaultHTTPTimeout() commonconfig.Duration MaxRunDuration() time.Duration ReaperInterval() time.Duration ReaperThreshold() time.Duration diff --git a/core/services/pipeline/mocks/config.go b/core/services/pipeline/mocks/config.go index 4cd6bc7a724..581a84dc049 100644 --- a/core/services/pipeline/mocks/config.go +++ b/core/services/pipeline/mocks/config.go @@ -3,7 +3,7 @@ package mocks import ( - models "github.com/smartcontractkit/chainlink/v2/core/store/models" + config "github.com/smartcontractkit/chainlink-common/pkg/config" mock "github.com/stretchr/testify/mock" time "time" @@ -33,18 +33,18 @@ func (_m *Config) DefaultHTTPLimit() int64 { } // DefaultHTTPTimeout provides a mock function with given fields: -func (_m *Config) DefaultHTTPTimeout() models.Duration { +func (_m *Config) DefaultHTTPTimeout() config.Duration { ret := _m.Called() if len(ret) == 0 { panic("no return value specified for DefaultHTTPTimeout") } - var r0 models.Duration - if rf, ok := ret.Get(0).(func() models.Duration); ok { + var r0 config.Duration + if rf, ok := ret.Get(0).(func() config.Duration); ok { r0 = rf() } else { - r0 = ret.Get(0).(models.Duration) + r0 = ret.Get(0).(config.Duration) } return r0 diff --git a/core/services/pipeline/task.bridge_test.go b/core/services/pipeline/task.bridge_test.go index 03a804c9c12..bf1e63d6314 100644 --- a/core/services/pipeline/task.bridge_test.go +++ b/core/services/pipeline/task.bridge_test.go @@ -21,6 +21,7 @@ import ( "github.com/stretchr/testify/require" "gopkg.in/guregu/null.v4" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" @@ -270,7 +271,7 @@ func TestBridgeTask_DoesNotReturnStaleResults(t *testing.T) { db := pgtest.NewSqlxDB(t) cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.WebServer.BridgeCacheTTL = models.MustNewDuration(30 * time.Second) + c.WebServer.BridgeCacheTTL = commonconfig.MustNewDuration(30 * time.Second) }) queryer := pg.NewQ(db, logger.TestLogger(t), cfg.Database()) s1 := httptest.NewServer(fakeIntermittentlyFailingPriceResponder(t, utils.MustUnmarshalToMap(btcUSDPairing), decimal.NewFromInt(9700), "", nil)) @@ -336,7 +337,7 @@ func TestBridgeTask_DoesNotReturnStaleResults(t *testing.T) { require.Equal(t, string(big.NewInt(9700).Bytes()), result2.Value) cfg2 := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.WebServer.BridgeCacheTTL = models.MustNewDuration(0 * time.Second) + c.WebServer.BridgeCacheTTL = commonconfig.MustNewDuration(0 * time.Second) }) task.HelperSetDependencies(cfg2.JobPipeline(), cfg2.WebServer(), orm, specID, uuid.UUID{}, c) diff --git a/core/services/telemetry/manager_test.go b/core/services/telemetry/manager_test.go index 8564be8466f..23752151cd0 100644 --- a/core/services/telemetry/manager_test.go +++ b/core/services/telemetry/manager_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/config/mocks" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" @@ -22,7 +23,6 @@ import ( mocks3 "github.com/smartcontractkit/chainlink/v2/core/services/keystore/mocks" "github.com/smartcontractkit/chainlink/v2/core/services/synchronization" mocks2 "github.com/smartcontractkit/chainlink/v2/core/services/synchronization/mocks" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func setupMockConfig(t *testing.T, useBatchSend bool) *mocks.TelemetryIngress { @@ -291,7 +291,7 @@ func TestCorrectEndpointRouting(t *testing.T) { func TestLegacyMode(t *testing.T) { tic := setupMockConfig(t, true) tic.On("Endpoints").Return(nil) - url, err := models.ParseURL("test.test") + url, err := commonconfig.ParseURL("test.test") require.NoError(t, err) tic.On("URL").Return(url.URL()) tic.On("ServerPubKey").Return("some-pub-key") diff --git a/core/services/vrf/v1/integration_test.go b/core/services/vrf/v1/integration_test.go index 3e9cfbe0870..b10ca160858 100644 --- a/core/services/vrf/v1/integration_test.go +++ b/core/services/vrf/v1/integration_test.go @@ -15,6 +15,7 @@ import ( "github.com/stretchr/testify/require" "gopkg.in/guregu/null.v4" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/solidity_vrf_coordinator_interface" @@ -28,7 +29,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/signatures/secp256k1" "github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrfcommon" "github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrftesthelpers" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/testdata/testspecs" ) @@ -133,7 +133,7 @@ func TestIntegration_VRF_WithBHS(t *testing.T) { c.EVM[0].BlockBackfillDepth = ptr[uint32](500) c.Feature.LogPoller = ptr(true) c.EVM[0].FinalityDepth = ptr[uint32](2) - c.EVM[0].LogPollInterval = models.MustNewDuration(time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(time.Second) c.EVM[0].ChainID = (*ubig.Big)(testutils.SimulatedChainID) }) key := cltest.MustGenerateRandomKey(t) diff --git a/core/services/vrf/v2/bhs_feeder_test.go b/core/services/vrf/v2/bhs_feeder_test.go index 31a4ff815a9..a02eea75757 100644 --- a/core/services/vrf/v2/bhs_feeder_test.go +++ b/core/services/vrf/v2/bhs_feeder_test.go @@ -4,6 +4,9 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" @@ -11,9 +14,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrftesthelpers" - "github.com/smartcontractkit/chainlink/v2/core/store/models" - - "github.com/stretchr/testify/require" ) func TestStartHeartbeats(t *testing.T) { @@ -56,7 +56,7 @@ func TestStartHeartbeats(t *testing.T) { c.Feature.LogPoller = ptr(true) c.EVM[0].FinalityDepth = ptr[uint32](2) c.EVM[0].GasEstimator.LimitDefault = ptr(uint32(gasLimit)) - c.EVM[0].LogPollInterval = models.MustNewDuration(time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(time.Second) }) heartbeatPeriod := 5 * time.Second diff --git a/core/services/vrf/v2/integration_helpers_test.go b/core/services/vrf/v2/integration_helpers_test.go index b5f6a095cff..47d0089ade6 100644 --- a/core/services/vrf/v2/integration_helpers_test.go +++ b/core/services/vrf/v2/integration_helpers_test.go @@ -16,6 +16,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" @@ -35,7 +36,6 @@ import ( v22 "github.com/smartcontractkit/chainlink/v2/core/services/vrf/v2" "github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrfcommon" "github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrftesthelpers" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/testdata/testspecs" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -74,7 +74,7 @@ func testSingleConsumerHappyPath( })(c, s) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, key1, key2) @@ -208,7 +208,7 @@ func testMultipleConsumersNeedBHS( simulatedOverrides(t, assets.GWei(10), keySpecificOverrides...)(c, s) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) c.EVM[0].FinalityDepth = ptr[uint32](2) }) keys = append(keys, ownerKey, vrfKey) @@ -356,7 +356,7 @@ func testMultipleConsumersNeedTrustedBHS( c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.EVM[0].GasEstimator.LimitDefault = ptr(uint32(5_000_000)) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) c.EVM[0].FinalityDepth = ptr[uint32](2) }) keys = append(keys, ownerKey, vrfKey) @@ -543,7 +543,7 @@ func testSingleConsumerHappyPathBatchFulfillment( c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.EVM[0].ChainID = (*ubig.Big)(testutils.SimulatedChainID) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, key1) @@ -647,7 +647,7 @@ func testSingleConsumerNeedsTopUp( })(c, s) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, key) @@ -753,7 +753,7 @@ func testBlockHeaderFeeder( })(c, s) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) c.EVM[0].FinalityDepth = ptr[uint32](2) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, vrfKey, bhfKey) @@ -912,7 +912,7 @@ func testSingleConsumerForcedFulfillment( })(c, s) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, key1, key2) @@ -1075,7 +1075,7 @@ func testSingleConsumerEIP150( c.EVM[0].GasEstimator.LimitDefault = ptr(uint32(3.5e6)) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, key1) consumer := uni.vrfConsumers[0] @@ -1145,7 +1145,7 @@ func testSingleConsumerEIP150Revert( c.EVM[0].GasEstimator.LimitDefault = ptr(uint32(gasLimit)) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, key1) consumer := uni.vrfConsumers[0] @@ -1210,7 +1210,7 @@ func testSingleConsumerBigGasCallbackSandwich( c.EVM[0].GasEstimator.LimitDefault = ptr[uint32](5_000_000) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, key1) consumer := uni.vrfConsumers[0] @@ -1332,7 +1332,7 @@ func testSingleConsumerMultipleGasLanes( c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.EVM[0].GasEstimator.LimitDefault = ptr[uint32](5_000_000) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, cheapKey, expensiveKey) @@ -1449,7 +1449,7 @@ func testSingleConsumerAlwaysRevertingCallbackStillFulfilled( })(c, s) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, key) consumer := uni.reverter @@ -1522,7 +1522,7 @@ func testConsumerProxyHappyPath( })(c, s) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, key1, key2) consumerOwner := uni.neil @@ -1648,7 +1648,7 @@ func testMaliciousConsumer( c.EVM[0].GasEstimator.FeeCapDefault = assets.GWei(1) c.EVM[0].ChainID = (*ubig.Big)(testutils.SimulatedChainID) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) carol := uni.vrfConsumers[0] diff --git a/core/services/vrf/v2/integration_v2_plus_test.go b/core/services/vrf/v2/integration_v2_plus_test.go index fb47d84ed7a..e5eed6f09bc 100644 --- a/core/services/vrf/v2/integration_v2_plus_test.go +++ b/core/services/vrf/v2/integration_v2_plus_test.go @@ -16,6 +16,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -50,7 +51,6 @@ import ( v22 "github.com/smartcontractkit/chainlink/v2/core/services/vrf/v2" "github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrfcommon" "github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrftesthelpers" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) type coordinatorV2PlusUniverse struct { @@ -1147,7 +1147,7 @@ func TestVRFV2PlusIntegration_Migration(t *testing.T) { c.EVM[0].GasEstimator.LimitDefault = ptr[uint32](5_000_000) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) app := cltest.NewApplicationWithConfigV2AndKeyOnSimulatedBlockchain(t, config, uni.backend, ownerKey, key1) diff --git a/core/services/vrf/v2/integration_v2_test.go b/core/services/vrf/v2/integration_v2_test.go index dee69c9abef..d415793ede4 100644 --- a/core/services/vrf/v2/integration_v2_test.go +++ b/core/services/vrf/v2/integration_v2_test.go @@ -30,6 +30,7 @@ import ( "github.com/jmoiron/sqlx" commonassets "github.com/smartcontractkit/chainlink-common/pkg/assets" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr" @@ -82,7 +83,6 @@ import ( v22 "github.com/smartcontractkit/chainlink/v2/core/services/vrf/v2" "github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrfcommon" "github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrftesthelpers" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/testdata/testspecs" "github.com/smartcontractkit/chainlink/v2/core/utils" ) @@ -1227,7 +1227,7 @@ func TestVRFV2Integration_Wrapper_High_Gas(t *testing.T) { c.EVM[0].GasEstimator.LimitDefault = ptr[uint32](3_500_000) c.EVM[0].MinIncomingConfirmations = ptr[uint32](2) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) }) ownerKey := cltest.MustGenerateRandomKey(t) uni := newVRFCoordinatorV2Universe(t, ownerKey, 1) @@ -1466,13 +1466,13 @@ func simulatedOverrides(t *testing.T, defaultGasPrice *assets.Wei, ks ...toml.Ke c.EVM[0].GasEstimator.LimitDefault = ptr[uint32](3_500_000) c.Feature.LogPoller = ptr(true) - c.EVM[0].LogPollInterval = models.MustNewDuration(1 * time.Second) + c.EVM[0].LogPollInterval = commonconfig.MustNewDuration(1 * time.Second) c.EVM[0].HeadTracker.MaxBufferSize = ptr[uint32](100) - c.EVM[0].HeadTracker.SamplingInterval = models.MustNewDuration(0) // Head sampling disabled + c.EVM[0].HeadTracker.SamplingInterval = commonconfig.MustNewDuration(0) // Head sampling disabled - c.EVM[0].Transactions.ResendAfterThreshold = models.MustNewDuration(0) - c.EVM[0].Transactions.ReaperThreshold = models.MustNewDuration(100 * time.Millisecond) + c.EVM[0].Transactions.ResendAfterThreshold = commonconfig.MustNewDuration(0) + c.EVM[0].Transactions.ReaperThreshold = commonconfig.MustNewDuration(100 * time.Millisecond) c.EVM[0].FinalityDepth = ptr[uint32](15) c.EVM[0].MinIncomingConfirmations = ptr[uint32](1) diff --git a/core/sessions/ldapauth/helpers_test.go b/core/sessions/ldapauth/helpers_test.go index 3566ea84380..5c19afd17d3 100644 --- a/core/sessions/ldapauth/helpers_test.go +++ b/core/sessions/ldapauth/helpers_test.go @@ -5,11 +5,11 @@ import ( "github.com/jmoiron/sqlx" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/config" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/logger/audit" "github.com/smartcontractkit/chainlink/v2/core/services/pg" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) // Returns an instantiated ldapAuthenticator struct without validation for testing @@ -66,16 +66,16 @@ func (t *TestConfig) ServerTLS() bool { return false } -func (t *TestConfig) SessionTimeout() models.Duration { - return models.MustMakeDuration(time.Duration(0)) +func (t *TestConfig) SessionTimeout() commonconfig.Duration { + return *commonconfig.MustNewDuration(time.Duration(0)) } func (t *TestConfig) QueryTimeout() time.Duration { return time.Duration(0) } -func (t *TestConfig) UserAPITokenDuration() models.Duration { - return models.MustMakeDuration(time.Duration(0)) +func (t *TestConfig) UserAPITokenDuration() commonconfig.Duration { + return *commonconfig.MustNewDuration(time.Duration(0)) } func (t *TestConfig) BaseUserAttr() string { @@ -122,10 +122,10 @@ func (t *TestConfig) UserApiTokenEnabled() bool { return true } -func (t *TestConfig) UpstreamSyncInterval() models.Duration { - return models.MustMakeDuration(time.Duration(0)) +func (t *TestConfig) UpstreamSyncInterval() commonconfig.Duration { + return *commonconfig.MustNewDuration(time.Duration(0)) } -func (t *TestConfig) UpstreamSyncRateLimit() models.Duration { - return models.MustMakeDuration(time.Duration(0)) +func (t *TestConfig) UpstreamSyncRateLimit() commonconfig.Duration { + return *commonconfig.MustNewDuration(time.Duration(0)) } diff --git a/core/sessions/localauth/reaper.go b/core/sessions/localauth/reaper.go index 48112456418..eef884367aa 100644 --- a/core/sessions/localauth/reaper.go +++ b/core/sessions/localauth/reaper.go @@ -4,9 +4,9 @@ import ( "database/sql" "time" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/utils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) type sessionReaper struct { @@ -16,8 +16,8 @@ type sessionReaper struct { } type SessionReaperConfig interface { - SessionTimeout() models.Duration - SessionReaperExpiration() models.Duration + SessionTimeout() commonconfig.Duration + SessionReaperExpiration() commonconfig.Duration } // NewSessionReaper creates a reaper that cleans stale sessions from the store. diff --git a/core/sessions/localauth/reaper_test.go b/core/sessions/localauth/reaper_test.go index 43a263d0321..fa9d882f743 100644 --- a/core/sessions/localauth/reaper_test.go +++ b/core/sessions/localauth/reaper_test.go @@ -4,27 +4,28 @@ import ( "testing" "time" + "github.com/onsi/gomega" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/logger/audit" "github.com/smartcontractkit/chainlink/v2/core/sessions" "github.com/smartcontractkit/chainlink/v2/core/sessions/localauth" - "github.com/smartcontractkit/chainlink/v2/core/store/models" - - "github.com/onsi/gomega" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) type sessionReaperConfig struct{} -func (c sessionReaperConfig) SessionTimeout() models.Duration { - return models.MustMakeDuration(42 * time.Second) +func (c sessionReaperConfig) SessionTimeout() commonconfig.Duration { + return *commonconfig.MustNewDuration(42 * time.Second) } -func (c sessionReaperConfig) SessionReaperExpiration() models.Duration { - return models.MustMakeDuration(142 * time.Second) +func (c sessionReaperConfig) SessionReaperExpiration() commonconfig.Duration { + return *commonconfig.MustNewDuration(142 * time.Second) } func TestSessionReaper_ReapSessions(t *testing.T) { diff --git a/core/store/models/common.go b/core/store/models/common.go index 93cc708fe0b..e446481ff64 100644 --- a/core/store/models/common.go +++ b/core/store/models/common.go @@ -197,119 +197,6 @@ func (c Cron) String() string { return string(c) } -// Duration is a non-negative time duration. -type Duration struct{ d time.Duration } - -func MakeDuration(d time.Duration) (Duration, error) { - if d < time.Duration(0) { - return Duration{}, fmt.Errorf("cannot make negative time duration: %s", d) - } - return Duration{d: d}, nil -} - -func ParseDuration(s string) (Duration, error) { - d, err := time.ParseDuration(s) - if err != nil { - return Duration{}, err - } - - return MakeDuration(d) -} - -func MustMakeDuration(d time.Duration) Duration { - rv, err := MakeDuration(d) - if err != nil { - panic(err) - } - return rv -} - -func MustNewDuration(d time.Duration) *Duration { - rv := MustMakeDuration(d) - return &rv -} - -// Duration returns the value as the standard time.Duration value. -func (d Duration) Duration() time.Duration { - return d.d -} - -// Before returns the time d units before time t -func (d Duration) Before(t time.Time) time.Time { - return t.Add(-d.Duration()) -} - -// Shorter returns true if and only if d is shorter than od. -func (d Duration) Shorter(od Duration) bool { return d.d < od.d } - -// IsInstant is true if and only if d is of duration 0 -func (d Duration) IsInstant() bool { return d.d == 0 } - -// String returns a string representing the duration in the form "72h3m0.5s". -// Leading zero units are omitted. As a special case, durations less than one -// second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure -// that the leading digit is non-zero. The zero duration formats as 0s. -func (d Duration) String() string { - return d.Duration().String() -} - -// MarshalJSON implements the json.Marshaler interface. -func (d Duration) MarshalJSON() ([]byte, error) { - return json.Marshal(d.String()) -} - -// UnmarshalJSON implements the json.Unmarshaler interface. -func (d *Duration) UnmarshalJSON(input []byte) error { - var txt string - err := json.Unmarshal(input, &txt) - if err != nil { - return err - } - v, err := time.ParseDuration(string(txt)) - if err != nil { - return err - } - *d, err = MakeDuration(v) - if err != nil { - return err - } - return nil -} - -func (d *Duration) Scan(v interface{}) (err error) { - switch tv := v.(type) { - case int64: - *d, err = MakeDuration(time.Duration(tv)) - return err - default: - return errors.Errorf(`don't know how to parse "%s" of type %T as a `+ - `models.Duration`, tv, tv) - } -} - -func (d Duration) Value() (driver.Value, error) { - return int64(d.d), nil -} - -// MarshalText implements the text.Marshaler interface. -func (d Duration) MarshalText() ([]byte, error) { - return []byte(d.d.String()), nil -} - -// UnmarshalText implements the text.Unmarshaler interface. -func (d *Duration) UnmarshalText(input []byte) error { - v, err := time.ParseDuration(string(input)) - if err != nil { - return err - } - pd, err := MakeDuration(v) - if err != nil { - return err - } - *d = pd - return nil -} - // Interval represents a time.Duration stored as a Postgres interval type type Interval time.Duration @@ -513,60 +400,6 @@ func (s Sha256Hash) Value() (driver.Value, error) { return b, nil } -// URL extends url.URL to implement encoding.TextMarshaler. -type URL url.URL - -func ParseURL(s string) (*URL, error) { - u, err := url.Parse(s) - if err != nil { - return nil, err - } - return (*URL)(u), nil -} - -func MustParseURL(s string) *URL { - u, err := ParseURL(s) - if err != nil { - panic(err) - } - return u -} - -func (u *URL) String() string { - return (*url.URL)(u).String() -} - -// URL returns a copy of u as a *url.URL -func (u *URL) URL() *url.URL { - if u == nil { - return nil - } - // defensive copy - r := url.URL(*u) - if u.User != nil { - r.User = new(url.Userinfo) - *r.User = *u.User - } - return &r -} - -func (u *URL) IsZero() bool { - return (url.URL)(*u) == url.URL{} -} - -func (u *URL) MarshalText() ([]byte, error) { - return []byte(u.String()), nil -} - -func (u *URL) UnmarshalText(input []byte) error { - v, err := url.Parse(string(input)) - if err != nil { - return err - } - *u = URL(*v) - return nil -} - // ServiceHeader is an HTTP header to include in POST to log service. type ServiceHeader struct { Header string diff --git a/core/store/models/common_test.go b/core/store/models/common_test.go index 57b7ca73c6b..eca703d5f3a 100644 --- a/core/store/models/common_test.go +++ b/core/store/models/common_test.go @@ -189,27 +189,6 @@ func TestWebURL_String_HasNilURL(t *testing.T) { assert.Equal(t, "", w.String()) } -func TestDuration_MarshalJSON(t *testing.T) { - tests := []struct { - name string - input models.Duration - want string - }{ - {"zero", models.MustMakeDuration(0), `"0s"`}, - {"one second", models.MustMakeDuration(time.Second), `"1s"`}, - {"one minute", models.MustMakeDuration(time.Minute), `"1m0s"`}, - {"one hour", models.MustMakeDuration(time.Hour), `"1h0m0s"`}, - {"one hour thirty minutes", models.MustMakeDuration(time.Hour + 30*time.Minute), `"1h30m0s"`}, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - b, err := json.Marshal(test.input) - assert.NoError(t, err) - assert.Equal(t, test.want, string(b)) - }) - } -} - func TestCron_UnmarshalJSON_Success(t *testing.T) { t.Parallel() @@ -385,49 +364,6 @@ func TestInterval_MarshalText_UnmarshalText(t *testing.T) { require.Equal(t, i, iNew) } -func TestDuration_Scan_Value(t *testing.T) { - t.Parallel() - - d := models.MustMakeDuration(100) - require.NotNil(t, d) - - val, err := d.Value() - require.NoError(t, err) - - dNew := models.MustMakeDuration(0) - err = dNew.Scan(val) - require.NoError(t, err) - - require.Equal(t, d, dNew) -} - -func TestDuration_MarshalJSON_UnmarshalJSON(t *testing.T) { - t.Parallel() - - d := models.MustMakeDuration(100) - require.NotNil(t, d) - - json, err := d.MarshalJSON() - require.NoError(t, err) - - dNew := models.MustMakeDuration(0) - err = dNew.UnmarshalJSON(json) - require.NoError(t, err) - - require.Equal(t, d, dNew) -} - -func TestDuration_MakeDurationFromString(t *testing.T) { - t.Parallel() - - d, err := models.ParseDuration("1s") - require.NoError(t, err) - require.Equal(t, 1*time.Second, d.Duration()) - - _, err = models.ParseDuration("xyz") - require.Error(t, err) -} - func TestWebURL_Scan_Value(t *testing.T) { t.Parallel() diff --git a/core/store/models/secrets.go b/core/store/models/secrets.go index a7afc95b6cc..ac5cac01734 100644 --- a/core/store/models/secrets.go +++ b/core/store/models/secrets.go @@ -4,6 +4,8 @@ import ( "encoding" "fmt" "net/url" + + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" ) const redacted = "xxxxx" @@ -33,22 +35,22 @@ var ( ) // SecretURL is a URL that formats and encodes redacted, as "xxxxx". -type SecretURL URL +type SecretURL commonconfig.URL -func NewSecretURL(u *URL) *SecretURL { return (*SecretURL)(u) } +func NewSecretURL(u *commonconfig.URL) *SecretURL { return (*SecretURL)(u) } -func MustSecretURL(u string) *SecretURL { return NewSecretURL(MustParseURL(u)) } +func MustSecretURL(u string) *SecretURL { return NewSecretURL(commonconfig.MustParseURL(u)) } func (s *SecretURL) String() string { return redacted } func (s *SecretURL) GoString() string { return redacted } -func (s *SecretURL) URL() *url.URL { return (*URL)(s).URL() } +func (s *SecretURL) URL() *url.URL { return (*commonconfig.URL)(s).URL() } func (s *SecretURL) MarshalText() ([]byte, error) { return []byte(redacted), nil } func (s *SecretURL) UnmarshalText(text []byte) error { - if err := (*URL)(s).UnmarshalText(text); err != nil { + if err := (*commonconfig.URL)(s).UnmarshalText(text); err != nil { //opt: if errors.Is(url.Error), just redact the err.URL field? return fmt.Errorf("failed to parse url: %s", redacted) } diff --git a/core/web/evm_transfer_controller_test.go b/core/web/evm_transfer_controller_test.go index cff996dd21c..86d6b4618aa 100644 --- a/core/web/evm_transfer_controller_test.go +++ b/core/web/evm_transfer_controller_test.go @@ -12,6 +12,7 @@ import ( "github.com/jmoiron/sqlx" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -295,7 +296,7 @@ func TestTransfersController_CreateSuccess_eip1559(t *testing.T) { c.EVM[0].ChainID = (*ubig.Big)(testutils.FixtureChainID) // NOTE: FallbackPollInterval is used in this test to quickly create TxAttempts // Testing triggers requires committing transactions and does not work with transactional tests - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(time.Second) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(time.Second) }) app := cltest.NewApplicationWithConfigAndKey(t, config, ethClient, key) diff --git a/core/web/pipeline_runs_controller_test.go b/core/web/pipeline_runs_controller_test.go index 6c45c1eb319..3c57847d187 100644 --- a/core/web/pipeline_runs_controller_test.go +++ b/core/web/pipeline_runs_controller_test.go @@ -18,13 +18,13 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" "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" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/webhook" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/testdata/testspecs" "github.com/smartcontractkit/chainlink/v2/core/web" "github.com/smartcontractkit/chainlink/v2/core/web/presenters" @@ -35,8 +35,8 @@ func TestPipelineRunsController_CreateWithBody_HappyPath(t *testing.T) { ethClient := cltest.NewEthMocksWithStartupAssertions(t) cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.JobPipeline.HTTPRequest.DefaultTimeout = models.MustNewDuration(2 * time.Second) - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(10 * time.Millisecond) + c.JobPipeline.HTTPRequest.DefaultTimeout = commonconfig.MustNewDuration(2 * time.Second) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(10 * time.Millisecond) }) app := cltest.NewApplicationWithConfig(t, cfg, ethClient) @@ -90,8 +90,8 @@ func TestPipelineRunsController_CreateNoBody_HappyPath(t *testing.T) { ethClient := cltest.NewEthMocksWithStartupAssertions(t) cfg := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) { - c.JobPipeline.HTTPRequest.DefaultTimeout = models.MustNewDuration(2 * time.Second) - c.Database.Listener.FallbackPollInterval = models.MustNewDuration(10 * time.Millisecond) + c.JobPipeline.HTTPRequest.DefaultTimeout = commonconfig.MustNewDuration(2 * time.Second) + c.Database.Listener.FallbackPollInterval = commonconfig.MustNewDuration(10 * time.Millisecond) }) app := cltest.NewApplicationWithConfig(t, cfg, ethClient) diff --git a/core/web/presenters/job.go b/core/web/presenters/job.go index e9b63c73615..a7aed0e5552 100644 --- a/core/web/presenters/job.go +++ b/core/web/presenters/job.go @@ -8,6 +8,7 @@ import ( "gopkg.in/guregu/null.v4" commonassets "github.com/smartcontractkit/chainlink-common/pkg/assets" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" clnull "github.com/smartcontractkit/chainlink/v2/core/null" @@ -272,15 +273,15 @@ type VRFSpec struct { CoordinatorAddress ethkey.EIP55Address `json:"coordinatorAddress"` PublicKey secp256k1.PublicKey `json:"publicKey"` FromAddresses []ethkey.EIP55Address `json:"fromAddresses"` - PollPeriod models.Duration `json:"pollPeriod"` + PollPeriod commonconfig.Duration `json:"pollPeriod"` MinIncomingConfirmations uint32 `json:"confirmations"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` EVMChainID *big.Big `json:"evmChainID"` ChunkSize uint32 `json:"chunkSize"` - RequestTimeout models.Duration `json:"requestTimeout"` - BackoffInitialDelay models.Duration `json:"backoffInitialDelay"` - BackoffMaxDelay models.Duration `json:"backoffMaxDelay"` + RequestTimeout commonconfig.Duration `json:"requestTimeout"` + BackoffInitialDelay commonconfig.Duration `json:"backoffInitialDelay"` + BackoffMaxDelay commonconfig.Duration `json:"backoffMaxDelay"` GasLanePrice *assets.Wei `json:"gasLanePrice"` RequestedConfsDelay int64 `json:"requestedConfsDelay"` VRFOwnerAddress *ethkey.EIP55Address `json:"vrfOwnerAddress,omitempty"` @@ -295,15 +296,15 @@ func NewVRFSpec(spec *job.VRFSpec) *VRFSpec { CoordinatorAddress: spec.CoordinatorAddress, PublicKey: spec.PublicKey, FromAddresses: spec.FromAddresses, - PollPeriod: models.MustMakeDuration(spec.PollPeriod), + PollPeriod: *commonconfig.MustNewDuration(spec.PollPeriod), MinIncomingConfirmations: spec.MinIncomingConfirmations, CreatedAt: spec.CreatedAt, UpdatedAt: spec.UpdatedAt, EVMChainID: spec.EVMChainID, ChunkSize: spec.ChunkSize, - RequestTimeout: models.MustMakeDuration(spec.RequestTimeout), - BackoffInitialDelay: models.MustMakeDuration(spec.BackoffInitialDelay), - BackoffMaxDelay: models.MustMakeDuration(spec.BackoffMaxDelay), + RequestTimeout: *commonconfig.MustNewDuration(spec.RequestTimeout), + BackoffInitialDelay: *commonconfig.MustNewDuration(spec.BackoffInitialDelay), + BackoffMaxDelay: *commonconfig.MustNewDuration(spec.BackoffMaxDelay), GasLanePrice: spec.GasLanePrice, RequestedConfsDelay: spec.RequestedConfsDelay, VRFOwnerAddress: spec.VRFOwnerAddress, diff --git a/core/web/resolver/node_test.go b/core/web/resolver/node_test.go index a209a60fc3c..7f4e69ac4ae 100644 --- a/core/web/resolver/node_test.go +++ b/core/web/resolver/node_test.go @@ -6,11 +6,11 @@ import ( gqlerrors "github.com/graph-gophers/graphql-go/errors" "github.com/pkg/errors" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func TestResolver_Nodes(t *testing.T) { @@ -124,8 +124,8 @@ func Test_NodeQuery(t *testing.T) { f.App.On("EVMORM").Return(f.Mocks.evmORM) f.Mocks.evmORM.PutChains(toml.EVMConfig{Nodes: []*toml.Node{{ Name: &name, - WSURL: models.MustParseURL("ws://some-url"), - HTTPURL: models.MustParseURL("http://some-url"), + WSURL: commonconfig.MustParseURL("ws://some-url"), + HTTPURL: commonconfig.MustParseURL("http://some-url"), Order: ptr(int32(11)), }}}) }, diff --git a/go.mod b/go.mod index 7fe535a425e..11659ac4645 100644 --- a/go.mod +++ b/go.mod @@ -65,7 +65,7 @@ require ( github.com/shopspring/decimal v1.3.1 github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 github.com/smartcontractkit/chainlink-automation v1.0.1 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20231222010926-795676d23c7a + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240104174432-88b0f2a535a6 github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231218175426-6e0427c661e5 github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 github.com/smartcontractkit/chainlink-feeds v0.0.0-20231127231053-2232d3a6766d diff --git a/go.sum b/go.sum index 38eaa89993a..4ca0b032a08 100644 --- a/go.sum +++ b/go.sum @@ -1150,8 +1150,8 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.1 h1:vVjBFq2Zsz21kPy1Pb0wpjF9zrbJX+zjXphDeeR4XZk= github.com/smartcontractkit/chainlink-automation v1.0.1/go.mod h1:INSchkV3ntyDdlZKGWA030MPDpp6pbeuiRkRKYFCm2k= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231222010926-795676d23c7a h1:ViX8kP1/WYW1dLG85Frqpvus1nRGif/1QiK7qeyS+Rc= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231222010926-795676d23c7a/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240104174432-88b0f2a535a6 h1:zFupIn0S1JYnKUJffFS+m4k+9BUlBG4IHsOpu6kkqKM= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240104174432-88b0f2a535a6/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231218175426-6e0427c661e5 h1:kBnmjv3fxU7krVIqZFvo1m4F6qBc4vPURQFX/mcChhI= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231218175426-6e0427c661e5/go.mod h1:EoM7wQ81mov7wsUzG4zEnnr0EH0POEo/I0hRDg433TU= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 h1:xYqRgZO0nMSO8CBCMR0r3WA+LZ4kNL8a6bnbyk/oBtQ= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 673fbf4dbd5..7d5ce8a9513 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -25,8 +25,8 @@ require ( github.com/segmentio/ksuid v1.0.4 github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.1 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20231222010926-795676d23c7a - github.com/smartcontractkit/chainlink-testing-framework v1.22.1 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240104174432-88b0f2a535a6 + github.com/smartcontractkit/chainlink-testing-framework v1.22.0 github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20231130143053-c5102a9c0fb7 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 9977ed84b8b..f6a201dc667 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1481,8 +1481,8 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.1 h1:vVjBFq2Zsz21kPy1Pb0wpjF9zrbJX+zjXphDeeR4XZk= github.com/smartcontractkit/chainlink-automation v1.0.1/go.mod h1:INSchkV3ntyDdlZKGWA030MPDpp6pbeuiRkRKYFCm2k= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231222010926-795676d23c7a h1:ViX8kP1/WYW1dLG85Frqpvus1nRGif/1QiK7qeyS+Rc= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231222010926-795676d23c7a/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240104174432-88b0f2a535a6 h1:zFupIn0S1JYnKUJffFS+m4k+9BUlBG4IHsOpu6kkqKM= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240104174432-88b0f2a535a6/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231218175426-6e0427c661e5 h1:kBnmjv3fxU7krVIqZFvo1m4F6qBc4vPURQFX/mcChhI= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231218175426-6e0427c661e5/go.mod h1:EoM7wQ81mov7wsUzG4zEnnr0EH0POEo/I0hRDg433TU= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 h1:xYqRgZO0nMSO8CBCMR0r3WA+LZ4kNL8a6bnbyk/oBtQ= @@ -1493,8 +1493,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231219140448-151a4725f31 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231219140448-151a4725f312/go.mod h1:vqnojBNdzHNI6asWezJlottUiVEXudMEGf2Mz5R+xps= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231219014050-0c4a7831293a h1:atCXqF8e5U2zfEaA87cKJs+K1MAbOVh3V05gEd60fR0= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231219014050-0c4a7831293a/go.mod h1:YWKpf+hO9XMlzIWQT8yGoky3aeFLzMUVsjbs80LD77M= -github.com/smartcontractkit/chainlink-testing-framework v1.22.1 h1:2XDxU1CTWJruUZv15/VPdaBT1W9ym4OI3I5baRbDhFg= -github.com/smartcontractkit/chainlink-testing-framework v1.22.1/go.mod h1:yu6qqrppNJfutQV37fiSs4eS0uQP5QT0ebi3tlIgWN0= +github.com/smartcontractkit/chainlink-testing-framework v1.22.0 h1:Lur628wkrceWgcLmxGZe7Mauwxht4YO71hX9Jj5YslE= +github.com/smartcontractkit/chainlink-testing-framework v1.22.0/go.mod h1:yu6qqrppNJfutQV37fiSs4eS0uQP5QT0ebi3tlIgWN0= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868/go.mod h1:Kn1Hape05UzFZ7bOUnm3GVsHzP0TNrVmpfXYNHdqGGs= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss= diff --git a/integration-tests/load/functions/config.go b/integration-tests/load/functions/config.go index ad7e7446afb..d34e8a9f1eb 100644 --- a/integration-tests/load/functions/config.go +++ b/integration-tests/load/functions/config.go @@ -8,7 +8,7 @@ import ( "github.com/pelletier/go-toml/v2" "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink/v2/core/store/models" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" ) const ( @@ -56,49 +56,49 @@ type Funding struct { } type Soak struct { - RPS int64 `toml:"rps"` - RequestsPerCall uint32 `toml:"requests_per_call"` - Duration *models.Duration `toml:"duration"` + RPS int64 `toml:"rps"` + RequestsPerCall uint32 `toml:"requests_per_call"` + Duration *commonconfig.Duration `toml:"duration"` } type SecretsSoak struct { - RPS int64 `toml:"rps"` - RequestsPerCall uint32 `toml:"requests_per_call"` - Duration *models.Duration `toml:"duration"` + RPS int64 `toml:"rps"` + RequestsPerCall uint32 `toml:"requests_per_call"` + Duration *commonconfig.Duration `toml:"duration"` } type RealSoak struct { - RPS int64 `toml:"rps"` - RequestsPerCall uint32 `toml:"requests_per_call"` - Duration *models.Duration `toml:"duration"` + RPS int64 `toml:"rps"` + RequestsPerCall uint32 `toml:"requests_per_call"` + Duration *commonconfig.Duration `toml:"duration"` } type Stress struct { - RPS int64 `toml:"rps"` - RequestsPerCall uint32 `toml:"requests_per_call"` - Duration *models.Duration `toml:"duration"` + RPS int64 `toml:"rps"` + RequestsPerCall uint32 `toml:"requests_per_call"` + Duration *commonconfig.Duration `toml:"duration"` } type SecretsStress struct { - RPS int64 `toml:"rps"` - RequestsPerCall uint32 `toml:"requests_per_call"` - Duration *models.Duration `toml:"duration"` + RPS int64 `toml:"rps"` + RequestsPerCall uint32 `toml:"requests_per_call"` + Duration *commonconfig.Duration `toml:"duration"` } type RealStress struct { - RPS int64 `toml:"rps"` - RequestsPerCall uint32 `toml:"requests_per_call"` - Duration *models.Duration `toml:"duration"` + RPS int64 `toml:"rps"` + RequestsPerCall uint32 `toml:"requests_per_call"` + Duration *commonconfig.Duration `toml:"duration"` } type GatewayListSoak struct { - RPS int64 `toml:"rps"` - Duration *models.Duration `toml:"duration"` + RPS int64 `toml:"rps"` + Duration *commonconfig.Duration `toml:"duration"` } type GatewaySetSoak struct { - RPS int64 `toml:"rps"` - Duration *models.Duration `toml:"duration"` + RPS int64 `toml:"rps"` + Duration *commonconfig.Duration `toml:"duration"` } func ReadConfig() (*PerformanceConfig, error) { diff --git a/integration-tests/load/ocr/config.go b/integration-tests/load/ocr/config.go index 2991df3774a..4b324210b09 100644 --- a/integration-tests/load/ocr/config.go +++ b/integration-tests/load/ocr/config.go @@ -8,7 +8,7 @@ import ( "github.com/pelletier/go-toml/v2" "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink/v2/core/store/models" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" ) const ( @@ -28,22 +28,22 @@ type Common struct { } type Load struct { - TestDuration *models.Duration `toml:"test_duration"` - Rate int64 `toml:"rate"` - RateLimitUnitDuration *models.Duration `toml:"rate_limit_unit_duration"` - VerificationInterval *models.Duration `toml:"verification_interval"` - VerificationTimeout *models.Duration `toml:"verification_timeout"` - EAChangeInterval *models.Duration `toml:"ea_change_interval"` + TestDuration *commonconfig.Duration `toml:"test_duration"` + Rate int64 `toml:"rate"` + RateLimitUnitDuration *commonconfig.Duration `toml:"rate_limit_unit_duration"` + VerificationInterval *commonconfig.Duration `toml:"verification_interval"` + VerificationTimeout *commonconfig.Duration `toml:"verification_timeout"` + EAChangeInterval *commonconfig.Duration `toml:"ea_change_interval"` } type Volume struct { - TestDuration *models.Duration `toml:"test_duration"` - Rate int64 `toml:"rate"` - VURequestsPerUnit int `toml:"vu_requests_per_unit"` - RateLimitUnitDuration *models.Duration `toml:"rate_limit_unit_duration"` - VerificationInterval *models.Duration `toml:"verification_interval"` - VerificationTimeout *models.Duration `toml:"verification_timeout"` - EAChangeInterval *models.Duration `toml:"ea_change_interval"` + TestDuration *commonconfig.Duration `toml:"test_duration"` + Rate int64 `toml:"rate"` + VURequestsPerUnit int `toml:"vu_requests_per_unit"` + RateLimitUnitDuration *commonconfig.Duration `toml:"rate_limit_unit_duration"` + VerificationInterval *commonconfig.Duration `toml:"verification_interval"` + VerificationTimeout *commonconfig.Duration `toml:"verification_timeout"` + EAChangeInterval *commonconfig.Duration `toml:"ea_change_interval"` } func ReadConfig() (*PerformanceConfig, error) { diff --git a/integration-tests/load/vrfv2/config.go b/integration-tests/load/vrfv2/config.go index d5e94bb75fb..e97ac6a964e 100644 --- a/integration-tests/load/vrfv2/config.go +++ b/integration-tests/load/vrfv2/config.go @@ -10,7 +10,7 @@ import ( "github.com/pelletier/go-toml/v2" "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink/v2/core/store/models" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" ) const ( @@ -86,10 +86,10 @@ type PerformanceTestConfig struct { NumberOfSubToCreate int `toml:"number_of_sub_to_create"` RPS int64 `toml:"rps"` - //Duration *models.Duration `toml:"duration"` - RateLimitUnitDuration *models.Duration `toml:"rate_limit_unit_duration"` - RandomnessRequestCountPerRequest uint16 `toml:"randomness_request_count_per_request"` - RandomnessRequestCountPerRequestDeviation uint16 `toml:"randomness_request_count_per_request_deviation"` + //Duration *commonconfig.Duration `toml:"duration"` + RateLimitUnitDuration *commonconfig.Duration `toml:"rate_limit_unit_duration"` + RandomnessRequestCountPerRequest uint16 `toml:"randomness_request_count_per_request"` + RandomnessRequestCountPerRequestDeviation uint16 `toml:"randomness_request_count_per_request_deviation"` } func ReadConfig() (*PerformanceConfig, error) { diff --git a/integration-tests/load/vrfv2plus/config.go b/integration-tests/load/vrfv2plus/config.go index 43bcf44d044..2fc6b6a4c7f 100644 --- a/integration-tests/load/vrfv2plus/config.go +++ b/integration-tests/load/vrfv2plus/config.go @@ -8,8 +8,8 @@ import ( "github.com/pelletier/go-toml/v2" "github.com/rs/zerolog/log" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_config" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) const ( @@ -86,10 +86,10 @@ type PerformanceTestConfig struct { NumberOfSubToCreate int `toml:"number_of_sub_to_create"` RPS int64 `toml:"rps"` - //Duration *models.Duration `toml:"duration"` - RateLimitUnitDuration *models.Duration `toml:"rate_limit_unit_duration"` - RandomnessRequestCountPerRequest uint16 `toml:"randomness_request_count_per_request"` - RandomnessRequestCountPerRequestDeviation uint16 `toml:"randomness_request_count_per_request_deviation"` + //Duration *commonconfig.Duration `toml:"duration"` + RateLimitUnitDuration *commonconfig.Duration `toml:"rate_limit_unit_duration"` + RandomnessRequestCountPerRequest uint16 `toml:"randomness_request_count_per_request"` + RandomnessRequestCountPerRequestDeviation uint16 `toml:"randomness_request_count_per_request_deviation"` } func ReadConfig() (*PerformanceConfig, error) { diff --git a/integration-tests/smoke/automation_test.go b/integration-tests/smoke/automation_test.go index 70b6a8f6856..0bdb6cf1f4e 100644 --- a/integration-tests/smoke/automation_test.go +++ b/integration-tests/smoke/automation_test.go @@ -29,16 +29,15 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/utils/ptr" "github.com/smartcontractkit/chainlink-testing-framework/utils/testcontext" - cltypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_utils_2_1" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/streams" - "github.com/smartcontractkit/chainlink/v2/core/store/models" - + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" + cltypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_utils_2_1" + "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/streams" ) var utilsABI = cltypes.MustGetABI(automation_utils_2_1.AutomationUtilsABI) @@ -1073,7 +1072,7 @@ func setupAutomationTestDocker( // build the node config clNodeConfig := node.NewConfig(node.NewBaseConfig()) - syncInterval := models.MustMakeDuration(5 * time.Minute) + syncInterval := *commonconfig.MustNewDuration(5 * time.Minute) clNodeConfig.Feature.LogPoller = ptr.Ptr[bool](true) clNodeConfig.OCR2.Enabled = ptr.Ptr[bool](true) clNodeConfig.Keeper.TurnLookBack = ptr.Ptr[int64](int64(0)) diff --git a/integration-tests/smoke/keeper_test.go b/integration-tests/smoke/keeper_test.go index 330d041c8f6..cac5aa93d36 100644 --- a/integration-tests/smoke/keeper_test.go +++ b/integration-tests/smoke/keeper_test.go @@ -11,12 +11,11 @@ import ( "github.com/onsi/gomega" "github.com/stretchr/testify/require" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/utils/testcontext" - "github.com/smartcontractkit/chainlink/v2/core/store/models" - "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" @@ -1100,7 +1099,7 @@ func setupKeeperTest(t *testing.T) ( ) { clNodeConfig := node.NewConfig(node.NewBaseConfig(), node.WithP2Pv2()) turnLookBack := int64(0) - syncInterval := models.MustMakeDuration(5 * time.Second) + syncInterval := *commonconfig.MustNewDuration(5 * time.Second) performGasOverhead := uint32(150000) clNodeConfig.Keeper.TurnLookBack = &turnLookBack clNodeConfig.Keeper.Registry.SyncInterval = &syncInterval diff --git a/integration-tests/types/config/node/core.go b/integration-tests/types/config/node/core.go index d8536c1395e..3508f77555f 100644 --- a/integration-tests/types/config/node/core.go +++ b/integration-tests/types/config/node/core.go @@ -7,25 +7,22 @@ import ( "os" "time" - "go.uber.org/zap/zapcore" - "github.com/segmentio/ksuid" + "go.uber.org/zap/zapcore" commonassets "github.com/smartcontractkit/chainlink-common/pkg/assets" "github.com/smartcontractkit/chainlink-common/pkg/config" - + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/utils/ptr" + it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" "github.com/smartcontractkit/chainlink/v2/core/config/toml" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" - "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/v2/core/utils" - - it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func NewBaseConfig() *chainlink.Config { @@ -48,7 +45,7 @@ func NewBaseConfig() *chainlink.Config { AllowOrigins: ptr.Ptr("*"), HTTPPort: ptr.Ptr[uint16](6688), SecureCookies: ptr.Ptr(false), - SessionTimeout: models.MustNewDuration(time.Hour * 999), + SessionTimeout: commonconfig.MustNewDuration(time.Hour * 999), TLS: toml.WebServerTLS{ HTTPSPort: ptr.Ptr[uint16](0), }, @@ -186,7 +183,7 @@ func WithPrivateEVMs(networks []blockchain.EVMNetwork) NodeConfigOpt { AutoCreateKey: ptr.Ptr(true), FinalityDepth: ptr.Ptr[uint32](50), MinContractPayment: commonassets.NewLinkFromJuels(0), - LogPollInterval: models.MustNewDuration(1 * time.Second), + LogPollInterval: commonconfig.MustNewDuration(1 * time.Second), HeadTracker: evmcfg.HeadTracker{ HistoryDepth: ptr.Ptr(uint32(100)), }, @@ -237,6 +234,6 @@ func WithVRFv2EVMEstimator(addresses []string, maxGasPriceGWei int64) NodeConfig func WithLogPollInterval(interval time.Duration) NodeConfigOpt { return func(c *chainlink.Config) { - c.EVM[0].Chain.LogPollInterval = models.MustNewDuration(interval) + c.EVM[0].Chain.LogPollInterval = commonconfig.MustNewDuration(interval) } } diff --git a/integration-tests/universal/log_poller/config.go b/integration-tests/universal/log_poller/config.go index 78a0da46bc6..d42520397e8 100644 --- a/integration-tests/universal/log_poller/config.go +++ b/integration-tests/universal/log_poller/config.go @@ -10,7 +10,7 @@ import ( "github.com/pelletier/go-toml/v2" "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink/v2/core/store/models" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" ) const ( @@ -65,11 +65,11 @@ type WaspConfig struct { } type Load struct { - RPS int64 `toml:"rps"` - LPS int64 `toml:"lps"` - RateLimitUnitDuration *models.Duration `toml:"rate_limit_unit_duration"` - Duration *models.Duration `toml:"duration"` - CallTimeout *models.Duration `toml:"call_timeout"` + RPS int64 `toml:"rps"` + LPS int64 `toml:"lps"` + RateLimitUnitDuration *commonconfig.Duration `toml:"rate_limit_unit_duration"` + Duration *commonconfig.Duration `toml:"duration"` + CallTimeout *commonconfig.Duration `toml:"call_timeout"` } func ReadConfig(configName string) (*Config, error) { @@ -105,7 +105,7 @@ func (c *Config) OverrideFromEnv() error { } if duration := os.Getenv("LOAD_DURATION"); duration != "" { - d, err := models.ParseDuration(duration) + d, err := commonconfig.ParseDuration(duration) if err != nil { return err } diff --git a/integration-tests/universal/log_poller/helpers.go b/integration-tests/universal/log_poller/helpers.go index 40040fd0aee..8ad115ecec8 100644 --- a/integration-tests/universal/log_poller/helpers.go +++ b/integration-tests/universal/log_poller/helpers.go @@ -23,11 +23,18 @@ import ( "github.com/smartcontractkit/wasp" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" ctf_test_env "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink-testing-framework/utils/ptr" + "github.com/smartcontractkit/chainlink/integration-tests/actions" + "github.com/smartcontractkit/chainlink/integration-tests/client" + "github.com/smartcontractkit/chainlink/integration-tests/contracts" + "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" + "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" + "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" cltypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" @@ -35,14 +42,6 @@ import ( le "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/log_emitter" core_logger "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/pg" - "github.com/smartcontractkit/chainlink/v2/core/store/models" - - "github.com/smartcontractkit/chainlink/integration-tests/actions" - "github.com/smartcontractkit/chainlink/integration-tests/client" - "github.com/smartcontractkit/chainlink/integration-tests/contracts" - "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" - "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" - "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" ) var ( @@ -1009,7 +1008,7 @@ func setupLogPollerTestDocker( // build the node config clNodeConfig := node.NewConfig(node.NewBaseConfig()) - syncInterval := models.MustMakeDuration(5 * time.Minute) + syncInterval := *commonconfig.MustNewDuration(5 * time.Minute) clNodeConfig.Feature.LogPoller = ptr.Ptr[bool](true) clNodeConfig.OCR2.Enabled = ptr.Ptr[bool](true) clNodeConfig.Keeper.TurnLookBack = ptr.Ptr[int64](int64(0)) @@ -1026,7 +1025,7 @@ func setupLogPollerTestDocker( clNodesCount := 5 var logPolllerSettingsFn = func(chain *evmcfg.Chain) *evmcfg.Chain { - chain.LogPollInterval = models.MustNewDuration(lpPollingInterval) + chain.LogPollInterval = commonconfig.MustNewDuration(lpPollingInterval) chain.FinalityDepth = ptr.Ptr[uint32](uint32(finalityDepth)) chain.FinalityTagEnabled = ptr.Ptr[bool](finalityTagEnabled) return chain diff --git a/integration-tests/utils/common.go b/integration-tests/utils/common.go index 34a40e396d2..cc77e4cc3b0 100644 --- a/integration-tests/utils/common.go +++ b/integration-tests/utils/common.go @@ -4,11 +4,11 @@ import ( "math/big" "net" - "github.com/smartcontractkit/chainlink/v2/core/store/models" + commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" ) -func MustURL(s string) *models.URL { - var u models.URL +func MustURL(s string) *commonconfig.URL { + var u commonconfig.URL if err := u.UnmarshalText([]byte(s)); err != nil { panic(err) }