From 1e75ff61093b09b9ec5bdaf969749a74ca9de5a7 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Wed, 26 Mar 2025 19:33:36 +0530 Subject: [PATCH] fix linters --- cmd/devp2p/internal/ethtest/suite_test.go | 1 - core/forkchoice_test.go | 1 - core/state_processor.go | 2 +- core/txpool/blobpool/blobpool.go | 2 +- core/txpool/legacypool/legacypool.go | 2 +- eth/downloader/bor_downloader.go | 2 -- eth/downloader/bor_downloader_test.go | 3 --- eth/fetcher/block_fetcher.go | 2 +- eth/handler_eth_test.go | 1 - eth/tracers/logger/logger_test.go | 1 - internal/cli/command.go | 4 ---- internal/cli/server/chains/chain_test.go | 2 -- metrics/runtimehistogram_test.go | 2 -- miner/worker.go | 4 +++- 14 files changed, 7 insertions(+), 22 deletions(-) diff --git a/cmd/devp2p/internal/ethtest/suite_test.go b/cmd/devp2p/internal/ethtest/suite_test.go index 90b2d0d2ac..3a6731f326 100644 --- a/cmd/devp2p/internal/ethtest/suite_test.go +++ b/cmd/devp2p/internal/ethtest/suite_test.go @@ -63,7 +63,6 @@ func TestEthSuite(t *testing.T) { } for _, test := range suite.EthTests() { - test := test t.Run(test.Name, func(t *testing.T) { t.Parallel() diff --git a/core/forkchoice_test.go b/core/forkchoice_test.go index 3e3de28b3e..acef26a359 100644 --- a/core/forkchoice_test.go +++ b/core/forkchoice_test.go @@ -77,7 +77,6 @@ func TestForkChoice(t *testing.T) { // nolint: paralleltest for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { res, err := mockForker.ReorgNeeded(tc.current, tc.incoming) require.Equal(t, tc.want, res, tc.name) diff --git a/core/state_processor.go b/core/state_processor.go index 649f48f7bb..d71b461270 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -141,7 +141,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg return &ProcessResult{ Receipts: receipts, - Requests: nil, + Requests: requests, Logs: allLogs, GasUsed: *usedGas, }, nil diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index 76a200ab20..9b29d35f91 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -1751,7 +1751,7 @@ func (p *BlobPool) Clear() { // The transaction addition may attempt to reserve the sender addr which // can't happen until Clear releases the reservation lock. Clear cannot // acquire the subpool lock until the transaction addition is completed. - for acct, _ := range p.index { + for acct := range p.index { p.reserve(acct, false) } p.lookup = newLookup() diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index ac726662c5..bf5d9f38d0 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -2017,7 +2017,7 @@ func (pool *LegacyPool) Clear() { senderAddr, _ := types.Sender(pool.signer, tx) pool.reserve(senderAddr, false) } - for localSender, _ := range pool.locals.accounts { + for localSender := range pool.locals.accounts { pool.reserve(localSender, false) } diff --git a/eth/downloader/bor_downloader.go b/eth/downloader/bor_downloader.go index b4a11bfad1..8db92e09ec 100644 --- a/eth/downloader/bor_downloader.go +++ b/eth/downloader/bor_downloader.go @@ -705,8 +705,6 @@ func (d *Downloader) spawnSync(fetchers []func() error) error { d.cancelWg.Add(len(fetchers)) for _, fn := range fetchers { - fn := fn - go func() { defer d.cancelWg.Done(); errc <- fn() }() } // Wait for the first error, then terminate the others. diff --git a/eth/downloader/bor_downloader_test.go b/eth/downloader/bor_downloader_test.go index 51c8bf0636..f6521ca0c8 100644 --- a/eth/downloader/bor_downloader_test.go +++ b/eth/downloader/bor_downloader_test.go @@ -1378,9 +1378,6 @@ func TestRemoteHeaderRequestSpan(t *testing.T) { } for i, tt := range testCases { - i := i - tt := tt - t.Run("", func(t *testing.T) { from, count, span, max := calculateRequestSpan(tt.remoteHeight, tt.localHeight) data := reqs(int(from), count, span) diff --git a/eth/fetcher/block_fetcher.go b/eth/fetcher/block_fetcher.go index 84906ff2c9..ab10c610c8 100644 --- a/eth/fetcher/block_fetcher.go +++ b/eth/fetcher/block_fetcher.go @@ -491,7 +491,7 @@ func (f *BlockFetcher) loop() { log.Trace("Fetching scheduled headers", "peer", peer, "list", hashes) // Create a closure of the fetch and schedule in on a new thread - fetchHeader, hashes, announcedAt := f.fetching[hashes[0]].fetchHeader, hashes, f.fetching[hashes[0]].time + fetchHeader, announcedAt := f.fetching[hashes[0]].fetchHeader, f.fetching[hashes[0]].time go func(peer string) { if f.fetchingHook != nil { f.fetchingHook(hashes) diff --git a/eth/handler_eth_test.go b/eth/handler_eth_test.go index 32bc23dc47..47d7691924 100644 --- a/eth/handler_eth_test.go +++ b/eth/handler_eth_test.go @@ -619,7 +619,6 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) { done := make(chan struct{}, peers) for _, ch := range blockChs { - ch := ch go func() { <-ch done <- struct{}{} diff --git a/eth/tracers/logger/logger_test.go b/eth/tracers/logger/logger_test.go index fcfb454919..f4b8816df7 100644 --- a/eth/tracers/logger/logger_test.go +++ b/eth/tracers/logger/logger_test.go @@ -103,7 +103,6 @@ func TestStructLogMarshalingOmitEmpty(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/cli/command.go b/internal/cli/command.go index 8c3bf02f0f..aaa110e929 100644 --- a/internal/cli/command.go +++ b/internal/cli/command.go @@ -33,10 +33,6 @@ func Run(args []string) int { mappedCommands := make(map[string]cli.CommandFactory) for k, v := range commands { - // Declare a new v to limit the scope of v to inside the block, so the anonymous function below - // can get the "current" value of v, instead of the value of last v in the loop. - // See this post: https://stackoverflow.com/questions/10116507/go-transfer-var-into-anonymous-function for more explanation - v := v mappedCommands[k] = func() (cli.Command, error) { cmd, err := v() return cmd.(cli.Command), err diff --git a/internal/cli/server/chains/chain_test.go b/internal/cli/server/chains/chain_test.go index b372a3c4b9..cc6e4996f3 100644 --- a/internal/cli/server/chains/chain_test.go +++ b/internal/cli/server/chains/chain_test.go @@ -39,8 +39,6 @@ func TestChain_ImportFromFile(t *testing.T) { } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/metrics/runtimehistogram_test.go b/metrics/runtimehistogram_test.go index d22d796f24..d8e33be85d 100644 --- a/metrics/runtimehistogram_test.go +++ b/metrics/runtimehistogram_test.go @@ -78,8 +78,6 @@ func TestRuntimeHistogramStats(t *testing.T) { } for i, test := range tests { - i, test := i, test - t.Run(fmt.Sprint(i), func(t *testing.T) { s := RuntimeHistogramFromData(1.0, &test.h).Snapshot() diff --git a/miner/worker.go b/miner/worker.go index d9afcbb3dd..e52d8aa678 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1442,7 +1442,9 @@ func (w *worker) generateWork(params *generateParams, witness bool) *newPayloadR block: block, fees: totalFees(block, work.receipts), sidecars: work.sidecars, - witness: work.witness, + stateDB: work.state, + receipts: work.receipts, + requests: requests, } }