Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autofix golangci-lint issues #15769

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion common/client/transaction_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ func TestTransactionSender_SendTransaction(t *testing.T) {
_, txSender = newTestTransactionSender(t, chainID, logger.Test(t),
[]Node[types.ID, TestSendTxRPCClient]{fastNode, slowNode},
[]SendOnlyNode[types.ID, TestSendTxRPCClient]{slowSendOnly})

})
t.Run("Returns error if there is no healthy primary nodes", func(t *testing.T) {
chainID := types.RandomID()
Expand Down
1 change: 1 addition & 0 deletions core/capabilities/ccip/launcher/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package launcher

import (
"fmt"

mapset "github.com/deckarep/golang-set/v2"
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"golang.org/x/exp/maps"
Expand Down
1 change: 0 additions & 1 deletion core/capabilities/ccip/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ func (l *launcher) processRemoved(removed map[registrysyncer.DonID]registrysynce

if err := p.CloseAll(); err != nil {
return fmt.Errorf("failed to shutdown oracles for CCIP DON %d: %w", id, err)

}

// after a successful shutdown we can safely remove the DON deployment from the map.
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/client/simulated_backend_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func (c *SimulatedBackendClient) SubscribeToHeads(
}
head = &evmtypes.Head{
Difficulty: h.Difficulty,
Timestamp: time.Unix(int64(h.Time), 0), //nolint:gosec // G115 false positive
Timestamp: time.Unix(int64(h.Time), 0),
Number: h.Number.Int64(),
Hash: h.Hash(),
ParentHash: h.ParentHash,
Expand Down
3 changes: 2 additions & 1 deletion core/cmd/nodes_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"slices"
"strings"

"github.com/urfave/cli"

"github.com/smartcontractkit/chainlink/v2/core/services/relay"
"github.com/smartcontractkit/chainlink/v2/core/web/presenters"
"github.com/urfave/cli"
)

func initNodeSubCmds(s *Shell) []cli.Command {
Expand Down
2 changes: 1 addition & 1 deletion core/services/llo/mercurytransmitter/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (o *orm) Insert(ctx context.Context, transmissions []*Transmission) error {
DonID: o.donID,
ServerURL: t.ServerURL,
ConfigDigest: t.ConfigDigest,
SeqNr: int64(t.SeqNr), //nolint:gosec // G115 false positive
SeqNr: int64(t.SeqNr),
Report: t.Report.Report,
LifecycleStage: string(t.Report.Info.LifeCycleStage),
ReportFormat: uint32(t.Report.Info.ReportFormat),
Expand Down
1 change: 0 additions & 1 deletion core/services/llo/onchain_channel_definition_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ func (c *channelDefinitionCache) readLogs(ctx context.Context) (err error) {
c.newLogCh <- unpacked
}
c.newLogMu.Unlock()

}

return nil
Expand Down
6 changes: 3 additions & 3 deletions core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,9 @@ func (d *Delegate) newServicesGenericPlugin(
providerClientConn = providerConn.ClientConn()
} else {
// We chose to deal with the difference between a LOOP provider and an embedded provider here rather than
//in NewServerAdapter because this has a smaller blast radius, as the scope of this workaround is to
//enable the medianpoc for EVM and not touch the other providers.
//TODO: remove this workaround when the EVM relayer is running inside of an LOOPP
// in NewServerAdapter because this has a smaller blast radius, as the scope of this workaround is to
// enable the medianpoc for EVM and not touch the other providers.
// TODO: remove this workaround when the EVM relayer is running inside of an LOOPP
d.lggr.Info("provider is not a LOOPP provider, switching to provider server")

ps, err2 := loop.NewProviderServer(provider, types.OCR2PluginType(pCfg.ProviderType), d.lggr)
Expand Down
4 changes: 2 additions & 2 deletions core/services/ocr2/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ func validateGenericPluginSpec(ctx context.Context, spec *job.OCR2OracleSpec, rc

loopID := fmt.Sprintf("%s-%s-%s", p.PluginName, spec.ContractID, spec.GetID())
// Starting and stopping a LOOPP isn't efficient; ideally, we'd initiate the LOOPP once and then reference
//it later to conserve resources. This code will be revisited once BCF-3126 is implemented, and we have
//the ability to reference the LOOPP for future use.
// it later to conserve resources. This code will be revisited once BCF-3126 is implemented, and we have
// the ability to reference the LOOPP for future use.
cmdFn, grpcOpts, err := rc.RegisterLOOP(plugins.CmdConfig{
ID: loopID,
Cmd: command,
Expand Down
1 change: 0 additions & 1 deletion core/services/registrysyncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ func New(
registryAddress string,
orm ORM,
) (RegistrySyncer, error) {

metricLabeler, err := newSyncerMetricLabeler()
if err != nil {
return nil, fmt.Errorf("failed to create syncer metric labeler: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions core/services/relay/evm/commit_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (p *SrcCommitProvider) Start(ctx context.Context) error {
if p.startBlock > math.MaxInt64 {
return fmt.Errorf("start block overflows int64: %d", p.startBlock)
}
return p.lp.Replay(ctx, int64(p.startBlock)) //nolint:gosec // G115 false positive
return p.lp.Replay(ctx, int64(p.startBlock))
}
return nil
}
Expand All @@ -236,7 +236,7 @@ func (p *DstCommitProvider) Start(ctx context.Context) error {
if p.startBlock > math.MaxInt64 {
return fmt.Errorf("start block overflows int64: %d", p.startBlock)
}
return p.lp.Replay(ctx, int64(p.startBlock)) //nolint:gosec // G115 false positive
return p.lp.Replay(ctx, int64(p.startBlock))
}
return nil
}
Expand Down
1 change: 0 additions & 1 deletion core/services/relay/evm/mercury/transmitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ func (s *server) runQueueLoop(stopCh services.StopChan, wg *sync.WaitGroup, feed
const TransmitQueueMaxSize = 10_000 // hardcode this for legacy transmitter since we want the config var to apply only to LLO

func newServer(lggr logger.Logger, cfg TransmitterConfig, client wsrpc.Client, pm *PersistenceManager, serverURL, feedIDHex string) *server {

return &server{
logger.Sugared(lggr),
cfg.TransmitTimeout().Duration(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,6 @@ func TestVRFV08_CompareFieldHash(t *testing.T) {
}
}

// randomKey deterministically generates a secp256k1 key.
//
// Never use this if cryptographic security is required
//func randomKey(t *testing.T, r *mrand.Rand) *ecdsa.PrivateKey {
// secretKey := vrfkey.FieldSize
// for secretKey.Cmp(vrfkey.FieldSize) >= 0 { // Keep picking until secretKey < fieldSize
// secretKey = randomUint256(t, r)
// }
// cKey := crypto.ToECDSAUnsafe(secretKey.Bytes())
// return cKey
//}
//
// pair returns the inputs as a length-2 big.Int array. Useful for translating
// coordinates to the uint256[2]'s VRF.sol uses to represent secp256k1 points.
//func pair(x, y *big.Int) [2]*big.Int { return [2]*big.Int{x, y} }
//func asPair(p kyber.Point) [2]*big.Int { return pair(secp256k1.Coordinates(p)) }

func TestVRFV08_CompareHashToCurve(t *testing.T) {
t.Parallel()
r := mrand.New(mrand.NewSource(4))
Expand All @@ -173,40 +156,6 @@ func TestVRFV08_CompareHashToCurve(t *testing.T) {
}
}

// randomPoint deterministically simulates a uniform sample of secp256k1 points,
// given r's seed
//
// Never use this if cryptographic security is required
//func randomPoint(t *testing.T, r *mrand.Rand) kyber.Point {
// p, err := vrfkey.HashToCurve(vrfkey.Generator, randomUint256(t, r), func(*big.Int) {})
// require.NoError(t, err,
// "failed to hash random value to secp256k1 while generating random point")
// if r.Int63n(2) == 1 { // Uniform sample of ±p
// p.Neg(p)
// }
// return p
//}
//
//// randomPointWithPair returns a random secp256k1, both as a kyber.Point and as
//// a pair of *big.Int's. Useful for translating between the types needed by the
//// golang contract wrappers.
//func randomPointWithPair(t *testing.T, r *mrand.Rand) (kyber.Point, [2]*big.Int) {
// p := randomPoint(t, r)
// return p, asPair(p)
//}

// randomScalar deterministically simulates a uniform sample of secp256k1
// scalars, given r's seed
//
// Never use this if cryptographic security is required
//func randomScalar(t *testing.T, r *mrand.Rand) kyber.Scalar {
// s := randomUint256(t, r)
// for s.Cmp(secp256k1.GroupOrder) >= 0 {
// s = randomUint256(t, r)
// }
// return secp256k1.IntToScalar(s)
//}

func TestVRFV08_CheckSolidityPointAddition(t *testing.T) {
t.Parallel()
r := mrand.New(mrand.NewSource(5))
Expand Down
1 change: 0 additions & 1 deletion core/store/migrate/migrations/0036_external_job_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func Up36(ctx context.Context, tx *sql.Tx) error {
stmt += ` AS vals(external_job_id, id) WHERE vals.id = j.id`
if _, err := tx.ExecContext(ctx, stmt); err != nil {
return err

}
}

Expand Down
Loading