From 74dd00191175454c378adf53cc3e9cbcf06bb355 Mon Sep 17 00:00:00 2001 From: healthykim Date: Sun, 7 Dec 2025 22:26:24 +0900 Subject: [PATCH] fix: fix trimReceiptsRLP bug --- eth/protocols/eth/handlers.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index a6c7b1c576..0551b8e169 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -388,9 +388,9 @@ func serviceGetReceiptsQuery70(chain *core.BlockChain, query GetReceiptsRequest, } if firstBlockReceiptIndex > 0 && lookups == 0 { - results, lastBlockIncomplete = trimReceiptsRLP(results, int(firstBlockReceiptIndex)) + results, lastBlockIncomplete = trimReceiptsRLP(results, int(firstBlockReceiptIndex), maxPacketSize) } else if bytes+len(results) > maxPacketSize { - results, lastBlockIncomplete = trimReceiptsRLP(results, 0) + results, lastBlockIncomplete = trimReceiptsRLP(results, 0, maxPacketSize-bytes) } receipts = append(receipts, results) @@ -401,7 +401,7 @@ func serviceGetReceiptsQuery70(chain *core.BlockChain, query GetReceiptsRequest, } // trimReceiptsRLP trims raw value from `from` index until it exceeds limit -func trimReceiptsRLP(receiptsRLP rlp.RawValue, from int) (rlp.RawValue, bool) { +func trimReceiptsRLP(receiptsRLP rlp.RawValue, from int, limit int) (rlp.RawValue, bool) { var ( out bytes.Buffer buffer = rlp.NewEncoderBuffer(&out) @@ -418,7 +418,7 @@ func trimReceiptsRLP(receiptsRLP rlp.RawValue, from int) (rlp.RawValue, bool) { continue } receipt := iter.Value() - if bytes+len(receipt) > maxPacketSize { + if bytes+len(receipt) > limit { overflow = true break }