diff --git a/packages/state-transition/src/block/processAttestationPhase0.ts b/packages/state-transition/src/block/processAttestationPhase0.ts index ac2e0e3ea20..3a44d11e7af 100644 --- a/packages/state-transition/src/block/processAttestationPhase0.ts +++ b/packages/state-transition/src/block/processAttestationPhase0.ts @@ -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)) { diff --git a/packages/state-transition/src/slot/upgradeStateToElectra.ts b/packages/state-transition/src/slot/upgradeStateToElectra.ts index e09b4169d18..3aae0f5b487 100644 --- a/packages/state-transition/src/slot/upgradeStateToElectra.ts +++ b/packages/state-transition/src/slot/upgradeStateToElectra.ts @@ -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[] = []; @@ -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?