Enable whitespace linter & fix findings (#12273)

* Enable whitespace linter & fix findings

* Fix new finding

* fix new violation

---------

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
This commit is contained in:
Justin Traglia 2023-04-18 13:58:27 -05:00 committed by GitHub
parent 03f63f294b
commit 8428a79971
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 3 additions and 84 deletions

View File

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

View File

@ -246,7 +246,6 @@ func (c *Client) GetHeader(ctx context.Context, slot primitives.Slot, parentHash
default: default:
return nil, fmt.Errorf("unsupported header version %s", strings.ToLower(v.Version)) return nil, fmt.Errorf("unsupported header version %s", strings.ToLower(v.Version))
} }
} }
// RegisterValidator encodes the SignedValidatorRegistrationV1 message to json (including hex-encoding the byte // RegisterValidator encodes the SignedValidatorRegistrationV1 message to json (including hex-encoding the byte

View File

@ -60,7 +60,6 @@ func logStateTransitionData(b interfaces.ReadOnlyBeaconBlock) error {
log = log.WithField("txCount", len(txs)) log = log.WithField("txCount", len(txs))
txsPerSlotCount.Set(float64(len(txs))) txsPerSlotCount.Set(float64(len(txs)))
} }
} }
log.Info("Finished applying state transition") log.Info("Finished applying state transition")
return nil return nil

View File

@ -55,7 +55,6 @@ func (s *Service) getAttPreState(ctx context.Context, c *ethpb.Checkpoint) (stat
return nil, errors.Wrap(err, "could not save checkpoint state to cache") return nil, errors.Wrap(err, "could not save checkpoint state to cache")
} }
return baseState, nil return baseState, nil
} }
// verifyAttTargetEpoch validates attestation is from the current or previous epoch. // verifyAttTargetEpoch validates attestation is from the current or previous epoch.

View File

@ -283,7 +283,6 @@ func (s *Service) onBlock(ctx context.Context, signed interfaces.ReadOnlySignedB
log.WithError(err).Error("Could not insert finalized deposits.") log.WithError(err).Error("Could not insert finalized deposits.")
} }
}() }()
} }
defer reportAttestationInclusion(b) defer reportAttestationInclusion(b)
if err := s.handleEpochBoundary(ctx, postState); err != nil { if err := s.handleEpochBoundary(ctx, postState); err != nil {

View File

@ -104,7 +104,6 @@ func attestationDelta(pBal *Balance, sqrtActiveCurrentEpoch uint64, v *Validator
} else { } else {
rewardNumerator := br * (pBal.PrevEpochAttested / effectiveBalanceIncrement) rewardNumerator := br * (pBal.PrevEpochAttested / effectiveBalanceIncrement)
r += rewardNumerator / currentEpochBalance r += rewardNumerator / currentEpochBalance
} }
} else { } else {
p += br p += br

View File

@ -874,5 +874,4 @@ func (s *Store) isStateValidatorMigrationOver() (bool, error) {
return returnFlag, err return returnFlag, err
} }
return returnFlag, nil return returnFlag, nil
} }

View File

@ -425,7 +425,6 @@ func (s *Service) batchRequestHeaders(startBlock, endBlock uint64) ([]*types.Hea
Error: error(nil), Error: error(nil),
}) })
headers = append(headers, header) headers = append(headers, header)
} }
ioErr := s.rpcClient.BatchCall(elems) ioErr := s.rpcClient.BatchCall(elems)
if ioErr != nil { if ioErr != nil {

View File

@ -246,7 +246,6 @@ func (r *RPCClient) BatchCall(b []rpc.BatchElem) error {
return err return err
} }
*e.Result.(*types.HeaderInfo) = types.HeaderInfo{Number: h.Number, Time: h.Time, Hash: h.Hash()} *e.Result.(*types.HeaderInfo) = types.HeaderInfo{Number: h.Number, Time: h.Time, Hash: h.Hash()}
} }
return nil return nil
} }

View File

@ -560,7 +560,6 @@ func (f *ForkChoice) ForkChoiceDump(ctx context.Context) (*v1.ForkChoiceDump, er
ForkChoiceNodes: nodes, ForkChoiceNodes: nodes,
} }
return resp, nil return resp, nil
} }
// SetBalancesByRooter sets the balanceByRoot handler in forkchoice // SetBalancesByRooter sets the balanceByRoot handler in forkchoice

View File

