mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
Handle Pending Balance Bug (#15123)
* Fix Getter and Add regression test * changelog
This commit is contained in:
@@ -486,7 +486,7 @@ func (b *BeaconState) HasPendingBalanceToWithdraw(idx primitives.ValidatorIndex)
|
||||
// MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD per slot. A more optimized storage indexing such as a
|
||||
// lookup map could be used to reduce the complexity marginally.
|
||||
for _, w := range b.pendingPartialWithdrawals {
|
||||
if w.Index == idx {
|
||||
if w.Index == idx && w.Amount > 0 {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +121,10 @@ func TestHasPendingBalanceToWithdraw(t *testing.T) {
|
||||
Amount: 300,
|
||||
Index: 3,
|
||||
},
|
||||
{
|
||||
Amount: 0,
|
||||
Index: 4,
|
||||
},
|
||||
},
|
||||
}
|
||||
state, err := statenative.InitializeFromProtoUnsafeElectra(pb)
|
||||
@@ -133,4 +137,9 @@ func TestHasPendingBalanceToWithdraw(t *testing.T) {
|
||||
ok, err = state.HasPendingBalanceToWithdraw(5)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, false, ok)
|
||||
|
||||
// Handle 0 amount case.
|
||||
ok, err = state.HasPendingBalanceToWithdraw(4)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, false, ok)
|
||||
}
|
||||
|
||||
3
changelog/nisdas_fix_state_getter.md
Normal file
3
changelog/nisdas_fix_state_getter.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Fixed
|
||||
|
||||
- Fix State Getter for pending withdrawal balance.
|
||||
Reference in New Issue
Block a user