From e2db0e2ea7317b54ba8deebe8c01a7badef9c621 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:29:33 +0100 Subject: [PATCH] chore: fix lint warnings --- abci/server/grpc_server.go | 2 +- abci/tests/server/client.go | 2 +- abci/types/application.go | 20 ++++++++--------- cmd/abcidump/cmd/capture.go | 2 +- cmd/abcidump/cmd/cbor.go | 4 ++-- cmd/abcidump/cmd/parse.go | 4 ++-- cmd/tenderdash/commands/gen_node_key.go | 4 ++-- cmd/tenderdash/commands/reset.go | 2 +- crypto/secp256k1/secp256k1.go | 6 ++--- dash/quorum/validator_conn_executor_test.go | 4 ++-- internal/blocksync/reactor_test.go | 4 ++-- internal/consensus/common_test.go | 8 +++---- internal/consensus/mempool_test.go | 4 ++-- internal/consensus/pbts_test.go | 2 +- internal/consensus/reactor.go | 2 +- internal/consensus/replay_stubs.go | 16 ++++++------- internal/consensus/replay_test.go | 10 ++++----- internal/consensus/state_test.go | 1 - internal/consensus/wal.go | 14 ++++++------ internal/consensus/wal_generator_test.go | 7 +++--- internal/evidence/pool_test.go | 15 ++++++------- internal/libs/clist/clist_property_test.go | 2 +- internal/p2p/peermanager.go | 3 ++- internal/p2p/router.go | 2 +- internal/p2p/rqueue.go | 2 +- internal/p2p/rqueue_test.go | 2 +- internal/rpc/core/net.go | 4 ++-- internal/rpc/core/tx.go | 2 +- internal/state/helpers_test.go | 8 +++---- internal/state/indexer/block/null/null.go | 4 ++-- internal/state/indexer/sink/psql/psql.go | 8 +++---- internal/state/indexer/tx/null/null.go | 8 +++---- internal/state/services.go | 6 ++--- internal/state/state_test.go | 2 +- internal/statesync/dispatcher.go | 2 +- internal/statesync/peer_test.go | 2 +- internal/statesync/reactor.go | 4 ++-- internal/statesync/reactor_test.go | 2 +- internal/store/store.go | 2 +- internal/store/store_test.go | 25 ++++++++++----------- internal/test/factory/commit.go | 1 - libs/cli/setup.go | 2 +- light/client.go | 6 ++--- light/client_benchmark_test.go | 2 +- light/proxy/routes.go | 2 +- light/store/db/db_test.go | 2 +- node/node_test.go | 2 +- rpc/client/http/ws.go | 6 ++--- rpc/client/local/local.go | 2 +- rpc/client/mock/abci.go | 12 +++++----- rpc/client/mock/status.go | 2 +- rpc/jsonrpc/jsonrpc_test.go | 10 ++++----- test/e2e/pkg/infra/docker/infra.go | 2 +- test/e2e/pkg/mockcoreserver/core_server.go | 2 +- 54 files changed, 137 insertions(+), 139 deletions(-) diff --git a/abci/server/grpc_server.go b/abci/server/grpc_server.go index 00821a843c..21bb42b03e 100644 --- a/abci/server/grpc_server.go +++ b/abci/server/grpc_server.go @@ -74,6 +74,6 @@ func (app *gRPCApplication) Echo(_ context.Context, req *types.RequestEcho) (*ty return &types.ResponseEcho{Message: req.Message}, nil } -func (app *gRPCApplication) Flush(_ context.Context, req *types.RequestFlush) (*types.ResponseFlush, error) { +func (app *gRPCApplication) Flush(_ context.Context, _req *types.RequestFlush) (*types.ResponseFlush, error) { return &types.ResponseFlush{}, nil } diff --git a/abci/tests/server/client.go b/abci/tests/server/client.go index 162f1a0007..687a17f25f 100644 --- a/abci/tests/server/client.go +++ b/abci/tests/server/client.go @@ -91,7 +91,7 @@ func FinalizeBlock(ctx context.Context, client abciclient.Client, txBytes [][]by return nil } -func PrepareProposal(ctx context.Context, client abciclient.Client, txBytes [][]byte, codeExp []types.TxRecord_TxAction, dataExp []byte) error { +func PrepareProposal(ctx context.Context, client abciclient.Client, txBytes [][]byte, codeExp []types.TxRecord_TxAction, _dataExp []byte) error { res, _ := client.PrepareProposal(ctx, &types.RequestPrepareProposal{Txs: txBytes}) for i, tx := range res.TxRecords { if tx.Action != codeExp[i] { diff --git a/abci/types/application.go b/abci/types/application.go index 19b52612f3..407c381ef7 100644 --- a/abci/types/application.go +++ b/abci/types/application.go @@ -55,37 +55,37 @@ func NewBaseApplication() *BaseApplication { return &BaseApplication{} } -func (BaseApplication) Info(_ context.Context, req *RequestInfo) (*ResponseInfo, error) { +func (BaseApplication) Info(_ context.Context, _req *RequestInfo) (*ResponseInfo, error) { return &ResponseInfo{}, nil } -func (BaseApplication) CheckTx(_ context.Context, req *RequestCheckTx) (*ResponseCheckTx, error) { +func (BaseApplication) CheckTx(_ context.Context, _req *RequestCheckTx) (*ResponseCheckTx, error) { return &ResponseCheckTx{Code: CodeTypeOK}, nil } -func (BaseApplication) ExtendVote(_ context.Context, req *RequestExtendVote) (*ResponseExtendVote, error) { +func (BaseApplication) ExtendVote(_ context.Context, _req *RequestExtendVote) (*ResponseExtendVote, error) { return &ResponseExtendVote{}, nil } -func (BaseApplication) VerifyVoteExtension(_ context.Context, req *RequestVerifyVoteExtension) (*ResponseVerifyVoteExtension, error) { +func (BaseApplication) VerifyVoteExtension(_ context.Context, _req *RequestVerifyVoteExtension) (*ResponseVerifyVoteExtension, error) { return &ResponseVerifyVoteExtension{ Status: ResponseVerifyVoteExtension_ACCEPT, }, nil } -func (BaseApplication) Query(_ context.Context, req *RequestQuery) (*ResponseQuery, error) { +func (BaseApplication) Query(_ context.Context, _req *RequestQuery) (*ResponseQuery, error) { return &ResponseQuery{Code: CodeTypeOK}, nil } -func (BaseApplication) InitChain(_ context.Context, req *RequestInitChain) (*ResponseInitChain, error) { +func (BaseApplication) InitChain(_ context.Context, _req *RequestInitChain) (*ResponseInitChain, error) { return &ResponseInitChain{}, nil } -func (BaseApplication) ListSnapshots(_ context.Context, req *RequestListSnapshots) (*ResponseListSnapshots, error) { +func (BaseApplication) ListSnapshots(_ context.Context, _req *RequestListSnapshots) (*ResponseListSnapshots, error) { return &ResponseListSnapshots{}, nil } -func (BaseApplication) OfferSnapshot(_ context.Context, req *RequestOfferSnapshot) (*ResponseOfferSnapshot, error) { +func (BaseApplication) OfferSnapshot(_ context.Context, _req *RequestOfferSnapshot) (*ResponseOfferSnapshot, error) { return &ResponseOfferSnapshot{}, nil } @@ -93,7 +93,7 @@ func (BaseApplication) LoadSnapshotChunk(_ context.Context, _ *RequestLoadSnapsh return &ResponseLoadSnapshotChunk{}, nil } -func (BaseApplication) ApplySnapshotChunk(_ context.Context, req *RequestApplySnapshotChunk) (*ResponseApplySnapshotChunk, error) { +func (BaseApplication) ApplySnapshotChunk(_ context.Context, _req *RequestApplySnapshotChunk) (*ResponseApplySnapshotChunk, error) { return &ResponseApplySnapshotChunk{}, nil } @@ -132,7 +132,7 @@ func (BaseApplication) ProcessProposal(_ context.Context, req *RequestProcessPro }, nil } -func (BaseApplication) FinalizeBlock(_ context.Context, req *RequestFinalizeBlock) (*ResponseFinalizeBlock, error) { +func (BaseApplication) FinalizeBlock(_ context.Context, _req *RequestFinalizeBlock) (*ResponseFinalizeBlock, error) { return &ResponseFinalizeBlock{}, nil } diff --git a/cmd/abcidump/cmd/capture.go b/cmd/abcidump/cmd/capture.go index f05d359efe..af76ebdd8e 100644 --- a/cmd/abcidump/cmd/capture.go +++ b/cmd/abcidump/cmd/capture.go @@ -68,7 +68,7 @@ func (captureCmd *CaptureCmd) Command() *cobra.Command { } // RunE executes traffic capture -func (captureCmd *CaptureCmd) RunE(cmd *cobra.Command, args []string) error { +func (captureCmd *CaptureCmd) RunE(_cmd *cobra.Command, _args []string) error { logger.Debug("Starting packet capture", "port", captureCmd.Port) return captureCmd.capture() diff --git a/cmd/abcidump/cmd/cbor.go b/cmd/abcidump/cmd/cbor.go index 69d3769914..827260871e 100644 --- a/cmd/abcidump/cmd/cbor.go +++ b/cmd/abcidump/cmd/cbor.go @@ -54,7 +54,7 @@ func (cborCmd *CborCmd) Command() *cobra.Command { } // PreRunE parses command line arguments -func (cborCmd *CborCmd) PreRunE(_ *cobra.Command, args []string) (err error) { +func (cborCmd *CborCmd) PreRunE(_ *cobra.Command, _args []string) (err error) { if cborCmd.Input, err = loadInputData(cborCmd.InputData, cborCmd.InputFormat); err != nil { return err } @@ -142,7 +142,7 @@ func marshalMap(mapToMarshal map[interface{}]interface{}, indent []byte, out io. } // RunE executes main logic of this command -func (cborCmd *CborCmd) RunE(_ *cobra.Command, args []string) error { +func (cborCmd *CborCmd) RunE(_ *cobra.Command, _args []string) error { data, err := io.ReadAll(cborCmd.Input) if err != nil { return fmt.Errorf("cannot read data: %w", err) diff --git a/cmd/abcidump/cmd/parse.go b/cmd/abcidump/cmd/parse.go index 7739a7967a..b0c750f2bc 100644 --- a/cmd/abcidump/cmd/parse.go +++ b/cmd/abcidump/cmd/parse.go @@ -72,7 +72,7 @@ func (parseCmd *ParseCmd) Command() *cobra.Command { } // PreRunE parses command line arguments -func (parseCmd *ParseCmd) PreRunE(cmd *cobra.Command, args []string) (err error) { +func (parseCmd *ParseCmd) PreRunE(_cmd *cobra.Command, _args []string) (err error) { if parseCmd.Input, err = loadInputData(parseCmd.InputData, parseCmd.InputFormat); err != nil { return err } @@ -114,7 +114,7 @@ func loadInputData(input, format string) (reader io.Reader, err error) { } // RunE executes parsing logic -func (parseCmd *ParseCmd) RunE(cmd *cobra.Command, args []string) error { +func (parseCmd *ParseCmd) RunE(cmd *cobra.Command, _args []string) error { var err error parser := parser.NewParser(cmd.InOrStdin()) diff --git a/cmd/tenderdash/commands/gen_node_key.go b/cmd/tenderdash/commands/gen_node_key.go index 3141662058..a17a95a8a5 100644 --- a/cmd/tenderdash/commands/gen_node_key.go +++ b/cmd/tenderdash/commands/gen_node_key.go @@ -57,7 +57,7 @@ Seed phrase and optional password is read from standard input.`, return cmd } -func genNodeKeyFlagsPreRunE(cmd *cobra.Command, args []string) error { +func genNodeKeyFlagsPreRunE(_cmd *cobra.Command, _args []string) error { if useSeedPhrase && pemFile != "" { return fmt.Errorf("--%s cannot be be used with --%s", flagFromMnemonic, flagFromPem) } @@ -138,7 +138,7 @@ func readMnemonic(in io.Reader, out io.Writer) (mnemonic string, password string } // nodeKeyFromMnemonic reads BIP39 mnemonic and optional passphrase from stdin, and derives node key from it. -func nodeKeyFromMnemonic(cmd *cobra.Command, args []string) (types.NodeKey, error) { +func nodeKeyFromMnemonic(cmd *cobra.Command, _args []string) (types.NodeKey, error) { mnemonic, password, err := readMnemonic(cmd.InOrStdin(), cmd.OutOrStdout()) if err != nil { return types.NodeKey{}, err diff --git a/cmd/tenderdash/commands/reset.go b/cmd/tenderdash/commands/reset.go index a8c491dcfe..30822ddcdd 100644 --- a/cmd/tenderdash/commands/reset.go +++ b/cmd/tenderdash/commands/reset.go @@ -146,7 +146,7 @@ func ResetState(dbDir string, logger log.Logger) error { // ResetFilePV loads the file private validator and resets the watermark to 0. If used on an existing network, // this can cause the node to double sign. // XXX: this is unsafe and should only suitable for testnets. -func ResetFilePV(privValKeyFile, privValStateFile string, logger log.Logger, keyType string) error { +func ResetFilePV(privValKeyFile, privValStateFile string, logger log.Logger, _keyType string) error { if _, err := os.Stat(privValKeyFile); err == nil { pv, err := privval.LoadFilePVEmptyState(privValKeyFile, privValStateFile) if err != nil { diff --git a/crypto/secp256k1/secp256k1.go b/crypto/secp256k1/secp256k1.go index 1827a126f8..bbb23e1fe3 100644 --- a/crypto/secp256k1/secp256k1.go +++ b/crypto/secp256k1/secp256k1.go @@ -254,15 +254,15 @@ func (privKey PrivKey) SignDigest(msg []byte) ([]byte, error) { return sigBytes, nil } -func (pubKey PubKey) AggregateSignatures(sigSharesData [][]byte, messages [][]byte) ([]byte, error) { +func (pubKey PubKey) AggregateSignatures(_sigSharesData [][]byte, _messages [][]byte) ([]byte, error) { return nil, errors.New("should not aggregate an edwards signature") } -func (pubKey PubKey) VerifyAggregateSignature(messages [][]byte, sig []byte) bool { +func (pubKey PubKey) VerifyAggregateSignature(_messages [][]byte, _sig []byte) bool { return false } -func (pubKey PubKey) VerifySignatureDigest(hash []byte, sig []byte) bool { +func (pubKey PubKey) VerifySignatureDigest(_hash []byte, _sig []byte) bool { return false } diff --git a/dash/quorum/validator_conn_executor_test.go b/dash/quorum/validator_conn_executor_test.go index e5fb35705c..a54bf180c4 100644 --- a/dash/quorum/validator_conn_executor_test.go +++ b/dash/quorum/validator_conn_executor_test.go @@ -592,7 +592,7 @@ func setup( } // cleanup frees some resources allocated for tests -func cleanup(t *testing.T, bus *eventbus.EventBus, dialer p2p.DashDialer, vc *ValidatorConnExecutor) { +func cleanup(_t *testing.T, bus *eventbus.EventBus, _dialer p2p.DashDialer, vc *ValidatorConnExecutor) { bus.Stop() vc.Stop() } @@ -620,7 +620,7 @@ func makeState(nVals int, height int64) (sm.State, dbm.DB) { return s, stateDB } -func makeBlock(ctx context.Context, t *testing.T, blockExec *sm.BlockExecutor, state sm.State, height int64, commit *types.Commit) *types.Block { +func makeBlock(ctx context.Context, t *testing.T, blockExec *sm.BlockExecutor, state sm.State, _height int64, commit *types.Commit) *types.Block { block, crs, err := blockExec.CreateProposalBlock(ctx, 1, 0, state, commit, state.Validators.Proposer.ProTxHash, 1) require.NoError(t, err) diff --git a/internal/blocksync/reactor_test.go b/internal/blocksync/reactor_test.go index a882b2e2a4..2585935952 100644 --- a/internal/blocksync/reactor_test.go +++ b/internal/blocksync/reactor_test.go @@ -102,9 +102,9 @@ func makeReactor( t *testing.T, conf *config.Config, proTxHash types.ProTxHash, - nodeID types.NodeID, + _nodeID types.NodeID, genDoc *types.GenesisDoc, - privVal types.PrivValidator, + _privVal types.PrivValidator, channelCreator p2p.ChannelCreator, peerEvents p2p.PeerEventSubscriber) *Reactor { diff --git a/internal/consensus/common_test.go b/internal/consensus/common_test.go index 807dbea5d0..15a65f6c1c 100644 --- a/internal/consensus/common_test.go +++ b/internal/consensus/common_test.go @@ -175,7 +175,7 @@ func signVotes( voteType tmproto.SignedMsgType, chainID string, blockID types.BlockID, - appHash []byte, + _appHash []byte, quorumType btcjson.LLMQType, quorumHash crypto.QuorumHash, vss ...*validatorStub, @@ -362,7 +362,7 @@ func validatePrevote( } } -func validateLastCommit(ctx context.Context, t *testing.T, cs *State, privVal *validatorStub, blockHash []byte) { +func validateLastCommit(_ctx context.Context, t *testing.T, cs *State, _privVal *validatorStub, blockHash []byte) { t.Helper() stateData := cs.GetStateData() @@ -852,7 +852,7 @@ func consensusLogger(t *testing.T) log.Logger { func makeConsensusState( ctx context.Context, t *testing.T, - cfg *config.Config, + _cfg *config.Config, nValidators int, testName string, tickerFunc func() TimeoutTicker, @@ -1031,7 +1031,7 @@ type genesisStateArgs struct { Time time.Time } -func makeGenesisState(ctx context.Context, t *testing.T, cfg *config.Config, args genesisStateArgs) (sm.State, []types.PrivValidator) { +func makeGenesisState(_ctx context.Context, t *testing.T, _cfg *config.Config, args genesisStateArgs) (sm.State, []types.PrivValidator) { t.Helper() if args.Power == 0 { args.Power = 1 diff --git a/internal/consensus/mempool_test.go b/internal/consensus/mempool_test.go index a3f75e729e..6d5712da17 100644 --- a/internal/consensus/mempool_test.go +++ b/internal/consensus/mempool_test.go @@ -285,7 +285,7 @@ func NewCounterApplication() *CounterApplication { return &CounterApplication{} } -func (app *CounterApplication) Info(_ context.Context, req *abci.RequestInfo) (*abci.ResponseInfo, error) { +func (app *CounterApplication) Info(_ context.Context, _req *abci.RequestInfo) (*abci.ResponseInfo, error) { app.mu.Lock() defer app.mu.Unlock() @@ -310,7 +310,7 @@ func (app *CounterApplication) txResults(txs [][]byte) []*abci.ExecTxResult { return respTxs } -func (app *CounterApplication) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { +func (app *CounterApplication) FinalizeBlock(_ context.Context, _req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { return &abci.ResponseFinalizeBlock{}, nil } diff --git a/internal/consensus/pbts_test.go b/internal/consensus/pbts_test.go index 203fc32f46..c1cb643397 100644 --- a/internal/consensus/pbts_test.go +++ b/internal/consensus/pbts_test.go @@ -239,7 +239,7 @@ func timestampedCollector(ctx context.Context, t *testing.T, eb *eventbus.EventB return eventCh } -func collectHeightResults(ctx context.Context, t *testing.T, eventCh <-chan timestampedEvent, height int64, proTxHash crypto.ProTxHash) heightResult { +func collectHeightResults(_ctx context.Context, t *testing.T, eventCh <-chan timestampedEvent, height int64, proTxHash crypto.ProTxHash) heightResult { t.Helper() var res heightResult for event := range eventCh { diff --git a/internal/consensus/reactor.go b/internal/consensus/reactor.go index fc9cb337d8..145c19f7a2 100644 --- a/internal/consensus/reactor.go +++ b/internal/consensus/reactor.go @@ -497,7 +497,7 @@ func (r *Reactor) peerUp(ctx context.Context, peerUpdate p2p.PeerUpdate, retries } } -func (r *Reactor) peerDown(_ context.Context, peerUpdate p2p.PeerUpdate, chans channelBundle) { +func (r *Reactor) peerDown(_ context.Context, peerUpdate p2p.PeerUpdate, _chans channelBundle) { r.mtx.RLock() ps, ok := r.peers[peerUpdate.NodeID] r.mtx.RUnlock() diff --git a/internal/consensus/replay_stubs.go b/internal/consensus/replay_stubs.go index 3d4ede0523..c0b52b6c2e 100644 --- a/internal/consensus/replay_stubs.go +++ b/internal/consensus/replay_stubs.go @@ -25,7 +25,7 @@ func (emptyMempool) Size() int { return 0 } func (emptyMempool) CheckTx(context.Context, types.Tx, func(*abci.ResponseCheckTx), mempool.TxInfo) error { return nil } -func (emptyMempool) RemoveTxByKey(txKey types.TxKey) error { return nil } +func (emptyMempool) RemoveTxByKey(_txKey types.TxKey) error { return nil } func (emptyMempool) ReapMaxBytesMaxGas(_, _ int64) types.Txs { return types.Txs{} } func (emptyMempool) ReapMaxTxs(_n int) types.Txs { return types.Txs{} } func (emptyMempool) Update( @@ -39,11 +39,11 @@ func (emptyMempool) Update( ) error { return nil } -func (emptyMempool) Flush() {} -func (emptyMempool) FlushAppConn(ctx context.Context) error { return nil } -func (emptyMempool) TxsAvailable() <-chan struct{} { return make(chan struct{}) } -func (emptyMempool) EnableTxsAvailable() {} -func (emptyMempool) SizeBytes() int64 { return 0 } +func (emptyMempool) Flush() {} +func (emptyMempool) FlushAppConn(_ctx context.Context) error { return nil } +func (emptyMempool) TxsAvailable() <-chan struct{} { return make(chan struct{}) } +func (emptyMempool) EnableTxsAvailable() {} +func (emptyMempool) SizeBytes() int64 { return 0 } func (emptyMempool) TxsFront() *clist.CElement { return nil } func (emptyMempool) TxsWaitChan() <-chan struct{} { return nil } @@ -104,7 +104,7 @@ type mockProxyApp struct { abciResponses *tmstate.ABCIResponses } -func (mock *mockProxyApp) ProcessProposal(_ context.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { +func (mock *mockProxyApp) ProcessProposal(_ context.Context, _req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { r := mock.abciResponses.ProcessProposal if r == nil { return &abci.ResponseProcessProposal{}, nil @@ -112,7 +112,7 @@ func (mock *mockProxyApp) ProcessProposal(_ context.Context, req *abci.RequestPr return r, nil } -func (mock *mockProxyApp) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { +func (mock *mockProxyApp) FinalizeBlock(_ context.Context, _req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { r := mock.abciResponses.FinalizeBlock mock.txCount++ if r == nil { diff --git a/internal/consensus/replay_test.go b/internal/consensus/replay_test.go index a82fe66731..d6ef79b79d 100644 --- a/internal/consensus/replay_test.go +++ b/internal/consensus/replay_test.go @@ -1212,10 +1212,10 @@ func (bs *mockBlockStore) Base() int64 { return bs.base } func (bs *mockBlockStore) Size() int64 { return bs.Height() - bs.Base() + 1 } func (bs *mockBlockStore) LoadBaseMeta() *types.BlockMeta { return bs.LoadBlockMeta(bs.base) } func (bs *mockBlockStore) LoadBlock(height int64) *types.Block { return bs.chain[height-1] } -func (bs *mockBlockStore) LoadBlockByHash(hash []byte) *types.Block { +func (bs *mockBlockStore) LoadBlockByHash(_hash []byte) *types.Block { return bs.chain[int64(len(bs.chain))-1] } -func (bs *mockBlockStore) LoadBlockMetaByHash(hash []byte) *types.BlockMeta { return nil } +func (bs *mockBlockStore) LoadBlockMetaByHash(_hash []byte) *types.BlockMeta { return nil } func (bs *mockBlockStore) LoadBlockMeta(height int64) *types.BlockMeta { block := bs.chain[height-1] bps, err := block.MakePartSet(types.BlockPartSizeBytes) @@ -1227,10 +1227,10 @@ func (bs *mockBlockStore) LoadBlockMeta(height int64) *types.BlockMeta { Header: block.Header, } } -func (bs *mockBlockStore) LoadBlockPart(height int64, index int) *types.Part { return nil } +func (bs *mockBlockStore) LoadBlockPart(_height int64, _index int) *types.Part { return nil } func (bs *mockBlockStore) SaveBlock( block *types.Block, - blockParts *types.PartSet, + _blockParts *types.PartSet, seenCommit *types.Commit, ) { bs.chain = append(bs.chain, block) @@ -1456,7 +1456,7 @@ type initChainApp struct { initialCoreHeight uint32 } -func (ica *initChainApp) InitChain(_ context.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { +func (ica *initChainApp) InitChain(_ context.Context, _req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { resp := abci.ResponseInitChain{ InitialCoreHeight: ica.initialCoreHeight, } diff --git a/internal/consensus/state_test.go b/internal/consensus/state_test.go index 2c3587b114..7825c0a828 100644 --- a/internal/consensus/state_test.go +++ b/internal/consensus/state_test.go @@ -3164,7 +3164,6 @@ func TestStateTryAddCommitCallsProcessProposal(t *testing.T) { css0StateData.Votes.Precommits(0), css0StateData.Validators, privvals, - block.StateID(), ) require.NoError(t, err) diff --git a/internal/consensus/wal.go b/internal/consensus/wal.go index b615058bb1..6f5fe608ad 100644 --- a/internal/consensus/wal.go +++ b/internal/consensus/wal.go @@ -440,12 +440,12 @@ type nilWAL struct{} var _ WAL = nilWAL{} -func (nilWAL) Write(m WALMessage) error { return nil } -func (nilWAL) WriteSync(m WALMessage) error { return nil } -func (nilWAL) FlushAndSync() error { return nil } -func (nilWAL) SearchForEndHeight(height int64, options *WALSearchOptions) (rd io.ReadCloser, found bool, err error) { +func (nilWAL) Write(_m WALMessage) error { return nil } +func (nilWAL) WriteSync(_m WALMessage) error { return nil } +func (nilWAL) FlushAndSync() error { return nil } +func (nilWAL) SearchForEndHeight(_height int64, _options *WALSearchOptions) (rd io.ReadCloser, found bool, err error) { return nil, false, nil } -func (nilWAL) Start(context.Context) error { return nil } -func (nilWAL) Stop() {} -func (nilWAL) Wait() {} +func (nilWAL) Start(_ctx context.Context) error { return nil } +func (nilWAL) Stop() {} +func (nilWAL) Wait() {} diff --git a/internal/consensus/wal_generator_test.go b/internal/consensus/wal_generator_test.go index 15a1a9d9c6..ab5ec26667 100644 --- a/internal/consensus/wal_generator_test.go +++ b/internal/consensus/wal_generator_test.go @@ -11,9 +11,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/dashpay/tenderdash/config" "github.com/dashpay/tenderdash/libs/log" - "github.com/stretchr/testify/require" ) // WALGenerateNBlocks generates a consensus WAL. It does this by @@ -157,8 +158,8 @@ func (w *byteBufferWAL) WriteSync(m WALMessage) error { func (w *byteBufferWAL) FlushAndSync() error { return nil } func (w *byteBufferWAL) SearchForEndHeight( - height int64, - options *WALSearchOptions) (rd io.ReadCloser, found bool, err error) { + _height int64, + _options *WALSearchOptions) (rd io.ReadCloser, found bool, err error) { return nil, false, nil } diff --git a/internal/evidence/pool_test.go b/internal/evidence/pool_test.go index 1669a47146..40f605e444 100644 --- a/internal/evidence/pool_test.go +++ b/internal/evidence/pool_test.go @@ -259,7 +259,7 @@ func TestEvidencePoolUpdate(t *testing.T) { state.Validators.QuorumHash, ) require.NoError(t, err) - lastCommit := makeCommit(height, state.Validators.QuorumHash, val.ProTxHash) + lastCommit := makeCommit(height, state.Validators.QuorumHash) coreChainLockHeight := state.LastCoreChainLockedBlockHeight block := types.MakeBlock(height+1, []types.Tx{}, lastCommit, []types.Evidence{ev}) @@ -402,14 +402,13 @@ func TestRecoverPendingEvidence(t *testing.T) { height := int64(10) quorumHash := crypto.RandQuorumHash() val := types.NewMockPVForQuorum(quorumHash) - proTxHash := val.ProTxHash evidenceDB := dbm.NewMemDB() stateStore := initializeValidatorState(ctx, t, val, height, btcjson.LLMQType_5_60, quorumHash) state, err := stateStore.Load() require.NoError(t, err) - blockStore, err := initializeBlockStore(dbm.NewMemDB(), state, proTxHash) + blockStore, err := initializeBlockStore(dbm.NewMemDB(), state) require.NoError(t, err) logger := log.NewNopLogger() @@ -536,11 +535,11 @@ func initializeValidatorState( // initializeBlockStore creates a block storage and populates it w/ a dummy // block at +height+. -func initializeBlockStore(db dbm.DB, state sm.State, valProTxHash []byte) (*store.BlockStore, error) { +func initializeBlockStore(db dbm.DB, state sm.State) (*store.BlockStore, error) { blockStore := store.NewBlockStore(db) for i := int64(1); i <= state.LastBlockHeight; i++ { - lastCommit := makeCommit(i-1, state.Validators.QuorumHash, valProTxHash) + lastCommit := makeCommit(i-1, state.Validators.QuorumHash) block := state.MakeBlock(i, []types.Tx{}, lastCommit, nil, state.Validators.GetProposer().ProTxHash, 0) block.Header.Time = defaultEvidenceTime.Add(time.Duration(i) * time.Minute) @@ -551,14 +550,14 @@ func initializeBlockStore(db dbm.DB, state sm.State, valProTxHash []byte) (*stor return nil, err } - seenCommit := makeCommit(i, state.Validators.QuorumHash, valProTxHash) + seenCommit := makeCommit(i, state.Validators.QuorumHash) blockStore.SaveBlock(block, partSet, seenCommit) } return blockStore, nil } -func makeCommit(height int64, quorumHash []byte, valProTxHash []byte) *types.Commit { +func makeCommit(height int64, quorumHash []byte) *types.Commit { return types.NewCommit( height, 0, @@ -581,7 +580,7 @@ func defaultTestPool(ctx context.Context, t *testing.T, height int64) (*evidence stateStore := initializeValidatorState(ctx, t, val, height, btcjson.LLMQType_5_60, quorumHash) state, err := stateStore.Load() require.NoError(t, err) - blockStore, err := initializeBlockStore(dbm.NewMemDB(), state, val.ProTxHash) + blockStore, err := initializeBlockStore(dbm.NewMemDB(), state) require.NoError(t, err) logger := log.NewNopLogger() diff --git a/internal/libs/clist/clist_property_test.go b/internal/libs/clist/clist_property_test.go index b33ab21aa3..c8c332c255 100644 --- a/internal/libs/clist/clist_property_test.go +++ b/internal/libs/clist/clist_property_test.go @@ -25,7 +25,7 @@ type clistModel struct { // Init is a method used by the rapid state machine testing library. // Init is called when the test starts to initialize the data that will be used // in the state machine test. -func (m *clistModel) Init(t *rapid.T) { +func (m *clistModel) Init(_t *rapid.T) { m.clist = clist.New() m.model = []*clist.CElement{} } diff --git a/internal/p2p/peermanager.go b/internal/p2p/peermanager.go index fe0ce29291..c818be9a5a 100644 --- a/internal/p2p/peermanager.go +++ b/internal/p2p/peermanager.go @@ -683,7 +683,7 @@ func (m *PeerManager) DialFailed(ctx context.Context, address NodeAddress) error } // scheduleDial will dial peers after some delay -func (m *PeerManager) scheduleDial(ctx context.Context, delay time.Duration) { +func (m *PeerManager) scheduleDial(_ctx context.Context, delay time.Duration) { if delay > 0 && delay != retryNever { m.dialWaker.WakeAfter(delay) } else { @@ -991,6 +991,7 @@ func (m *PeerManager) Disconnected(ctx context.Context, peerID types.NodeID) { // FIXME: This will cause the peer manager to immediately try to reconnect to // the peer, which is probably not always what we want. func (m *PeerManager) Errored(peerID types.NodeID, err error) { + m.logger.Error("peer errored", "peer", peerID, "error", err) m.mtx.Lock() defer m.mtx.Unlock() diff --git a/internal/p2p/router.go b/internal/p2p/router.go index ed6e2c0d52..644fcb7592 100644 --- a/internal/p2p/router.go +++ b/internal/p2p/router.go @@ -230,7 +230,7 @@ func (r *Router) createQueueFactory(ctx context.Context) (func(int) queue, error }, nil case queueTypeSimplePriority: - return func(size int) queue { return newSimplePriorityQueue(ctx, size, r.chDescs) }, nil + return func(size int) queue { return newSimplePriorityQueue(ctx, size) }, nil default: return nil, fmt.Errorf("cannot construct queue of type %q", r.options.QueueType) diff --git a/internal/p2p/rqueue.go b/internal/p2p/rqueue.go index 8d6406864a..a46eefe50f 100644 --- a/internal/p2p/rqueue.go +++ b/internal/p2p/rqueue.go @@ -19,7 +19,7 @@ type simpleQueue struct { chDescs []*ChannelDescriptor } -func newSimplePriorityQueue(ctx context.Context, size int, chDescs []*ChannelDescriptor) *simpleQueue { +func newSimplePriorityQueue(ctx context.Context, size int) *simpleQueue { if size%2 != 0 { size++ } diff --git a/internal/p2p/rqueue_test.go b/internal/p2p/rqueue_test.go index 43c4066e57..0ea137ee89 100644 --- a/internal/p2p/rqueue_test.go +++ b/internal/p2p/rqueue_test.go @@ -13,7 +13,7 @@ func TestSimpleQueue(t *testing.T) { // set up a small queue with very small buffers so we can // watch it shed load, then send a bunch of messages to the // queue, most of which we'll watch it drop. - sq := newSimplePriorityQueue(ctx, 1, nil) + sq := newSimplePriorityQueue(ctx, 1) for i := 0; i < 100; i++ { sq.enqueue() <- Envelope{From: "merlin"} } diff --git a/internal/rpc/core/net.go b/internal/rpc/core/net.go index 60622f0ffd..c38520e2ba 100644 --- a/internal/rpc/core/net.go +++ b/internal/rpc/core/net.go @@ -36,7 +36,7 @@ func (env *Environment) NetInfo(_ctx context.Context) (*coretypes.ResultNetInfo, // Genesis returns genesis file. // More: https://docs.tendermint.com/master/rpc/#/Info/genesis -func (env *Environment) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error) { +func (env *Environment) Genesis(_ctx context.Context) (*coretypes.ResultGenesis, error) { if len(env.genChunks) > 1 { return nil, errors.New("genesis response is large, please use the genesis_chunked API instead") } @@ -44,7 +44,7 @@ func (env *Environment) Genesis(ctx context.Context) (*coretypes.ResultGenesis, return &coretypes.ResultGenesis{Genesis: env.GenDoc}, nil } -func (env *Environment) GenesisChunked(ctx context.Context, req *coretypes.RequestGenesisChunked) (*coretypes.ResultGenesisChunk, error) { +func (env *Environment) GenesisChunked(_ctx context.Context, req *coretypes.RequestGenesisChunked) (*coretypes.ResultGenesisChunk, error) { if env.genChunks == nil { return nil, fmt.Errorf("service configuration error, genesis chunks are not initialized") } diff --git a/internal/rpc/core/tx.go b/internal/rpc/core/tx.go index 1258ae41ee..527d2142b3 100644 --- a/internal/rpc/core/tx.go +++ b/internal/rpc/core/tx.go @@ -17,7 +17,7 @@ import ( // transaction is in the mempool, invalidated, or was not sent in the first // place. // More: https://docs.tendermint.com/master/rpc/#/Info/tx -func (env *Environment) Tx(ctx context.Context, req *coretypes.RequestTx) (*coretypes.ResultTx, error) { +func (env *Environment) Tx(_ctx context.Context, req *coretypes.RequestTx) (*coretypes.ResultTx, error) { // if index is disabled, return error if !indexer.KVSinkEnabled(env.EventSinks) { return nil, errors.New("transaction querying is disabled due to no kvEventSink") diff --git a/internal/state/helpers_test.go b/internal/state/helpers_test.go index 699f855b56..aeba7f965b 100644 --- a/internal/state/helpers_test.go +++ b/internal/state/helpers_test.go @@ -196,7 +196,7 @@ func makeRandomStateFromValidatorSet( } } func makeRandomStateFromConsensusParams( - ctx context.Context, + _ctx context.Context, t *testing.T, consensusParams *types.ConsensusParams, height, @@ -226,7 +226,7 @@ type testApp struct { var _ abci.Application = (*testApp)(nil) -func (app *testApp) Info(_ context.Context, req *abci.RequestInfo) (*abci.ResponseInfo, error) { +func (app *testApp) Info(_ context.Context, _req *abci.RequestInfo) (*abci.ResponseInfo, error) { return &abci.ResponseInfo{}, nil } @@ -238,11 +238,11 @@ func (app *testApp) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBl }, nil } -func (app *testApp) CheckTx(_ context.Context, req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) { +func (app *testApp) CheckTx(_ context.Context, _req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) { return &abci.ResponseCheckTx{}, nil } -func (app *testApp) Query(_ context.Context, req *abci.RequestQuery) (*abci.ResponseQuery, error) { +func (app *testApp) Query(_ context.Context, _req *abci.RequestQuery) (*abci.ResponseQuery, error) { return &abci.ResponseQuery{}, nil } diff --git a/internal/state/indexer/block/null/null.go b/internal/state/indexer/block/null/null.go index e864490aa4..a2ae24c2f1 100644 --- a/internal/state/indexer/block/null/null.go +++ b/internal/state/indexer/block/null/null.go @@ -14,7 +14,7 @@ var _ indexer.BlockIndexer = (*BlockerIndexer)(nil) // TxIndex implements a no-op block indexer. type BlockerIndexer struct{} -func (idx *BlockerIndexer) Has(height int64) (bool, error) { +func (idx *BlockerIndexer) Has(_height int64) (bool, error) { return false, errors.New(`indexing is disabled (set 'tx_index = "kv"' in config)`) } @@ -22,6 +22,6 @@ func (idx *BlockerIndexer) Index(types.EventDataNewBlockHeader) error { return nil } -func (idx *BlockerIndexer) Search(ctx context.Context, q *query.Query) ([]int64, error) { +func (idx *BlockerIndexer) Search(_ctx context.Context, _q *query.Query) ([]int64, error) { return []int64{}, nil } diff --git a/internal/state/indexer/sink/psql/psql.go b/internal/state/indexer/sink/psql/psql.go index 9d8c68761f..b3f751880d 100644 --- a/internal/state/indexer/sink/psql/psql.go +++ b/internal/state/indexer/sink/psql/psql.go @@ -238,22 +238,22 @@ INSERT INTO `+tableTxResults+` (block_id, index, created_at, tx_hash, tx_result) } // SearchBlockEvents is not implemented by this sink, and reports an error for all queries. -func (es *EventSink) SearchBlockEvents(ctx context.Context, q *query.Query) ([]int64, error) { +func (es *EventSink) SearchBlockEvents(_ctx context.Context, _q *query.Query) ([]int64, error) { return nil, errors.New("block search is not supported via the postgres event sink") } // SearchTxEvents is not implemented by this sink, and reports an error for all queries. -func (es *EventSink) SearchTxEvents(ctx context.Context, q *query.Query) ([]*abci.TxResult, error) { +func (es *EventSink) SearchTxEvents(_ctx context.Context, _q *query.Query) ([]*abci.TxResult, error) { return nil, errors.New("tx search is not supported via the postgres event sink") } // GetTxByHash is not implemented by this sink, and reports an error for all queries. -func (es *EventSink) GetTxByHash(hash []byte) (*abci.TxResult, error) { +func (es *EventSink) GetTxByHash(_hash []byte) (*abci.TxResult, error) { return nil, errors.New("getTxByHash is not supported via the postgres event sink") } // HasBlock is not implemented by this sink, and reports an error for all queries. -func (es *EventSink) HasBlock(h int64) (bool, error) { +func (es *EventSink) HasBlock(_h int64) (bool, error) { return false, errors.New("hasBlock is not supported via the postgres event sink") } diff --git a/internal/state/indexer/tx/null/null.go b/internal/state/indexer/tx/null/null.go index d6a1be056f..969b7e9183 100644 --- a/internal/state/indexer/tx/null/null.go +++ b/internal/state/indexer/tx/null/null.go @@ -15,20 +15,20 @@ var _ indexer.TxIndexer = (*TxIndex)(nil) type TxIndex struct{} // Get on a TxIndex is disabled and panics when invoked. -func (txi *TxIndex) Get(hash []byte) (*abci.TxResult, error) { +func (txi *TxIndex) Get(_hash []byte) (*abci.TxResult, error) { return nil, errors.New(`indexing is disabled (set 'tx_index = "kv"' in config)`) } // AddBatch is a noop and always returns nil. -func (txi *TxIndex) AddBatch(batch *indexer.Batch) error { +func (txi *TxIndex) AddBatch(_batch *indexer.Batch) error { return nil } // Index is a noop and always returns nil. -func (txi *TxIndex) Index(results []*abci.TxResult) error { +func (txi *TxIndex) Index(_results []*abci.TxResult) error { return nil } -func (txi *TxIndex) Search(ctx context.Context, q *query.Query) ([]*abci.TxResult, error) { +func (txi *TxIndex) Search(_ctx context.Context, _q *query.Query) ([]*abci.TxResult, error) { return []*abci.TxResult{}, nil } diff --git a/internal/state/services.go b/internal/state/services.go index ad104641dc..836e5fa926 100644 --- a/internal/state/services.go +++ b/internal/state/services.go @@ -57,12 +57,12 @@ type EvidencePool interface { // to the consensus evidence pool interface type EmptyEvidencePool struct{} -func (EmptyEvidencePool) PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64) { +func (EmptyEvidencePool) PendingEvidence(_maxBytes int64) (ev []types.Evidence, size int64) { return nil, 0 } func (EmptyEvidencePool) AddEvidence(context.Context, types.Evidence) error { return nil } func (EmptyEvidencePool) Update(context.Context, State, types.EvidenceList) {} -func (EmptyEvidencePool) CheckEvidence(ctx context.Context, evList types.EvidenceList) error { +func (EmptyEvidencePool) CheckEvidence(_ctx context.Context, _evList types.EvidenceList) error { return nil } -func (EmptyEvidencePool) ReportConflictingVotes(voteA, voteB *types.Vote) {} +func (EmptyEvidencePool) ReportConflictingVotes(_voteA, _voteB *types.Vote) {} diff --git a/internal/state/state_test.go b/internal/state/state_test.go index 5c2e05056d..7d77af19ca 100644 --- a/internal/state/state_test.go +++ b/internal/state/state_test.go @@ -1117,7 +1117,7 @@ func TestStateProto(t *testing.T) { } } -func blockExecutorFunc(ctx context.Context, t *testing.T) func(prevState, state sm.State, ucState sm.CurrentRoundState) sm.State { +func blockExecutorFunc(_ctx context.Context, t *testing.T) func(prevState, state sm.State, ucState sm.CurrentRoundState) sm.State { return func(prevState, state sm.State, ucState sm.CurrentRoundState) sm.State { t.Helper() diff --git a/internal/statesync/dispatcher.go b/internal/statesync/dispatcher.go index 5ded294ca1..6539285fef 100644 --- a/internal/statesync/dispatcher.go +++ b/internal/statesync/dispatcher.go @@ -229,7 +229,7 @@ func (p *BlockProvider) LightBlock(ctx context.Context, height int64) (*types.Li // attacks. This is a no op as there currently isn't a way to wire this up to // the evidence reactor (we should endeavor to do this in the future but for now // it's not critical for backwards verification) -func (p *BlockProvider) ReportEvidence(ctx context.Context, ev types.Evidence) error { +func (p *BlockProvider) ReportEvidence(_ctx context.Context, _ev types.Evidence) error { return nil } diff --git a/internal/statesync/peer_test.go b/internal/statesync/peer_test.go index 23d6d0d7f8..7b32e9f728 100644 --- a/internal/statesync/peer_test.go +++ b/internal/statesync/peer_test.go @@ -12,7 +12,7 @@ import ( "github.com/dashpay/tenderdash/types" ) -func TestPeerSubscriberBasic(t *testing.T) { +func TestPeerSubscriberBasic(_t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond) defer cancel() inCh := make(chan p2p.PeerUpdate) diff --git a/internal/statesync/reactor.go b/internal/statesync/reactor.go index d1b64b329a..4dd794268d 100644 --- a/internal/statesync/reactor.go +++ b/internal/statesync/reactor.go @@ -389,7 +389,7 @@ func (r *Reactor) Sync(ctx context.Context) (sm.State, error) { return sm.State{}, fmt.Errorf("failed to bootstrap node with new state: %w", err) } - if err := r.blockStore.SaveSeenCommit(state.LastBlockHeight, commit); err != nil { + if err := r.blockStore.SaveSeenCommit(commit); err != nil { return sm.State{}, fmt.Errorf("failed to store last seen commit: %w", err) } @@ -1055,7 +1055,7 @@ func (r *Reactor) processPeerUp(ctx context.Context, peerUpdate p2p.PeerUpdate) } } -func (r *Reactor) processPeerDown(ctx context.Context, peerUpdate p2p.PeerUpdate) { +func (r *Reactor) processPeerDown(_ctx context.Context, peerUpdate p2p.PeerUpdate) { r.peers.Remove(peerUpdate.NodeID) syncer := r.getSyncer() if syncer != nil { diff --git a/internal/statesync/reactor_test.go b/internal/statesync/reactor_test.go index 17a6895c1a..ecfa88fa27 100644 --- a/internal/statesync/reactor_test.go +++ b/internal/statesync/reactor_test.go @@ -901,7 +901,7 @@ func mockLB(ctx context.Context, t *testing.T, height int64, time time.Time, las StateID: stateID.Hash(), } voteSet := types.NewVoteSet(factory.DefaultTestChainID, height, 0, tmproto.PrecommitType, currentVals) - commit, err := factory.MakeCommit(ctx, lastBlockID, height, 0, voteSet, currentVals, currentPrivVals, stateID) + commit, err := factory.MakeCommit(ctx, lastBlockID, height, 0, voteSet, currentVals, currentPrivVals) require.NoError(t, err) return nextVals, nextPrivVals, &types.LightBlock{ SignedHeader: &types.SignedHeader{ diff --git a/internal/store/store.go b/internal/store/store.go index 04d3d8ccdc..02faa0e519 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -545,7 +545,7 @@ func (bs *BlockStore) saveBlockPart(height int64, index int, part *types.Part, b } // SaveSeenCommit saves a seen commit, used by e.g. the state sync reactor when bootstrapping node. -func (bs *BlockStore) SaveSeenCommit(height int64, seenCommit *types.Commit) error { +func (bs *BlockStore) SaveSeenCommit(seenCommit *types.Commit) error { pbc := seenCommit.ToProto() seenCommitBytes, err := proto.Marshal(pbc) if err != nil { diff --git a/internal/store/store_test.go b/internal/store/store_test.go index 1b03e7ef25..0c02455064 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -7,7 +7,6 @@ import ( "runtime/debug" "strings" "testing" - "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -25,8 +24,8 @@ import ( "github.com/dashpay/tenderdash/version" ) -// make a Commit with a single vote containing just the height and a timestamp -func makeTestCommit(state sm.State, height int64, timestamp time.Time) *types.Commit { +// make a Commit with a single vote containing just the height +func makeTestCommit(state sm.State, height int64) *types.Commit { blockID := types.BlockID{ Hash: []byte(""), PartSetHeader: types.PartSetHeader{ @@ -105,7 +104,7 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { require.NoError(t, err) part2 := validPartSet.GetPart(1) - seenCommit := makeTestCommit(state, block.Header.Height, tmtime.Now()) + seenCommit := makeTestCommit(state, block.Header.Height) bs.SaveBlock(block, validPartSet, seenCommit) require.EqualValues(t, 1, bs.Base(), "expecting the new height to be changed") require.EqualValues(t, block.Header.Height, bs.Height(), "expecting the new height to be changed") @@ -125,7 +124,7 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { } // End of setup, test data - commitAtH10 := makeTestCommit(state, 10, tmtime.Now()) + commitAtH10 := makeTestCommit(state, 10) tuples := []struct { block *types.Block parts *types.PartSet @@ -159,17 +158,17 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { Time: tmtime.Now(), ValidatorsHash: tmrand.Bytes(crypto.DefaultHashSize), ProposerProTxHash: tmrand.Bytes(crypto.DefaultHashSize)}, - makeTestCommit(state, 5, tmtime.Now()), + makeTestCommit(state, 5), ), parts: validPartSet, - seenCommit: makeTestCommit(state, 5, tmtime.Now()), + seenCommit: makeTestCommit(state, 5), }, { block: newBlock(header1, commitAtH10), parts: incompletePartSet, wantPanic: "only save complete block", // incomplete parts - seenCommit: makeTestCommit(state, 10, tmtime.Now()), + seenCommit: makeTestCommit(state, 10), }, { @@ -315,7 +314,7 @@ func TestLoadBaseMeta(t *testing.T) { require.NoError(t, err) partSet, err := block.MakePartSet(2) require.NoError(t, err) - seenCommit := makeTestCommit(state, h, tmtime.Now()) + seenCommit := makeTestCommit(state, h) bs.SaveBlock(block, partSet, seenCommit) } @@ -396,7 +395,7 @@ func TestPruneBlocks(t *testing.T) { require.NoError(t, err) partSet, err := block.MakePartSet(2) require.NoError(t, err) - seenCommit := makeTestCommit(state, h, tmtime.Now()) + seenCommit := makeTestCommit(state, h) bs.SaveBlock(block, partSet, seenCommit) } @@ -503,7 +502,7 @@ func TestBlockFetchAtHeight(t *testing.T) { partSet, err := block.MakePartSet(2) require.NoError(t, err) - seenCommit := makeTestCommit(state, block.Header.Height, tmtime.Now()) + seenCommit := makeTestCommit(state, block.Header.Height) bs.SaveBlock(block, partSet, seenCommit) require.Equal(t, bs.Height(), block.Header.Height, "expecting the new height to be changed") @@ -542,12 +541,12 @@ func TestSeenAndCanonicalCommit(t *testing.T) { // are persisted. for h := int64(3); h <= 5; h++ { state.LastBlockHeight = h - 1 - blockCommit := makeTestCommit(state, h-1, tmtime.Now()) + blockCommit := makeTestCommit(state, h-1) block, err := factory.MakeBlock(state, h, blockCommit, 0) require.NoError(t, err) partSet, err := block.MakePartSet(2) require.NoError(t, err) - seenCommit := makeTestCommit(state, h, tmtime.Now()) + seenCommit := makeTestCommit(state, h) store.SaveBlock(block, partSet, seenCommit) c3 := store.LoadSeenCommit() require.NotNil(t, c3) diff --git a/internal/test/factory/commit.go b/internal/test/factory/commit.go index 80c52ea7e8..385c8e03d6 100644 --- a/internal/test/factory/commit.go +++ b/internal/test/factory/commit.go @@ -15,7 +15,6 @@ func MakeCommit( voteSet *types.VoteSet, validatorSet *types.ValidatorSet, validators []types.PrivValidator, - stateID tmproto.StateID, ) (*types.Commit, error) { // all sign for i := 0; i < len(validators); i++ { diff --git a/libs/cli/setup.go b/libs/cli/setup.go index 54ea90358e..63734dd4c0 100644 --- a/libs/cli/setup.go +++ b/libs/cli/setup.go @@ -68,7 +68,7 @@ func concatCobraCmdFuncs(fs ...cobraCmdFunc) cobraCmdFunc { } // Bind all flags and read the config into viper -func BindFlagsLoadViper(cmd *cobra.Command, args []string) error { +func BindFlagsLoadViper(cmd *cobra.Command, _args []string) error { // cmd.Flags() includes flags from this command and all persistent flags from the parent if err := viper.BindPFlags(cmd.Flags()); err != nil { return err diff --git a/light/client.go b/light/client.go index d31157f51e..e2e10487ec 100644 --- a/light/client.go +++ b/light/client.go @@ -467,7 +467,7 @@ func (c *Client) VerifyHeader(ctx context.Context, newHeader *types.Header, now return c.verifyLightBlock(ctx, l, now) } -func (c *Client) verifyLightBlock(ctx context.Context, newLightBlock *types.LightBlock, now time.Time) error { +func (c *Client) verifyLightBlock(ctx context.Context, newLightBlock *types.LightBlock, _now time.Time) error { c.logger.Info("verify light block", "height", newLightBlock.Height, "hash", newLightBlock.Hash()) if err := newLightBlock.ValidateBasic(c.ChainID()); err != nil { @@ -514,7 +514,7 @@ func (c *Client) verifyBlockWithDashCore(ctx context.Context, newLightBlock *typ return nil } -func (c *Client) verifyBlockSignatureWithDashCore(ctx context.Context, newLightBlock *types.LightBlock) error { +func (c *Client) verifyBlockSignatureWithDashCore(_ctx context.Context, newLightBlock *types.LightBlock) error { quorumHash := newLightBlock.ValidatorSet.QuorumHash quorumType := newLightBlock.ValidatorSet.QuorumType @@ -878,7 +878,7 @@ func (c *Client) compareFirstHeaderWithWitnesses(ctx context.Context, h *types.S return c.removeWitnesses(witnessesToRemove) } -func (c *Client) Status(ctx context.Context) *types.LightClientInfo { +func (c *Client) Status(_ctx context.Context) *types.LightClientInfo { chunks := make([]string, len(c.witnesses)) // If primary is in witness list we do not want to count it twice in the number of peers diff --git a/light/client_benchmark_test.go b/light/client_benchmark_test.go index d4fbf86fc5..09bf34ac06 100644 --- a/light/client_benchmark_test.go +++ b/light/client_benchmark_test.go @@ -45,7 +45,7 @@ func newProviderBenchmarkImpl(headers map[int64]*types.SignedHeader, return &impl } -func (impl *providerBenchmarkImpl) LightBlock(ctx context.Context, height int64) (*types.LightBlock, error) { +func (impl *providerBenchmarkImpl) LightBlock(_ctx context.Context, height int64) (*types.LightBlock, error) { if height == 0 { return impl.blocks[impl.currentHeight], nil } diff --git a/light/proxy/routes.go b/light/proxy/routes.go index e00091dc70..3bc23f1251 100644 --- a/light/proxy/routes.go +++ b/light/proxy/routes.go @@ -15,7 +15,7 @@ type proxyService struct { Client *lrpc.Client } -func (p proxyService) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error) { panic("ok") } +func (p proxyService) ABCIInfo(_ctx context.Context) (*coretypes.ResultABCIInfo, error) { panic("ok") } func (p proxyService) ABCIQuery(ctx context.Context, req *coretypes.RequestABCIQuery) (*coretypes.ResultABCIQuery, error) { return p.Client.ABCIQueryWithOptions(ctx, req.Path, req.Data, rpcclient.ABCIQueryOptions{ diff --git a/light/store/db/db_test.go b/light/store/db/db_test.go index a0742c5af6..16be663975 100644 --- a/light/store/db/db_test.go +++ b/light/store/db/db_test.go @@ -193,7 +193,7 @@ func Test_Concurrency(t *testing.T) { wg.Wait() } -func randLightBlock(ctx context.Context, t *testing.T, height int64) *types.LightBlock { +func randLightBlock(_ctx context.Context, t *testing.T, height int64) *types.LightBlock { t.Helper() vals, _ := types.RandValidatorSet(2) return &types.LightBlock{ diff --git a/node/node_test.go b/node/node_test.go index 4376202e41..cba1e308ed 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -780,7 +780,7 @@ func TestLoadStateFromGenesis(t *testing.T) { _ = loadStatefromGenesis(ctx, t) } -func loadStatefromGenesis(ctx context.Context, t *testing.T) sm.State { +func loadStatefromGenesis(_ctx context.Context, t *testing.T) sm.State { t.Helper() stateDB := dbm.NewMemDB() diff --git a/rpc/client/http/ws.go b/rpc/client/http/ws.go index 088beb2aae..3b43a7ee9b 100644 --- a/rpc/client/http/ws.go +++ b/rpc/client/http/ws.go @@ -77,7 +77,7 @@ func (w *wsEvents) Stop() error { return w.ws.Stop() } // event. // // It returns an error if wsEvents is not running. -func (w *wsEvents) Subscribe(ctx context.Context, subscriber, query string, +func (w *wsEvents) Subscribe(ctx context.Context, _subscriber, query string, outCapacity ...int) (out <-chan coretypes.ResultEvent, err error) { if err := w.ws.Subscribe(ctx, query); err != nil { return nil, err @@ -102,7 +102,7 @@ func (w *wsEvents) Subscribe(ctx context.Context, subscriber, query string, // given subscriber from query. // // It returns an error if wsEvents is not running. -func (w *wsEvents) Unsubscribe(ctx context.Context, subscriber, query string) error { +func (w *wsEvents) Unsubscribe(ctx context.Context, _subscriber, query string) error { if err := w.ws.Unsubscribe(ctx, query); err != nil { return err } @@ -124,7 +124,7 @@ func (w *wsEvents) Unsubscribe(ctx context.Context, subscriber, query string) er // unsubscribe given subscriber from all the queries. // // It returns an error if wsEvents is not running. -func (w *wsEvents) UnsubscribeAll(ctx context.Context, subscriber string) error { +func (w *wsEvents) UnsubscribeAll(ctx context.Context, _subscriber string) error { if err := w.ws.UnsubscribeAll(ctx); err != nil { return err } diff --git a/rpc/client/local/local.go b/rpc/client/local/local.go index bfcb39d590..6408a377ba 100644 --- a/rpc/client/local/local.go +++ b/rpc/client/local/local.go @@ -114,7 +114,7 @@ func (c *Local) CheckTx(ctx context.Context, tx types.Tx) (*coretypes.ResultChec return c.env.CheckTx(ctx, &coretypes.RequestCheckTx{Tx: tx}) } -func (c *Local) RemoveTx(ctx context.Context, txKey types.TxKey) error { +func (c *Local) RemoveTx(_ctx context.Context, txKey types.TxKey) error { return c.env.Mempool.RemoveTxByKey(txKey) } diff --git a/rpc/client/mock/abci.go b/rpc/client/mock/abci.go index 1bdbfe2d8c..ddc22692e1 100644 --- a/rpc/client/mock/abci.go +++ b/rpc/client/mock/abci.go @@ -146,7 +146,7 @@ type ABCIMock struct { Broadcast Call } -func (m ABCIMock) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error) { +func (m ABCIMock) ABCIInfo(_ctx context.Context) (*coretypes.ResultABCIInfo, error) { res, err := m.Info.GetResponse(nil) if err != nil { return nil, err @@ -158,7 +158,7 @@ func (m ABCIMock) ABCIQuery(ctx context.Context, path string, data bytes.HexByte return m.ABCIQueryWithOptions(ctx, path, data, client.DefaultABCIQueryOptions) } -func (m ABCIMock) ABCIQueryWithOptions(ctx context.Context, path string, data bytes.HexBytes, opts client.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error) { +func (m ABCIMock) ABCIQueryWithOptions(_ctx context.Context, path string, data bytes.HexBytes, opts client.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error) { res, err := m.Query.GetResponse(QueryArgs{path, data, opts.Height, opts.Prove}) if err != nil { return nil, err @@ -167,7 +167,7 @@ func (m ABCIMock) ABCIQueryWithOptions(ctx context.Context, path string, data by return &coretypes.ResultABCIQuery{Response: resQuery}, nil } -func (m ABCIMock) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTxCommit, error) { +func (m ABCIMock) BroadcastTxCommit(_ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTxCommit, error) { res, err := m.BroadcastCommit.GetResponse(tx) if err != nil { return nil, err @@ -175,7 +175,7 @@ func (m ABCIMock) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*coretype return res.(*coretypes.ResultBroadcastTxCommit), nil } -func (m ABCIMock) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) { +func (m ABCIMock) BroadcastTxAsync(_ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) { res, err := m.Broadcast.GetResponse(tx) if err != nil { return nil, err @@ -183,7 +183,7 @@ func (m ABCIMock) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*coretypes return res.(*coretypes.ResultBroadcastTx), nil } -func (m ABCIMock) BroadcastTx(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) { +func (m ABCIMock) BroadcastTx(_ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) { res, err := m.Broadcast.GetResponse(tx) if err != nil { return nil, err @@ -191,7 +191,7 @@ func (m ABCIMock) BroadcastTx(ctx context.Context, tx types.Tx) (*coretypes.Resu return res.(*coretypes.ResultBroadcastTx), nil } -func (m ABCIMock) BroadcastTxSync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) { +func (m ABCIMock) BroadcastTxSync(_ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) { res, err := m.Broadcast.GetResponse(tx) if err != nil { return nil, err diff --git a/rpc/client/mock/status.go b/rpc/client/mock/status.go index 1a446896e8..3e7f16db43 100644 --- a/rpc/client/mock/status.go +++ b/rpc/client/mock/status.go @@ -17,7 +17,7 @@ var ( _ client.StatusClient = (*StatusRecorder)(nil) ) -func (m *StatusMock) Status(ctx context.Context) (*coretypes.ResultStatus, error) { +func (m *StatusMock) Status(_ctx context.Context) (*coretypes.ResultStatus, error) { res, err := m.GetResponse(nil) if err != nil { return nil, err diff --git a/rpc/jsonrpc/jsonrpc_test.go b/rpc/jsonrpc/jsonrpc_test.go index b171de3cc3..4bf9d5a537 100644 --- a/rpc/jsonrpc/jsonrpc_test.go +++ b/rpc/jsonrpc/jsonrpc_test.go @@ -75,23 +75,23 @@ var Routes = map[string]*server.RPCFunc{ "echo_int": server.NewRPCFunc(EchoIntResult), } -func EchoResult(ctx context.Context, v *RequestEcho) (*ResultEcho, error) { +func EchoResult(_ctx context.Context, v *RequestEcho) (*ResultEcho, error) { return &ResultEcho{v.Value}, nil } -func EchoWSResult(ctx context.Context, v *RequestEcho) (*ResultEcho, error) { +func EchoWSResult(_ctx context.Context, v *RequestEcho) (*ResultEcho, error) { return &ResultEcho{v.Value}, nil } -func EchoIntResult(ctx context.Context, v *RequestEchoInt) (*ResultEchoInt, error) { +func EchoIntResult(_ctx context.Context, v *RequestEchoInt) (*ResultEchoInt, error) { return &ResultEchoInt{v.Value}, nil } -func EchoBytesResult(ctx context.Context, v *RequestEchoBytes) (*ResultEchoBytes, error) { +func EchoBytesResult(_ctx context.Context, v *RequestEchoBytes) (*ResultEchoBytes, error) { return &ResultEchoBytes{v.Value}, nil } -func EchoDataBytesResult(ctx context.Context, v *RequestEchoDataBytes) (*ResultEchoDataBytes, error) { +func EchoDataBytesResult(_ctx context.Context, v *RequestEchoDataBytes) (*ResultEchoDataBytes, error) { return &ResultEchoDataBytes{v.Value}, nil } diff --git a/test/e2e/pkg/infra/docker/infra.go b/test/e2e/pkg/infra/docker/infra.go index 65a710b8fd..cf412d8fd3 100644 --- a/test/e2e/pkg/infra/docker/infra.go +++ b/test/e2e/pkg/infra/docker/infra.go @@ -30,7 +30,7 @@ func NewTestnetInfra(logger log.Logger, testnet *e2e.Testnet) infra.TestnetInfra } } -func (ti *testnetInfra) Setup(ctx context.Context) error { +func (ti *testnetInfra) Setup(_ctx context.Context) error { compose, err := makeDockerCompose(ti.testnet) if err != nil { return err diff --git a/test/e2e/pkg/mockcoreserver/core_server.go b/test/e2e/pkg/mockcoreserver/core_server.go index 9a3880f837..4281d30c36 100644 --- a/test/e2e/pkg/mockcoreserver/core_server.go +++ b/test/e2e/pkg/mockcoreserver/core_server.go @@ -219,7 +219,7 @@ func (c *StaticCoreServer) GetNetworkInfo(_ context.Context, _ btcjson.GetNetwor } // Ping ... -func (c *StaticCoreServer) Ping(_ context.Context, cmd btcjson.PingCmd) error { +func (c *StaticCoreServer) Ping(_ context.Context, _cmd btcjson.PingCmd) error { return nil }