@ -28,7 +28,6 @@ func DefaultConfig(enableDebugRPCEndpoints bool, httpModules string) MuxConfig {
} }
if enableDebugRPCEndpoints { if enableDebugRPCEndpoints {
v1AlphaRegistrations = append(v1AlphaRegistrations, ethpbalpha.RegisterDebugHandler) v1AlphaRegistrations = append(v1AlphaRegistrations, ethpbalpha.RegisterDebugHandler)
} }
v1AlphaMux := gwruntime.NewServeMux( v1AlphaMux := gwruntime.NewServeMux(
gwruntime.WithMarshalerOption(gwruntime.MIMEWildcard, &gwruntime.HTTPBodyMarshaler{ gwruntime.WithMarshalerOption(gwruntime.MIMEWildcard, &gwruntime.HTTPBodyMarshaler{
@ -60,7 +59,6 @@ func DefaultConfig(enableDebugRPCEndpoints bool, httpModules string) MuxConfig {
} }
if enableDebugRPCEndpoints { if enableDebugRPCEndpoints {
ethRegistrations = append(ethRegistrations, ethpbservice.RegisterBeaconDebugHandler) ethRegistrations = append(ethRegistrations, ethpbservice.RegisterBeaconDebugHandler)
} }
ethMux := gwruntime.NewServeMux( ethMux := gwruntime.NewServeMux(
gwruntime.WithMarshalerOption(gwruntime.MIMEWildcard, &gwruntime.HTTPBodyMarshaler{ gwruntime.WithMarshalerOption(gwruntime.MIMEWildcard, &gwruntime.HTTPBodyMarshaler{

View File

@ -133,7 +133,6 @@ func (s *Service) processSlashings(blk interfaces.ReadOnlyBeaconBlock) {
"SourceEpoch2": slashing.Attestation_2.Data.Source.Epoch, "SourceEpoch2": slashing.Attestation_2.Data.Source.Epoch,
"TargetEpoch2": slashing.Attestation_2.Data.Target.Epoch, "TargetEpoch2": slashing.Attestation_2.Data.Target.Epoch,
}).Info("Attester slashing was included") }).Info("Attester slashing was included")
} }
} }
} }

View File

@ -127,7 +127,6 @@ func (p *Pool) InsertBLSToExecChange(change *ethpb.SignedBLSToExecutionChange) {
p.m[change.Message.ValidatorIndex] = p.pending.Last() p.m[change.Message.ValidatorIndex] = p.pending.Last()
blsToExecMessageInPoolTotal.Inc() blsToExecMessageInPoolTotal.Inc()
} }
// MarkIncluded is used when an object has been included in a beacon block. Every block seen by this // MarkIncluded is used when an object has been included in a beacon block. Every block seen by this

View File

@ -887,7 +887,6 @@ func (bs *Server) GetIndividualVotes(
val, err := st.ValidatorAtIndexReadOnly(index) val, err := st.ValidatorAtIndexReadOnly(index)
if err != nil { if err != nil {
return nil, status.Errorf(codes.Internal, "Could not retrieve validator: %v", err) return nil, status.Errorf(codes.Internal, "Could not retrieve validator: %v", err)
} }
pb := val.PublicKey() pb := val.PublicKey()
votes = append(votes, &ethpb.IndividualVotesRespond_IndividualVote{ votes = append(votes, &ethpb.IndividualVotesRespond_IndividualVote{

View File

@ -284,7 +284,6 @@ func (is *infostream) generateValidatorsInfo(pubKeys [][]byte) ([]*ethpb.Validat
v, err := headState.ValidatorAtIndexReadOnly(i) v, err := headState.ValidatorAtIndexReadOnly(i)
if err != nil { if err != nil {
return nil, status.Errorf(codes.Internal, "Could not retrieve validator: %v", err) return nil, status.Errorf(codes.Internal, "Could not retrieve validator: %v", err)
} }
info, err := is.generateValidatorInfo(pubKey, v, headState, epoch) info, err := is.generateValidatorInfo(pubKey, v, headState, epoch)
if err != nil { if err != nil {

View File

@ -229,7 +229,6 @@ func (vs *Server) GetFeeRecipientByPubKey(ctx context.Context, request *ethpb.Fe
log.WithError(err).Error("An error occurred while retrieving validator index") log.WithError(err).Error("An error occurred while retrieving validator index")
return nil, err return nil, err
} }
} }
address, err := vs.BeaconDB.FeeRecipientByValidatorID(ctx, resp.GetIndex()) address, err := vs.BeaconDB.FeeRecipientByValidatorID(ctx, resp.GetIndex())
if err != nil { if err != nil {

View File

@ -97,7 +97,6 @@ func (vs *Server) canonicalEth1Data(
ctx context.Context, ctx context.Context,
beaconState state.BeaconState, beaconState state.BeaconState,
currentVote *ethpb.Eth1Data) (*ethpb.Eth1Data, *big.Int, error) { currentVote *ethpb.Eth1Data) (*ethpb.Eth1Data, *big.Int, error) {
var eth1BlockHash [32]byte var eth1BlockHash [32]byte
// Add in current vote, to get accurate vote tally // Add in current vote, to get accurate vote tally

View File

@ -265,7 +265,6 @@ func (vs *Server) optimisticStatus(ctx context.Context) error {
} }
return status.Errorf(codes.Unavailable, errOptimisticMode.Error()) return status.Errorf(codes.Unavailable, errOptimisticMode.Error())
} }
// validatorStatus searches for the requested validator's state and deposit to retrieve its inclusion estimate. Also returns the validators index. // validatorStatus searches for the requested validator's state and deposit to retrieve its inclusion estimate. Also returns the validators index.

View File

@ -84,7 +84,6 @@ func (s *Service) detectAllAttesterSlashings(
args *chunkUpdateArgs, args *chunkUpdateArgs,
attestations []*slashertypes.IndexedAttestationWrapper, attestations []*slashertypes.IndexedAttestationWrapper,
) ([]*ethpb.AttesterSlashing, error) { ) ([]*ethpb.AttesterSlashing, error) {
// Map of updated chunks by chunk index, which will be saved at the end. // Map of updated chunks by chunk index, which will be saved at the end.
updatedChunks := make(map[uint64]Chunker) updatedChunks := make(map[uint64]Chunker)
groupedAtts := s.groupByChunkIndex(attestations) groupedAtts := s.groupByChunkIndex(attestations)

View File

@ -204,7 +204,6 @@ func (s *Service) waitForChainInitialization() {
return return
} }
} }
} }
func (s *Service) waitForSync(genesisTime time.Time) { func (s *Service) waitForSync(genesisTime time.Time) {

View File

@ -79,7 +79,6 @@ func NewFieldTrie(field types.FieldIndex, dataType types.DataType, elements inte
default: default:
return nil, errors.Errorf("unrecognized data type in field map: %v", reflect.TypeOf(dataType).Name()) return nil, errors.Errorf("unrecognized data type in field map: %v", reflect.TypeOf(dataType).Name())
} }
} }
// RecomputeTrie rebuilds the affected branches in the trie according to the provided // RecomputeTrie rebuilds the affected branches in the trie according to the provided

View File

@ -57,7 +57,6 @@ func (b *BeaconState) UnrealizedCheckpointBalances() (uint64, uint64, uint64, er
} }
return stateutil.UnrealizedCheckpointBalances(cp, pp, b.validators, currentEpoch) return stateutil.UnrealizedCheckpointBalances(cp, pp, b.validators, currentEpoch)
} }
// currentEpochParticipationVal corresponding to participation bits on the beacon chain. // currentEpochParticipationVal corresponding to participation bits on the beacon chain.

