-
Notifications
You must be signed in to change notification settings - Fork 985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Aggregated Public Key Method #14178
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import ( | |
"github.com/prysmaticlabs/prysm/v5/config/params" | ||
consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types" | ||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" | ||
"github.com/prysmaticlabs/prysm/v5/crypto/bls" | ||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" | ||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" | ||
"github.com/prysmaticlabs/prysm/v5/runtime/version" | ||
|
@@ -223,6 +224,36 @@ func (b *BeaconState) PubkeyAtIndex(idx primitives.ValidatorIndex) [fieldparams. | |
return bytesutil.ToBytes48(v.PublicKey) | ||
} | ||
|
||
// AggregatedKeyFromIndices builds an aggregated public key from the provided | ||
// validator indices. | ||
func (b *BeaconState) AggregatedKeyFromIndices(idxs []uint64) (bls.PublicKey, error) { | ||
b.lock.RLock() | ||
defer b.lock.RUnlock() | ||
|
||
pubKeys := make([][]byte, len(idxs)) | ||
for i, idx := range idxs { | ||
var v *ethpb.Validator | ||
if features.Get().EnableExperimentalState { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This case is not tested at all, is it expected? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its fine in this particular case as its simply for the experimental state, we don't do the same for a few other methods too. Also the experimental state has been tested in e2e, so these paths are tested, just not in the current unit tests. Once we flip the flag, it will get tested as it becomes the default path |
||
var err error | ||
v, err = b.validatorsMultiValue.At(b, idx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} else { | ||
if idx >= uint64(len(b.validators)) { | ||
return nil, consensus_types.ErrOutOfBounds | ||
} | ||
v = b.validators[idx] | ||
} | ||
|
||
if v == nil { | ||
return nil, ErrNilWrappedValidator | ||
} | ||
pubKeys[i] = v.PublicKey | ||
} | ||
return bls.AggregatePublicKeys(pubKeys) | ||
} | ||
|
||
// PublicKeys builds a list of all validator public keys, with each key's index aligned to its validator index. | ||
func (b *BeaconState) PublicKeys() ([][fieldparams.BLSPubkeyLength]byte, error) { | ||
b.lock.RLock() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The previous function is
AggregatePublicKeys
. Should'nt this function nameAggregateKeyFromIndices
?