From 64d05e0e8e5583de1e8352a5c3bc7a5dfacecd2d Mon Sep 17 00:00:00 2001 From: harkamal Date: Tue, 27 Aug 2024 20:57:56 +0530 Subject: [PATCH 1/4] fix: use next epoch for pending balance/consolidations processing --- packages/beacon-node/test/spec/specTestVersioning.ts | 2 +- .../src/epoch/processPendingBalanceDeposits.ts | 5 ++--- .../src/epoch/processPendingConsolidations.ts | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/beacon-node/test/spec/specTestVersioning.ts b/packages/beacon-node/test/spec/specTestVersioning.ts index e97770e8146..7229a0236d8 100644 --- a/packages/beacon-node/test/spec/specTestVersioning.ts +++ b/packages/beacon-node/test/spec/specTestVersioning.ts @@ -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", diff --git a/packages/state-transition/src/epoch/processPendingBalanceDeposits.ts b/packages/state-transition/src/epoch/processPendingBalanceDeposits.ts index 81da34349e5..bef3ec0b272 100644 --- a/packages/state-transition/src/epoch/processPendingBalanceDeposits.ts +++ b/packages/state-transition/src/epoch/processPendingBalanceDeposits.ts @@ -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: @@ -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 = []; @@ -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 diff --git a/packages/state-transition/src/epoch/processPendingConsolidations.ts b/packages/state-transition/src/epoch/processPendingConsolidations.ts index 7d8548046e7..28178a509bb 100644 --- a/packages/state-transition/src/epoch/processPendingConsolidations.ts +++ b/packages/state-transition/src/epoch/processPendingConsolidations.ts @@ -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; @@ -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 From 23355fae0bf2bb4cf552d6a3e86c7494a23fa99a Mon Sep 17 00:00:00 2001 From: harkamal Date: Wed, 28 Aug 2024 01:59:02 +0530 Subject: [PATCH 2/4] skip electra light client spec tests as fixes pending --- packages/beacon-node/test/spec/utils/specTestIterator.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/beacon-node/test/spec/utils/specTestIterator.ts b/packages/beacon-node/test/spec/utils/specTestIterator.ts index ac0d70307d3..9368be90aa6 100644 --- a/packages/beacon-node/test/spec/utils/specTestIterator.ts +++ b/packages/beacon-node/test/spec/utils/specTestIterator.ts @@ -65,6 +65,7 @@ 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/], From b9f0b50f598846f26fbcbacf22cf05054ea0e72c Mon Sep 17 00:00:00 2001 From: harkamal Date: Wed, 28 Aug 2024 17:41:14 +0530 Subject: [PATCH 3/4] ignore electra light client test at deneb --- packages/beacon-node/test/spec/utils/specTestIterator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-node/test/spec/utils/specTestIterator.ts b/packages/beacon-node/test/spec/utils/specTestIterator.ts index 9368be90aa6..19a20f20f3c 100644 --- a/packages/beacon-node/test/spec/utils/specTestIterator.ts +++ b/packages/beacon-node/test/spec/utils/specTestIterator.ts @@ -68,7 +68,7 @@ export const defaultSkipOpts: SkipOpts = { /^electra\/light_client\/.*/, ], // TODO Electra: Review this test in the next spec test release - skippedTests: [/incorrect_not_enough_consolidation_churn_available/], + skippedTests: [/incorrect_not_enough_consolidation_churn_available/, /^deneb\/light_client\/sync\/.*electra_fork.*/], skippedRunners: ["merkle_proof", "networking"], }; From 02b328b3fd72bb4384a1674de36d29a736b44b9a Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Wed, 28 Aug 2024 18:30:44 +0100 Subject: [PATCH 4/4] Enable `incorrect_not_enough_consolidation_churn_available` spec test --- packages/beacon-node/test/spec/utils/specTestIterator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-node/test/spec/utils/specTestIterator.ts b/packages/beacon-node/test/spec/utils/specTestIterator.ts index 19a20f20f3c..48a00258004 100644 --- a/packages/beacon-node/test/spec/utils/specTestIterator.ts +++ b/packages/beacon-node/test/spec/utils/specTestIterator.ts @@ -68,7 +68,7 @@ export const defaultSkipOpts: SkipOpts = { /^electra\/light_client\/.*/, ], // TODO Electra: Review this test in the next spec test release - skippedTests: [/incorrect_not_enough_consolidation_churn_available/, /^deneb\/light_client\/sync\/.*electra_fork.*/], + skippedTests: [/^deneb\/light_client\/sync\/.*electra_fork.*/], skippedRunners: ["merkle_proof", "networking"], };