mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
* Electra: Beacon State * Electra: Beacon state fixes from PR 13919 * Add missing tests - part 1 * Split eip_7251_root.go into different files and reuse/share code with historical state summaries root. It's identical! * Add missing tests - part 2 * deposit receipts start index getters and setters (#13947) * adding in getters and setters for deposit receipts start index * adding tests * gaz * Add missing tests - part 3 of 3 Update the electra withdrawal example with a ssz state containing pending partial withdrawals * add tests for beacon-chain/state/state-native/getters_balance_deposits.go * Add electra field to testing/util/block.go execution payload * godoc commentary on public methods * Fix failing test * Add balances index out of bounds check and relevant tests. * Revert switch case electra * Instead of copying spectest data into testdata, use the spectest dependency * Deepsource fixes * Address @rkapka PR feedback * s/MaxPendingPartialsPerWithdrawalSweep/MaxPendingPartialsPerWithdrawalsSweep/ * Use multivalue slice compatible accessors for validator and balance in ActiveBalanceAtIndex * More @rkapka feedback. What a great reviewer! * More tests for branching logic in ExitEpochAndUpdateChurn * fix build --------- Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
54 lines
1.9 KiB
Go
54 lines
1.9 KiB
Go
package helpers
|
|
|
|
import (
|
|
"github.com/prysmaticlabs/prysm/v5/config/params"
|
|
"github.com/prysmaticlabs/prysm/v5/math"
|
|
)
|
|
|
|
// BalanceChurnLimit for the current active balance, in gwei.
|
|
// New in Electra EIP-7251: https://eips.ethereum.org/EIPS/eip-7251
|
|
//
|
|
// Spec definition:
|
|
//
|
|
// def get_balance_churn_limit(state: BeaconState) -> Gwei:
|
|
// """
|
|
// Return the churn limit for the current epoch.
|
|
// """
|
|
// churn = max(
|
|
// MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA,
|
|
// get_total_active_balance(state) // CHURN_LIMIT_QUOTIENT
|
|
// )
|
|
// return churn - churn % EFFECTIVE_BALANCE_INCREMENT
|
|
func BalanceChurnLimit(activeBalance math.Gwei) math.Gwei {
|
|
churn := max(
|
|
params.BeaconConfig().MinPerEpochChurnLimitElectra,
|
|
(uint64(activeBalance) / params.BeaconConfig().ChurnLimitQuotient),
|
|
)
|
|
return math.Gwei(churn - churn%params.BeaconConfig().EffectiveBalanceIncrement)
|
|
}
|
|
|
|
// ActivationExitChurnLimit for the current active balance, in gwei.
|
|
// New in Electra EIP-7251: https://eips.ethereum.org/EIPS/eip-7251
|
|
//
|
|
// Spec definition:
|
|
//
|
|
// def get_activation_exit_churn_limit(state: BeaconState) -> Gwei:
|
|
// """
|
|
// Return the churn limit for the current epoch dedicated to activations and exits.
|
|
// """
|
|
// return min(MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT, get_balance_churn_limit(state))
|
|
func ActivationExitChurnLimit(activeBalance math.Gwei) math.Gwei {
|
|
return min(math.Gwei(params.BeaconConfig().MaxPerEpochActivationExitChurnLimit), BalanceChurnLimit(activeBalance))
|
|
}
|
|
|
|
// ConsolidationChurnLimit for the current active balance, in gwei.
|
|
// New in EIP-7251: https://eips.ethereum.org/EIPS/eip-7251
|
|
//
|
|
// Spec definition:
|
|
//
|
|
// def get_consolidation_churn_limit(state: BeaconState) -> Gwei:
|
|
// return get_balance_churn_limit(state) - get_activation_exit_churn_limit(state)
|
|
func ConsolidationChurnLimit(activeBalance math.Gwei) math.Gwei {
|
|
return BalanceChurnLimit(activeBalance) - ActivationExitChurnLimit(activeBalance)
|
|
}
|