2021-09-23 18:53:46 +00:00
|
|
|
package util
|
2021-07-28 17:15:23 +00:00
|
|
|
|
|
|
|
import (
|
2023-03-17 18:52:56 +00:00
|
|
|
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/config/params"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
2021-07-28 17:15:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// HydrateSyncCommittee hydrates the provided sync committee message.
|
2021-08-10 19:55:24 +00:00
|
|
|
func HydrateSyncCommittee(s *ethpb.SyncCommitteeMessage) *ethpb.SyncCommitteeMessage {
|
2021-07-28 17:15:23 +00:00
|
|
|
if s.Signature == nil {
|
|
|
|
s.Signature = make([]byte, 96)
|
|
|
|
}
|
|
|
|
if s.BlockRoot == nil {
|
2021-12-14 18:42:05 +00:00
|
|
|
s.BlockRoot = make([]byte, fieldparams.RootLength)
|
2021-07-28 17:15:23 +00:00
|
|
|
}
|
|
|
|
return s
|
|
|
|
}
|
2021-11-24 01:56:34 +00:00
|
|
|
|
|
|
|
// ConvertToCommittee takes a list of pubkeys and returns a SyncCommittee with
|
|
|
|
// these keys as members. Some keys may appear repeated
|
|
|
|
func ConvertToCommittee(inputKeys [][]byte) *ethpb.SyncCommittee {
|
|
|
|
var pubKeys [][]byte
|
|
|
|
for i := uint64(0); i < params.BeaconConfig().SyncCommitteeSize; i++ {
|
|
|
|
if i < uint64(len(inputKeys)) {
|
|
|
|
pubKeys = append(pubKeys, bytesutil.PadTo(inputKeys[i], params.BeaconConfig().BLSPubkeyLength))
|
|
|
|
} else {
|
|
|
|
pubKeys = append(pubKeys, bytesutil.PadTo([]byte{}, params.BeaconConfig().BLSPubkeyLength))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ðpb.SyncCommittee{
|
|
|
|
Pubkeys: pubKeys,
|
|
|
|
AggregatePubkey: bytesutil.PadTo([]byte{}, params.BeaconConfig().BLSPubkeyLength),
|
|
|
|
}
|
|
|
|
}
|