Skip to content

Commit

Permalink
fix: use next epoch for pending balance/consolidations processing (#7053
Browse files Browse the repository at this point in the history
)
  • Loading branch information
g11tech authored Aug 28, 2024
1 parent 7fe30b4 commit 03f7396
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/beacon-node/test/spec/specTestVersioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {DownloadTestsOptions} from "@lodestar/spec-test-util/downloadTests";
const __dirname = path.dirname(fileURLToPath(import.meta.url));

export const ethereumConsensusSpecsTests: DownloadTestsOptions = {
specVersion: "v1.5.0-alpha.3",
specVersion: "v1.5.0-alpha.5",
// Target directory is the host package root: 'packages/*/spec-tests'
outputDir: path.join(__dirname, "../../spec-tests"),
specTestsRepoUrl: "https://github.com/ethereum/consensus-spec-tests",
Expand Down
3 changes: 2 additions & 1 deletion packages/beacon-node/test/spec/utils/specTestIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ export const defaultSkipOpts: SkipOpts = {
skippedTestSuites: [
/^capella\/light_client\/single_merkle_proof\/BeaconBlockBody.*/,
/^deneb\/light_client\/single_merkle_proof\/BeaconBlockBody.*/,
/^electra\/light_client\/.*/,
],
// TODO Electra: Review this test in the next spec test release
skippedTests: [/incorrect_not_enough_consolidation_churn_available/],
skippedTests: [/^deneb\/light_client\/sync\/.*electra_fork.*/],
skippedRunners: ["merkle_proof", "networking"],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {FAR_FUTURE_EPOCH} from "@lodestar/params";
import {CachedBeaconStateElectra, EpochTransitionCache} from "../types.js";
import {increaseBalance} from "../util/balance.js";
import {getActivationExitChurnLimit} from "../util/validator.js";
import {getCurrentEpoch} from "../util/epoch.js";

/**
* Starting from Electra:
Expand All @@ -14,8 +13,8 @@ import {getCurrentEpoch} from "../util/epoch.js";
* TODO Electra: Update ssz library to support batch push to `pendingBalanceDeposits`
*/
export function processPendingBalanceDeposits(state: CachedBeaconStateElectra, cache: EpochTransitionCache): void {
const nextEpoch = state.epochCtx.epoch + 1;
const availableForProcessing = state.depositBalanceToConsume + BigInt(getActivationExitChurnLimit(state.epochCtx));
const currentEpoch = getCurrentEpoch(state);
let processedAmount = 0n;
let nextDepositIndex = 0;
const depositsToPostpone = [];
Expand All @@ -28,7 +27,7 @@ export function processPendingBalanceDeposits(state: CachedBeaconStateElectra, c

// Validator is exiting, postpone the deposit until after withdrawable epoch
if (validator.exitEpoch < FAR_FUTURE_EPOCH) {
if (currentEpoch <= validator.withdrawableEpoch) {
if (nextEpoch <= validator.withdrawableEpoch) {
depositsToPostpone.push(deposit);
} else {
// Deposited balance will never become active. Increase balance but do not consume churn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {switchToCompoundingValidator} from "../util/electra.js";
*
*/
export function processPendingConsolidations(state: CachedBeaconStateElectra, cache: EpochTransitionCache): void {
const nextEpoch = state.epochCtx.epoch + 1;
let nextPendingConsolidation = 0;
const validators = state.validators;
const cachedBalances = cache.balances;
Expand All @@ -32,7 +33,7 @@ export function processPendingConsolidations(state: CachedBeaconStateElectra, ca
continue;
}

if (sourceValidator.withdrawableEpoch > state.epochCtx.epoch) {
if (sourceValidator.withdrawableEpoch > nextEpoch) {
break;
}
// Churn any target excess active balance of target and raise its max
Expand Down

0 comments on commit 03f7396

Please sign in to comment.