Skip to content

Commit

Permalink
Merge 8d60623 into 58dea75
Browse files Browse the repository at this point in the history
  • Loading branch information
ensi321 authored Sep 26, 2024
2 parents 58dea75 + 8d60623 commit 1e23466
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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) {
const penaltyNumeratorByIncrement = effectiveBalanceIncrement * adjustedTotalSlashingBalanceByIncrement;
penalty = Math.floor(penaltyNumeratorByIncrement / totalBalanceByIncrement) * increment;
} else {
penalty = penaltyPerEffectiveBalanceIncrement * effectiveBalanceIncrement;
}
penaltiesByEffectiveBalanceIncrement.set(effectiveBalanceIncrement, penalty);
}

Expand Down

0 comments on commit 1e23466

Please sign in to comment.