mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
5a66807989
* 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>
40 lines
1.2 KiB
Go
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(ðpb.SignedBeaconBlockHeader{
|
|
Header: ðpb.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
|
|
}
|