Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(spec): fix attestors slashing specs for electra fork #6758

Merged
merged 5 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {ForkName, MAX_COMMITTEES_PER_SLOT, MAX_VALIDATORS_PER_COMMITTEE} from "@lodestar/params";
import {phase0} from "@lodestar/types";
nazarhussain marked this conversation as resolved.
Show resolved Hide resolved
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.fork.epoch >= state.config.ELECTRA_FORK_EPOCH
? MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT
nazarhussain marked this conversation as resolved.
Show resolved Hide resolved
: 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.ceil((balanceToProcess - 1) / (perEpochChurn + 1));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you detail this? Also, is it worth having some test for this, as apparently this change didn't require any associated test change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally my preferences is to have unit tests for every function, but unfortunatley we don't have it yet.

I updated with a code comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I misread the spec here.
We should do

const additionalEpochs = Math.floor((balanceToProcess - 1) / perEpochChurn) + 1

Let me know if the spec test's still passing after making this change

earliestExitEpoch += additionalEpochs;
exitBalanceToConsume += additionalEpochs * perEpochChurn;
}
Expand Down
Loading