eth/protocols: fix Cells/GetCells RLP encoding (#35428)
Some checks are pending
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Docker Image (push) Waiting to run
/ Linux Build (push) Waiting to run

This PR aligns the `Cells` and `GetCells` message implementations with
the spec: https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getcells-0x14

Previously, `GetCellsPacket` and `CellsPacket` embedded `GetCellsRequest` 
and `CellsResponse`. This caused them to be encoded as nested lists, which
does not match the wire format defined by the spec. This PR inlines their fields
to flatten the RLP layout of `Cells` and `GetCells`.
This commit is contained in:
Bosul Mun 2026-07-28 07:13:32 +02:00 committed by GitHub
parent d6f222a081
commit 38271784c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 14 deletions

View file

@ -694,7 +694,7 @@ func handleGetCells(backend Backend, msg Decoder, peer *Peer) error {
if err := msg.Decode(&query); err != nil {
return err
}
hashes, cells, custody := answerGetCells(backend, query.GetCellsRequest)
hashes, cells, custody := answerGetCells(backend, GetCellsRequest{Hashes: query.Hashes, Mask: query.Mask})
return peer.ReplyCells(query.RequestId, hashes, cells, custody)
}
@ -754,12 +754,16 @@ func handleCells(backend Backend, msg Decoder, peer *Peer) error {
tresp := tracker.Response{
ID: cellsResponse.RequestId,
MsgCode: CellsMsg,
Size: cellsResponse.CellsResponse.Cells.Len(),
Size: cellsResponse.Cells.Len(),
}
if err := peer.tracker.Fulfil(tresp); err != nil {
return fmt.Errorf("Cells: %w", err)
}
return backend.Handle(peer, &cellsResponse.CellsResponse)
return backend.Handle(peer, &CellsResponse{
Hashes: cellsResponse.Hashes,
Cells: cellsResponse.Cells,
Mask: cellsResponse.Mask,
})
}
// handleGetBlockAccessLists serves a GetBlockAccessLists request.

View file

@ -273,11 +273,9 @@ func (p *Peer) ReplyCells(id uint64, hashes []common.Hash, cells [][]kzg4844.Cel
}
return p2p.Send(p.rw, CellsMsg, &CellsPacket{
RequestId: id,
CellsResponse: CellsResponse{
Hashes: hashes,
Cells: rawCells,
Mask: mask,
},
Hashes: hashes,
Cells: rawCells,
Mask: mask,
})
}
@ -297,10 +295,8 @@ func (p *Peer) RequestPayload(hashes []common.Hash, cell types.CustodyBitmap) er
}
return p2p.Send(p.rw, GetCellsMsg, &GetCellsRequestPacket{
RequestId: id,
GetCellsRequest: GetCellsRequest{
Hashes: hashes,
Mask: cell,
},
Hashes: hashes,
Mask: cell,
})
}

View file

@ -314,7 +314,8 @@ type GetCellsRequest struct {
// GetCellsRequestPacket represents a cell request with request ID wrapping.
type GetCellsRequestPacket struct {
RequestId uint64
GetCellsRequest
Hashes []common.Hash
Mask types.CustodyBitmap
}
// CellsResponse represents a response containing cells for blob transactions.
@ -327,7 +328,9 @@ type CellsResponse struct {
// CellsPacket represents a cells response with request ID wrapping.
type CellsPacket struct {
RequestId uint64
CellsResponse
Hashes []common.Hash
Cells rlp.RawList[rlp.RawList[kzg4844.Cell]]
Mask types.CustodyBitmap
}
type GetBlockAccessListsRequest []common.Hash