Skip to content

Commit

Permalink
debug: no sleep wit error 'nonce too low'
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhang2023 committed Feb 5, 2024
1 parent c83fde1 commit 1cab972
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion eth/fetcher/tx_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/common/gopool"
"github.com/ethereum/go-ethereum/common/lru"
"github.com/ethereum/go-ethereum/common/mclock"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -305,6 +306,8 @@ func (f *TxFetcher) Enqueue(peer string, txs []*types.Transaction, direct bool)
duplicate int64
underpriced int64
otherreject int64

rejectwithoutnoncetoolow int64
)
batch := txs[i:end]
for j, err := range f.addTxs(batch) {
Expand All @@ -326,6 +329,9 @@ func (f *TxFetcher) Enqueue(peer string, txs []*types.Transaction, direct bool)

default:
otherreject++
if !errors.Is(err, core.ErrNonceTooLow) {
rejectwithoutnoncetoolow++
}
log.Warn("Peer's transaction rejected", "peer", peer, "txHash", batch[j].Hash().String(), "err", err.Error())
}
added = append(added, batch[j].Hash())
Expand All @@ -335,7 +341,7 @@ func (f *TxFetcher) Enqueue(peer string, txs []*types.Transaction, direct bool)
otherRejectMeter.Mark(otherreject)

// If 'other reject' is >25% of the deliveries in any batch, sleep a bit.
if otherreject > 128/4 {
if rejectwithoutnoncetoolow > 128/4 {
time.Sleep(200 * time.Millisecond)
log.Warn("Peer delivering stale transactions", "peer", peer, "rejected", otherreject)
}
Expand Down

0 comments on commit 1cab972

Please sign in to comment.