Skip to content

Commit 9e3c25a

Browse files
committed
chore: add sanity check for receipts and transaction length
1 parent 148d074 commit 9e3c25a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

eth/filters/filter.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,11 @@ func filterReceipts(txHashes []common.Hash, ev core.ChainEvent) []*ReceiptWithTx
569569
receipts := ev.Receipts
570570
txs := ev.Transactions
571571

572+
if len(receipts) != len(txs) {
573+
log.Warn("Receipts and transactions length mismatch", "receipts", len(receipts), "transactions", len(txs))
574+
return ret
575+
}
576+
572577
if len(txHashes) == 0 {
573578
// No filter, send all receipts with their transactions.
574579
ret = make([]*ReceiptWithTx, len(receipts))
@@ -582,7 +587,7 @@ func filterReceipts(txHashes []common.Hash, ev core.ChainEvent) []*ReceiptWithTx
582587
// Filter by single transaction hash.
583588
// This is a common case, so we distinguish it from filtering by multiple tx hashes and made a small optimization.
584589
for i, receipt := range receipts {
585-
if receipt.TxHash == (txHashes)[0] {
590+
if receipt.TxHash == txHashes[0] {
586591
ret = append(ret, &ReceiptWithTx{
587592
Receipt: receipt,
588593
Transaction: txs[i],

0 commit comments

Comments
 (0)