Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions packages/beacon-node/test/spec/utils/specTestIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ export const defaultSkipOpts: SkipOpts = {
/^capella\/light_client\/single_merkle_proof\/BeaconBlockBody.*/,
/^deneb\/light_client\/single_merkle_proof\/BeaconBlockBody.*/,
/^electra\/light_client\/single_merkle_proof\/BeaconBlockBody.*/,
// TODO Electra: slashings tests to be enabled in PR#7071
/^electra\/epoch_processing\/slashings.*/,
],
skippedTests: [],
skippedRunners: ["merkle_proof", "networking"],
Expand Down
12 changes: 10 additions & 2 deletions packages/state-transition/src/epoch/processSlashings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,23 @@ export function processSlashings(
totalBalanceByIncrement
);
const increment = EFFECTIVE_BALANCE_INCREMENT;

const penaltyPerEffectiveBalanceIncrement = Math.floor(
(adjustedTotalSlashingBalanceByIncrement * increment) / totalBalanceByIncrement
);
const penalties: number[] = [];

const penaltiesByEffectiveBalanceIncrement = new Map<number, number>();
for (const index of cache.indicesToSlash) {
const effectiveBalanceIncrement = effectiveBalanceIncrements[index];
let penalty = penaltiesByEffectiveBalanceIncrement.get(effectiveBalanceIncrement);
if (penalty === undefined) {
const penaltyNumeratorByIncrement = effectiveBalanceIncrement * adjustedTotalSlashingBalanceByIncrement;
penalty = Math.floor(penaltyNumeratorByIncrement / totalBalanceByIncrement) * increment;
if (fork < ForkSeq.electra) {
Copy link
Member

Choose a reason for hiding this comment

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

any reason why the check is reversed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

any reason why the check is reversed here?

No particular reason. I don't think there is a convention for fork check to be >= ForkSeq.electra vs < ForkSeq.electra.

Several places use < see:

const penaltyNumeratorByIncrement = effectiveBalanceIncrement * adjustedTotalSlashingBalanceByIncrement;
penalty = Math.floor(penaltyNumeratorByIncrement / totalBalanceByIncrement) * increment;
} else {
penalty = penaltyPerEffectiveBalanceIncrement * effectiveBalanceIncrement;
}
penaltiesByEffectiveBalanceIncrement.set(effectiveBalanceIncrement, penalty);
}

Expand Down