eth/protocols/eth: remove ReceiptsRLPPacket

It's better to have only one type for receipt requests.
This commit is contained in:
Felix Lange 2026-02-28 00:14:32 +01:00
parent dddcb3c023
commit 3cf8e99374
4 changed files with 8 additions and 18 deletions

View file

@ -259,14 +259,14 @@ func handleGetReceipts(backend Backend, msg Decoder, peer *Peer) error {
// ServiceGetReceiptsQuery assembles the response to a receipt query. // ServiceGetReceiptsQuery assembles the response to a receipt query.
// It does not send the bloom filters for the receipts. It is exposed // It does not send the bloom filters for the receipts. It is exposed
// to allow external packages to test protocol behavior. // to allow external packages to test protocol behavior.
func ServiceGetReceiptsQuery(chain *core.BlockChain, query GetReceiptsRequest) []rlp.RawValue { func ServiceGetReceiptsQuery(chain *core.BlockChain, query GetReceiptsRequest) rlp.RawList[*ReceiptList] {
// Gather state data until the fetch or network limits is reached // Gather state data until the fetch or network limits is reached
var ( var (
bytes int bytes int
receipts []rlp.RawValue receipts rlp.RawList[*ReceiptList]
) )
for lookups, hash := range query { for lookups, hash := range query {
if bytes >= softResponseLimit || len(receipts) >= maxReceiptsServe || if bytes >= softResponseLimit || receipts.Len() >= maxReceiptsServe ||
lookups >= 2*maxReceiptsServe { lookups >= 2*maxReceiptsServe {
break break
} }
@ -288,7 +288,7 @@ func ServiceGetReceiptsQuery(chain *core.BlockChain, query GetReceiptsRequest) [
continue continue
} }
} }
receipts = append(receipts, results) receipts.AppendRaw(results)
bytes += len(results) bytes += len(results)
} }
return receipts return receipts

View file

@ -215,10 +215,10 @@ func (p *Peer) ReplyBlockBodiesRLP(id uint64, bodies []rlp.RawValue) error {
} }
// ReplyReceiptsRLP is the response to GetReceipts. // ReplyReceiptsRLP is the response to GetReceipts.
func (p *Peer) ReplyReceiptsRLP(id uint64, receipts []rlp.RawValue) error { func (p *Peer) ReplyReceiptsRLP(id uint64, receipts rlp.RawList[*ReceiptList]) error {
return p2p.Send(p.rw, ReceiptsMsg, &ReceiptsRLPPacket{ return p2p.Send(p.rw, ReceiptsMsg, &ReceiptsPacket{
RequestId: id, RequestId: id,
ReceiptsRLPResponse: receipts, List: receipts,
}) })
} }

View file

@ -230,12 +230,6 @@ type ReceiptsPacket struct {
// ReceiptsRLPResponse is used for receipts, when we already have it encoded // ReceiptsRLPResponse is used for receipts, when we already have it encoded
type ReceiptsRLPResponse []rlp.RawValue type ReceiptsRLPResponse []rlp.RawValue
// ReceiptsRLPPacket is ReceiptsRLPResponse with request ID wrapping.
type ReceiptsRLPPacket struct {
RequestId uint64
ReceiptsRLPResponse
}
// NewPooledTransactionHashesPacket represents a transaction announcement packet on eth/68 and newer. // NewPooledTransactionHashesPacket represents a transaction announcement packet on eth/68 and newer.
type NewPooledTransactionHashesPacket struct { type NewPooledTransactionHashesPacket struct {
Types []byte Types []byte

View file

@ -229,10 +229,6 @@ func TestMessages(t *testing.T) {
GetReceiptsPacket{1111, GetReceiptsRequest(hashes)}, GetReceiptsPacket{1111, GetReceiptsRequest(hashes)},
common.FromHex("f847820457f842a000000000000000000000000000000000000000000000000000000000deadc0dea000000000000000000000000000000000000000000000000000000000feedbeef"), common.FromHex("f847820457f842a000000000000000000000000000000000000000000000000000000000deadc0dea000000000000000000000000000000000000000000000000000000000feedbeef"),
}, },
{
ReceiptsRLPPacket{1111, ReceiptsRLPResponse([]rlp.RawValue{receiptsRlp})},
common.FromHex("f902e6820457f902e0f902ddf901688082014db9010000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000004000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ffb9016f01f9016b018201bcb9010000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000001000000000000000000000000000000000000000000000000040000000000000000000000000004000000000000000000000000000000000000000000000000000000008000400000000000000000000000000000000000000000000000000000000000000000000000000000040f862f860940000000000000000000000000000000000000022f842a00000000000000000000000000000000000000000000000000000000000005668a0000000000000000000000000000000000000000000000000000000000000977386020f0f0f0608"),
},
{ {
ReceiptsPacket{1111, encodeRL([]*ReceiptList{NewReceiptList(receipts)})}, ReceiptsPacket{1111, encodeRL([]*ReceiptList{NewReceiptList(receipts)})},
common.FromHex("f8da820457f8d5f8d3f866808082014df85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100fff86901018201bcf862f860940000000000000000000000000000000000000022f842a00000000000000000000000000000000000000000000000000000000000005668a0000000000000000000000000000000000000000000000000000000000000977386020f0f0f0608"), common.FromHex("f8da820457f8d5f8d3f866808082014df85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100fff86901018201bcf862f860940000000000000000000000000000000000000022f842a00000000000000000000000000000000000000000000000000000000000005668a0000000000000000000000000000000000000000000000000000000000000977386020f0f0f0608"),