2023-06-14 18:04:48 +00:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
2024-02-15 05:46:47 +00:00
|
|
|
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
2023-06-14 18:04:48 +00:00
|
|
|
)
|
|
|
|
|
2023-07-10 19:02:44 +00:00
|
|
|
// HydrateBlobSidecar hydrates a blob sidecar with correct field length sizes
|
|
|
|
// to comply with SSZ marshalling and unmarshalling rules.
|
2023-12-12 15:58:11 +00:00
|
|
|
func HydrateBlobSidecar(b *ethpb.BlobSidecar) *ethpb.BlobSidecar {
|
|
|
|
if b.SignedBlockHeader == nil {
|
|
|
|
b.SignedBlockHeader = HydrateSignedBeaconHeader(ðpb.SignedBeaconBlockHeader{
|
|
|
|
Header: ðpb.BeaconBlockHeader{},
|
|
|
|
})
|
2023-07-10 19:02:44 +00:00
|
|
|
}
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2023-12-12 15:58:11 +00:00
|
|
|
if b.CommitmentInclusionProof == nil {
|
|
|
|
b.CommitmentInclusionProof = HydrateCommitmentInclusionProofs()
|
2023-11-28 23:20:02 +00:00
|
|
|
}
|
2023-06-14 18:04:48 +00:00
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2023-12-12 15:58:11 +00:00
|
|
|
// 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)
|
2023-06-14 18:04:48 +00:00
|
|
|
}
|
2023-12-12 15:58:11 +00:00
|
|
|
return r
|
2023-06-14 18:04:48 +00:00
|
|
|
}
|