Skip to content

Commit

Permalink
test(spec): fix attestors slashing specs for electra fork (#6758)
Browse files Browse the repository at this point in the history
* Fix attester slashing specs for electra

* Remove unused import

* Add code comment

* Update the expression

* Update the fork check
  • Loading branch information
nazarhussain authored and g11tech committed Aug 27, 2024
1 parent c34eac7 commit 81e7682
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions packages/beacon-node/test/spec/utils/specTestIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/src/util/epoch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 81e7682

Please sign in to comment.