Skip to content

Commit

Permalink
Fix revive:unused-parameter linter
Browse files Browse the repository at this point in the history
  • Loading branch information
KaloyanTanev committed Jul 18, 2024
1 parent 4fdf004 commit 4adfb52
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 42 deletions.
6 changes: 3 additions & 3 deletions app/health/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var checks = []check{
Name: "beacon_node_syncing",
Description: "Beacon Node in syncing state.",
Severity: severityCritical,
Func: func(q query, m Metadata) (bool, error) {
Func: func(q query, _ Metadata) (bool, error) {
max, err := q("app_monitoring_beacon_node_syncing", noLabels, gaugeMax)
if err != nil {
return false, err
Expand Down Expand Up @@ -97,7 +97,7 @@ var checks = []check{
Name: "pending_validators",
Description: "Pending validators detected. Activate them to start validating.",
Severity: severityInfo,
Func: func(q query, m Metadata) (bool, error) {
Func: func(q query, _ Metadata) (bool, error) {
max, err := q("core_scheduler_validator_status",
countLabels(l("status", "pending")),
gaugeMax)
Expand All @@ -112,7 +112,7 @@ var checks = []check{
Name: "proposal_failures",
Description: "Proposal failures detected. See <link to troubleshoot proposal failures>.",
Severity: severityWarning,
Func: func(q query, m Metadata) (bool, error) {
Func: func(q query, _ Metadata) (bool, error) {
increase, err := q("core_tracker_failed_duties_total",
sumLabels(l("duty", ".*proposal")), increase)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion app/log/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func InitLogger(config Config) error {
// WithClock returns a function that uses the provided clock to encode log timestamps.
func WithClock(clock clockwork.Clock) func(config *zapcore.EncoderConfig) {
return func(config *zapcore.EncoderConfig) {
config.EncodeTime = func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
config.EncodeTime = func(_ time.Time, enc zapcore.PrimitiveArrayEncoder) {
enc.AppendString(clock.Now().Format("15:04:05.000"))
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func errFields(err error) z.Field {
// is used and this avoids exporting the structured error type.
ferr, ok := err.(structErr) //nolint:errorlint
if !ok {
return func(add func(zap.Field)) {}
return func(func(zap.Field)) {}
}

return func(add func(zap.Field)) {
Expand Down
2 changes: 1 addition & 1 deletion app/tracer/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func WithStdOut(w io.Writer) func(*options) {
// if the address is not empty, else the default noop tracer is retained.
func WithJaegerOrNoop(jaegerAddr string) func(*options) {
if jaegerAddr == "" {
return func(o *options) {}
return func(*options) {}
}

return WithJaeger(jaegerAddr)
Expand Down
2 changes: 1 addition & 1 deletion app/z/zapfield.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ func Any(key string, val any) Field {
}

// Skip is a noop wrapped zap field similar to zap.Skip.
var Skip = func(add func(zap.Field)) {}
var Skip = func(func(zap.Field)) {}
2 changes: 1 addition & 1 deletion cmd/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func bindRelayFlag(cmd *cobra.Command, config *relay.Config) {
var advertisePriv bool
cmd.Flags().BoolVar(&advertisePriv, "p2p-advertise-private-addresses", false, "Enable advertising of libp2p auto-detected private addresses. This doesn't affect manually provided p2p-external-ip/hostname.")

wrapPreRunE(cmd, func(cmd *cobra.Command, args []string) error {
wrapPreRunE(cmd, func(*cobra.Command, []string) error {
// Invert p2p-advertise-private-addresses flag boolean:
// -- Do not ADVERTISE private addresses by default in the binary.
// -- Do not FILTER private addresses in unit tests.
Expand Down
2 changes: 1 addition & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func bindRunFlags(cmd *cobra.Command, config *app.Config) {
cmd.Flags().Int64Var(&config.TestnetConfig.GenesisTimestamp, "testnet-genesis-timestamp", 0, "Genesis timestamp of the custom test network.")
cmd.Flags().StringVar(&config.TestnetConfig.CapellaHardFork, "testnet-capella-hard-fork", "", "Capella hard fork version of the custom test network.")

wrapPreRunE(cmd, func(cmd *cobra.Command, args []string) error {
wrapPreRunE(cmd, func(*cobra.Command, []string) error {
if len(config.BeaconNodeAddrs) == 0 && !config.SimnetBMock {
return errors.New("either flag 'beacon-node-endpoints' or flag 'simnet-beacon-mock=true' must be specified")
}
Expand Down
4 changes: 2 additions & 2 deletions core/consensus/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ func newDefinition(nodes int, subs func() []subscriber, roundTimer roundTimer,
},

// LogRoundChange logs round changes at debug level.
LogRoundChange: func(ctx context.Context, duty core.Duty, process,
round, newRound int64, uponRule qbft.UponRule, msgs []qbft.Msg[core.Duty, [32]byte],
LogRoundChange: func(ctx context.Context, duty core.Duty, process, round, newRound int64, //nolint:revive // keep process variable name for clarity
uponRule qbft.UponRule, msgs []qbft.Msg[core.Duty, [32]byte],
) {
fields := []z.Field{
z.Any("rule", uponRule),
Expand Down
2 changes: 1 addition & 1 deletion core/consensus/roundtimer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type timerFunc func(core.Duty) roundTimer
// getTimerFunc returns a timer function based on the enabled features.
func getTimerFunc() timerFunc {
if featureset.Enabled(featureset.EagerDoubleLinear) {
return func(duty core.Duty) roundTimer {
return func(core.Duty) roundTimer {
return newDoubleEagerLinearRoundTimer()
}
}
Expand Down
2 changes: 1 addition & 1 deletion p2p/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type TestPingConfig struct {
// and collects metrics.
func NewPingService(h host.Host, peers []peer.ID, conf TestPingConfig) lifecycle.HookFuncCtx {
if conf.Disable {
return func(ctx context.Context) {}
return func(context.Context) {}
}

maxBackoff := time.Second * 30 // Sweet spot between not spamming, but snappy recovery.
Expand Down
2 changes: 1 addition & 1 deletion p2p/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func SetFuzzerDefaultsUnsafe() {
defaultWriterFunc = func(s network.Stream) pbio.Writer {
return fuzzReaderWriter{w: pbio.NewDelimitedWriter(s)}
}
defaultReaderFunc = func(s network.Stream) pbio.Reader {
defaultReaderFunc = func(network.Stream) pbio.Reader {
return fuzzReaderWriter{}
}
}
Expand Down
4 changes: 2 additions & 2 deletions testutil/beaconmock/beaconmock_fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func WithBeaconMockFuzzer() Option {
return duties, nil
}

mock.ProposerDutiesFunc = func(_ context.Context, epoch eth2p0.Epoch, indices []eth2p0.ValidatorIndex) ([]*eth2v1.ProposerDuty, error) {
mock.ProposerDutiesFunc = func(context.Context, eth2p0.Epoch, []eth2p0.ValidatorIndex) ([]*eth2v1.ProposerDuty, error) {
var duties []*eth2v1.ProposerDuty
fuzz.New().Fuzz(&duties)

Expand All @@ -115,7 +115,7 @@ func WithBeaconMockFuzzer() Option {
return block, nil
}

mock.AggregateAttestationFunc = func(ctx context.Context, slot eth2p0.Slot, attestationDataRoot eth2p0.Root) (*eth2p0.Attestation, error) {
mock.AggregateAttestationFunc = func(context.Context, eth2p0.Slot, eth2p0.Root) (*eth2p0.Attestation, error) {
var att *eth2p0.Attestation
fuzz.New().Fuzz(&att)

Expand Down
22 changes: 11 additions & 11 deletions testutil/beaconmock/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ var ValidatorSetA = ValidatorSet{
// WithValidatorSet configures the mock with the provided validator set.
func WithValidatorSet(set ValidatorSet) Option {
return func(mock *Mock) {
mock.ValidatorsByPubKeyFunc = func(ctx context.Context, stateID string, pubkeys []eth2p0.BLSPubKey) (map[eth2p0.ValidatorIndex]*eth2v1.Validator, error) {
mock.ValidatorsByPubKeyFunc = func(ctx context.Context, _ string, pubkeys []eth2p0.BLSPubKey) (map[eth2p0.ValidatorIndex]*eth2v1.Validator, error) {
resp := make(map[eth2p0.ValidatorIndex]*eth2v1.Validator)
if len(pubkeys) == 0 {
for idx, val := range set {
Expand Down Expand Up @@ -499,7 +499,7 @@ func defaultMock(httpMock HTTPMock, httpServer *http.Server, clock clockwork.Clo
HTTPMock: httpMock,
httpServer: httpServer,
headProducer: headProducer,
ProposalFunc: func(ctx context.Context, opts *eth2api.ProposalOpts) (*eth2api.VersionedProposal, error) {
ProposalFunc: func(_ context.Context, opts *eth2api.ProposalOpts) (*eth2api.VersionedProposal, error) {
var block *eth2api.VersionedProposal
if opts.BuilderBoostFactor == nil || *opts.BuilderBoostFactor == 0 {
block = &eth2api.VersionedProposal{
Expand All @@ -526,7 +526,7 @@ func defaultMock(httpMock HTTPMock, httpServer *http.Server, clock clockwork.Clo

return block, nil
},
SignedBeaconBlockFunc: func(_ context.Context, blockID string) (*eth2spec.VersionedSignedBeaconBlock, error) {
SignedBeaconBlockFunc: func(context.Context, string) (*eth2spec.VersionedSignedBeaconBlock, error) {
return testutil.RandomCapellaVersionedSignedBeaconBlock(), nil // Note the slot is probably wrong.
},
ProposerDutiesFunc: func(context.Context, eth2p0.Epoch, []eth2p0.ValidatorIndex) ([]*eth2v1.ProposerDuty, error) {
Expand All @@ -535,16 +535,16 @@ func defaultMock(httpMock HTTPMock, httpServer *http.Server, clock clockwork.Clo
AttesterDutiesFunc: func(context.Context, eth2p0.Epoch, []eth2p0.ValidatorIndex) ([]*eth2v1.AttesterDuty, error) {
return []*eth2v1.AttesterDuty{}, nil
},
BlockAttestationsFunc: func(ctx context.Context, stateID string) ([]*eth2p0.Attestation, error) {
BlockAttestationsFunc: func(context.Context, string) ([]*eth2p0.Attestation, error) {
return []*eth2p0.Attestation{}, nil
},
NodePeerCountFunc: func(ctx context.Context) (int, error) {
NodePeerCountFunc: func(context.Context) (int, error) {
return 80, nil
},
AttestationDataFunc: func(ctx context.Context, slot eth2p0.Slot, index eth2p0.CommitteeIndex) (*eth2p0.AttestationData, error) {
return attStore.NewAttestationData(ctx, slot, index)
},
AggregateAttestationFunc: func(ctx context.Context, slot eth2p0.Slot, root eth2p0.Root) (*eth2p0.Attestation, error) {
AggregateAttestationFunc: func(_ context.Context, _ eth2p0.Slot, root eth2p0.Root) (*eth2p0.Attestation, error) {
attData, err := attStore.AttestationDataByRoot(root)
if err != nil {
return nil, err
Expand All @@ -555,7 +555,7 @@ func defaultMock(httpMock HTTPMock, httpServer *http.Server, clock clockwork.Clo
Data: attData,
}, nil
},
CachedValidatorsFunc: func(_ context.Context) (eth2wrap.ActiveValidators, eth2wrap.CompleteValidators, error) {
CachedValidatorsFunc: func(context.Context) (eth2wrap.ActiveValidators, eth2wrap.CompleteValidators, error) {
return nil, nil, nil
},
ValidatorsFunc: func(context.Context, *eth2api.ValidatorsOpts) (map[eth2p0.ValidatorIndex]*eth2v1.Validator, error) {
Expand Down Expand Up @@ -590,7 +590,7 @@ func defaultMock(httpMock HTTPMock, httpServer *http.Server, clock clockwork.Clo
SubmitValidatorRegistrationsFunc: func(context.Context, []*eth2api.VersionedSignedValidatorRegistration) error {
return nil
},
AggregateBeaconCommitteeSelectionsFunc: func(ctx context.Context, selections []*eth2exp.BeaconCommitteeSelection) ([]*eth2exp.BeaconCommitteeSelection, error) {
AggregateBeaconCommitteeSelectionsFunc: func(_ context.Context, selections []*eth2exp.BeaconCommitteeSelection) ([]*eth2exp.BeaconCommitteeSelection, error) {
return selections, nil
},
SubmitAggregateAttestationsFunc: func(context.Context, []*eth2p0.SignedAggregateAndProof) error {
Expand All @@ -605,7 +605,7 @@ func defaultMock(httpMock HTTPMock, httpServer *http.Server, clock clockwork.Clo
SyncCommitteeDutiesFunc: func(context.Context, eth2p0.Epoch, []eth2p0.ValidatorIndex) ([]*eth2v1.SyncCommitteeDuty, error) {
return []*eth2v1.SyncCommitteeDuty{}, nil
},
AggregateSyncCommitteeSelectionsFunc: func(ctx context.Context, selections []*eth2exp.SyncCommitteeSelection) ([]*eth2exp.SyncCommitteeSelection, error) {
AggregateSyncCommitteeSelectionsFunc: func(_ context.Context, selections []*eth2exp.SyncCommitteeSelection) ([]*eth2exp.SyncCommitteeSelection, error) {
return selections, nil
},
SubmitSyncCommitteeMessagesFunc: func(context.Context, []*altair.SyncCommitteeMessage) error {
Expand All @@ -614,7 +614,7 @@ func defaultMock(httpMock HTTPMock, httpServer *http.Server, clock clockwork.Clo
SubmitSyncCommitteeSubscriptionsFunc: func(context.Context, []*eth2v1.SyncCommitteeSubscription) error {
return nil
},
SyncCommitteeContributionFunc: func(ctx context.Context, slot eth2p0.Slot, subcommitteeIndex uint64, beaconBlockRoot eth2p0.Root) (*altair.SyncCommitteeContribution, error) {
SyncCommitteeContributionFunc: func(_ context.Context, slot eth2p0.Slot, subcommitteeIndex uint64, beaconBlockRoot eth2p0.Root) (*altair.SyncCommitteeContribution, error) {
aggBits := bitfield.NewBitvector128()
aggBits.SetBitAt(uint64(slot%128), true)

Expand All @@ -637,7 +637,7 @@ func defaultMock(httpMock HTTPMock, httpServer *http.Server, clock clockwork.Clo

return eth2Resp.Data, nil
},
ProposerConfigFunc: func(ctx context.Context) (*eth2exp.ProposerConfigResponse, error) {
ProposerConfigFunc: func(context.Context) (*eth2exp.ProposerConfigResponse, error) {
return nil, nil
},
}
Expand Down
18 changes: 9 additions & 9 deletions testutil/beaconmock/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,30 @@ func newHTTPServer(addr string, optionalHandlers map[string]http.HandlerFunc, ov
shutdown := make(chan struct{})

endpoints := map[string]http.HandlerFunc{
"/up": func(w http.ResponseWriter, r *http.Request) {
"/up": func(http.ResponseWriter, *http.Request) {
// Can be used to test if server is up.
},
"/eth/v1/validator/sync_committee_subscriptions": func(w http.ResponseWriter, r *http.Request) {
"/eth/v1/validator/sync_committee_subscriptions": func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
},
"/eth/v1/validator/aggregate_attestation": func(w http.ResponseWriter, r *http.Request) {
"/eth/v1/validator/aggregate_attestation": func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusBadRequest)
_, _ = w.Write([]byte(`{"code": 403,"message": "Beacon node was not assigned to aggregate on that subnet."}`))
},
"/eth/v1/validator/beacon_committee_subscriptions": func(w http.ResponseWriter, r *http.Request) {
"/eth/v1/validator/beacon_committee_subscriptions": func(http.ResponseWriter, *http.Request) {
},
"/eth/v1/node/version": func(w http.ResponseWriter, r *http.Request) {
"/eth/v1/node/version": func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte(`{"data": {"version": "charon/static_beacon_mock"}}`))
},
"/eth/v1/node/syncing": func(w http.ResponseWriter, r *http.Request) {
"/eth/v1/node/syncing": func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte(`{"data": {"head_slot": "1","sync_distance": "0","is_syncing": false}}`))
},
"/eth/v1/beacon/headers/head": func(w http.ResponseWriter, r *http.Request) {
"/eth/v1/beacon/headers/head": func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte(`{"data": {"header": {"message": {"slot": "1"}}}}`))
},
"/eth/v1/validator/prepare_beacon_proposer": func(w http.ResponseWriter, r *http.Request) {
"/eth/v1/validator/prepare_beacon_proposer": func(http.ResponseWriter, *http.Request) {
},
"/eth/v1/events": func(w http.ResponseWriter, r *http.Request) {
"/eth/v1/events": func(_ http.ResponseWriter, r *http.Request) {
select {
case <-shutdown:
case <-r.Context().Done():
Expand Down
4 changes: 2 additions & 2 deletions testutil/compose/compose/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func newAutoCmd() *cobra.Command {
Use: "auto",
Short: "Convenience function that runs `compose define && compose lock && compose run`",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error { //nolint:revive // keep args variable name for clarity
err := compose.Auto(cmd.Context(), conf)
if err != nil {
log.Error(cmd.Context(), "auto command fatal error", err)
Expand All @@ -112,7 +112,7 @@ func newBuildLocalCmd() *cobra.Command {
Use: "build-local",
Short: "Builds the obolnetwork/charon:local docker container from the local source code. Note this requires the CHARON_REPO env var.",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error { //nolint:revive // keep args variable name for clarity
return compose.BuildLocal(cmd.Context())
},
}
Expand Down
2 changes: 1 addition & 1 deletion testutil/fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NewEth2Fuzzer(t *testing.T, seed int64) *fuzz.Fuzzer {
e.BlockHash = blockHash[:]
},
// Just zero BeaconBlockBody.Deposits to pass validation.
func(e *[]*eth2p0.Deposit, c fuzz.Continue) {
func(e *[]*eth2p0.Deposit, _ fuzz.Continue) {
*e = []*eth2p0.Deposit{}
},
// SyncAggregate.SyncCommitteeBits must have 64 bits
Expand Down
4 changes: 2 additions & 2 deletions testutil/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
)

// BuilderFalse is a core.BuilderEnabled function that always returns false.
var BuilderFalse = func(slot uint64) bool { return false }
var BuilderFalse = func(slot uint64) bool { return false } //nolint:revive // keep slot variable name for clarity

// BuilderTrue is a core.BuilderEnabled function that always returns true.
var BuilderTrue = func(slot uint64) bool { return true }
var BuilderTrue = func(slot uint64) bool { return true } //nolint:revive // keep slot variable name for clarity

// NewTCPNodeCallback returns a callback that can be used to connect a TCP node to all other TCP nodes.
func NewTCPNodeCallback(t *testing.T, protocols ...protocol.ID) func(host host.Host) {
Expand Down
2 changes: 1 addition & 1 deletion testutil/promrated/promrated/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func newRootCmd(runFunc func(context.Context, promrated.Config) error) *cobra.Co
Short: "Starts a promrated server",
Long: `Starts a promrated server that polls rated and makes metrics available to prometheus`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error { //nolint:revive // keep args variable name for clarity
return runFunc(cmd.Context(), config)
},
}
Expand Down

0 comments on commit 4adfb52

Please sign in to comment.