Skip to content

Commit

Permalink
fixup! BlobSidecarsByRoot RPC handler
Browse files Browse the repository at this point in the history
  • Loading branch information
kasey committed Jun 10, 2023
1 parent 9058832 commit f8a1c0b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions beacon-chain/p2p/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions beacon-chain/sync/rpc_send_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/beacon-chain/flags/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down

0 comments on commit f8a1c0b

Please sign in to comment.