mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
Check for array out of bounds when calculating proposer delta -- follow up (#6630)
* failing test * fix
This commit is contained in:
parent
5336a167af
commit
c573306621
@ -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")
|
||||
}
|
||||
|
@ -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},
|
||||
|
Loading…
Reference in New Issue
Block a user