fix is_eligible_for_activation_queue for electra (#6427)
This commit is contained in:
parent
7853bd2878
commit
ebd0217a10
|
@ -515,10 +515,17 @@ template get_total_balance(
|
||||||
max(EFFECTIVE_BALANCE_INCREMENT.Gwei, res)
|
max(EFFECTIVE_BALANCE_INCREMENT.Gwei, res)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#is_eligible_for_activation_queue
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#is_eligible_for_activation_queue
|
||||||
func is_eligible_for_activation_queue*(validator: Validator): bool =
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#updated-is_eligible_for_activation_queue
|
||||||
|
func is_eligible_for_activation_queue*(
|
||||||
|
fork: static ConsensusFork, validator: Validator): bool =
|
||||||
## Check if ``validator`` is eligible to be placed into the activation queue.
|
## Check if ``validator`` is eligible to be placed into the activation queue.
|
||||||
validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH and
|
when fork <= ConsensusFork.Deneb:
|
||||||
validator.effective_balance == MAX_EFFECTIVE_BALANCE.Gwei
|
validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH and
|
||||||
|
validator.effective_balance == MAX_EFFECTIVE_BALANCE.Gwei
|
||||||
|
else:
|
||||||
|
# [Modified in Electra:EIP7251]
|
||||||
|
validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH and
|
||||||
|
validator.effective_balance >= MIN_ACTIVATION_BALANCE.Gwei
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#is_eligible_for_activation
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#is_eligible_for_activation
|
||||||
func is_eligible_for_activation*(
|
func is_eligible_for_activation*(
|
||||||
|
|
|
@ -932,7 +932,8 @@ func process_registry_updates*(
|
||||||
var maybe_exit_queue_info: Opt[ExitQueueInfo]
|
var maybe_exit_queue_info: Opt[ExitQueueInfo]
|
||||||
|
|
||||||
for vidx in state.validators.vindices:
|
for vidx in state.validators.vindices:
|
||||||
if is_eligible_for_activation_queue(state.validators.item(vidx)):
|
if is_eligible_for_activation_queue(
|
||||||
|
typeof(state).kind, state.validators.item(vidx)):
|
||||||
state.validators.mitem(vidx).activation_eligibility_epoch =
|
state.validators.mitem(vidx).activation_eligibility_epoch =
|
||||||
get_current_epoch(state) + 1
|
get_current_epoch(state) + 1
|
||||||
|
|
||||||
|
@ -977,7 +978,7 @@ func process_registry_updates*(
|
||||||
# Process activation eligibility and ejections
|
# Process activation eligibility and ejections
|
||||||
for index in 0 ..< state.validators.len:
|
for index in 0 ..< state.validators.len:
|
||||||
let validator = state.validators.item(index)
|
let validator = state.validators.item(index)
|
||||||
if is_eligible_for_activation_queue(validator):
|
if is_eligible_for_activation_queue(typeof(state).kind, validator):
|
||||||
# Usually not too many at once, so do this individually
|
# Usually not too many at once, so do this individually
|
||||||
state.validators.mitem(index).activation_eligibility_epoch =
|
state.validators.mitem(index).activation_eligibility_epoch =
|
||||||
get_current_epoch(state) + 1
|
get_current_epoch(state) + 1
|
||||||
|
|
Loading…
Reference in New Issue