View File

@ -899,7 +899,6 @@ func finalizerCleanup(b *BeaconState) {
if b.stateFieldLeaves[field].FieldReference() != nil { if b.stateFieldLeaves[field].FieldReference() != nil {
b.stateFieldLeaves[field].FieldReference().MinusRef() b.stateFieldLeaves[field].FieldReference().MinusRef()
} }
} }
for i := range b.dirtyFields { for i := range b.dirtyFields {
delete(b.dirtyFields, i) delete(b.dirtyFields, i)

View File

@ -123,7 +123,6 @@ func VerifyBeaconStateValidatorByPubkey(t *testing.T, factory getState) {
n := b.Copy() n := b.Copy()
// Append to another state // Append to another state
assert.NoError(t, n.AppendValidator(&ethpb.Validator{PublicKey: key[:]})) assert.NoError(t, n.AppendValidator(&ethpb.Validator{PublicKey: key[:]}))
}, },
exists: false, exists: false,
expectedIdx: 0, expectedIdx: 0,
@ -136,7 +135,6 @@ func VerifyBeaconStateValidatorByPubkey(t *testing.T, factory getState) {
n := b.Copy() n := b.Copy()
// Append to another state // Append to another state
assert.NoError(t, n.AppendValidator(&ethpb.Validator{PublicKey: key[:]})) assert.NoError(t, n.AppendValidator(&ethpb.Validator{PublicKey: key[:]}))
}, },
exists: false, exists: false,
expectedIdx: 0, expectedIdx: 0,

View File

@ -56,7 +56,6 @@ func VerifyBeaconStateBlockRootsNative(
} else { } else {
want[i] = make([]byte, 32) want[i] = make([]byte, 32)
} }
} }
s, err = factoryBR(want) s, err = factoryBR(want)
require.NoError(t, err) require.NoError(t, err)

View File

@ -214,7 +214,6 @@ func cliActionRequestBlocks(cliCtx *cli.Context) error {
"timeFromSendingToProcessingResponse": end, "timeFromSendingToProcessingResponse": end,
"totalBlocksWithExecutionPayloads": totalExecutionBlocks, "totalBlocksWithExecutionPayloads": totalExecutionBlocks,
}).Info("Received blocks from peer") }).Info("Received blocks from peer")
} }
return nil return nil
} }

View File

