prysm-pulse/testing/util/blob.go
Radosław Kapka 6a638bd148
HTTP handler for Beacon API events (#13207)
* in progress

* implementation done

* bzl

* fixes

* tests in progress

* tests

* go mod tidy

* Update beacon-chain/rpc/eth/events/events.go

Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>

* fix config test

* fix unreachable code issue

* remove proto service dir

* test fix

---------

Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>
Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
2023-11-28 23:20:02 +00:00

75 lines
2.4 KiB
Go

package util
import (
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
)
// HydrateSignedBlobSidecar hydrates a signed blob sidecar with correct field length sizes
// to comply with SSZ marshalling and unmarshalling rules.
func HydrateSignedBlobSidecar(b *ethpb.SignedBlobSidecar) *ethpb.SignedBlobSidecar {
if b.Signature == nil {
b.Signature = make([]byte, fieldparams.BLSSignatureLength)
}
if b.Message == nil {
b.Message = &ethpb.DeprecatedBlobSidecar{}
}
b.Message = HydrateBlobSidecar(b.Message)
return b
}
// HydrateBlobSidecar hydrates a blob sidecar with correct field length sizes
// to comply with SSZ marshalling and unmarshalling rules.
func HydrateBlobSidecar(b *ethpb.DeprecatedBlobSidecar) *ethpb.DeprecatedBlobSidecar {
if b.BlockRoot == nil {
b.BlockRoot = make([]byte, fieldparams.RootLength)
}
if b.BlockParentRoot == nil {
b.BlockParentRoot = make([]byte, fieldparams.RootLength)
}
if b.Blob == nil {
b.Blob = make([]byte, fieldparams.BlobLength)
}
if b.KzgCommitment == nil {
b.KzgCommitment = make([]byte, fieldparams.BLSPubkeyLength)
}
if b.KzgProof == nil {
b.KzgProof = make([]byte, fieldparams.BLSPubkeyLength)
}
return b
}
// HydrateSignedBlindedBlobSidecar hydrates a signed blinded blob sidecar with correct field length sizes
// to comply with SSZ marshalling and unmarshalling rules.
func HydrateSignedBlindedBlobSidecar(b *ethpb.SignedBlindedBlobSidecar) *ethpb.SignedBlindedBlobSidecar {
if b.Signature == nil {
b.Signature = make([]byte, fieldparams.BLSSignatureLength)
}
if b.Message == nil {
b.Message = &ethpb.BlindedBlobSidecar{}
}
b.Message = HydrateBlindedBlobSidecar(b.Message)
return b
}
// HydrateBlindedBlobSidecar hydrates a blinded blob sidecar with correct field length sizes
// to comply with SSZ marshalling and unmarshalling rules.
func HydrateBlindedBlobSidecar(b *ethpb.BlindedBlobSidecar) *ethpb.BlindedBlobSidecar {
if b.BlockRoot == nil {
b.BlockRoot = make([]byte, fieldparams.RootLength)
}
if b.BlockParentRoot == nil {
b.BlockParentRoot = make([]byte, fieldparams.RootLength)
}
if b.KzgCommitment == nil {
b.KzgCommitment = make([]byte, fieldparams.BLSPubkeyLength)
}
if b.KzgProof == nil {
b.KzgProof = make([]byte, fieldparams.BLSPubkeyLength)
}
if b.BlobRoot == nil {
b.BlobRoot = make([]byte, fieldparams.RootLength)
}
return b
}