Enable dupword linter & fix findings (#12271)

* Enable dupword linter & fix findings

* Correct an incorrect fix

* Add nolint comment

* Add another nolint comment

* Revert unintended change to bazel version

---------

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
Justin Traglia 2023-04-18 17:01:27 -05:00 committed by GitHub
parent b6181f8d1a
commit 4c916403e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 43 additions and 33 deletions

View File

@ -17,6 +17,7 @@ linters:
- errcheck
- gosimple
- gocognit
- dupword
- nilerr
- whitespace
- misspell

View File

@ -126,7 +126,7 @@ type WeakSubjectivityData struct {
}
// CheckpointString returns the standard string representation of a Checkpoint.
// The format is a a hex-encoded block root, followed by the epoch of the block, separated by a colon. For example:
// The format is a hex-encoded block root, followed by the epoch of the block, separated by a colon. For example:
// "0x1c35540cac127315fabb6bf29181f2ae0de1a3fc909d2e76ba771e61312cc49a:74888"
func (wsd *WeakSubjectivityData) CheckpointString() string {
return fmt.Sprintf("%#x:%d", wsd.BlockRoot, wsd.Epoch)

View File

@ -14,7 +14,7 @@ type WorkerResults struct {
// Scatter scatters a computation across multiple goroutines.
// This breaks the task in to a number of chunks and executes those chunks in parallel with the function provided.
// Results returned are collected and presented a a set of WorkerResults, which can be reassembled by the calling function.
// Results returned are collected and presented as a set of WorkerResults, which can be reassembled by the calling function.
// Any error that occurs in the workers will be passed back to the calling function.
func Scatter(inputLen int, sFunc func(int, int, *sync.RWMutex) (interface{}, error)) ([]*WorkerResults, error) {
if inputLen <= 0 {

View File

@ -64,7 +64,7 @@ func (s *Service) verifyBlkPreState(ctx context.Context, b interfaces.ReadOnlyBe
parentRoot := b.ParentRoot()
// Loosen the check to HasBlock because state summary gets saved in batches
// during initial syncing. There's no risk given a state summary object is just a
// a subset of the block object.
// subset of the block object.
if !s.cfg.BeaconDB.HasStateSummary(ctx, parentRoot) && !s.cfg.BeaconDB.HasBlock(ctx, parentRoot) {
return errors.New("could not reconstruct parent state")
}

View File

@ -208,7 +208,7 @@ func ProcessEpochParticipation(
}
// ProcessRewardsAndPenaltiesPrecompute processes the rewards and penalties of individual validator.
// This is an optimized version by passing in precomputed validator attesting records and and total epoch balances.
// This is an optimized version by passing in precomputed validator attesting records and total epoch balances.
func ProcessRewardsAndPenaltiesPrecompute(
beaconState state.BeaconState,
bal *precompute.Balance,

View File

@ -12,6 +12,7 @@ import (
// ProcessSyncCommitteeUpdates processes sync client committee updates for the beacon state.
//
// nolint:dupword
// Spec code:
// def process_sync_committee_updates(state: BeaconState) -> None:
//
@ -45,6 +46,7 @@ func ProcessSyncCommitteeUpdates(ctx context.Context, beaconState state.BeaconSt
// ProcessParticipationFlagUpdates processes participation flag updates by rotating current to previous.
//
// nolint:dupword
// Spec code:
// def process_participation_flag_updates(state: BeaconState) -> None:
//

View File

@ -393,6 +393,7 @@ func ProcessHistoricalDataUpdate(state state.BeaconState) (state.BeaconState, er
// ProcessParticipationRecordUpdates rotates current/previous epoch attestations during epoch processing.
//
// nolint:dupword
// Spec pseudocode definition:
//
// def process_participation_record_updates(state: BeaconState) -> None:

View File

@ -14,7 +14,7 @@ type attesterRewardsFunc func(state.ReadOnlyBeaconState, *Balance, []*Validator)
type proposerRewardsFunc func(state.ReadOnlyBeaconState, *Balance, []*Validator) ([]uint64, error)
// ProcessRewardsAndPenaltiesPrecompute processes the rewards and penalties of individual validator.
// This is an optimized version by passing in precomputed validator attesting records and and total epoch balances.
// This is an optimized version by passing in precomputed validator attesting records and total epoch balances.
func ProcessRewardsAndPenaltiesPrecompute(
state state.BeaconState,
pBal *Balance,

View File

@ -285,6 +285,7 @@ func BeaconProposerIndex(ctx context.Context, state state.ReadOnlyBeaconState) (
// ComputeProposerIndex returns the index sampled by effective balance, which is used to calculate proposer.
//
// nolint:dupword
// Spec pseudocode definition:
//
// def compute_proposer_index(state: BeaconState, indices: Sequence[ValidatorIndex], seed: Bytes32) -> ValidatorIndex:

View File

@ -228,7 +228,7 @@ func (ns *Server) ListPeers(ctx context.Context, req *ethpb.PeersRequest) (*ethp
return &ethpb.PeersResponse{Data: filteredPeers}, nil
}
// PeerCount retrieves retrieves number of known peers.
// PeerCount retrieves number of known peers.
func (ns *Server) PeerCount(ctx context.Context, _ *emptypb.Empty) (*ethpb.PeerCountResponse, error) {
ctx, span := trace.StartSpan(ctx, "node.PeerCount")
defer span.End()

View File

@ -183,7 +183,7 @@ func (bs *Server) ListValidatorBalances(
}
// ListValidators retrieves the current list of active validators with an optional historical epoch flag to
// to retrieve validator set in time.
// retrieve validator set in time.
func (bs *Server) ListValidators(
ctx context.Context,
req *ethpb.ListValidatorsRequest,

View File

@ -34,7 +34,7 @@ var errParticipation = status.Errorf(codes.Internal, "Failed to obtain epoch par
// DEPOSITED - validator's deposit has been recognized by Ethereum 1, not yet recognized by Ethereum.
// PENDING - validator is in Ethereum's activation queue.
// ACTIVE - validator is active.
// EXITING - validator has initiated an an exit request, or has dropped below the ejection balance and is being kicked out.
// EXITING - validator has initiated an exit request, or has dropped below the ejection balance and is being kicked out.
// EXITED - validator is no longer validating.
// SLASHING - validator has been kicked out due to meeting a slashing condition.
// UNKNOWN_STATUS - validator does not have a known status in the network.

View File

@ -53,6 +53,8 @@ type Chunker interface {
// specified epoch and all attestation target epochs a validator has created
// where att.source.epoch > e.
//
// nolint:dupword
//
// Under ideal network conditions, where every target epoch immediately follows its source,
// min spans for a validator will look as follows:
//

View File

@ -1,3 +1,5 @@
// nolint:dupword
//
// Package slasher defines an optimized implementation of Ethereum proof-of-stake slashing
// detection, namely focused on catching "surround vote" slashable
// offenses as explained here: https://blog.ethereum.org/2020/01/13/validated-staking-on-eth2-1-incentives/.

View File

@ -44,7 +44,7 @@ func (b *BeaconState) setCurrentEpochAttestations(val []*ethpb.PendingAttestatio
}
// AppendCurrentEpochAttestations for the beacon state. Appends the new value
// to the the end of list.
// to the end of list.
func (b *BeaconState) AppendCurrentEpochAttestations(val *ethpb.PendingAttestation) error {
b.lock.Lock()
defer b.lock.Unlock()
@ -74,7 +74,7 @@ func (b *BeaconState) AppendCurrentEpochAttestations(val *ethpb.PendingAttestati
}
// AppendPreviousEpochAttestations for the beacon state. Appends the new value
// to the the end of list.
// to the end of list.
func (b *BeaconState) AppendPreviousEpochAttestations(val *ethpb.PendingAttestation) error {
b.lock.Lock()
defer b.lock.Unlock()

View File

@ -42,7 +42,7 @@ func (b *BeaconState) SetEth1DepositIndex(val uint64) error {
}
// AppendEth1DataVotes for the beacon state. Appends the new value
// to the the end of list.
// to the end of list.
func (b *BeaconState) AppendEth1DataVotes(val *ethpb.Eth1Data) error {
b.lock.Lock()
defer b.lock.Unlock()

View File

@ -45,7 +45,7 @@ func (b *BeaconState) SetCurrentParticipationBits(val []byte) error {
}
// AppendCurrentParticipationBits for the beacon state. Appends the new value
// to the the end of list.
// to the end of list.
func (b *BeaconState) AppendCurrentParticipationBits(val byte) error {
b.lock.Lock()
defer b.lock.Unlock()
@ -70,7 +70,7 @@ func (b *BeaconState) AppendCurrentParticipationBits(val byte) error {
}
// AppendPreviousParticipationBits for the beacon state. Appends the new value
// to the the end of list.
// to the end of list.
func (b *BeaconState) AppendPreviousParticipationBits(val byte) error {
b.lock.Lock()
defer b.lock.Unlock()

View File

@ -159,7 +159,7 @@ func (b *BeaconState) UpdateSlashingsAtIndex(idx, val uint64) error {
}
// AppendValidator for the beacon state. Appends the new value
// to the the end of list.
// to the end of list.
func (b *BeaconState) AppendValidator(val *ethpb.Validator) error {
b.lock.Lock()
defer b.lock.Unlock()
@ -183,7 +183,7 @@ func (b *BeaconState) AppendValidator(val *ethpb.Validator) error {
}
// AppendBalance for the beacon state. Appends the new value
// to the the end of list.
// to the end of list.
func (b *BeaconState) AppendBalance(bal uint64) error {
b.lock.Lock()
defer b.lock.Unlock()

View File

@ -37,7 +37,7 @@ func TestBeaconState_ProtoBeaconStateCompatibility(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, r1, r2, "Mismatched roots")
// We then write to the the state and compare hash tree roots again.
// We then write to the state and compare hash tree roots again.
balances := genesis.Balances
balances[0] = 3823
require.NoError(t, customState.SetBalances(balances))

View File

@ -65,13 +65,13 @@ func cliActionDownload(_ *cli.Context) error {
if err != nil {
return err
}
log.Printf("saved ssz-encoded block to to %s", blockPath)
log.Printf("saved ssz-encoded block to %s", blockPath)
statePath, err := od.SaveState(cwd)
if err != nil {
return err
}
log.Printf("saved ssz-encoded state to to %s", statePath)
log.Printf("saved ssz-encoded state to %s", statePath)
return nil
}

View File

@ -27,7 +27,7 @@ const (
// 1. Parse a path to the validator's datadir from the CLI context.
// 2. Open the validator database.
// 3. Call the function which actually exports the data from
// from the validator's db into an EIP standard slashing protection format
// the validator's db into an EIP standard slashing protection format
// 4. Format and save the JSON file to a user's specified output directory.
func exportSlashingProtectionJSON(cliCtx *cli.Context) error {
log.Info(

View File

@ -22,7 +22,7 @@ import (
// 2. Open the validator database.
// 3. Read the JSON file from user input.
// 4. Call the function which actually imports the data from
// from the standard slashing protection JSON file into our database.
// the standard slashing protection JSON file into our database.
func importSlashingProtectionJSON(cliCtx *cli.Context) error {
var err error
dataDir := cliCtx.String(cmd.DataDirFlag.Name)

View File

@ -34,7 +34,7 @@ func WrapFlags(flags []cli.Flag) []cli.Flag {
f = altsrc.NewPathFlag(t)
case *cli.Int64Flag:
// Int64Flag does not work. See https://github.com/prysmaticlabs/prysm/issues/6478
panic(fmt.Sprintf("unsupported flag type type %T", f))
panic(fmt.Sprintf("unsupported flag type %T", f))
case *cli.IntSliceFlag:
f = altsrc.NewIntSliceFlag(t)
default:

View File

@ -1,3 +1,4 @@
//nolint:dupword
/*
Package leakybucket implements a scalable leaky bucket algorithm.

View File

@ -1,5 +1,5 @@
// Package bls implements a go-wrapper around a library implementing the
// the BLS12-381 curve and signature scheme. This package exposes a public API for
// BLS12-381 curve and signature scheme. This package exposes a public API for
// verifying and aggregating BLS signatures used by Ethereum.
package bls

View File

@ -1,5 +1,5 @@
// Package blst implements a go-wrapper around a library implementing the
// the BLS12-381 curve and signature scheme. This package exposes a public API for
// BLS12-381 curve and signature scheme. This package exposes a public API for
// verifying and aggregating BLS signatures used by Ethereum.
//
// This implementation uses the library written by Supranational, blst.

View File

@ -6,9 +6,9 @@ import (
)
// Merkleize.go is mostly a directly copy of the same filename from
// https://github.com/protolambda/zssz/blob/master/merkle/merkleize.go.
// https://github.com/protolambda/zssz/blob/master/merkle/merkleize.go.
// The reason the method is copied instead of imported is due to us using a
// a custom hasher interface for a reduced memory footprint when using
// custom hasher interface for a reduced memory footprint when using
// 'Merkleize'.
const (

View File

@ -74,7 +74,7 @@ done
echo "Converting hex yaml keys to a format that Prysm understands"
# Expect YAML keys in hex encoded format. Convert this into the format the the validator already understands.
# Expect YAML keys in hex encoded format. Convert this into the format the validator already understands.
./convert-keys $YAML_KEY_FILE /tmp/keys.json
echo "Starting beacon chain and logging to $BEACON_LOG_FILE"

View File

@ -26,7 +26,7 @@ type Streamer interface {
LogsFeed() *event.Feed
}
// StreamServer defines a a websocket server which can receive events from
// StreamServer defines a websocket server which can receive events from
// a feed and write them to open websocket connections.
type StreamServer struct {
feed *event.Feed
@ -56,7 +56,7 @@ func (ss *StreamServer) GetLastFewLogs() [][]byte {
return messages
}
// LogsFeed returns a feed callers can subscribe to to receive logs via a channel.
// LogsFeed returns a feed callers can subscribe to receive logs via a channel.
func (ss *StreamServer) LogsFeed() *event.Feed {
return ss.feed
}

View File

@ -90,7 +90,7 @@ func (p *params) Logfile(rel ...string) string {
// Eth1RPCURL gives the full url to use to connect to the given eth1 client's RPC endpoint.
// The `index` param corresponds to the `index` field of the `eth1.Node` e2e component.
// These are are off by one compared to corresponding beacon nodes, because the miner is assigned index 0.
// These are off by one compared to corresponding beacon nodes, because the miner is assigned index 0.
// eg instance the index of the EL instance associated with beacon node index `0` would typically be `1`.
func (p *params) Eth1RPCURL(index int) *url.URL {
return &url.URL{

View File

@ -276,7 +276,7 @@ func namesForExcludeCheck(pass *analysis.Pass, call *ast.CallExpr) []string {
}
// This will be missing for functions without a receiver (like fmt.Printf),
// so just fall back to the the function's fullName in that case.
// so just fall back to the function's fullName in that case.
selection, ok := pass.TypesInfo.Selections[sel]
if !ok {
return []string{name}

View File

@ -16,7 +16,7 @@ const (
// DataDirDirPromptText for the validator database directory.
DataDirDirPromptText = "Enter the directory of the validator database you would like to use"
// SlashingProtectionJSONPromptText for the EIP-3076 slashing protection JSON userprompt.
SlashingProtectionJSONPromptText = "Enter the the filepath of your EIP-3076 Slashing Protection JSON from your previously used validator client"
SlashingProtectionJSONPromptText = "Enter the filepath of your EIP-3076 Slashing Protection JSON from your previously used validator client"
// WalletDirPromptText for the wallet.
WalletDirPromptText = "Enter a wallet directory"
// SelectAccountsDeletePromptText --

View File

@ -151,7 +151,7 @@ func (c *beaconApiValidatorClient) checkDoppelGanger(ctx context.Context, in *et
indexes[i] = index
}
// Get validators liveness for the the last epoch.
// Get validators liveness for the last epoch.
// We request a state 1 epoch ago. We are guaranteed to have currentEpoch > 2
// since we assume that we are not in phase0.
previousEpoch := currentEpoch - 1

View File

@ -449,7 +449,7 @@ func (s *Store) saveAttestationRecords(ctx context.Context, atts []*AttestationR
return errors.Wrap(err, "could not create signing roots bucket")
}
if err := signingRootsBucket.Put(targetEpochBytes, att.SigningRoot[:]); err != nil {
return errors.Wrapf(err, "could not save signing signing root for epoch %d", att.Target)
return errors.Wrapf(err, "could not save signing root for epoch %d", att.Target)
}
sourceEpochsBucket, err := pkBucket.CreateBucketIfNotExists(attestationSourceEpochsBucket)
if err != nil {