@ -76,7 +76,6 @@ func getWithdrawalMessagesFromPathFlag(c *cli.Context) ([]*apimiddleware.SignedB
Signature: to[i].Signature, Signature: to[i].Signature,
}) })
} }
} }
if len(setWithdrawalAddressJsons) == 0 { if len(setWithdrawalAddressJsons) == 0 {
return setWithdrawalAddressJsons, errors.New("the list of signed requests is empty") return setWithdrawalAddressJsons, errors.New("the list of signed requests is empty")

View File

@ -27,7 +27,6 @@ func walletWithKeymanager(c *cli.Context) (*wallet.Wallet, keymanager.IKeymanage
return nil, nil, errors.Wrap(err, accounts.ErrCouldNotInitializeKeymanager) return nil, nil, errors.Wrap(err, accounts.ErrCouldNotInitializeKeymanager)
} }
return w, km, nil return w, km, nil
} }
func walletWithWeb3SignerKeymanager(c *cli.Context, config *remote_web3signer.SetupConfig) (*wallet.Wallet, keymanager.IKeymanager, error) { func walletWithWeb3SignerKeymanager(c *cli.Context, config *remote_web3signer.SetupConfig) (*wallet.Wallet, keymanager.IKeymanager, error) {

View File

@ -112,7 +112,6 @@ func (b *SignedBeaconBlock) PbGenericBlock() (*eth.GenericSignedBeaconBlock, err
default: default:
return nil, errIncorrectBlockVersion return nil, errIncorrectBlockVersion
} }
} }
// PbPhase0Block returns the underlying protobuf object. // PbPhase0Block returns the underlying protobuf object.

View File

@ -92,7 +92,6 @@ func (p *PublicKey) Equals(p2 common.PublicKey) bool {
// Aggregate two public keys. // Aggregate two public keys.
func (p *PublicKey) Aggregate(p2 common.PublicKey) common.PublicKey { func (p *PublicKey) Aggregate(p2 common.PublicKey) common.PublicKey {
agg := new(blstAggregatePublicKey) agg := new(blstAggregatePublicKey)
// No group check here since it is checked at decompression time // No group check here since it is checked at decompression time
agg.Add(p.p, false) agg.Add(p.p, false)

View File

@ -259,7 +259,6 @@ func kdfKey(cryptoJSON cryptoJSON, auth string) ([]byte, error) {
r := ensureInt(cryptoJSON.KDFParams["r"]) r := ensureInt(cryptoJSON.KDFParams["r"])
p := ensureInt(cryptoJSON.KDFParams["p"]) p := ensureInt(cryptoJSON.KDFParams["p"])
return scrypt.Key(authArray, salt, n, r, p, dkLen) return scrypt.Key(authArray, salt, n, r, p, dkLen)
} else if cryptoJSON.KDF == "pbkdf2" { } else if cryptoJSON.KDF == "pbkdf2" {
c := ensureInt(cryptoJSON.KDFParams["c"]) c := ensureInt(cryptoJSON.KDFParams["c"])
prf, ok := cryptoJSON.KDFParams["prf"].(string) prf, ok := cryptoJSON.KDFParams["prf"].(string)

View File

@ -188,7 +188,7 @@ func Mod64(a, b uint64) (uint64, error) {
return val, nil return val, nil
} }
// Int returns the integer value of the uint64 argument. If there is an overlow, then an error is // Int returns the integer value of the uint64 argument. If there is an overflow, then an error is
// returned. // returned.
func Int(u uint64) (int, error) { func Int(u uint64) (int, error) {
if u > stdmath.MaxInt { if u > stdmath.MaxInt {
@ -208,7 +208,6 @@ func AddInt(i ...int) (int, error) {
} }
sum += ii sum += ii
} }
return sum, nil return sum, nil
} }

View File

@ -9,7 +9,7 @@ import (
"strings" "strings"
"github.com/coreos/go-systemd/journal" "github.com/coreos/go-systemd/journal"
logrus "github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
type JournalHook struct{} type JournalHook struct{}
@ -52,7 +52,6 @@ func stringifyKey(key string) string {
func stringifyEntries(data map[string]interface{}) map[string]string { func stringifyEntries(data map[string]interface{}) map[string]string {
entries := make(map[string]string) entries := make(map[string]string)
for k, v := range data { for k, v := range data {
key := stringifyKey(k) key := stringifyKey(k)
entries[key] = fmt.Sprint(v) entries[key] = fmt.Sprint(v)
} }

View File

@ -119,7 +119,6 @@ func SendTransaction(client *rpc.Client, key *ecdsa.PrivateKey, f *filler.Filler
err = backend.SendTransaction(context.Background(), signedTx) err = backend.SendTransaction(context.Background(), signedTx)
return nil return nil
}) })
} }
return g.Wait() return g.Wait()
} }

