From 9e3c25a676c5e5acb5b854bed3c1975662070bea Mon Sep 17 00:00:00 2001 From: 10gic <2391796+10gic@users.noreply.github.com> Date: Thu, 25 Sep 2025 10:50:40 +0800 Subject: [PATCH] chore: add sanity check for receipts and transaction length --- eth/filters/filter.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eth/filters/filter.go b/eth/filters/filter.go index 0b2f403355..02399bc801 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -569,6 +569,11 @@ func filterReceipts(txHashes []common.Hash, ev core.ChainEvent) []*ReceiptWithTx receipts := ev.Receipts txs := ev.Transactions + if len(receipts) != len(txs) { + log.Warn("Receipts and transactions length mismatch", "receipts", len(receipts), "transactions", len(txs)) + return ret + } + if len(txHashes) == 0 { // No filter, send all receipts with their transactions. ret = make([]*ReceiptWithTx, len(receipts)) @@ -582,7 +587,7 @@ func filterReceipts(txHashes []common.Hash, ev core.ChainEvent) []*ReceiptWithTx // Filter by single transaction hash. // This is a common case, so we distinguish it from filtering by multiple tx hashes and made a small optimization. for i, receipt := range receipts { - if receipt.TxHash == (txHashes)[0] { + if receipt.TxHash == txHashes[0] { ret = append(ret, &ReceiptWithTx{ Receipt: receipt, Transaction: txs[i],