diff --git a/eth/handler_eth.go b/eth/handler_eth.go index 79fd1d118d..3fae75f3c5 100644 --- a/eth/handler_eth.go +++ b/eth/handler_eth.go @@ -23,8 +23,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/eth/protocols/eth" "github.com/ethereum/go-ethereum/p2p/enode" + "github.com/ethereum/go-ethereum/params" ) // ethHandler implements the eth.Backend interface to handle the various network @@ -94,7 +96,20 @@ func (h *ethHandler) Handle(peer *eth.Peer, packet eth.Packet) error { return h.txFetcher.Enqueue(peer.ID(), peer.Version(), txs, true) case *eth.CellsResponse: - return h.blobFetcher.Enqueue(peer.ID(), packet.Hashes, packet.Cells, packet.Mask) + outer, err := packet.Cells.Items() + if err != nil { + return fmt.Errorf("Cells: %v", err) + } + cells := make([][]kzg4844.Cell, len(outer)) + for i := range outer { + if outer[i].Len() > params.BlobTxMaxBlobs*kzg4844.CellsPerBlob { + return fmt.Errorf("Cells: cells per tx exceeded the possible maximum") + } + if cells[i], err = outer[i].Items(); err != nil { + return fmt.Errorf("Cells: %v", err) + } + } + return h.blobFetcher.Enqueue(peer.ID(), packet.Hashes, cells, packet.Mask) default: return fmt.Errorf("unexpected eth packet type: %T", packet) diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index ce2bc876c5..4beb0a7f48 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -754,7 +754,7 @@ func handleCells(backend Backend, msg Decoder, peer *Peer) error { tresp := tracker.Response{ ID: cellsResponse.RequestId, MsgCode: CellsMsg, - Size: len(cellsResponse.CellsResponse.Hashes), + Size: cellsResponse.CellsResponse.Cells.Len(), } if err := peer.tracker.Fulfil(tresp); err != nil { return fmt.Errorf("Cells: %w", err) diff --git a/eth/protocols/eth/peer.go b/eth/protocols/eth/peer.go index cd97325cf0..583b2dce38 100644 --- a/eth/protocols/eth/peer.go +++ b/eth/protocols/eth/peer.go @@ -253,11 +253,23 @@ func (p *Peer) ReplyReceiptsRLP69(id uint64, receipts rlp.RawList[*ReceiptList]) // ReplyCells is the response to GetCells. func (p *Peer) ReplyCells(id uint64, hashes []common.Hash, cells [][]kzg4844.Cell, mask types.CustodyBitmap) error { + inner := make([]rlp.RawList[kzg4844.Cell], len(cells)) + for i, c := range cells { + raw, err := rlp.EncodeToRawList(c) + if err != nil { + return err + } + inner[i] = raw + } + rawCells, err := rlp.EncodeToRawList(inner) + if err != nil { + return err + } return p2p.Send(p.rw, CellsMsg, &CellsPacket{ RequestId: id, CellsResponse: CellsResponse{ Hashes: hashes, - Cells: cells, + Cells: rawCells, Mask: mask, }, }) diff --git a/eth/protocols/eth/protocol.go b/eth/protocols/eth/protocol.go index 2e27fdd74c..6dd1e8bec3 100644 --- a/eth/protocols/eth/protocol.go +++ b/eth/protocols/eth/protocol.go @@ -252,7 +252,8 @@ type ReceiptsPacket70 struct { // ReceiptsRLPResponse is used for receipts, when we already have it encoded type ReceiptsRLPResponse []rlp.RawValue -// NewPooledTransactionHashesPacket71 represents a transaction announcement packet on eth/72. +// NewPooledTransactionHashesPacket71 represents a transaction announcement packet on protocol version +// less than or equal to 71. type NewPooledTransactionHashesPacket71 struct { Types []byte Sizes []uint32 @@ -319,7 +320,7 @@ type GetCellsRequestPacket struct { // CellsResponse represents a response containing cells for blob transactions. type CellsResponse struct { Hashes []common.Hash - Cells [][]kzg4844.Cell + Cells rlp.RawList[rlp.RawList[kzg4844.Cell]] Mask types.CustodyBitmap }