View File

@ -659,7 +659,6 @@ func validatorsAreWithdrawn(ec *e2etypes.EvaluationContext, conns ...*grpc.Clien
if bal > 1*params.BeaconConfig().GweiPerEth { if bal > 1*params.BeaconConfig().GweiPerEth {
return errors.Errorf("Validator index %d with key %#x hasn't withdrawn. Their balance is %d.", valIdx, key, bal) return errors.Errorf("Validator index %d with key %#x hasn't withdrawn. Their balance is %d.", valIdx, key, bal)
} }
} }
return nil return nil
} }

View File

@ -116,7 +116,6 @@ func validatorsLoseBalance(_ *e2eTypes.EvaluationContext, conns ...*grpc.ClientC
valResp.EffectiveBalance, valResp.EffectiveBalance,
) )
} }
} }
return nil return nil
} }

View File

@ -45,7 +45,6 @@ func (s *EpochTicker) start(
secondsPerEpoch uint64, secondsPerEpoch uint64,
since, until func(time.Time) time.Duration, since, until func(time.Time) time.Duration,
after func(time.Duration) <-chan time.Time) { after func(time.Duration) <-chan time.Time) {
d := time.Duration(secondsPerEpoch) * time.Second d := time.Duration(secondsPerEpoch) * time.Second
go func() { go func() {

View File

@ -147,5 +147,4 @@ func (bb *Builder) Check(t testing.TB, c *Check) {
got := fmt.Sprintf("%#x", bb.service.ProposerBoost()) got := fmt.Sprintf("%#x", bb.service.ProposerBoost())
require.DeepEqual(t, want, got) require.DeepEqual(t, want, got)
} }
} }

View File

@ -131,7 +131,6 @@ func runTest(t *testing.T, config string, fork int, basePath string) {
} }
if step.PayloadStatus != nil { if step.PayloadStatus != nil {
require.NoError(t, builder.SetPayloadStatus(step.PayloadStatus)) require.NoError(t, builder.SetPayloadStatus(step.PayloadStatus))
} }
if step.PowBlock != nil { if step.PowBlock != nil {
powBlockFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), fmt.Sprint(*step.PowBlock, ".ssz_snappy")) powBlockFile, err := util.BazelFileBytes(testsFolderPath, folder.Name(), fmt.Sprint(*step.PowBlock, ".ssz_snappy"))

View File

@ -74,7 +74,6 @@ func (s *SlotTicker) start(
secondsPerSlot uint64, secondsPerSlot uint64,
since, until func(time.Time) time.Duration, since, until func(time.Time) time.Duration,
after func(time.Duration) <-chan time.Time) { after func(time.Duration) <-chan time.Time) {
d := time.Duration(secondsPerSlot) * time.Second d := time.Duration(secondsPerSlot) * time.Second
go func() { go func() {

View File

@ -253,7 +253,6 @@ func extractPrivateKey() *ecdsa.PrivateKey {
if err != nil { if err != nil {
panic(err) panic(err)
} }
} else { } else {
privInterfaceKey, _, err := crypto.GenerateSecp256k1Key(rand.Reader) privInterfaceKey, _, err := crypto.GenerateSecp256k1Key(rand.Reader)
if err != nil { if err != nil {

View File

@ -364,7 +364,6 @@ func printStates(stateC <-chan *modifiedState, doneC chan<- bool) {
log.Infof("previous_justified_checkpoint : sizeSSZ = %s", humanize.Bytes(uint64(st.PreviousJustifiedCheckpoint().SizeSSZ()))) log.Infof("previous_justified_checkpoint : sizeSSZ = %s", humanize.Bytes(uint64(st.PreviousJustifiedCheckpoint().SizeSSZ())))
log.Infof("current_justified_checkpoint : sizeSSZ = %s", humanize.Bytes(uint64(st.CurrentJustifiedCheckpoint().SizeSSZ()))) log.Infof("current_justified_checkpoint : sizeSSZ = %s", humanize.Bytes(uint64(st.CurrentJustifiedCheckpoint().SizeSSZ())))
log.Infof("finalized_checkpoint : sizeSSZ = %s", humanize.Bytes(uint64(st.FinalizedCheckpoint().SizeSSZ()))) log.Infof("finalized_checkpoint : sizeSSZ = %s", humanize.Bytes(uint64(st.FinalizedCheckpoint().SizeSSZ())))
} }
doneC <- true doneC <- true
} }

View File

@ -18,35 +18,29 @@ import (
func mergeProfiles(p, merge *cover.Profile) { func mergeProfiles(p, merge *cover.Profile) {
if p.Mode != merge.Mode { if p.Mode != merge.Mode {
log.Fatalf("cannot merge profiles with different modes") log.Fatalf("cannot merge profiles with different modes")
} }
// Since the blocks are sorted, we can keep track of where the last block // Since the blocks are sorted, we can keep track of where the last block
// was inserted and only look at the blocks after that as targets for merge // was inserted and only look at the blocks after that as targets for merge
startIndex := 0 startIndex := 0
for _, b := range merge.Blocks { for _, b := range merge.Blocks {
startIndex = mergeProfileBlock(p, b, startIndex) startIndex = mergeProfileBlock(p, b, startIndex)
} }
} }
func mergeProfileBlock(p *cover.Profile, pb cover.ProfileBlock, startIndex int) int { func mergeProfileBlock(p *cover.Profile, pb cover.ProfileBlock, startIndex int) int {
sortFunc := func(i int) bool { sortFunc := func(i int) bool {
pi := p.Blocks[i+startIndex] pi := p.Blocks[i+startIndex]
return pi.StartLine >= pb.StartLine && (pi.StartLine != pb.StartLine || pi.StartCol >= pb.StartCol) return pi.StartLine >= pb.StartLine && (pi.StartLine != pb.StartLine || pi.StartCol >= pb.StartCol)
} }
i := 0 i := 0
if !sortFunc(i) { if !sortFunc(i) {
i = sort.Search(len(p.Blocks)-startIndex, sortFunc) i = sort.Search(len(p.Blocks)-startIndex, sortFunc)
} }
i += startIndex i += startIndex
if i < len(p.Blocks) && p.Blocks[i].StartLine == pb.StartLine && p.Blocks[i].StartCol == pb.StartCol { if i < len(p.Blocks) && p.Blocks[i].StartLine == pb.StartLine && p.Blocks[i].StartCol == pb.StartCol {
if p.Blocks[i].EndLine != pb.EndLine || p.Blocks[i].EndCol != pb.EndCol { if p.Blocks[i].EndLine != pb.EndLine || p.Blocks[i].EndCol != pb.EndCol {
log.Fatalf("OVERLAP MERGE: %v %v %v", p.FileName, p.Blocks[i], pb) log.Fatalf("OVERLAP MERGE: %v %v %v", p.FileName, p.Blocks[i], pb)
} }
switch p.Mode { switch p.Mode {
case "set": case "set":
@ -55,54 +49,42 @@ func mergeProfileBlock(p *cover.Profile, pb cover.ProfileBlock, startIndex int)
p.Blocks[i].Count += pb.Count p.Blocks[i].Count += pb.Count
default: default:
log.Fatalf("unsupported covermode: '%s'", p.Mode) log.Fatalf("unsupported covermode: '%s'", p.Mode)
} }
} else { } else {
if i > 0 { if i > 0 {
pa := p.Blocks[i-1] pa := p.Blocks[i-1]
if pa.EndLine >= pb.EndLine && (pa.EndLine != pb.EndLine || pa.EndCol > pb.EndCol) { if pa.EndLine >= pb.EndLine && (pa.EndLine != pb.EndLine || pa.EndCol > pb.EndCol) {
log.Fatalf("OVERLAP BEFORE: %v %v %v", p.FileName, pa, pb) log.Fatalf("OVERLAP BEFORE: %v %v %v", p.FileName, pa, pb)
} }
} }
if i < len(p.Blocks)-1 { if i < len(p.Blocks)-1 {
pa := p.Blocks[i+1] pa := p.Blocks[i+1]
if pa.StartLine <= pb.StartLine && (pa.StartLine != pb.StartLine || pa.StartCol < pb.StartCol) { if pa.StartLine <= pb.StartLine && (pa.StartLine != pb.StartLine || pa.StartCol < pb.StartCol) {
log.Fatalf("OVERLAP AFTER: %v %v %v", p.FileName, pa, pb) log.Fatalf("OVERLAP AFTER: %v %v %v", p.FileName, pa, pb)
} }
} }
p.Blocks = append(p.Blocks, cover.ProfileBlock{}) p.Blocks = append(p.Blocks, cover.ProfileBlock{})
copy(p.Blocks[i+1:], p.Blocks[i:]) copy(p.Blocks[i+1:], p.Blocks[i:])
p.Blocks[i] = pb p.Blocks[i] = pb
} }
return i + 1 return i + 1
} }
func addProfile(profiles []*cover.Profile, p *cover.Profile) []*cover.Profile { func addProfile(profiles []*cover.Profile, p *cover.Profile) []*cover.Profile {
i := sort.Search(len(profiles), func(i int) bool { return profiles[i].FileName >= p.FileName }) i := sort.Search(len(profiles), func(i int) bool { return profiles[i].FileName >= p.FileName })
if i < len(profiles) && profiles[i].FileName == p.FileName { if i < len(profiles) && profiles[i].FileName == p.FileName {
mergeProfiles(profiles[i], p) mergeProfiles(profiles[i], p)
} else { } else {
profiles = append(profiles, nil) profiles = append(profiles, nil)
copy(profiles[i+1:], profiles[i:]) copy(profiles[i+1:], profiles[i:])
profiles[i] = p profiles[i] = p
} }
return profiles return profiles
} }
func dumpProfiles(profiles []*cover.Profile, out io.Writer) { func dumpProfiles(profiles []*cover.Profile, out io.Writer) {
if len(profiles) == 0 { if len(profiles) == 0 {
return return
} }
if _, err := fmt.Fprintf(out, "mode: %s\n", profiles[0].Mode); err != nil { if _, err := fmt.Fprintf(out, "mode: %s\n", profiles[0].Mode); err != nil {
panic(err) panic(err)
@ -112,11 +94,8 @@ func dumpProfiles(profiles []*cover.Profile, out io.Writer) {
if _, err := fmt.Fprintf(out, "%s:%d.%d,%d.%d %d %d\n", p.FileName, b.StartLine, b.StartCol, b.EndLine, b.EndCol, b.NumStmt, b.Count); err != nil { if _, err := fmt.Fprintf(out, "%s:%d.%d,%d.%d %d %d\n", p.FileName, b.StartLine, b.StartCol, b.EndLine, b.EndCol, b.NumStmt, b.Count); err != nil {
panic(err) panic(err)
} }
} }
} }
} }
func main() { func main() {
@ -128,15 +107,11 @@ func main() {
profiles, err := cover.ParseProfiles(file) profiles, err := cover.ParseProfiles(file)
if err != nil { if err != nil {
log.WithError(err).Fatal("failed to parse profiles") log.WithError(err).Fatal("failed to parse profiles")
} }
for _, p := range profiles { for _, p := range profiles {
merged = addProfile(merged, p) merged = addProfile(merged, p)
} }
} }
dumpProfiles(merged, os.Stdout) dumpProfiles(merged, os.Stdout)
} }

View File

@ -383,7 +383,6 @@ func (w *Wallet) ReadKeymanagerConfigFromDisk(_ context.Context) (io.ReadCloser,
} }
w.configFilePath = configFilePath w.configFilePath = configFilePath
return os.Open(configFilePath) // #nosec G304 return os.Open(configFilePath) // #nosec G304
} }
// WriteKeymanagerConfigToDisk takes an encoded keymanager config file // WriteKeymanagerConfigToDisk takes an encoded keymanager config file

