mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 11:20:45 +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/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"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/eth/protocols/eth"
|
||||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ethHandler implements the eth.Backend interface to handle the various network
|
// 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)
|
return h.txFetcher.Enqueue(peer.ID(), peer.Version(), txs, true)
|
||||||
|
|
||||||
case *eth.CellsResponse:
|
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:
|
default:
|
||||||
return fmt.Errorf("unexpected eth packet type: %T", packet)
|
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{
|
tresp := tracker.Response{
|
||||||
ID: cellsResponse.RequestId,
|
ID: cellsResponse.RequestId,
|
||||||
MsgCode: CellsMsg,
|
MsgCode: CellsMsg,
|
||||||
Size: len(cellsResponse.CellsResponse.Hashes),
|
Size: cellsResponse.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)
|
||||||
|
|
|
||||||
|
|
@ -253,11 +253,23 @@ func (p *Peer) ReplyReceiptsRLP69(id uint64, receipts rlp.RawList[*ReceiptList])
|
||||||
|
|
||||||
// ReplyCells is the response to GetCells.
|
// ReplyCells is the response to GetCells.
|
||||||
func (p *Peer) ReplyCells(id uint64, hashes []common.Hash, cells [][]kzg4844.Cell, mask types.CustodyBitmap) error {
|
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{
|
return p2p.Send(p.rw, CellsMsg, &CellsPacket{
|
||||||
RequestId: id,
|
RequestId: id,
|
||||||
CellsResponse: CellsResponse{
|
CellsResponse: CellsResponse{
|
||||||
Hashes: hashes,
|
Hashes: hashes,
|
||||||
Cells: cells,
|
Cells: rawCells,
|
||||||
Mask: mask,
|
Mask: mask,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,8 @@ type ReceiptsPacket70 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
|
||||||
|
|
||||||
// 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 {
|
type NewPooledTransactionHashesPacket71 struct {
|
||||||
Types []byte
|
Types []byte
|
||||||
Sizes []uint32
|
Sizes []uint32
|
||||||
|
|
@ -319,7 +320,7 @@ type GetCellsRequestPacket struct {
|
||||||
// CellsResponse represents a response containing cells for blob transactions.
|
// CellsResponse represents a response containing cells for blob transactions.
|
||||||
type CellsResponse struct {
|
type CellsResponse struct {
|
||||||
Hashes []common.Hash
|
Hashes []common.Hash
|
||||||
Cells [][]kzg4844.Cell
|
Cells rlp.RawList[rlp.RawList[kzg4844.Cell]]
|
||||||
Mask types.CustodyBitmap
|
Mask types.CustodyBitmap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue