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

Enable dupword linter & fix findings #12271

Merged
merged 10 commits into from
Apr 18, 2023
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ linters:
- errcheck
- gosimple
- gocognit
- dupword
- nilerr
- whitespace
- misspell
Expand Down
2 changes: 1 addition & 1 deletion api/client/beacon/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion async/scatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/blockchain/process_block_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/core/altair/epoch_precompute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions beacon-chain/core/altair/epoch_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand Down Expand Up @@ -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:
//
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/core/epoch/epoch_processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/core/epoch/precompute/reward_penalty.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/core/helpers/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/rpc/eth/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/rpc/prysm/v1alpha1/beacon/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/rpc/prysm/v1alpha1/validator/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions beacon-chain/slasher/chunks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand Down
2 changes: 2 additions & 0 deletions beacon-chain/slasher/doc.go
Original file line number Diff line number Diff line change
@@ -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/.
Expand Down
4 changes: 2 additions & 2 deletions beacon-chain/state/state-native/setters_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/state/state-native/setters_eth1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions beacon-chain/state/state-native/setters_participation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions beacon-chain/state/state-native/setters_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/state/state-native/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions cmd/prysmctl/checkpointsync/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion cmd/validator/slashing-protection/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion cmd/validator/slashing-protection/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/wrap_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions container/leaky-bucket/leakybucket.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:dupword
/*
Package leakybucket implements a scalable leaky bucket algorithm.

Expand Down
2 changes: 1 addition & 1 deletion crypto/bls/bls.go
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion crypto/bls/blst/doc.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions encoding/ssz/merkleize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion hack/interop_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions io/logs/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion testing/endtoend/params/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion tools/analyzers/errcheck/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion validator/accounts/userprompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
Expand Down
2 changes: 1 addition & 1 deletion validator/client/beacon-api/doppelganger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion validator/db/kv/attester_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down