mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 03:10:48 +00:00
eth/protocols: use rawList for Cells
This commit is contained in:
parent
f9d89dd5f2
commit
ae128b98eb
4 changed files with 33 additions and 5 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue