Skip to content

Commit

Permalink
Remove churn limit in processRegistryUpdates
Browse files Browse the repository at this point in the history
  • Loading branch information
ensi321 committed Apr 30, 2024
1 parent 1553e6c commit afde7b7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/state-transition/src/cache/epochCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export class EpochCache {
const nextEpoch = currentEpoch + 1;

let totalActiveBalanceIncrements = 0;
let exitQueueEpoch = computeActivationExitEpoch(currentEpoch); // TODO Electra: New exit epoch calculation
let exitQueueEpoch = computeActivationExitEpoch(currentEpoch);
let exitQueueChurn = 0;

const validators = state.validators.getAllReadonlyValues();
Expand Down Expand Up @@ -590,7 +590,7 @@ export class EpochCache {
);

// Maybe advance exitQueueEpoch at the end of the epoch if there haven't been any exists for a while
const exitQueueEpoch = computeActivationExitEpoch(currEpoch); // TODO Electra: New exit epoch calculation
const exitQueueEpoch = computeActivationExitEpoch(currEpoch);
if (exitQueueEpoch > this.exitQueueEpoch) {
this.exitQueueEpoch = exitQueueEpoch;
this.exitQueueChurn = 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/state-transition/src/cache/epochTransitionCache.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Epoch, ValidatorIndex} from "@lodestar/types";
import {intDiv} from "@lodestar/utils";
import {EPOCHS_PER_SLASHINGS_VECTOR, FAR_FUTURE_EPOCH, ForkSeq, MAX_EFFECTIVE_BALANCE} from "@lodestar/params";
import {EPOCHS_PER_SLASHINGS_VECTOR, FAR_FUTURE_EPOCH, ForkSeq, MAX_EFFECTIVE_BALANCE, MIN_ACTIVATION_BALANCE} from "@lodestar/params";

import {
AttesterStatus,
Expand Down Expand Up @@ -248,7 +248,7 @@ export function beforeProcessEpoch(
// ```
if (
validator.activationEligibilityEpoch === FAR_FUTURE_EPOCH &&
validator.effectiveBalance >= MAX_EFFECTIVE_BALANCE
validator.effectiveBalance >= MIN_ACTIVATION_BALANCE
) {
indicesEligibleForActivationQueue.push(i);
}
Expand Down
15 changes: 9 additions & 6 deletions packages/state-transition/src/epoch/processRegistryUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,21 @@ export function processRegistryUpdates(
initiateValidatorExit(fork, state, validators.get(index));
}

// TODO Electra: New logic to set validator.activation_epoch
if (fork >= ForkSeq.electra) {
}

// set new activation eligibilities
for (const index of cache.indicesEligibleForActivationQueue) {
validators.get(index).activationEligibilityEpoch = epochCtx.epoch + 1;
}

const finalityEpoch = state.finalizedCheckpoint.epoch;
// dequeue validators for activation up to churn limit
for (const index of cache.indicesEligibleForActivation.slice(0, epochCtx.activationChurnLimit)) {
let indicesEligibleForActivation;
if (fork < ForkSeq.electra) {
// dequeue validators for activation up to churn limit
indicesEligibleForActivation = cache.indicesEligibleForActivation.slice(0, epochCtx.activationChurnLimit)
} else {
// no churn limit post-electra
indicesEligibleForActivation = cache.indicesEligibleForActivation;
}
for (const index of indicesEligibleForActivation) {
const validator = validators.get(index);
// placement in queue is finalized
if (validator.activationEligibilityEpoch > finalityEpoch) {
Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/src/util/genesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export function applyDeposits(
}

const balance = balancesArr[i];
const effectiveBalance = Math.min(balance - (balance % EFFECTIVE_BALANCE_INCREMENT), MAX_EFFECTIVE_BALANCE); // TODO Electra: Double check if we use MIN_ACTIVATION_BALANCE
const effectiveBalance = Math.min(balance - (balance % EFFECTIVE_BALANCE_INCREMENT), MAX_EFFECTIVE_BALANCE);

validator.effectiveBalance = effectiveBalance;
epochCtx.effectiveBalanceIncrementsSet(i, effectiveBalance);
Expand Down

0 comments on commit afde7b7

Please sign in to comment.