From 236a5c4167b7d4b2429536b64ae2b6a20dc59ffe Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Thu, 2 Dec 2021 02:56:07 +0800 Subject: [PATCH] Cleanup From Deepsource (#9961) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ds cleanup * fix Co-authored-by: RadosÅ‚aw Kapka Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- .../core/blocks/block_operations_fuzz_test.go | 10 +++--- .../core/helpers/rewards_penalties.go | 2 +- beacon-chain/db/slasherkv/pruning.go | 4 +-- beacon-chain/db/slasherkv/slasher.go | 2 +- beacon-chain/operations/slashings/mock.go | 4 +-- .../p2p/gossip_scoring_params_test.go | 2 +- .../rpc/prysm/v1alpha1/beacon/blocks.go | 32 +++++++++---------- beacon-chain/slasher/mock_slashing_checker.go | 4 +-- beacon-chain/state/v1/unsupported_setters.go | 6 ++-- beacon-chain/state/v2/deprecated_setters.go | 6 ++-- beacon-chain/state/v3/deprecated_setters.go | 6 ++-- beacon-chain/state/v3/state_trie.go | 4 +-- .../sync/initial-sync/blocks_fetcher_test.go | 10 +++--- tools/deployContract/deployContract.go | 3 +- validator/keymanager/imported/import.go | 6 ++-- validator/rpc/wallet.go | 2 +- .../slashing-protection-history/import.go | 4 +-- validator/testing/mock_slasher.go | 2 +- 18 files changed, 52 insertions(+), 57 deletions(-) diff --git a/beacon-chain/core/blocks/block_operations_fuzz_test.go b/beacon-chain/core/blocks/block_operations_fuzz_test.go index 6e18710e44..e2b76fbe21 100644 --- a/beacon-chain/core/blocks/block_operations_fuzz_test.go +++ b/beacon-chain/core/blocks/block_operations_fuzz_test.go @@ -47,7 +47,7 @@ func TestFuzzProcessBlockHeader_10000(t *testing.T) { } } -func TestFuzzverifyDepositDataSigningRoot_10000(t *testing.T) { +func TestFuzzverifyDepositDataSigningRoot_10000(_ *testing.T) { fuzzer := fuzz.NewWithSeed(0) var ba []byte pubkey := [48]byte{} @@ -85,7 +85,7 @@ func TestFuzzProcessEth1DataInBlock_10000(t *testing.T) { } } -func TestFuzzareEth1DataEqual_10000(t *testing.T) { +func TestFuzzareEth1DataEqual_10000(_ *testing.T) { fuzzer := fuzz.NewWithSeed(0) eth1data := ð.Eth1Data{} eth1data2 := ð.Eth1Data{} @@ -227,7 +227,7 @@ func TestFuzzVerifyAttesterSlashing_10000(t *testing.T) { } } -func TestFuzzIsSlashableAttestationData_10000(t *testing.T) { +func TestFuzzIsSlashableAttestationData_10000(_ *testing.T) { fuzzer := fuzz.NewWithSeed(0) attestationData := ð.AttestationData{} attestationData2 := ð.AttestationData{} @@ -239,7 +239,7 @@ func TestFuzzIsSlashableAttestationData_10000(t *testing.T) { } } -func TestFuzzslashableAttesterIndices_10000(t *testing.T) { +func TestFuzzslashableAttesterIndices_10000(_ *testing.T) { fuzzer := fuzz.NewWithSeed(0) attesterSlashing := ð.AttesterSlashing{} @@ -397,7 +397,7 @@ func TestFuzzProcessVoluntaryExitsNoVerify_10000(t *testing.T) { } } -func TestFuzzVerifyExit_10000(t *testing.T) { +func TestFuzzVerifyExit_10000(_ *testing.T) { fuzzer := fuzz.NewWithSeed(0) ve := ð.SignedVoluntaryExit{} rawVal := ðpb.Validator{} diff --git a/beacon-chain/core/helpers/rewards_penalties.go b/beacon-chain/core/helpers/rewards_penalties.go index d7b9b2afd0..2c169dddd4 100644 --- a/beacon-chain/core/helpers/rewards_penalties.go +++ b/beacon-chain/core/helpers/rewards_penalties.go @@ -59,7 +59,7 @@ func TotalActiveBalance(s state.ReadOnlyBeaconState) (uint64, error) { case err == nil: return bal, nil case errors.Is(err, cache.ErrNotFound): - break + // Do nothing if we receive a not found error. default: // In the event, we encounter another error we return it. return 0, err diff --git a/beacon-chain/db/slasherkv/pruning.go b/beacon-chain/db/slasherkv/pruning.go index 27cf1eca6e..1a6be7ffcc 100644 --- a/beacon-chain/db/slasherkv/pruning.go +++ b/beacon-chain/db/slasherkv/pruning.go @@ -14,7 +14,7 @@ import ( // PruneAttestationsAtEpoch deletes all attestations from the slasher DB with target epoch // less than or equal to the specified epoch. func (s *Store) PruneAttestationsAtEpoch( - ctx context.Context, maxEpoch types.Epoch, + _ context.Context, maxEpoch types.Epoch, ) (numPruned uint, err error) { // We can prune everything less than the current epoch - history length. encodedEndPruneEpoch := fssz.MarshalUint64([]byte{}, uint64(maxEpoch)) @@ -85,7 +85,7 @@ func (s *Store) PruneAttestationsAtEpoch( // PruneProposalsAtEpoch deletes all proposals from the slasher DB with epoch // less than or equal to the specified epoch. func (s *Store) PruneProposalsAtEpoch( - ctx context.Context, maxEpoch types.Epoch, + _ context.Context, maxEpoch types.Epoch, ) (numPruned uint, err error) { var endPruneSlot types.Slot endPruneSlot, err = slots.EpochEnd(maxEpoch) diff --git a/beacon-chain/db/slasherkv/slasher.go b/beacon-chain/db/slasherkv/slasher.go index b380086b73..5a48823dc5 100644 --- a/beacon-chain/db/slasherkv/slasher.go +++ b/beacon-chain/db/slasherkv/slasher.go @@ -394,7 +394,7 @@ func (s *Store) SaveBlockProposals( // HighestAttestations retrieves the last attestation data from the database for all indices. func (s *Store) HighestAttestations( - ctx context.Context, + _ context.Context, indices []types.ValidatorIndex, ) ([]*slashpb.HighestAttestation, error) { if len(indices) == 0 { diff --git a/beacon-chain/operations/slashings/mock.go b/beacon-chain/operations/slashings/mock.go index 47046ce83a..b5042e2c11 100644 --- a/beacon-chain/operations/slashings/mock.go +++ b/beacon-chain/operations/slashings/mock.go @@ -36,11 +36,11 @@ func (m *PoolMock) InsertProposerSlashing(_ context.Context, _ state.ReadOnlyBea } // MarkIncludedAttesterSlashing -- -func (_ *PoolMock) MarkIncludedAttesterSlashing(_ *ethpb.AttesterSlashing) { +func (*PoolMock) MarkIncludedAttesterSlashing(_ *ethpb.AttesterSlashing) { panic("implement me") } // MarkIncludedProposerSlashing -- -func (_ *PoolMock) MarkIncludedProposerSlashing(_ *ethpb.ProposerSlashing) { +func (*PoolMock) MarkIncludedProposerSlashing(_ *ethpb.ProposerSlashing) { panic("implement me") } diff --git a/beacon-chain/p2p/gossip_scoring_params_test.go b/beacon-chain/p2p/gossip_scoring_params_test.go index e8ac1a721f..c66824198f 100644 --- a/beacon-chain/p2p/gossip_scoring_params_test.go +++ b/beacon-chain/p2p/gossip_scoring_params_test.go @@ -63,7 +63,7 @@ func TestCorrect_ActiveValidatorsCount(t *testing.T) { assert.Equal(t, int(params.BeaconConfig().MinGenesisActiveValidatorCount)+100, int(vals), "mainnet genesis active count isn't accurate") } -func TestLoggingParameters(t *testing.T) { +func TestLoggingParameters(_ *testing.T) { logGossipParameters("testing", nil) logGossipParameters("testing", &pubsub.TopicScoreParams{}) // Test out actual gossip parameters. diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks.go index 78356e86ae..81cbc271c3 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/blocks.go @@ -48,7 +48,7 @@ func (bs *Server) ListBlocks( switch q := req.QueryFilter.(type) { case *ethpb.ListBlocksRequest_Epoch: - ctrs, numBlks, nextPageToken, err := bs.ListBlocksForEpoch(ctx, req, q) + ctrs, numBlks, nextPageToken, err := bs.listBlocksForEpoch(ctx, req, q) if err != nil { return nil, err } @@ -63,7 +63,7 @@ func (bs *Server) ListBlocks( NextPageToken: nextPageToken, }, nil case *ethpb.ListBlocksRequest_Root: - ctrs, numBlks, nextPageToken, err := bs.ListBlocksForRoot(ctx, req, q) + ctrs, numBlks, nextPageToken, err := bs.listBlocksForRoot(ctx, req, q) if err != nil { return nil, err } @@ -79,7 +79,7 @@ func (bs *Server) ListBlocks( }, nil case *ethpb.ListBlocksRequest_Slot: - ctrs, numBlks, nextPageToken, err := bs.ListBlocksForSlot(ctx, req, q) + ctrs, numBlks, nextPageToken, err := bs.listBlocksForSlot(ctx, req, q) if err != nil { return nil, err } @@ -94,7 +94,7 @@ func (bs *Server) ListBlocks( NextPageToken: nextPageToken, }, nil case *ethpb.ListBlocksRequest_Genesis: - ctrs, numBlks, nextPageToken, err := bs.ListBlocksForGenesis(ctx, req, q) + ctrs, numBlks, nextPageToken, err := bs.listBlocksForGenesis(ctx, req, q) if err != nil { return nil, err } @@ -128,7 +128,7 @@ func (bs *Server) ListBeaconBlocks( switch q := req.QueryFilter.(type) { case *ethpb.ListBlocksRequest_Epoch: - ctrs, numBlks, nextPageToken, err := bs.ListBlocksForEpoch(ctx, req, q) + ctrs, numBlks, nextPageToken, err := bs.listBlocksForEpoch(ctx, req, q) if err != nil { return nil, err } @@ -142,7 +142,7 @@ func (bs *Server) ListBeaconBlocks( NextPageToken: nextPageToken, }, nil case *ethpb.ListBlocksRequest_Root: - ctrs, numBlks, nextPageToken, err := bs.ListBlocksForRoot(ctx, req, q) + ctrs, numBlks, nextPageToken, err := bs.listBlocksForRoot(ctx, req, q) if err != nil { return nil, err } @@ -157,7 +157,7 @@ func (bs *Server) ListBeaconBlocks( }, nil case *ethpb.ListBlocksRequest_Slot: - ctrs, numBlks, nextPageToken, err := bs.ListBlocksForSlot(ctx, req, q) + ctrs, numBlks, nextPageToken, err := bs.listBlocksForSlot(ctx, req, q) if err != nil { return nil, err } @@ -171,7 +171,7 @@ func (bs *Server) ListBeaconBlocks( NextPageToken: nextPageToken, }, nil case *ethpb.ListBlocksRequest_Genesis: - ctrs, numBlks, nextPageToken, err := bs.ListBlocksForGenesis(ctx, req, q) + ctrs, numBlks, nextPageToken, err := bs.listBlocksForGenesis(ctx, req, q) if err != nil { return nil, err } @@ -224,8 +224,8 @@ func convertToBlockContainer(blk block.SignedBeaconBlock, root [32]byte, isCanon return ctr, nil } -// ListBlocksForEpoch retrieves all blocks for the provided epoch. -func (bs *Server) ListBlocksForEpoch(ctx context.Context, req *ethpb.ListBlocksRequest, q *ethpb.ListBlocksRequest_Epoch) ([]blockContainer, int, string, error) { +// listBlocksForEpoch retrieves all blocks for the provided epoch. +func (bs *Server) listBlocksForEpoch(ctx context.Context, req *ethpb.ListBlocksRequest, q *ethpb.ListBlocksRequest_Epoch) ([]blockContainer, int, string, error) { blks, _, err := bs.BeaconDB.Blocks(ctx, filters.NewFilter().SetStartEpoch(q.Epoch).SetEndEpoch(q.Epoch)) if err != nil { return nil, 0, strconv.Itoa(0), status.Errorf(codes.Internal, "Could not get blocks: %v", err) @@ -262,8 +262,8 @@ func (bs *Server) ListBlocksForEpoch(ctx context.Context, req *ethpb.ListBlocksR return containers, numBlks, nextPageToken, nil } -// ListBlocksForRoot retrieves the block for the provided root. -func (bs *Server) ListBlocksForRoot(ctx context.Context, _ *ethpb.ListBlocksRequest, q *ethpb.ListBlocksRequest_Root) ([]blockContainer, int, string, error) { +// listBlocksForRoot retrieves the block for the provided root. +func (bs *Server) listBlocksForRoot(ctx context.Context, _ *ethpb.ListBlocksRequest, q *ethpb.ListBlocksRequest_Root) ([]blockContainer, int, string, error) { blk, err := bs.BeaconDB.Block(ctx, bytesutil.ToBytes32(q.Root)) if err != nil { return nil, 0, strconv.Itoa(0), status.Errorf(codes.Internal, "Could not retrieve block: %v", err) @@ -286,8 +286,8 @@ func (bs *Server) ListBlocksForRoot(ctx context.Context, _ *ethpb.ListBlocksRequ }}, 1, strconv.Itoa(0), nil } -// ListBlocksForSlot retrieves all blocks for the provided slot. -func (bs *Server) ListBlocksForSlot(ctx context.Context, req *ethpb.ListBlocksRequest, q *ethpb.ListBlocksRequest_Slot) ([]blockContainer, int, string, error) { +// listBlocksForSlot retrieves all blocks for the provided slot. +func (bs *Server) listBlocksForSlot(ctx context.Context, req *ethpb.ListBlocksRequest, q *ethpb.ListBlocksRequest_Slot) ([]blockContainer, int, string, error) { hasBlocks, blks, err := bs.BeaconDB.BlocksBySlot(ctx, q.Slot) if err != nil { return nil, 0, strconv.Itoa(0), status.Errorf(codes.Internal, "Could not retrieve blocks for slot %d: %v", q.Slot, err) @@ -323,8 +323,8 @@ func (bs *Server) ListBlocksForSlot(ctx context.Context, req *ethpb.ListBlocksRe return containers, numBlks, nextPageToken, nil } -// ListBlocksForGenesis retrieves the genesis block. -func (bs *Server) ListBlocksForGenesis(ctx context.Context, _ *ethpb.ListBlocksRequest, _ *ethpb.ListBlocksRequest_Genesis) ([]blockContainer, int, string, error) { +// listBlocksForGenesis retrieves the genesis block. +func (bs *Server) listBlocksForGenesis(ctx context.Context, _ *ethpb.ListBlocksRequest, _ *ethpb.ListBlocksRequest_Genesis) ([]blockContainer, int, string, error) { genBlk, err := bs.BeaconDB.GenesisBlock(ctx) if err != nil { return nil, 0, strconv.Itoa(0), status.Errorf(codes.Internal, "Could not retrieve blocks for genesis slot: %v", err) diff --git a/beacon-chain/slasher/mock_slashing_checker.go b/beacon-chain/slasher/mock_slashing_checker.go index 43efdcab35..cbec22ae40 100644 --- a/beacon-chain/slasher/mock_slashing_checker.go +++ b/beacon-chain/slasher/mock_slashing_checker.go @@ -28,7 +28,7 @@ func (s *MockSlashingChecker) HighestAttestations( return atts, nil } -func (s *MockSlashingChecker) IsSlashableBlock(ctx context.Context, proposal *ethpb.SignedBeaconBlockHeader) (*ethpb.ProposerSlashing, error) { +func (s *MockSlashingChecker) IsSlashableBlock(_ context.Context, _ *ethpb.SignedBeaconBlockHeader) (*ethpb.ProposerSlashing, error) { if s.ProposerSlashingFound { return ðpb.ProposerSlashing{ Header_1: ðpb.SignedBeaconBlockHeader{ @@ -56,7 +56,7 @@ func (s *MockSlashingChecker) IsSlashableBlock(ctx context.Context, proposal *et return nil, nil } -func (s *MockSlashingChecker) IsSlashableAttestation(ctx context.Context, attestation *ethpb.IndexedAttestation) ([]*ethpb.AttesterSlashing, error) { +func (s *MockSlashingChecker) IsSlashableAttestation(_ context.Context, _ *ethpb.IndexedAttestation) ([]*ethpb.AttesterSlashing, error) { if s.AttesterSlashingFound { return []*ethpb.AttesterSlashing{ { diff --git a/beacon-chain/state/v1/unsupported_setters.go b/beacon-chain/state/v1/unsupported_setters.go index c4e3b4a63d..40cfeeab6a 100644 --- a/beacon-chain/state/v1/unsupported_setters.go +++ b/beacon-chain/state/v1/unsupported_setters.go @@ -6,17 +6,17 @@ import ( ) // AppendCurrentParticipationBits is not supported for phase 0 beacon state. -func (b *BeaconState) AppendCurrentParticipationBits(val byte) error { +func (*BeaconState) AppendCurrentParticipationBits(_ byte) error { return errors.New("AppendCurrentParticipationBits is not supported for phase 0 beacon state") } // AppendPreviousParticipationBits is not supported for phase 0 beacon state. -func (b *BeaconState) AppendPreviousParticipationBits(val byte) error { +func (*BeaconState) AppendPreviousParticipationBits(_ byte) error { return errors.New("AppendPreviousParticipationBits is not supported for phase 0 beacon state") } // AppendInactivityScore is not supported for phase 0 beacon state. -func (b *BeaconState) AppendInactivityScore(s uint64) error { +func (*BeaconState) AppendInactivityScore(_ uint64) error { return errors.New("AppendInactivityScore is not supported for phase 0 beacon state") } diff --git a/beacon-chain/state/v2/deprecated_setters.go b/beacon-chain/state/v2/deprecated_setters.go index 7125a7cd2c..69dfce48d0 100644 --- a/beacon-chain/state/v2/deprecated_setters.go +++ b/beacon-chain/state/v2/deprecated_setters.go @@ -6,17 +6,17 @@ import ( ) // SetPreviousEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) SetPreviousEpochAttestations(val []*ethpb.PendingAttestation) error { +func (b *BeaconState) SetPreviousEpochAttestations(_ []*ethpb.PendingAttestation) error { return errors.New("SetPreviousEpochAttestations is not supported for hard fork 1 beacon state") } // SetCurrentEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) SetCurrentEpochAttestations(val []*ethpb.PendingAttestation) error { +func (b *BeaconState) SetCurrentEpochAttestations(_ []*ethpb.PendingAttestation) error { return errors.New("SetCurrentEpochAttestations is not supported for hard fork 1 beacon state") } // AppendCurrentEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) AppendCurrentEpochAttestations(val *ethpb.PendingAttestation) error { +func (b *BeaconState) AppendCurrentEpochAttestations(_ *ethpb.PendingAttestation) error { return errors.New("AppendCurrentEpochAttestations is not supported for hard fork 1 beacon state") } diff --git a/beacon-chain/state/v3/deprecated_setters.go b/beacon-chain/state/v3/deprecated_setters.go index e99b23993d..e4d9a24b1c 100644 --- a/beacon-chain/state/v3/deprecated_setters.go +++ b/beacon-chain/state/v3/deprecated_setters.go @@ -6,17 +6,17 @@ import ( ) // SetPreviousEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) SetPreviousEpochAttestations(val []*ethpb.PendingAttestation) error { +func (*BeaconState) SetPreviousEpochAttestations(_ []*ethpb.PendingAttestation) error { return errors.New("SetPreviousEpochAttestations is not supported for version Merge beacon state") } // SetCurrentEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) SetCurrentEpochAttestations(val []*ethpb.PendingAttestation) error { +func (*BeaconState) SetCurrentEpochAttestations(_ []*ethpb.PendingAttestation) error { return errors.New("SetCurrentEpochAttestations is not supported for version Merge beacon state") } // AppendCurrentEpochAttestations is not supported for HF1 beacon state. -func (b *BeaconState) AppendCurrentEpochAttestations(val *ethpb.PendingAttestation) error { +func (*BeaconState) AppendCurrentEpochAttestations(_ *ethpb.PendingAttestation) error { return errors.New("AppendCurrentEpochAttestations is not supported for version Merge beacon state") } diff --git a/beacon-chain/state/v3/state_trie.go b/beacon-chain/state/v3/state_trie.go index c34571f85f..08604d74cc 100644 --- a/beacon-chain/state/v3/state_trie.go +++ b/beacon-chain/state/v3/state_trie.go @@ -219,7 +219,7 @@ func (b *BeaconState) HashTreeRoot(ctx context.Context) ([32]byte, error) { } for field := range b.dirtyFields { - root, err := b.rootSelector(ctx, field) + root, err := b.rootSelector(field) if err != nil { return [32]byte{}, err } @@ -256,7 +256,7 @@ func (b *BeaconState) IsNil() bool { return b == nil || b.state == nil } -func (b *BeaconState) rootSelector(ctx context.Context, field types.FieldIndex) ([32]byte, error) { +func (b *BeaconState) rootSelector(field types.FieldIndex) ([32]byte, error) { hasher := hash.CustomSHA256Hasher() switch field { case genesisTime: diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_test.go b/beacon-chain/sync/initial-sync/blocks_fetcher_test.go index 896d41372e..ed382b5869 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_test.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_test.go @@ -717,10 +717,9 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) blk.Block.Slot = req.StartSlot - 1 assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) break - } else { - blk.Block.Slot = i - assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) } + blk.Block.Slot = i + assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) } } }, @@ -749,10 +748,9 @@ func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) blk.Block.Slot = req.StartSlot.Add(req.Count * req.Step) assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) break - } else { - blk.Block.Slot = i - assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) } + blk.Block.Slot = i + assert.NoError(t, beaconsync.WriteBlockChunk(stream, chain, p1.Encoding(), wrapper.WrappedPhase0SignedBeaconBlock(blk))) } } }, diff --git a/tools/deployContract/deployContract.go b/tools/deployContract/deployContract.go index f86733a2d5..05bfc1e950 100644 --- a/tools/deployContract/deployContract.go +++ b/tools/deployContract/deployContract.go @@ -174,9 +174,8 @@ func main() { if k8sConfigMapName != "" { if err := updateKubernetesConfigMap(context.Background(), addr.Hex()); err != nil { log.Fatalf("Failed to update kubernetes config map: %v", err) - } else { - log.Printf("Updated config map %s", k8sConfigMapName) } + log.Printf("Updated config map %s", k8sConfigMapName) } return nil } diff --git a/validator/keymanager/imported/import.go b/validator/keymanager/imported/import.go index 9a78ebdd7d..45f88b6584 100644 --- a/validator/keymanager/imported/import.go +++ b/validator/keymanager/imported/import.go @@ -28,10 +28,8 @@ func (km *Keymanager) ImportKeystores( return nil, errors.New("no passwords provided for keystores") } else if len(passwords) == 1 { singlePasswordForAll = passwords[0] - } else { - if len(passwords) != len(keystores) { - return nil, errors.New("number of passwords does not match number of keystores") - } + } else if len(passwords) != len(keystores) { + return nil, errors.New("number of passwords does not match number of keystores") } decryptor := keystorev4.New() diff --git a/validator/rpc/wallet.go b/validator/rpc/wallet.go index 043a3c3203..b978b242ab 100644 --- a/validator/rpc/wallet.go +++ b/validator/rpc/wallet.go @@ -216,7 +216,7 @@ func (s *Server) RecoverWallet(ctx context.Context, req *pb.RecoverWalletRequest // we return an empty response with no error. If the password is incorrect for a single keystore, // we return an appropriate error. func (s *Server) ValidateKeystores( - ctx context.Context, req *pb.ValidateKeystoresRequest, + _ context.Context, req *pb.ValidateKeystoresRequest, ) (*emptypb.Empty, error) { if req.KeystoresPassword == "" { return nil, status.Error(codes.InvalidArgument, "Password required for keystores") diff --git a/validator/slashing-protection-history/import.go b/validator/slashing-protection-history/import.go index 8caa0f01a0..94e4764f4a 100644 --- a/validator/slashing-protection-history/import.go +++ b/validator/slashing-protection-history/import.go @@ -235,7 +235,7 @@ func parseAttestationsForUniquePublicKeys(data []*format.ProtectionData) (map[[4 return signedAttestationsByPubKey, nil } -func filterSlashablePubKeysFromBlocks(ctx context.Context, historyByPubKey map[[48]byte]kv.ProposalHistoryForPubkey) [][48]byte { +func filterSlashablePubKeysFromBlocks(_ context.Context, historyByPubKey map[[48]byte]kv.ProposalHistoryForPubkey) [][48]byte { // Given signing roots are optional in the EIP standard, we behave as follows: // For a given block: // If we have a previous block with the same slot in our history: @@ -311,7 +311,7 @@ func filterSlashablePubKeysFromAttestations( return slashablePubKeys, nil } -func transformSignedBlocks(ctx context.Context, signedBlocks []*format.SignedBlock) (*kv.ProposalHistoryForPubkey, error) { +func transformSignedBlocks(_ context.Context, signedBlocks []*format.SignedBlock) (*kv.ProposalHistoryForPubkey, error) { proposals := make([]kv.Proposal, len(signedBlocks)) for i, proposal := range signedBlocks { slot, err := SlotFromString(proposal.Slot) diff --git a/validator/testing/mock_slasher.go b/validator/testing/mock_slasher.go index 7944976508..f421afe6cc 100644 --- a/validator/testing/mock_slasher.go +++ b/validator/testing/mock_slasher.go @@ -18,7 +18,7 @@ type MockSlasher struct { } // HighestAttestations will return an empty array of attestations. -func (_ MockSlasher) HighestAttestations(ctx context.Context, req *eth.HighestAttestationRequest, _ ...grpc.CallOption) (*eth.HighestAttestationResponse, error) { +func (MockSlasher) HighestAttestations(ctx context.Context, req *eth.HighestAttestationRequest, _ ...grpc.CallOption) (*eth.HighestAttestationResponse, error) { return ð.HighestAttestationResponse{ Attestations: nil, }, nil