prysm-pulse/testing/util/blob.go
james-prysm 5e56b5fdd7
Beacon APIs: re enabling blob events (#13315)
* re enabling blob events

* terence's comments

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

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

---------

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
2023-12-12 15:58:11 +00:00

40 lines
1.2 KiB
Go

package util
import (
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
ethpb "github.com/prysmaticlabs/prysm/v4/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
}