Skip to content

Commit

Permalink
Fix earliestExitEpoch
Browse files Browse the repository at this point in the history
  • Loading branch information
ensi321 authored and nflaig committed Dec 3, 2024
1 parent d3fdb52 commit 75480a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ export function validateAttestation(fork: ForkSeq, state: CachedBeaconStateAllFo
// Total number of attestation participants of every committee specified
let committeeOffset = 0;
for (const committeeValidators of validatorsByCommittee) {
const committeeAggregationBits = aggregationBitsArray.slice(committeeOffset, committeeOffset + committeeValidators.length);
const committeeAggregationBits = aggregationBitsArray.slice(
committeeOffset,
committeeOffset + committeeValidators.length
);

// Assert aggregation bits in this committee have at least one true bit
if (committeeAggregationBits.every((bit) => !bit)) {
Expand Down
12 changes: 4 additions & 8 deletions packages/state-transition/src/slot/upgradeStateToElectra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export function upgradeStateToElectra(stateDeneb: CachedBeaconStateDeneb): Cache
stateElectraView.exitBalanceToConsume = BigInt(0);

const validatorsArr = stateElectraView.validators.getAllReadonly();
const exitEpochs: Epoch[] = [];
const currentEpochPre = stateDeneb.epochCtx.epoch;
let earliestExitEpoch = computeActivationExitEpoch(currentEpochPre);

// [EIP-7251]: add validators that are not yet active to pending balance deposits
const preActivation: ValidatorIndex[] = [];
Expand All @@ -66,16 +66,12 @@ export function upgradeStateToElectra(stateDeneb: CachedBeaconStateDeneb): Cache
if (activationEpoch === FAR_FUTURE_EPOCH) {
preActivation.push(validatorIndex);
}
if (exitEpoch !== FAR_FUTURE_EPOCH) {
exitEpochs.push(exitEpoch);
if (exitEpoch !== FAR_FUTURE_EPOCH && exitEpoch > earliestExitEpoch) {
earliestExitEpoch = exitEpoch;
}
}


if (exitEpochs.length === 0) {
exitEpochs.push(computeActivationExitEpoch(currentEpochPre));
}
stateElectraView.earliestExitEpoch = Math.max(...exitEpochs) + 1;
stateElectraView.earliestExitEpoch = earliestExitEpoch + 1;
stateElectraView.consolidationBalanceToConsume = BigInt(0);
stateElectraView.earliestConsolidationEpoch = computeActivationExitEpoch(currentEpochPre);
// TODO-electra: can we improve this?
Expand Down

0 comments on commit 75480a3

Please sign in to comment.