From d9e85580af4133fe3c6963b9d38002ff19645674 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Fri, 7 Nov 2025 12:10:42 +0100 Subject: [PATCH] eth/handler: check for tx on chain as well The fetcher should not fetch transactions that are already on chain. Until now we were only checking in the txpool, but that does not have the old transaction. Here we extend the check to the chain as well. Still WIP, as this check might be expensive, and there are other options to do the same check. Signed-off-by: Csaba Kiraly --- eth/handler.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/eth/handler.go b/eth/handler.go index ff970e2ba628..b6eab93a3d7e 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -205,7 +205,16 @@ func newHandler(config *handlerConfig) (*handler, error) { addTxs := func(txs []*types.Transaction) []error { return h.txpool.Add(txs, false) } - h.txFetcher = fetcher.NewTxFetcher(h.txpool.Has, addTxs, fetchTx, h.removePeer) + hasTx := func(hash common.Hash) bool { + txpoolHas := h.txpool.Has(hash) + // check on chain as well (no need to check limbo separately, as chain checks limbo too) + _, tx := h.chain.GetCanonicalTransaction(hash) + if !txpoolHas && tx != nil { + log.Trace("handler: hasTx found tx on chain", "txhash", hash) + } + return txpoolHas || tx != nil + } + h.txFetcher = fetcher.NewTxFetcher(hasTx, addTxs, fetchTx, h.removePeer) return h, nil }