Skip to content

Commit

Permalink
Prevent nextEpochTotalActiveBalance = zero
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Aug 30, 2021
1 parent c100e92 commit 984c318
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
SYNC_REWARD_WEIGHT,
WEIGHT_DENOMINATOR,
} from "@chainsafe/lodestar-params";
import {bigIntSqrt, intToBytes, LodestarError} from "@chainsafe/lodestar-utils";
import {bigIntMax, bigIntSqrt, intToBytes, LodestarError} from "@chainsafe/lodestar-utils";

import {
computeActivationExitEpoch,
Expand Down Expand Up @@ -337,7 +337,8 @@ export function afterProcessEpoch(
}

if (currEpoch >= epochCtx.config.ALTAIR_FORK_EPOCH) {
const totalActiveBalance = epochProcess.nextEpochTotalActiveBalance;
// To pass spec tests, force to EFFECTIVE_BALANCE_INCREMENT since nextEpochTotalActiveBalance may be zero
const totalActiveBalance = bigIntMax(epochProcess.nextEpochTotalActiveBalance, EFFECTIVE_BALANCE_INCREMENT);
epochCtx.syncParticipantReward = computeSyncParticipantReward(epochCtx.config, totalActiveBalance);
epochCtx.syncProposerReward =
(epochCtx.syncParticipantReward * PROPOSER_WEIGHT) / (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT);
Expand Down

0 comments on commit 984c318

Please sign in to comment.