diff --git a/.golangci.yml b/.golangci.yml index bc720ccf4..648673954 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -17,6 +17,7 @@ linters: - errcheck - gosimple - gocognit + - dupword - nilerr - whitespace - misspell diff --git a/api/client/beacon/checkpoint.go b/api/client/beacon/checkpoint.go index 9182da7e0..38958e8e7 100644 --- a/api/client/beacon/checkpoint.go +++ b/api/client/beacon/checkpoint.go @@ -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) diff --git a/async/scatter.go b/async/scatter.go index faafcb72d..09b8d9d1c 100644 --- a/async/scatter.go +++ b/async/scatter.go @@ -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 { diff --git a/beacon-chain/blockchain/process_block_helpers.go b/beacon-chain/blockchain/process_block_helpers.go index 1f5d24e6a..042fe72bd 100644 --- a/beacon-chain/blockchain/process_block_helpers.go +++ b/beacon-chain/blockchain/process_block_helpers.go @@ -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") } diff --git a/beacon-chain/core/altair/epoch_precompute.go b/beacon-chain/core/altair/epoch_precompute.go index d2ee97b69..285a49e00 100644 --- a/beacon-chain/core/altair/epoch_precompute.go +++ b/beacon-chain/core/altair/epoch_precompute.go @@ -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, diff --git a/beacon-chain/core/altair/epoch_spec.go b/beacon-chain/core/altair/epoch_spec.go index fd8cd49fa..bb9a465ea 100644 --- a/beacon-chain/core/altair/epoch_spec.go +++ b/beacon-chain/core/altair/epoch_spec.go @@ -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: // diff --git a/beacon-chain/core/epoch/epoch_processing.go b/beacon-chain/core/epoch/epoch_processing.go index 48550c15d..072647708 100644 --- a/beacon-chain/core/epoch/epoch_processing.go +++ b/beacon-chain/core/epoch/epoch_processing.go @@ -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: diff --git a/beacon-chain/core/epoch/precompute/reward_penalty.go b/beacon-chain/core/epoch/precompute/reward_penalty.go index 0c49016f1..4b4930b95 100644 --- a/beacon-chain/core/epoch/precompute/reward_penalty.go +++ b/beacon-chain/core/epoch/precompute/reward_penalty.go @@ -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, diff --git a/beacon-chain/core/helpers/validators.go b/beacon-chain/core/helpers/validators.go index b0a2edfbb..d37eb7806 100644 --- a/beacon-chain/core/helpers/validators.go +++ b/beacon-chain/core/helpers/validators.go @@ -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: diff --git a/beacon-chain/rpc/eth/node/node.go b/beacon-chain/rpc/eth/node/node.go index 2ab5ea0a8..14ff6539f 100644 --- a/beacon-chain/rpc/eth/node/node.go +++ b/beacon-chain/rpc/eth/node/node.go @@ -228,7 +228,7 @@ func (ns *Server) ListPeers(ctx context.Context, req *ethpb.PeersRequest) (*ethp return ðpb.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() diff --git a/beacon-chain/rpc/prysm/v1alpha1/beacon/validators.go b/beacon-chain/rpc/prysm/v1alpha1/beacon/validators.go index b0607d56d..390632598 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/beacon/validators.go +++ b/beacon-chain/rpc/prysm/v1alpha1/beacon/validators.go @@ -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, diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/status.go b/beacon-chain/rpc/prysm/v1alpha1/validator/status.go index 73d571f31..d904717c7 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/status.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/status.go @@ -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. diff --git a/beacon-chain/slasher/chunks.go b/beacon-chain/slasher/chunks.go index 5e3d81d1d..672a04c26 100644 --- a/beacon-chain/slasher/chunks.go +++ b/beacon-chain/slasher/chunks.go @@ -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: // diff --git a/beacon-chain/slasher/doc.go b/beacon-chain/slasher/doc.go index fa2c9f492..b6a6b5f81 100644 --- a/beacon-chain/slasher/doc.go +++ b/beacon-chain/slasher/doc.go @@ -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/. diff --git a/beacon-chain/state/state-native/setters_attestation.go b/beacon-chain/state/state-native/setters_attestation.go index fe6c994fa..6fbec49be 100644 --- a/beacon-chain/state/state-native/setters_attestation.go +++ b/beacon-chain/state/state-native/setters_attestation.go @@ -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() diff --git a/beacon-chain/state/state-native/setters_eth1.go b/beacon-chain/state/state-native/setters_eth1.go index 697a3af73..603bfed4c 100644 --- a/beacon-chain/state/state-native/setters_eth1.go +++ b/beacon-chain/state/state-native/setters_eth1.go @@ -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() diff --git a/beacon-chain/state/state-native/setters_participation.go b/beacon-chain/state/state-native/setters_participation.go index 044329943..3a81d4690 100644 --- a/beacon-chain/state/state-native/setters_participation.go +++ b/beacon-chain/state/state-native/setters_participation.go @@ -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() diff --git a/beacon-chain/state/state-native/setters_validator.go b/beacon-chain/state/state-native/setters_validator.go index efd144406..00230349f 100644 --- a/beacon-chain/state/state-native/setters_validator.go +++ b/beacon-chain/state/state-native/setters_validator.go @@ -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() diff --git a/beacon-chain/state/state-native/types_test.go b/beacon-chain/state/state-native/types_test.go index 4f442a135..05f029582 100644 --- a/beacon-chain/state/state-native/types_test.go +++ b/beacon-chain/state/state-native/types_test.go @@ -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)) diff --git a/cmd/prysmctl/checkpointsync/download.go b/cmd/prysmctl/checkpointsync/download.go index 611871a4a..366794027 100644 --- a/cmd/prysmctl/checkpointsync/download.go +++ b/cmd/prysmctl/checkpointsync/download.go @@ -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 } diff --git a/cmd/validator/slashing-protection/export.go b/cmd/validator/slashing-protection/export.go index ffbd717bd..d03a4c22d 100644 --- a/cmd/validator/slashing-protection/export.go +++ b/cmd/validator/slashing-protection/export.go @@ -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( diff --git a/cmd/validator/slashing-protection/import.go b/cmd/validator/slashing-protection/import.go index a3ef178ab..ca7130302 100644 --- a/cmd/validator/slashing-protection/import.go +++ b/cmd/validator/slashing-protection/import.go @@ -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) diff --git a/cmd/wrap_flags.go b/cmd/wrap_flags.go index 039df63cc..cbddd2925 100644 --- a/cmd/wrap_flags.go +++ b/cmd/wrap_flags.go @@ -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: diff --git a/container/leaky-bucket/leakybucket.go b/container/leaky-bucket/leakybucket.go index 1ca8ca680..03ceeef1a 100644 --- a/container/leaky-bucket/leakybucket.go +++ b/container/leaky-bucket/leakybucket.go @@ -1,3 +1,4 @@ +//nolint:dupword /* Package leakybucket implements a scalable leaky bucket algorithm. diff --git a/crypto/bls/bls.go b/crypto/bls/bls.go index 921c1396e..6e8df3998 100644 --- a/crypto/bls/bls.go +++ b/crypto/bls/bls.go @@ -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 diff --git a/crypto/bls/blst/doc.go b/crypto/bls/blst/doc.go index 76a2e9aeb..b5f885083 100644 --- a/crypto/bls/blst/doc.go +++ b/crypto/bls/blst/doc.go @@ -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. diff --git a/encoding/ssz/merkleize.go b/encoding/ssz/merkleize.go index 5702de4da..1b22b159e 100644 --- a/encoding/ssz/merkleize.go +++ b/encoding/ssz/merkleize.go @@ -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 ( diff --git a/hack/interop_start.sh b/hack/interop_start.sh index 868b2950b..e6655f6d5 100755 --- a/hack/interop_start.sh +++ b/hack/interop_start.sh @@ -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" diff --git a/io/logs/stream.go b/io/logs/stream.go index 232764f6d..1e150f073 100644 --- a/io/logs/stream.go +++ b/io/logs/stream.go @@ -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 } diff --git a/testing/endtoend/params/params.go b/testing/endtoend/params/params.go index 73067784e..65de6c880 100644 --- a/testing/endtoend/params/params.go +++ b/testing/endtoend/params/params.go @@ -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{ diff --git a/tools/analyzers/errcheck/analyzer.go b/tools/analyzers/errcheck/analyzer.go index d4be49f82..0b1804b9b 100644 --- a/tools/analyzers/errcheck/analyzer.go +++ b/tools/analyzers/errcheck/analyzer.go @@ -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} diff --git a/validator/accounts/userprompt/prompt.go b/validator/accounts/userprompt/prompt.go index 16ae1ff5b..0abdf27b5 100644 --- a/validator/accounts/userprompt/prompt.go +++ b/validator/accounts/userprompt/prompt.go @@ -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 -- diff --git a/validator/client/beacon-api/doppelganger.go b/validator/client/beacon-api/doppelganger.go index 0d3589c6f..2f34a40a7 100644 --- a/validator/client/beacon-api/doppelganger.go +++ b/validator/client/beacon-api/doppelganger.go @@ -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 diff --git a/validator/db/kv/attester_protection.go b/validator/db/kv/attester_protection.go index 00a9c8d04..3069609e9 100644 --- a/validator/db/kv/attester_protection.go +++ b/validator/db/kv/attester_protection.go @@ -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 {