prysm-pulse/testing/util/blob.go
terence 5a66807989
Update to V5 (#13622)
* First take at updating everything to v5

* Patch gRPC gateway to use prysm v5

Fix patch

* Update go ssz

---------

Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
2024-02-15 05:46:47 +00:00

40 lines
1.2 KiB
Go

package util
import (
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
)
// HydrateBlobSidecar hydrates a blob sidecar with correct field length sizes
// to comply with SSZ marshalling and unmarshalling rules.
func HydrateBlobSidecar(b *ethpb.BlobSidecar) *ethpb.BlobSidecar {
if b.SignedBlockHeader == nil {
b.SignedBlockHeader = HydrateSignedBeaconHeader(&ethpb.SignedBeaconBlockHeader{
Header: &ethpb.BeaconBlockHeader{},
})
}
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)
}
if b.CommitmentInclusionProof == nil {
b.CommitmentInclusionProof = HydrateCommitmentInclusionProofs()
}
return b
}
// HydrateCommitmentInclusionProofs returns 2d byte slice of Commitment Inclusion Proofs
func HydrateCommitmentInclusionProofs() [][]byte {
r := make([][]byte, fieldparams.KzgCommitmentInclusionProofDepth)
for i := range r {
r[i] = make([]byte, fieldparams.RootLength)
}
return r
}