eth: fix lint issues after rebase

Three files had goimports drift from resolving rebase conflicts
(eth/dropper_test.go, eth/fetcher/tx_fetcher.go, eth/handler.go) —
re-run goimports.

Also remove an unused mockConsumer.count() helper in
eth/txtracker/tracker_test.go that no test calls. The method was
left in during the peerstats split and never needed.
This commit is contained in:
Csaba Kiraly 2026-04-20 10:01:49 +02:00
parent b6b6345be9
commit e8083ed0f7
4 changed files with 38 additions and 44 deletions

View file

@ -243,17 +243,17 @@ func TestProtectedByPoolRequestLatencyBasic(t *testing.T) {
// Three peers have enough samples; the two fastest should win. // Three peers have enough samples; the two fastest should win.
stats[dialed[0].ID().String()] = peerstats.PeerStats{ stats[dialed[0].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 50 * time.Millisecond, RequestLatencyEMA: 50 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
stats[dialed[1].ID().String()] = peerstats.PeerStats{ stats[dialed[1].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 100 * time.Millisecond, RequestLatencyEMA: 100 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
stats[dialed[2].ID().String()] = peerstats.PeerStats{ stats[dialed[2].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 2 * time.Second, RequestLatencyEMA: 2 * time.Second,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
@ -282,12 +282,12 @@ func TestProtectedByPoolRequestLatencyBootstrapGuard(t *testing.T) {
// A lucky-fast peer with only 1 sample — must NOT be protected. // A lucky-fast peer with only 1 sample — must NOT be protected.
stats[dialed[0].ID().String()] = peerstats.PeerStats{ stats[dialed[0].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 1 * time.Millisecond, RequestLatencyEMA: 1 * time.Millisecond,
RequestSuccesses: 1, RequestSuccesses: 1,
} }
// A warmed-up but slower peer — should be protected on latency. // A warmed-up but slower peer — should be protected on latency.
stats[dialed[1].ID().String()] = peerstats.PeerStats{ stats[dialed[1].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 500 * time.Millisecond, RequestLatencyEMA: 500 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
@ -317,7 +317,7 @@ func TestProtectedByPoolRequestLatencyPerPool(t *testing.T) {
for _, p := range inbound { for _, p := range inbound {
stats[p.ID().String()] = peerstats.PeerStats{ stats[p.ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 50 * time.Millisecond, RequestLatencyEMA: 50 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
} }
@ -326,7 +326,7 @@ func TestProtectedByPoolRequestLatencyPerPool(t *testing.T) {
for _, p := range dialed { for _, p := range dialed {
stats[p.ID().String()] = peerstats.PeerStats{ stats[p.ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 1 * time.Second, RequestLatencyEMA: 1 * time.Second,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
} }
@ -356,14 +356,14 @@ func TestProtectedByPoolRequestLatencyStale(t *testing.T) {
// Fresh, fast peer — should be protected. // Fresh, fast peer — should be protected.
stats[dialed[0].ID().String()] = peerstats.PeerStats{ stats[dialed[0].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 50 * time.Millisecond, RequestLatencyEMA: 50 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now(), LastLatencySample: time.Now(),
} }
// Stale, fast peer — was fast, but hasn't answered in too long. // Stale, fast peer — was fast, but hasn't answered in too long.
// Same EMA and sample count as the fresh peer; only staleness differs. // Same EMA and sample count as the fresh peer; only staleness differs.
stats[dialed[1].ID().String()] = peerstats.PeerStats{ stats[dialed[1].ID().String()] = peerstats.PeerStats{
RequestLatencyEMA: 50 * time.Millisecond, RequestLatencyEMA: 50 * time.Millisecond,
RequestSuccesses: peerstats.MinLatencySamples, RequestSuccesses: peerstats.MinLatencySamples,
LastLatencySample: time.Now().Add(-2 * peerstats.MaxLatencyStaleness), LastLatencySample: time.Now().Add(-2 * peerstats.MaxLatencyStaleness),
} }

View file

@ -180,11 +180,11 @@ type TxFetcher struct {
alternates map[common.Hash]map[string]struct{} // In-flight transaction alternate origins if retrieval fails alternates map[common.Hash]map[string]struct{} // In-flight transaction alternate origins if retrieval fails
// Callbacks // Callbacks
validateMeta func(common.Hash, byte) error // Validate a tx metadata based on the local txpool validateMeta func(common.Hash, byte) error // Validate a tx metadata based on the local txpool
addTxs func([]*types.Transaction) []error // Insert a batch of transactions into local txpool addTxs func([]*types.Transaction) []error // Insert a batch of transactions into local txpool
fetchTxs func(string, []common.Hash) error // Retrieves a set of txs from a remote peer fetchTxs func(string, []common.Hash) error // Retrieves a set of txs from a remote peer
dropPeer func(string) // Drops a peer in case of announcement violation dropPeer func(string) // Drops a peer in case of announcement violation
onAccepted func(peer string, hashes []common.Hash) // Optional: notified with accepted tx hashes per peer onAccepted func(peer string, hashes []common.Hash) // Optional: notified with accepted tx hashes per peer
onRequestResult func(peer string, latency time.Duration, timeout bool) // Optional: notified once per completed/timed-out tx request onRequestResult func(peer string, latency time.Duration, timeout bool) // Optional: notified once per completed/timed-out tx request
step chan struct{} // Notification channel when the fetcher loop iterates step chan struct{} // Notification channel when the fetcher loop iterates
@ -207,30 +207,30 @@ func NewTxFetcherForTests(
chain *core.BlockChain, validateMeta func(common.Hash, byte) error, addTxs func([]*types.Transaction) []error, fetchTxs func(string, []common.Hash) error, dropPeer func(string), onAccepted func(string, []common.Hash), onRequestResult func(string, time.Duration, bool), chain *core.BlockChain, validateMeta func(common.Hash, byte) error, addTxs func([]*types.Transaction) []error, fetchTxs func(string, []common.Hash) error, dropPeer func(string), onAccepted func(string, []common.Hash), onRequestResult func(string, time.Duration, bool),
clock mclock.Clock, realTime func() time.Time, rand *mrand.Rand) *TxFetcher { clock mclock.Clock, realTime func() time.Time, rand *mrand.Rand) *TxFetcher {
return &TxFetcher{ return &TxFetcher{
notify: make(chan *txAnnounce), notify: make(chan *txAnnounce),
cleanup: make(chan *txDelivery), cleanup: make(chan *txDelivery),
drop: make(chan *txDrop), drop: make(chan *txDrop),
quit: make(chan struct{}), quit: make(chan struct{}),
waitlist: make(map[common.Hash]map[string]struct{}), waitlist: make(map[common.Hash]map[string]struct{}),
waittime: make(map[common.Hash]mclock.AbsTime), waittime: make(map[common.Hash]mclock.AbsTime),
waitslots: make(map[string]map[common.Hash]*txMetadataWithSeq), waitslots: make(map[string]map[common.Hash]*txMetadataWithSeq),
announces: make(map[string]map[common.Hash]*txMetadataWithSeq), announces: make(map[string]map[common.Hash]*txMetadataWithSeq),
announced: make(map[common.Hash]map[string]struct{}), announced: make(map[common.Hash]map[string]struct{}),
fetching: make(map[common.Hash]string), fetching: make(map[common.Hash]string),
requests: make(map[string]*txRequest), requests: make(map[string]*txRequest),
alternates: make(map[common.Hash]map[string]struct{}), alternates: make(map[common.Hash]map[string]struct{}),
underpriced: lru.NewCache[common.Hash, time.Time](maxTxUnderpricedSetSize), underpriced: lru.NewCache[common.Hash, time.Time](maxTxUnderpricedSetSize),
txOnChainCache: lru.NewCache[common.Hash, struct{}](txOnChainCacheLimit), txOnChainCache: lru.NewCache[common.Hash, struct{}](txOnChainCacheLimit),
chain: chain, chain: chain,
validateMeta: validateMeta, validateMeta: validateMeta,
addTxs: addTxs, addTxs: addTxs,
fetchTxs: fetchTxs, fetchTxs: fetchTxs,
dropPeer: dropPeer, dropPeer: dropPeer,
onAccepted: onAccepted, onAccepted: onAccepted,
onRequestResult: onRequestResult, onRequestResult: onRequestResult,
clock: clock, clock: clock,
realTime: realTime, realTime: realTime,
rand: rand, rand: rand,
} }
} }

View file

@ -36,9 +36,9 @@ import (
"github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/eth/fetcher" "github.com/ethereum/go-ethereum/eth/fetcher"
"github.com/ethereum/go-ethereum/eth/peerstats"
"github.com/ethereum/go-ethereum/eth/protocols/eth" "github.com/ethereum/go-ethereum/eth/protocols/eth"
"github.com/ethereum/go-ethereum/eth/protocols/snap" "github.com/ethereum/go-ethereum/eth/protocols/snap"
"github.com/ethereum/go-ethereum/eth/peerstats"
"github.com/ethereum/go-ethereum/eth/txtracker" "github.com/ethereum/go-ethereum/eth/txtracker"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"

View file

@ -175,12 +175,6 @@ func (c *mockConsumer) last() signal {
return c.signals[len(c.signals)-1] return c.signals[len(c.signals)-1]
} }
func (c *mockConsumer) count() int {
c.mu.Lock()
defer c.mu.Unlock()
return len(c.signals)
}
// waitStep blocks until the tracker has processed one event. // waitStep blocks until the tracker has processed one event.
func waitStep(t *testing.T, tr *Tracker) { func waitStep(t *testing.T, tr *Tracker) {
t.Helper() t.Helper()