diff --git a/beacon-chain/p2p/types/types.go b/beacon-chain/p2p/types/types.go index 545dc7b279c9..1ffc4dfd54ea 100644 --- a/beacon-chain/p2p/types/types.go +++ b/beacon-chain/p2p/types/types.go @@ -136,7 +136,7 @@ func (b *BlobSidecarsByRootReq) SizeSSZ() int { return len(*b) * blobIdSize } -// MarshalSSZTo marshals the block by roots request with the provided byte slice. +// MarshalSSZTo appends the serialized BlobSidecarsByRootReq value to the provided byte slice. func (b *BlobSidecarsByRootReq) MarshalSSZTo(dst []byte) ([]byte, error) { // A List without an enclosing container is marshaled exactly like a vector, no length offset required. marshalledObj, err := b.MarshalSSZ() @@ -146,7 +146,7 @@ func (b *BlobSidecarsByRootReq) MarshalSSZTo(dst []byte) ([]byte, error) { return append(dst, marshalledObj...), nil } -// MarshalSSZ Marshals the block by roots request type into the serialized object. +// MarshalSSZ serializes the BlobSidecarsByRootReq value to a byte slice. func (b *BlobSidecarsByRootReq) MarshalSSZ() ([]byte, error) { buf := make([]byte, len(*b)*blobIdSize) for i, id := range *b { @@ -160,7 +160,7 @@ func (b *BlobSidecarsByRootReq) MarshalSSZ() ([]byte, error) { } // UnmarshalSSZ unmarshals the provided bytes buffer into the -// block by roots request object. +// BlobSidecarsByRootReq value. func (b *BlobSidecarsByRootReq) UnmarshalSSZ(buf []byte) error { bufLen := len(buf) maxLength := int(params.BeaconNetworkConfig().MaxRequestBlobsSidecars) * blobIdSize diff --git a/beacon-chain/sync/rpc_send_request.go b/beacon-chain/sync/rpc_send_request.go index 0d760aaf1125..be6dd78f5e99 100644 --- a/beacon-chain/sync/rpc_send_request.go +++ b/beacon-chain/sync/rpc_send_request.go @@ -95,6 +95,10 @@ func SendBeaconBlocksByRootRequest( ctx context.Context, clock blockchain.TemporalOracle, p2pProvider p2p.P2P, pid peer.ID, req *p2ptypes.BeaconBlockByRootsReq, blockProcessor BeaconBlockProcessor, ) ([]interfaces.ReadOnlySignedBeaconBlock, error) { + if uint64(len(*req)) > params.BeaconNetworkConfig().MaxRequestBlobsSidecars { + return nil, errors.Wrapf(p2ptypes.ErrMaxBlobReqExceeded, "length=%d", len(*req)) + } + topic, err := p2p.TopicFromMessage(p2p.BeaconBlocksByRootsMessageName, slots.ToEpoch(clock.CurrentSlot())) if err != nil { return nil, err diff --git a/cmd/beacon-chain/flags/base.go b/cmd/beacon-chain/flags/base.go index 5891648bdd35..e48ed7cf144a 100644 --- a/cmd/beacon-chain/flags/base.go +++ b/cmd/beacon-chain/flags/base.go @@ -170,7 +170,7 @@ var ( Usage: "The amount of blobs the local peer is bounded to request and respond to in a batch.", Value: 8, } - // BlockBatchLimitBurstFactor specifies the factor by which block batch size may increase. + // BlobBatchLimitBurstFactor specifies the factor by which blob batch size may increase. BlobBatchLimitBurstFactor = &cli.IntFlag{ Name: "blob-batch-limit-burst-factor", Usage: "The factor by which blob batch limit may increase on burst.",