From cc11ffd4637968a1e12a7cfa10bca2515a47c670 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/eth/handler.go b/eth/handler.go index 0d07e88c7a..1278dceed8 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -179,9 +179,17 @@ func newHandler(config *handlerConfig) (*handler, error) { addTxs := func(txs []*types.Transaction) []error { return h.txpool.Add(txs, false) } - + 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 + } validateMeta := func(tx common.Hash, kind byte) error { - if h.txpool.Has(tx) { + if hasTx(tx) { return txpool.ErrAlreadyKnown } if !h.txpool.FilterType(kind) {