Check for array out of bounds when calculating proposer delta -- follow up (#6630)

* failing test
* fix
This commit is contained in:
Preston Van Loon 2020-07-17 23:39:43 -07:00 committed by GitHub
parent 5336a167af
commit c573306621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -162,7 +162,7 @@ func ProposersDelta(state *stateTrie.BeaconState, pBal *Balance, vp []*Validator
baseRewardsPerEpoch := params.BeaconConfig().BaseRewardsPerEpoch
proposerRewardQuotient := params.BeaconConfig().ProposerRewardQuotient
for _, v := range vp {
if v.ProposerIndex > uint64(len(rewards)) {
if v.ProposerIndex >= uint64(len(rewards)) {
// This should never happen with a valid state / validator.
return nil, errors.New("proposer index out of range")
}

View File

@ -368,7 +368,7 @@ func TestProposerDeltaPrecompute_ValidatorIndexOutOfRange(t *testing.T) {
t.Fatal(err)
}
proposerIndex := validatorCount + 1
proposerIndex := validatorCount
b := &Balance{ActiveCurrentEpoch: 1000}
v := []*Validator{
{IsPrevEpochAttester: true, CurrentEpochEffectiveBalance: 32, ProposerIndex: proposerIndex},