View File

@ -113,7 +113,6 @@ func (v *validator) SubmitAggregateAndProof(ctx context.Context, slot primitives
if v.emitAccountMetrics { if v.emitAccountMetrics {
ValidatorAggSuccessVec.WithLabelValues(fmtKey).Inc() ValidatorAggSuccessVec.WithLabelValues(fmtKey).Inc()
} }
} }
// Signs input slot with domain selection proof. This is used to create the signature for aggregator selection. // Signs input slot with domain selection proof. This is used to create the signature for aggregator selection.

View File

@ -224,7 +224,6 @@ func (c beaconApiDutiesProvider) GetCommittees(ctx context.Context, epoch primit
// GetAttesterDuties retrieves the attester duties for the given epoch and validatorIndices // GetAttesterDuties retrieves the attester duties for the given epoch and validatorIndices
func (c beaconApiDutiesProvider) GetAttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*apimiddleware.AttesterDutyJson, error) { func (c beaconApiDutiesProvider) GetAttesterDuties(ctx context.Context, epoch primitives.Epoch, validatorIndices []primitives.ValidatorIndex) ([]*apimiddleware.AttesterDutyJson, error) {
jsonValidatorIndices := make([]string, len(validatorIndices)) jsonValidatorIndices := make([]string, len(validatorIndices))
for index, validatorIndex := range validatorIndices { for index, validatorIndex := range validatorIndices {
jsonValidatorIndices[index] = strconv.FormatUint(uint64(validatorIndex), 10) jsonValidatorIndices[index] = strconv.FormatUint(uint64(validatorIndex), 10)

View File

@ -725,7 +725,6 @@ func (v *validator) RolesAt(ctx context.Context, slot primitives.Slot) (map[[fie
if aggregator { if aggregator {
roles = append(roles, iface.RoleAggregator) roles = append(roles, iface.RoleAggregator)
} }
} }
// Being assigned to a sync committee for a given slot means that the validator produces and // Being assigned to a sync committee for a given slot means that the validator produces and

View File

@ -172,5 +172,4 @@ func (km *Keymanager) ListKeymanagerAccounts(ctx context.Context, cfg keymanager
fmt.Println(" ") fmt.Println(" ")
} }
return nil return nil
} }

View File

@ -277,7 +277,6 @@ func (km *Keymanager) SaveStoreAndReInitialize(ctx context.Context, store *accou
accountsKeystore, err := CreateAccountsKeystoreRepresentation(ctx, store, km.wallet.Password()) accountsKeystore, err := CreateAccountsKeystoreRepresentation(ctx, store, km.wallet.Password())
if err != nil { if err != nil {
return err return err
} }
encodedAccounts, err := json.MarshalIndent(accountsKeystore, "", "\t") encodedAccounts, err := json.MarshalIndent(accountsKeystore, "", "\t")
if err != nil { if err != nil {

View File

@ -348,7 +348,6 @@ func MapBeaconBlockBodyAltair(body *ethpb.BeaconBlockBodyAltair) (*BeaconBlockBo
block.Deposits[i] = deposit block.Deposits[i] = deposit
} }
for i, exit := range body.VoluntaryExits { for i, exit := range body.VoluntaryExits {
exit, err := MapSignedVoluntaryExit(exit) exit, err := MapSignedVoluntaryExit(exit)
if err != nil { if err != nil {
return nil, fmt.Errorf("could not map signed voluntary exit at index %v: %v", i, err) return nil, fmt.Errorf("could not map signed voluntary exit at index %v: %v", i, err)

View File

@ -620,7 +620,6 @@ func MockForkInfo() *v1.ForkInfo {
}, },
GenesisValidatorsRoot: make([]byte, fieldparams.RootLength), GenesisValidatorsRoot: make([]byte, fieldparams.RootLength),
} }
} }
// MockAttestation is a mock implementation of the Attestation. // MockAttestation is a mock implementation of the Attestation.

View File

@ -230,7 +230,6 @@ func (c *ValidatorClient) initializeFromCLI(cliCtx *cli.Context) error {
"to use for your validator data", "to use for your validator data",
) )
} }
} }
if err := clearDB(cliCtx.Context, dataDir, forceClearFlag); err != nil { if err := clearDB(cliCtx.Context, dataDir, forceClearFlag); err != nil {
return err return err
@ -314,7 +313,6 @@ func (c *ValidatorClient) initializeForWeb(cliCtx *cli.Context) error {
"to use for your validator data", "to use for your validator data",
) )
} }
} }
if err := clearDB(cliCtx.Context, dataDir, forceClearFlag); err != nil { if err := clearDB(cliCtx.Context, dataDir, forceClearFlag); err != nil {
return err return err
@ -376,7 +374,6 @@ func (c *ValidatorClient) registerPrometheusService(cliCtx *cli.Context) error {
} }
func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error { func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error {
endpoint := c.cliCtx.String(flags.BeaconRPCProviderFlag.Name) endpoint := c.cliCtx.String(flags.BeaconRPCProviderFlag.Name)
dataDir := c.cliCtx.String(cmd.DataDirFlag.Name) dataDir := c.cliCtx.String(cmd.DataDirFlag.Name)
logValidatorBalances := !c.cliCtx.Bool(flags.DisablePenaltyRewardLogFlag.Name) logValidatorBalances := !c.cliCtx.Bool(flags.DisablePenaltyRewardLogFlag.Name)
@ -596,7 +593,6 @@ func proposerSettings(cliCtx *cli.Context) (*validatorServiceConfig.ProposerSett
}, },
BuilderConfig: option.BuilderConfig, BuilderConfig: option.BuilderConfig,
} }
} }
} }

