Skip to content

Commit

Permalink
Fix spectest violation
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonvanloon committed May 16, 2024
1 parent 33b441a commit 74e3000
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
33 changes: 18 additions & 15 deletions beacon-chain/core/electra/registry_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ import (
//
// Spec pseudocode definition:
//
// def process_registry_updates(state: BeaconState) -> None:
// # Process activation eligibility and ejections
// for index, validator in enumerate(state.validators):
// if is_eligible_for_activation_queue(validator):
// validator.activation_eligibility_epoch = get_current_epoch(state) + 1
// def process_registry_updates(state: BeaconState) -> None:
// # Process activation eligibility and ejections
// for index, validator in enumerate(state.validators):
// if is_eligible_for_activation_queue(validator):
// validator.activation_eligibility_epoch = get_current_epoch(state) + 1
//
// if (
// is_active_validator(validator, get_current_epoch(state))
// and validator.effective_balance <= EJECTION_BALANCE
// ):
// initiate_validator_exit(state, ValidatorIndex(index))
// if (
// is_active_validator(validator, get_current_epoch(state))
// and validator.effective_balance <= EJECTION_BALANCE
// ):
// initiate_validator_exit(state, ValidatorIndex(index))
//
// # Activate all eligible validators
// activation_epoch = compute_activation_exit_epoch(get_current_epoch(state))
// for validator in state.validators:
// if is_eligible_for_activation(state, validator):
// validator.activation_epoch = activation_epoch
// # Activate all eligible validators
// activation_epoch = compute_activation_exit_epoch(get_current_epoch(state))
// for validator in state.validators:
// if is_eligible_for_activation(state, validator):
// validator.activation_epoch = activation_epoch
func ProcessRegistryUpdates(ctx context.Context, state state.BeaconState) (state.BeaconState, error) {
currentEpoch := time.CurrentEpoch(state)
ejectionBal := params.BeaconConfig().EjectionBalance
Expand All @@ -41,6 +41,9 @@ func ProcessRegistryUpdates(ctx context.Context, state state.BeaconState) (state
for idx, val := range vals {
if helpers.IsEligibleForActivationQueue(val, currentEpoch) {
val.ActivationEligibilityEpoch = currentEpoch + 1
if err := state.UpdateValidatorAtIndex(primitives.ValidatorIndex(idx), val); err != nil {
return nil, err
}
}
if helpers.IsActiveValidator(val, currentEpoch) && val.EffectiveBalance <= ejectionBal {
var err error
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/core/electra/registry_updates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestProcessRegistryUpdates(t *testing.T) {
check func(*testing.T, state.BeaconState)
}{
{
name: "No rotation",
name: "No rotation", // No validators activated?
state: func() state.BeaconState {
base := &eth.BeaconState{
Slot: 5 * params.BeaconConfig().SlotsPerEpoch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import (
"github.com/prysmaticlabs/prysm/v5/testing/spectest/shared/electra/epoch_processing"
)

func TestMainnet_Electra_EpochProcessing_ResetRegistryUpdates(t *testing.T) {
func TestMainnet_Electra_EpochProcessing_RegistryUpdates(t *testing.T) {
epoch_processing.RunRegistryUpdatesTests(t, "mainnet")
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import (
"github.com/prysmaticlabs/prysm/v5/testing/spectest/shared/electra/epoch_processing"
)

func TestMinimal_Electra_EpochProcessing_ResetRegistryUpdates(t *testing.T) {
func TestMinimal_Electra_EpochProcessing_RegistryUpdates(t *testing.T) {
epoch_processing.RunRegistryUpdatesTests(t, "minimal")
}

0 comments on commit 74e3000

Please sign in to comment.