From 8e5901da3dba13594ff04dbf1d17138c0fd55a4a Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Sat, 11 May 2024 00:01:42 +0200 Subject: [PATCH] test(spec): fix attestors slashing specs for electra fork (#6758) * Fix attester slashing specs for electra * Remove unused import * Add code comment * Update the expression * Update the fork check --- packages/beacon-node/test/spec/utils/specTestIterator.ts | 3 +-- .../src/block/isValidIndexedAttestation.ts | 8 ++++++-- packages/state-transition/src/util/epoch.ts | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/beacon-node/test/spec/utils/specTestIterator.ts b/packages/beacon-node/test/spec/utils/specTestIterator.ts index b99bc281cf50..393983bb8a56 100644 --- a/packages/beacon-node/test/spec/utils/specTestIterator.ts +++ b/packages/beacon-node/test/spec/utils/specTestIterator.ts @@ -65,8 +65,7 @@ export const defaultSkipOpts: SkipOpts = { skippedTestSuites: [ /^capella\/light_client\/single_merkle_proof\/BeaconBlockBody.*/, /^deneb\/light_client\/single_merkle_proof\/BeaconBlockBody.*/, - // /^electra\/(?!operations\/attestations)(?!operations\/attester_slashing)/, - /^electra\/(?!operations\/attestation)/, + /^electra\/(?!operations\/attestations)(?!operations\/attester_slashing)/, ], skippedTests: [], skippedRunners: ["merkle_proof", "networking"], diff --git a/packages/state-transition/src/block/isValidIndexedAttestation.ts b/packages/state-transition/src/block/isValidIndexedAttestation.ts index e3965b97ee73..33d92a208260 100644 --- a/packages/state-transition/src/block/isValidIndexedAttestation.ts +++ b/packages/state-transition/src/block/isValidIndexedAttestation.ts @@ -1,4 +1,4 @@ -import {MAX_VALIDATORS_PER_COMMITTEE} from "@lodestar/params"; +import {ForkSeq, MAX_COMMITTEES_PER_SLOT, MAX_VALIDATORS_PER_COMMITTEE} from "@lodestar/params"; import {phase0} from "@lodestar/types"; import {CachedBeaconStateAllForks} from "../types.js"; import {verifySignatureSet} from "../util/index.js"; @@ -44,7 +44,11 @@ export function isValidIndexedAttestationBigint( */ export function isValidIndexedAttestationIndices(state: CachedBeaconStateAllForks, indices: number[]): boolean { // verify max number of indices - if (!(indices.length > 0 && indices.length <= MAX_VALIDATORS_PER_COMMITTEE)) { + const maxIndices = + state.config.getForkSeq(state.slot) >= ForkSeq.electra + ? MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT + : MAX_VALIDATORS_PER_COMMITTEE; + if (!(indices.length > 0 && indices.length <= maxIndices)) { return false; } diff --git a/packages/state-transition/src/util/epoch.ts b/packages/state-transition/src/util/epoch.ts index 9e8dd0cff5b7..8ae501c51f71 100644 --- a/packages/state-transition/src/util/epoch.ts +++ b/packages/state-transition/src/util/epoch.ts @@ -52,7 +52,7 @@ export function computeExitEpochAndUpdateChurn(state: CachedBeaconStateElectra, // Exit doesn't fit in the current earliest epoch. if (exitBalance > exitBalanceToConsume) { const balanceToProcess = Number(exitBalance) - exitBalanceToConsume; - const additionalEpochs = Math.floor((balanceToProcess - 1) / (perEpochChurn + 1)); + const additionalEpochs = Math.floor((balanceToProcess - 1) / perEpochChurn) + 1; earliestExitEpoch += additionalEpochs; exitBalanceToConsume += additionalEpochs * perEpochChurn; }