Check seed before shuffle (#5841)

This commit is contained in:
terence tsao 2020-05-13 14:25:36 -07:00 committed by GitHub
parent ffa08f5a85
commit 8ce01acbcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -298,13 +298,6 @@ func ShuffledIndices(state *stateTrie.BeaconState, epoch uint64) ([]uint64, erro
// list with committee index and epoch number. It caches the shuffled indices for current epoch and next epoch. // list with committee index and epoch number. It caches the shuffled indices for current epoch and next epoch.
func UpdateCommitteeCache(state *stateTrie.BeaconState, epoch uint64) error { func UpdateCommitteeCache(state *stateTrie.BeaconState, epoch uint64) error {
for _, e := range []uint64{epoch, epoch + 1} { for _, e := range []uint64{epoch, epoch + 1} {
shuffledIndices, err := ShuffledIndices(state, e)
if err != nil {
return err
}
count := SlotCommitteeCount(uint64(len(shuffledIndices)))
seed, err := Seed(state, e, params.BeaconConfig().DomainBeaconAttester) seed, err := Seed(state, e, params.BeaconConfig().DomainBeaconAttester)
if err != nil { if err != nil {
return err return err
@ -313,6 +306,13 @@ func UpdateCommitteeCache(state *stateTrie.BeaconState, epoch uint64) error {
return nil return nil
} }
shuffledIndices, err := ShuffledIndices(state, e)
if err != nil {
return err
}
count := SlotCommitteeCount(uint64(len(shuffledIndices)))
// Store the sorted indices as well as shuffled indices. In current spec, // Store the sorted indices as well as shuffled indices. In current spec,
// sorted indices is required to retrieve proposer index. This is also // sorted indices is required to retrieve proposer index. This is also
// used for failing verify signature fallback. // used for failing verify signature fallback.