avoid decoding during validation

This commit is contained in:
healthykim 2026-02-24 18:19:04 +09:00
parent be6aa56569
commit 48da785c86

View file

@ -525,13 +525,21 @@ func (p *Peer) validateLastBlockReceipt(receiptLists []*ReceiptList69, id uint64
// should be dropped, don't clear the buffer // should be dropped, don't clear the buffer
return 0, fmt.Errorf("total number of tx exceeded limit") return 0, fmt.Errorf("total number of tx exceeded limit")
} }
// todo: avoid calling Items() here // Count log size per receipt
receipts, err := lastReceipts.items.Items() it := lastReceipts.items.ContentIterator()
if err != nil { for it.Next() {
return 0, fmt.Errorf("invalid receipts: %v", err) content, _, err := rlp.SplitList(it.Value())
} if err != nil {
for _, rc := range receipts { return 0, fmt.Errorf("invalid receipt structure: %v", err)
log += uint64(len(rc.Logs)) }
rest := content
for range 3 {
_, _, rest, err = rlp.Split(rest)
if err != nil {
return 0, fmt.Errorf("invalid receipt structure: %v", err)
}
}
log += uint64(len(rest))
} }
// Verify that the overall downloaded receipt size does not exceed the block gas limit. // Verify that the overall downloaded receipt size does not exceed the block gas limit.
if previousLog+log > gasUsed/params.LogDataGas { if previousLog+log > gasUsed/params.LogDataGas {