diff --git a/cmd/devp2p/internal/ethtest/large.go b/cmd/devp2p/internal/ethtest/large.go index e7067521c..0ff8cd556 100644 --- a/cmd/devp2p/internal/ethtest/large.go +++ b/cmd/devp2p/internal/ethtest/large.go @@ -26,7 +26,7 @@ import ( ) // largeNumber returns a very large big.Int. -func largeNumber(megabytes int) *uint256.Int { +func largeNumber(megabytes int) *uint256.Int { //nolint:unparam buf := make([]byte, megabytes*1024*1024) //nolint:errcheck rand.Read(buf) @@ -36,7 +36,7 @@ func largeNumber(megabytes int) *uint256.Int { } // largeBuffer returns a very large buffer. -func largeBuffer(megabytes int) []byte { +func largeBuffer(megabytes int) []byte { //nolint:unparam buf := make([]byte, megabytes*1024*1024) //nolint:errcheck rand.Read(buf) @@ -44,7 +44,7 @@ func largeBuffer(megabytes int) []byte { } // largeString returns a very large string. -func largeString(megabytes int) string { +func largeString(megabytes int) string { //nolint:unparam buf := make([]byte, megabytes*1024*1024) //nolint:errcheck rand.Read(buf) diff --git a/cmd/utils/diskusage.go b/cmd/utils/diskusage.go index 8e358a568..93c296877 100644 --- a/cmd/utils/diskusage.go +++ b/cmd/utils/diskusage.go @@ -24,7 +24,7 @@ import ( "golang.org/x/sys/unix" ) -func getFreeDiskSpace(path string) (uint64, error) { +func getFreeDiskSpace(path string) (uint64, error) { //nolint:deadcode var stat unix.Statfs_t if err := unix.Statfs(path, &stat); err != nil { return 0, fmt.Errorf("failed to call Statfs: %v", err) diff --git a/common/types_test.go b/common/types_test.go index 318e985f8..012235209 100644 --- a/common/types_test.go +++ b/common/types_test.go @@ -446,8 +446,8 @@ func TestAddress_Format(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if tt.out != tt.want { - t.Errorf("%s does not render as expected:\n got %s\nwant %s", tt.name, tt.out, tt.want) + if tt.out != tt.want { //nolint:scopelint + t.Errorf("%s does not render as expected:\n got %s\nwant %s", tt.name, tt.out, tt.want) //nolint:scopelint } }) } @@ -531,8 +531,8 @@ func TestHash_Format(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if tt.out != tt.want { - t.Errorf("%s does not render as expected:\n got %s\nwant %s", tt.name, tt.out, tt.want) + if tt.out != tt.want { //nolint:scopelint + t.Errorf("%s does not render as expected:\n got %s\nwant %s", tt.name, tt.out, tt.want) //nolint:scopelint } }) } diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 84b039b2e..2daeb37da 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -787,7 +787,7 @@ func ReadAllBadBlocks(db ethdb.Database) []*types.Block { if err := rlp.DecodeBytes(blob, &badBlocks); err != nil { return nil } - var blocks []*types.Block + var blocks []*types.Block //nolint:prealloc for _, bad := range badBlocks { blocks = append(blocks, types.NewBlockWithHeader(bad.Header).WithBody(bad.Body.Transactions, bad.Body.Uncles)) } diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index 8dff0b29b..918c0479e 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -75,7 +75,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, ibs *state.IntraBlockStat // precacheTransaction attempts to apply a transaction to the given state database // and uses the input parameters for its environment. The goal is not to execute // the transaction successfully, rather to warm up touched data slots. -func precacheTransaction(msg types.Message, config *params.ChainConfig, gaspool *GasPool, ibs vm.IntraBlockState, header *types.Header, evm *vm.EVM) error { +func precacheTransaction(msg types.Message, config *params.ChainConfig, gaspool *GasPool, ibs vm.IntraBlockState, header *types.Header, evm *vm.EVM) error { //nolint:unparam // Update the evm with the new transaction context. evm.Reset(NewEVMTxContext(msg), ibs) // Add addresses to access list if applicable diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 015660955..7f9df6df8 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -130,7 +130,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr Time: parent.Time() + 10, UncleHash: types.EmptyUncleHash, } - var receipts []*types.Receipt + var receipts []*types.Receipt //nolint:prealloc // The post-state result doesn't need to be correct (this is a bad block), but we do need something there // Preferably something unique. So let's use a combo of blocknum + txhash diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index 03d3eede3..6c1ef6620 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -998,9 +998,10 @@ func testShiftedHeaderAttack(t *testing.T, protocol uint, mode SyncMode) { // for various failure scenarios. Afterwards a full sync is attempted to make // sure no state was corrupted. // no fast sync for TurboGeth -//func TestInvalidHeaderRollback63Fast(t *testing.T) { testInvalidHeaderRollback(t, 63, FastSync) } -//func TestInvalidHeaderRollback64Fast(t *testing.T) { testInvalidHeaderRollback(t, 64, FastSync) } -//func TestInvalidHeaderRollback65Fast(t *testing.T) { testInvalidHeaderRollback(t, 65, FastSync) } +/* +func TestInvalidHeaderRollback63Fast(t *testing.T) { testInvalidHeaderRollback(t, 63, FastSync) } +func TestInvalidHeaderRollback64Fast(t *testing.T) { testInvalidHeaderRollback(t, 64, FastSync) } +func TestInvalidHeaderRollback65Fast(t *testing.T) { testInvalidHeaderRollback(t, 65, FastSync) } func testInvalidHeaderRollback(t *testing.T, protocol uint, mode SyncMode) { t.Skip("deadlock") @@ -1087,6 +1088,7 @@ func testInvalidHeaderRollback(t *testing.T, protocol uint, mode SyncMode) { } tester.terminate() } +*/ // Tests that a peer advertising a high TD doesn't get to stall the downloader // afterwards by not sending any useful hashes. diff --git a/eth/downloader/queue_test.go b/eth/downloader/queue_test.go index 4963f324a..9db1f8bc7 100644 --- a/eth/downloader/queue_test.go +++ b/eth/downloader/queue_test.go @@ -115,9 +115,9 @@ func dummyPeer(id string) *peerConnection { } func TestBasics(t *testing.T) { - emptyChain := getEmptyChain() //nolint:govet - numOfBlocks := len(emptyChain.blocks) - numOfReceipts := len(emptyChain.blocks) / 2 + emptyCh := getEmptyChain() + numOfBlocks := len(emptyCh.blocks) + numOfReceipts := len(emptyCh.blocks) / 2 q := newQueue(10, 10) if !q.Idle() { diff --git a/eth/handler.go b/eth/handler.go index 43c8d7d11..cb1fdb53d 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -131,7 +131,7 @@ type handler struct { } // newHandler returns a handler for all Ethereum chain management protocol. -func newHandler(config *handlerConfig) (*handler, error) { +func newHandler(config *handlerConfig) (*handler, error) { //nolint:unparam // Create the protocol manager with the base fields if config.EventMux == nil { config.EventMux = new(event.TypeMux) // Nicety initialization for tests diff --git a/eth/handler_eth.go b/eth/handler_eth.go index 7df1aedfb..ed5c60cbc 100644 --- a/eth/handler_eth.go +++ b/eth/handler_eth.go @@ -196,7 +196,7 @@ func (h *ethHandler) handleBlockAnnounces(peer *eth.Peer, hashes []common.Hash, // handleBlockBroadcast is invoked from a peer's message handler when it transmits a // block broadcast for the local node to process. -func (h *ethHandler) handleBlockBroadcast(peer *eth.Peer, block *types.Block, td *big.Int) error { +func (h *ethHandler) handleBlockBroadcast(peer *eth.Peer, block *types.Block, td *big.Int) error { //nolint:unparam // Schedule the block for import if err := h.blockFetcher.Enqueue(peer.ID(), block); err != nil { log.Error("blockFetcher.Enqueue", "error", err) diff --git a/eth/peerset.go b/eth/peerset.go index 930008619..9a62e47c4 100644 --- a/eth/peerset.go +++ b/eth/peerset.go @@ -37,10 +37,6 @@ var ( // errPeerNotRegistered is returned if a peer is attempted to be removed from // a peer set, but no peer with the given id exists. errPeerNotRegistered = errors.New("peer not registered") - - // errSnapWithoutEth is returned if a peer attempts to connect only on the - // snap protocol without advertizing the eth main protocol. - errSnapWithoutEth = errors.New("peer connected on snap without compatible eth support") ) // peerSet represents the collection of active peers currently participating in diff --git a/eth/protocols/eth/handler.go b/eth/protocols/eth/handler.go index 822f3e262..ae8e68492 100644 --- a/eth/protocols/eth/handler.go +++ b/eth/protocols/eth/handler.go @@ -46,10 +46,6 @@ const ( // nowadays, the practical limit will always be softResponseLimit. maxBodiesServe = 1024 - // maxNodeDataServe is the maximum number of state trie nodes to serve. This - // number is there to limit the number of disk lookups. - maxNodeDataServe = 1024 - // maxReceiptsServe is the maximum number of block receipts to serve. This // number is mostly there to limit the number of disk lookups. With block // containing 200+ transactions nowadays, the practical limit will always diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index f1e4af652..78ecc31b0 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -154,7 +154,7 @@ func handleGetBlockBodies66(backend Backend, msg Decoder, peer *Peer) error { return peer.ReplyBlockBodiesRLP(query.RequestId, response) } -func answerGetBlockBodiesQuery(backend Backend, query GetBlockBodiesPacket, peer *Peer) []rlp.RawValue { +func answerGetBlockBodiesQuery(backend Backend, query GetBlockBodiesPacket, peer *Peer) []rlp.RawValue { //nolint:unparam // Gather blocks until the fetch or network limits is reached var ( bytes int @@ -217,7 +217,7 @@ func handleGetReceipts66(backend Backend, msg Decoder, peer *Peer) error { return peer.ReplyReceiptsRLP(query.RequestId, response) } -func answerGetReceiptsQuery(backend Backend, query GetReceiptsPacket, peer *Peer) []rlp.RawValue { +func answerGetReceiptsQuery(backend Backend, query GetReceiptsPacket, peer *Peer) []rlp.RawValue { //nolint:unparam // Gather state data until the fetch or network limits is reached var ( bytes int @@ -395,7 +395,7 @@ func handleGetPooledTransactions66(backend Backend, msg Decoder, peer *Peer) err return peer.ReplyPooledTransactionsRLP(query.RequestId, hashes, txs) } -func answerGetPooledTransactions(backend Backend, query GetPooledTransactionsPacket, peer *Peer) ([]common.Hash, []rlp.RawValue) { +func answerGetPooledTransactions(backend Backend, query GetPooledTransactionsPacket, peer *Peer) ([]common.Hash, []rlp.RawValue) { //nolint:unparam // Gather transactions until the fetch or network limits is reached var ( bytes int diff --git a/eth/protocols/eth/peer.go b/eth/protocols/eth/peer.go index 95e09bcb2..dc211cf70 100644 --- a/eth/protocols/eth/peer.go +++ b/eth/protocols/eth/peer.go @@ -57,7 +57,7 @@ const ( ) // max is a helper function which returns the larger of the two given integers. -func max(a, b int) int { +func max(a, b int) int { //nolint:unparam if a > b { return a } diff --git a/eth/sync.go b/eth/sync.go index d9e323ede..fa3099d5e 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -182,7 +182,7 @@ func newChainSyncer(handler *handler) *chainSyncer { // handlePeerEvent notifies the syncer about a change in the peer set. // This is called for new peers and every time a peer announces a new // chain head. -func (cs *chainSyncer) handlePeerEvent(peer *eth.Peer) bool { +func (cs *chainSyncer) handlePeerEvent(peer *eth.Peer) bool { //nolint:unparam select { case cs.peerEventCh <- struct{}{}: return true diff --git a/signer/core/api.go b/signer/core/api.go index 7b133012a..6b49af2af 100644 --- a/signer/core/api.go +++ b/signer/core/api.go @@ -357,7 +357,7 @@ func (api *SignerAPI) derivationLoop(events chan accounts.WalletEvent) { // Derive first N accounts, hardcoded for now for i := 0; i < limit; i++ { path := next() - if acc, err := event.Wallet.Derive(path, true); err != nil { + if acc, err := event.Wallet.Derive(path, true); err != nil { //nolint:scopelint log.Warn("Account derivation failed", "error", err) } else { log.Info("Derived account", "address", acc.Address, "path", path)