mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
Fix max churn bug (#2121)
This commit is contained in:
parent
02f9a56513
commit
6b3df2f776
@ -529,7 +529,7 @@ func allValidatorsIndices(state *pb.BeaconState) []uint64 {
|
||||
// MAX_DEPOSIT_AMOUNT,
|
||||
// total_balance // (2 * MAX_BALANCE_CHURN_QUOTIENT))
|
||||
func maxBalanceChurn(totalBalance uint64) uint64 {
|
||||
maxBalanceChurn := totalBalance / 2 * params.BeaconConfig().MaxBalanceChurnQuotient
|
||||
maxBalanceChurn := totalBalance / (2 * params.BeaconConfig().MaxBalanceChurnQuotient)
|
||||
if maxBalanceChurn > params.BeaconConfig().MaxDepositAmount {
|
||||
return maxBalanceChurn
|
||||
}
|
||||
|
@ -586,14 +586,15 @@ func TestUpdateRegistry_Exits(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMaxBalanceChurn_OK(t *testing.T) {
|
||||
maxDepositAmount := params.BeaconConfig().MaxDepositAmount
|
||||
tests := []struct {
|
||||
totalBalance uint64
|
||||
maxBalanceChurn uint64
|
||||
}{
|
||||
{totalBalance: 1e9, maxBalanceChurn: params.BeaconConfig().MaxDepositAmount},
|
||||
{totalBalance: params.BeaconConfig().MaxDepositAmount, maxBalanceChurn: 512 * 1e9},
|
||||
{totalBalance: params.BeaconConfig().MaxDepositAmount * 10, maxBalanceChurn: 512 * 1e10},
|
||||
{totalBalance: params.BeaconConfig().MaxDepositAmount * 1000, maxBalanceChurn: 512 * 1e12},
|
||||
{totalBalance: 1e9, maxBalanceChurn: maxDepositAmount},
|
||||
{totalBalance: maxDepositAmount, maxBalanceChurn: maxDepositAmount},
|
||||
{totalBalance: maxDepositAmount * 10, maxBalanceChurn: maxDepositAmount},
|
||||
{totalBalance: params.BeaconConfig().MaxDepositAmount * 1000, maxBalanceChurn: 5 * 1e11},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user