mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 17:03:46 +00:00
eth/protocols: fix Cells/GetCells RLP encoding (#35428)
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:
parent
d6f222a081
commit
38271784c2
3 changed files with 17 additions and 14 deletions
|
|
@ -694,7 +694,7 @@ func handleGetCells(backend Backend, msg Decoder, peer *Peer) error {
|
||||||
if err := msg.Decode(&query); err != nil {
|
if err := msg.Decode(&query); err != nil {
|
||||||
return err
|
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)
|
return peer.ReplyCells(query.RequestId, hashes, cells, custody)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -754,12 +754,16 @@ func handleCells(backend Backend, msg Decoder, peer *Peer) error {
|
||||||
tresp := tracker.Response{
|
tresp := tracker.Response{
|
||||||
ID: cellsResponse.RequestId,
|
ID: cellsResponse.RequestId,
|
||||||
MsgCode: CellsMsg,
|
MsgCode: CellsMsg,
|
||||||
Size: cellsResponse.CellsResponse.Cells.Len(),
|
Size: cellsResponse.Cells.Len(),
|
||||||
}
|
}
|
||||||
if err := peer.tracker.Fulfil(tresp); err != nil {
|
if err := peer.tracker.Fulfil(tresp); err != nil {
|
||||||
return fmt.Errorf("Cells: %w", err)
|
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.
|
// handleGetBlockAccessLists serves a GetBlockAccessLists request.
|
||||||
|
|
|
||||||
|
|
@ -273,11 +273,9 @@ func (p *Peer) ReplyCells(id uint64, hashes []common.Hash, cells [][]kzg4844.Cel
|
||||||
}
|
}
|
||||||
return p2p.Send(p.rw, CellsMsg, &CellsPacket{
|
return p2p.Send(p.rw, CellsMsg, &CellsPacket{
|
||||||
RequestId: id,
|
RequestId: id,
|
||||||
CellsResponse: CellsResponse{
|
Hashes: hashes,
|
||||||
Hashes: hashes,
|
Cells: rawCells,
|
||||||
Cells: rawCells,
|
Mask: mask,
|
||||||
Mask: mask,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,10 +295,8 @@ func (p *Peer) RequestPayload(hashes []common.Hash, cell types.CustodyBitmap) er
|
||||||
}
|
}
|
||||||
return p2p.Send(p.rw, GetCellsMsg, &GetCellsRequestPacket{
|
return p2p.Send(p.rw, GetCellsMsg, &GetCellsRequestPacket{
|
||||||
RequestId: id,
|
RequestId: id,
|
||||||
GetCellsRequest: GetCellsRequest{
|
Hashes: hashes,
|
||||||
Hashes: hashes,
|
Mask: cell,
|
||||||
Mask: cell,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,8 @@ type GetCellsRequest struct {
|
||||||
// GetCellsRequestPacket represents a cell request with request ID wrapping.
|
// GetCellsRequestPacket represents a cell request with request ID wrapping.
|
||||||
type GetCellsRequestPacket struct {
|
type GetCellsRequestPacket struct {
|
||||||
RequestId uint64
|
RequestId uint64
|
||||||
GetCellsRequest
|
Hashes []common.Hash
|
||||||
|
Mask types.CustodyBitmap
|
||||||
}
|
}
|
||||||
|
|
||||||
// CellsResponse represents a response containing cells for blob transactions.
|
// 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.
|
// CellsPacket represents a cells response with request ID wrapping.
|
||||||
type CellsPacket struct {
|
type CellsPacket struct {
|
||||||
RequestId uint64
|
RequestId uint64
|
||||||
CellsResponse
|
Hashes []common.Hash
|
||||||
|
Cells rlp.RawList[rlp.RawList[kzg4844.Cell]]
|
||||||
|
Mask types.CustodyBitmap
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetBlockAccessListsRequest []common.Hash
|
type GetBlockAccessListsRequest []common.Hash
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue