diff --git a/core/capabilities/integration_tests/setup.go b/core/capabilities/integration_tests/setup.go index 8e31ce5ba5..9eba7b901b 100644 --- a/core/capabilities/integration_tests/setup.go +++ b/core/capabilities/integration_tests/setup.go @@ -95,6 +95,7 @@ func setupStreamDonsWithTransmissionSchedule(ctx context.Context, t *testing.T, return consumer, feedIDs, sink } +// nolint:revive func createDons(ctx context.Context, t *testing.T, lggr logger.Logger, reportsSink *reportsSink, workflowDon donInfo, triggerDon donInfo, diff --git a/core/capabilities/targets/write_target.go b/core/capabilities/targets/write_target.go index eb3a390de4..0c16b8f8e8 100644 --- a/core/capabilities/targets/write_target.go +++ b/core/capabilities/targets/write_target.go @@ -179,6 +179,7 @@ func success() <-chan capabilities.CapabilityResponse { return callback } +// nolint:revive func (cap *WriteTarget) Execute(ctx context.Context, rawRequest capabilities.CapabilityRequest) (<-chan capabilities.CapabilityResponse, error) { // Bind to the contract address on the write path. // Bind() requires a connection to the node's RPCs and @@ -283,8 +284,8 @@ func (cap *WriteTarget) Execute(ctx context.Context, rawRequest capabilities.Cap if err := cap.cw.SubmitTransaction(ctx, "forwarder", "report", req, txID.String(), cap.forwarderAddress, &meta, value); err != nil { if commontypes.ErrSettingTransactionGasLimitNotSupported.Is(err) { meta.GasLimit = nil - if err := cap.cw.SubmitTransaction(ctx, "forwarder", "report", req, txID.String(), cap.forwarderAddress, &meta, value); err != nil { - return nil, fmt.Errorf("failed to submit transaction: %w", err) + if err2 := cap.cw.SubmitTransaction(ctx, "forwarder", "report", req, txID.String(), cap.forwarderAddress, &meta, value); err != nil { + return nil, fmt.Errorf("failed to submit transaction: %w", err2) } } else { return nil, fmt.Errorf("failed to submit transaction: %w", err) diff --git a/core/capabilities/targets/write_target_test.go b/core/capabilities/targets/write_target_test.go index 9f7b6a2de2..e9ecece45f 100644 --- a/core/capabilities/targets/write_target_test.go +++ b/core/capabilities/targets/write_target_test.go @@ -116,11 +116,11 @@ func TestWriteTarget(t *testing.T) { }) t.Run("passes gas limit set on config to the chain writer", func(t *testing.T) { - configGasLimit, err := values.NewMap(map[string]any{ + configGasLimit, err2 := values.NewMap(map[string]any{ "Address": forwarderAddr, "GasLimit": 500000, }) - require.NoError(t, err) + require.NoError(t, err2) req := capabilities.CapabilityRequest{ Metadata: validMetadata, Config: configGasLimit, @@ -130,16 +130,16 @@ func TestWriteTarget(t *testing.T) { meta := types.TxMeta{WorkflowExecutionID: &req.Metadata.WorkflowExecutionID, GasLimit: big.NewInt(500000)} cw.On("SubmitTransaction", mock.Anything, "forwarder", "report", mock.Anything, mock.Anything, forwarderAddr, &meta, mock.Anything).Return(types.ErrSettingTransactionGasLimitNotSupported) - _, err2 := writeTarget.Execute(ctx, req) + _, err2 = writeTarget.Execute(ctx, req) require.Error(t, err2) }) t.Run("retries without gas limit when ChainWriter's SubmitTransaction returns error due to gas limit not supported", func(t *testing.T) { - configGasLimit, err := values.NewMap(map[string]any{ + configGasLimit, err2 := values.NewMap(map[string]any{ "Address": forwarderAddr, "GasLimit": 500000, }) - require.NoError(t, err) + require.NoError(t, err2) req := capabilities.CapabilityRequest{ Metadata: validMetadata, Config: configGasLimit, @@ -151,7 +151,7 @@ func TestWriteTarget(t *testing.T) { meta = types.TxMeta{WorkflowExecutionID: &req.Metadata.WorkflowExecutionID} cw.On("SubmitTransaction", mock.Anything, "forwarder", "report", mock.Anything, mock.Anything, forwarderAddr, &meta, mock.Anything).Return(nil) - configGasLimit, err = values.NewMap(map[string]any{ + configGasLimit, _ = values.NewMap(map[string]any{ "Address": forwarderAddr, }) req = capabilities.CapabilityRequest{ @@ -160,7 +160,7 @@ func TestWriteTarget(t *testing.T) { Inputs: validInputs, } - _, err2 := writeTarget.Execute(ctx, req) + _, err2 = writeTarget.Execute(ctx, req) require.Error(t, err2) }) diff --git a/core/chains/evm/client/rpc_client_test.go b/core/chains/evm/client/rpc_client_test.go index 1555e436e3..642d16b8e2 100644 --- a/core/chains/evm/client/rpc_client_test.go +++ b/core/chains/evm/client/rpc_client_test.go @@ -156,7 +156,6 @@ func TestRPCClient_SubscribeNewHead(t *testing.T) { }() wg.Wait() } - }) t.Run("Concurrent Unsubscribe and onNewHead calls do not lead to a deadlock", func(t *testing.T) { const numberOfAttempts = 1000 // need a large number to increase the odds of reproducing the issue diff --git a/core/services/llo/data_source.go b/core/services/llo/data_source.go index 4f6e91675c..3d265de261 100644 --- a/core/services/llo/data_source.go +++ b/core/services/llo/data_source.go @@ -149,7 +149,7 @@ func (d *dataSource) Observe(ctx context.Context, streamValues llo.StreamValues, if opts.VerboseLogging() { successes := make([]streams.StreamID, 0, len(streamValues)) - for strmID, _ := range streamValues { + for strmID := range streamValues { successes = append(successes, strmID) } sort.Slice(successes, func(i, j int) bool { return successes[i] < successes[j] }) diff --git a/core/services/llo/evm/report_codec_premium_legacy.go b/core/services/llo/evm/report_codec_premium_legacy.go index a062f77b65..3dba6b3ea2 100644 --- a/core/services/llo/evm/report_codec_premium_legacy.go +++ b/core/services/llo/evm/report_codec_premium_legacy.go @@ -51,10 +51,7 @@ func (r *ReportFormatEVMPremiumLegacyOpts) Decode(opts []byte) error { // special case if opts are unspecified, just use the zero options rather than erroring return nil } - if err := json.Unmarshal(opts, r); err != nil { - return err - } - return nil + return json.Unmarshal(opts, r) } func (r ReportCodecPremiumLegacy) Encode(report llo.Report, cd llotypes.ChannelDefinition) ([]byte, error) { @@ -103,6 +100,7 @@ func (r ReportCodecPremiumLegacy) Decode(b []byte) (*reporttypes.Report, error) } // Pack assembles the report values into a payload for verifying on-chain +// nolint:revive func (r ReportCodecPremiumLegacy) Pack(digest types.ConfigDigest, seqNr uint64, report ocr2types.Report, sigs []types.AttributedOnchainSignature) ([]byte, error) { var rs [][32]byte var ss [][32]byte diff --git a/core/services/llo/evm/report_codec_premium_legacy_test.go b/core/services/llo/evm/report_codec_premium_legacy_test.go index c22d29c340..54eb4f2c68 100644 --- a/core/services/llo/evm/report_codec_premium_legacy_test.go +++ b/core/services/llo/evm/report_codec_premium_legacy_test.go @@ -18,6 +18,7 @@ import ( "github.com/smartcontractkit/chainlink-data-streams/llo" ) +// nolint:unused const ethMainnetChainSelector uint64 = 5009297550715157269 func newValidPremiumLegacyReport() llo.Report { diff --git a/core/services/llo/onchain_channel_definition_cache.go b/core/services/llo/onchain_channel_definition_cache.go index 51cfae964d..137525d5ca 100644 --- a/core/services/llo/onchain_channel_definition_cache.go +++ b/core/services/llo/onchain_channel_definition_cache.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "maps" "math/big" "net/http" @@ -151,7 +150,7 @@ func (c *channelDefinitionCache) Start(ctx context.Context) error { } else if pd != nil { c.definitions = pd.Definitions c.initialBlockNum = pd.BlockNum + 1 - c.definitionsVersion = uint32(pd.Version) + c.definitionsVersion = pd.Version } else { // ensure non-nil map ready for assignment later c.definitions = make(llotypes.ChannelDefinitions) @@ -385,7 +384,7 @@ func (c *channelDefinitionCache) fetchChannelDefinitions(ctx context.Context, ur // logs with potentially huge messages body := http.MaxBytesReader(nil, reader, 1024) defer body.Close() - bodyBytes, err := ioutil.ReadAll(body) + bodyBytes, err := io.ReadAll(body) if err != nil { return nil, fmt.Errorf("got error from %s: (status code: %d, error reading response body: %w, response body: %s)", url, statusCode, err, bodyBytes) } @@ -453,6 +452,7 @@ func (c *channelDefinitionCache) persist(ctx context.Context) (memoryVersion, pe // Checks persisted version and tries to save if necessary on a periodic timer // Simple backup in case database persistence fails +// nolint:revive func (c *channelDefinitionCache) failedPersistLoop() { defer c.wg.Done() diff --git a/core/services/llo/onchain_channel_definition_cache_test.go b/core/services/llo/onchain_channel_definition_cache_test.go index 5bd7eedbb1..12aac615de 100644 --- a/core/services/llo/onchain_channel_definition_cache_test.go +++ b/core/services/llo/onchain_channel_definition_cache_test.go @@ -277,7 +277,7 @@ func Test_ChannelDefinitionCache(t *testing.T) { } t.Run("nil ctx returns error", func(t *testing.T) { - _, err := cdc.fetchChannelDefinitions(nil, "notvalid://foos", [32]byte{}) + _, err := cdc.fetchChannelDefinitions(context.Background(), "notvalid://foos", [32]byte{}) assert.EqualError(t, err, "failed to create http.Request; net/http: nil Context") }) @@ -363,7 +363,7 @@ func Test_ChannelDefinitionCache(t *testing.T) { cd, err := cdc.fetchChannelDefinitions(ctx, "http://example.com/definitions.json", common.HexToHash("0x367bbc75f7b6c9fc66a98ea99f837ea7ac4a3c2d6a9ee284de018bd02c41b52d")) assert.NoError(t, err) - assert.Equal(t, llotypes.ChannelDefinitions(llotypes.ChannelDefinitions{0x2a: llotypes.ChannelDefinition{ReportFormat: 0x1, Streams: []llotypes.Stream{llotypes.Stream{StreamID: 0x34, Aggregator: 0x1}, llotypes.Stream{StreamID: 0x35, Aggregator: 0x1}, llotypes.Stream{StreamID: 0x37, Aggregator: 0x3}}, Opts: llotypes.ChannelOpts{0x7b, 0x22, 0x62, 0x61, 0x73, 0x65, 0x55, 0x53, 0x44, 0x46, 0x65, 0x65, 0x22, 0x3a, 0x22, 0x31, 0x30, 0x22, 0x2c, 0x22, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x22, 0x3a, 0x33, 0x36, 0x30, 0x30, 0x2c, 0x22, 0x66, 0x65, 0x65, 0x64, 0x49, 0x64, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x30, 0x30, 0x33, 0x36, 0x62, 0x34, 0x61, 0x61, 0x37, 0x65, 0x35, 0x37, 0x63, 0x61, 0x37, 0x62, 0x36, 0x38, 0x61, 0x65, 0x31, 0x62, 0x66, 0x34, 0x35, 0x36, 0x35, 0x33, 0x66, 0x35, 0x36, 0x62, 0x36, 0x35, 0x36, 0x66, 0x64, 0x33, 0x61, 0x61, 0x33, 0x33, 0x35, 0x65, 0x66, 0x37, 0x66, 0x61, 0x65, 0x36, 0x39, 0x36, 0x62, 0x36, 0x36, 0x33, 0x66, 0x31, 0x62, 0x38, 0x34, 0x37, 0x32, 0x22, 0x2c, 0x22, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x22, 0x3a, 0x22, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d}}}), cd) + assert.Equal(t, llotypes.ChannelDefinitions{0x2a: llotypes.ChannelDefinition{ReportFormat: 0x1, Streams: []llotypes.Stream{llotypes.Stream{StreamID: 0x34, Aggregator: 0x1}, llotypes.Stream{StreamID: 0x35, Aggregator: 0x1}, llotypes.Stream{StreamID: 0x37, Aggregator: 0x3}}, Opts: llotypes.ChannelOpts{0x7b, 0x22, 0x62, 0x61, 0x73, 0x65, 0x55, 0x53, 0x44, 0x46, 0x65, 0x65, 0x22, 0x3a, 0x22, 0x31, 0x30, 0x22, 0x2c, 0x22, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x22, 0x3a, 0x33, 0x36, 0x30, 0x30, 0x2c, 0x22, 0x66, 0x65, 0x65, 0x64, 0x49, 0x64, 0x22, 0x3a, 0x22, 0x30, 0x78, 0x30, 0x30, 0x30, 0x33, 0x36, 0x62, 0x34, 0x61, 0x61, 0x37, 0x65, 0x35, 0x37, 0x63, 0x61, 0x37, 0x62, 0x36, 0x38, 0x61, 0x65, 0x31, 0x62, 0x66, 0x34, 0x35, 0x36, 0x35, 0x33, 0x66, 0x35, 0x36, 0x62, 0x36, 0x35, 0x36, 0x66, 0x64, 0x33, 0x61, 0x61, 0x33, 0x33, 0x35, 0x65, 0x66, 0x37, 0x66, 0x61, 0x65, 0x36, 0x39, 0x36, 0x62, 0x36, 0x36, 0x33, 0x66, 0x31, 0x62, 0x38, 0x34, 0x37, 0x32, 0x22, 0x2c, 0x22, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x22, 0x3a, 0x22, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x7d}}}, cd) }) }) diff --git a/core/services/ocr2/plugins/ccip/prices/da_price_estimator.go b/core/services/ocr2/plugins/ccip/prices/da_price_estimator.go index 83b0a8d453..34239398c8 100644 --- a/core/services/ocr2/plugins/ccip/prices/da_price_estimator.go +++ b/core/services/ocr2/plugins/ccip/prices/da_price_estimator.go @@ -19,9 +19,6 @@ type DAGasPriceEstimator struct { feeEstimatorConfig ccipdata.FeeEstimatorConfigReader priceEncodingLength uint daDeviationPPB int64 - daOverheadGas int64 - gasPerDAByte int64 - daMultiplier int64 } func NewDAGasPriceEstimator( diff --git a/core/services/ocr2/plugins/llo/helpers_test.go b/core/services/ocr2/plugins/llo/helpers_test.go index 23a0cc7064..9ff6b2dfb1 100644 --- a/core/services/ocr2/plugins/llo/helpers_test.go +++ b/core/services/ocr2/plugins/llo/helpers_test.go @@ -113,6 +113,7 @@ func (s *mercuryServer) LatestReport(ctx context.Context, lrr *pb.LatestReportRe return out, nil } +// nolint:unused func startMercuryServer(t *testing.T, srv *mercuryServer, pubKeys []ed25519.PublicKey) (serverURL string) { // Set up the wsrpc server lis, err := net.Listen("tcp", "127.0.0.1:0") @@ -352,6 +353,7 @@ transmitterID = "%x" )) } +// nolint:unused func addOCRJobs( t *testing.T, streams []Stream, @@ -366,7 +368,6 @@ func addOCRJobs( pluginConfig, relayType, relayConfig string) (streamJobIDs []int32) { - // Add OCR jobs - one per feed on each node for i, node := range nodes { for j, strm := range streams { diff --git a/core/services/ocr2/plugins/llo/integration_test.go b/core/services/ocr2/plugins/llo/integration_test.go index 787946b6ad..f3fa3d2606 100644 --- a/core/services/ocr2/plugins/llo/integration_test.go +++ b/core/services/ocr2/plugins/llo/integration_test.go @@ -48,6 +48,7 @@ var ( nNodes = 4 // number of nodes (not including bootstrap) ) +// nolint:unused func setupBlockchain(t *testing.T) (*bind.TransactOpts, *backends.SimulatedBackend, *channel_verifier.ChannelVerifier, common.Address, *channel_config_store.ChannelConfigStore, common.Address) { steve := testutils.MustNewSimTransactor(t) // config contract deployer and owner genesisData := core.GenesisAlloc{steve.From: {Balance: assets.Ether(1000).ToInt()}} @@ -77,10 +78,6 @@ type Stream struct { } var ( - btcStream = Stream{ - id: 51, - baseBenchmarkPrice: decimal.NewFromFloat32(56_114.41), - } ethStream = Stream{ id: 52, baseBenchmarkPrice: decimal.NewFromFloat32(2_976.39), @@ -89,10 +86,6 @@ var ( id: 53, baseBenchmarkPrice: decimal.NewFromFloat32(13.25), } - dogeStream = Stream{ - id: 54, - baseBenchmarkPrice: decimal.NewFromFloat32(0.10960935), - } quoteStream = Stream{ id: 55, baseBenchmarkPrice: decimal.NewFromFloat32(1000.1212), @@ -113,8 +106,6 @@ func generateConfig(t *testing.T, oracles []confighelper.OracleIdentityExtra) ( reportingPluginConfig, err := rawReportingPluginConfig.Encode() require.NoError(t, err) - offchainConfig = []byte{} - signers, transmitters, f, onchainConfig, offchainConfigVersion, offchainConfig, err = ocr3confighelper.ContractSetConfigArgsForTests( 2*time.Second, // DeltaProgress 20*time.Second, // DeltaResend @@ -140,6 +131,7 @@ func generateConfig(t *testing.T, oracles []confighelper.OracleIdentityExtra) ( return } +// nolint:unused func setConfig(t *testing.T, steve *bind.TransactOpts, backend *backends.SimulatedBackend, verifierContract *channel_verifier.ChannelVerifier, verifierAddress common.Address, nodes []Node, oracles []confighelper.OracleIdentityExtra) ocr2types.ConfigDigest { signers, _, _, _, offchainConfigVersion, offchainConfig := generateConfig(t, oracles) @@ -351,7 +343,6 @@ channelDefinitions = %q`, serverPubKey, channelDefinitions) _, err = verifierProxy.Verify(steve, signedReport, []byte{}) require.NoError(t, err) - }) } diff --git a/core/services/ocr2/plugins/llo/onchain_channel_definition_cache_integration_test.go b/core/services/ocr2/plugins/llo/onchain_channel_definition_cache_integration_test.go index d084e51531..b30ac538d5 100644 --- a/core/services/ocr2/plugins/llo/onchain_channel_definition_cache_integration_test.go +++ b/core/services/ocr2/plugins/llo/onchain_channel_definition_cache_integration_test.go @@ -80,7 +80,7 @@ func (m *MockReadCloser) Read(p []byte) (int, error) { func (m *MockReadCloser) Close() error { m.mu.Lock() defer m.mu.Unlock() - m.reader.Seek(0, io.SeekStart) + _, _ = m.reader.Seek(0, io.SeekStart) return nil } @@ -369,15 +369,19 @@ func Test_ChannelDefinitionCache_Integration(t *testing.T) { }) } +// nolint:unused type mockLogPoller struct { logpoller.LogPoller LatestBlockFn func(ctx context.Context) (int64, error) LogsWithSigsFn func(ctx context.Context, start, end int64, eventSigs []common.Hash, address common.Address) ([]logpoller.Log, error) } +// nolint:unused func (p *mockLogPoller) LogsWithSigs(ctx context.Context, start, end int64, eventSigs []common.Hash, address common.Address) ([]logpoller.Log, error) { return p.LogsWithSigsFn(ctx, start, end, eventSigs, address) } + +// nolint:unused func (p *mockLogPoller) LatestBlock(ctx context.Context) (logpoller.LogPollerBlock, error) { block, err := p.LatestBlockFn(ctx) return logpoller.LogPollerBlock{BlockNumber: block}, err diff --git a/core/services/relay/evm/mercury/verifier/verifier_test.go b/core/services/relay/evm/mercury/verifier/verifier_test.go index 4cc9dcc9bf..abe891b583 100644 --- a/core/services/relay/evm/mercury/verifier/verifier_test.go +++ b/core/services/relay/evm/mercury/verifier/verifier_test.go @@ -5,8 +5,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/test-go/testify/assert" - "github.com/test-go/testify/require" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury" ) diff --git a/core/services/versioning/orm_test.go b/core/services/versioning/orm_test.go index e2f05e3903..44c63f60d0 100644 --- a/core/services/versioning/orm_test.go +++ b/core/services/versioning/orm_test.go @@ -174,7 +174,6 @@ func TestORM_CheckVersion_CCIP(t *testing.T) { require.NoError(t, err) } }) - } }