View File

@ -42,7 +42,6 @@ func (s *Server) ExportSlashingProtection(ctx context.Context, _ *empty.Empty) (
return &pb.ExportSlashingProtectionResponse{ return &pb.ExportSlashingProtectionResponse{
File: string(encoded), File: string(encoded),
}, nil }, nil
} }
// ImportSlashingProtection reads an input slashing protection EIP-3076 // ImportSlashingProtection reads an input slashing protection EIP-3076

View File

@ -28,7 +28,6 @@ func (MockSlasher) HighestAttestations(_ context.Context, _ *eth.HighestAttestat
func (ms MockSlasher) IsSlashableAttestation(_ context.Context, in *eth.IndexedAttestation, _ ...grpc.CallOption) (*eth.AttesterSlashingResponse, error) { func (ms MockSlasher) IsSlashableAttestation(_ context.Context, in *eth.IndexedAttestation, _ ...grpc.CallOption) (*eth.AttesterSlashingResponse, error) {
ms.IsSlashableAttestationCalled = true // skipcq: RVV-B0006 ms.IsSlashableAttestationCalled = true // skipcq: RVV-B0006
if ms.SlashAttestation { if ms.SlashAttestation {
slashingAtt, ok := proto.Clone(in).(*eth.IndexedAttestation) slashingAtt, ok := proto.Clone(in).(*eth.IndexedAttestation)
if !ok { if !ok {
return nil, errors.New("object is not of type *eth.IndexedAttestation") return nil, errors.New("object is not of type *eth.IndexedAttestation")