From c04157c9696ce7b9b12518f61ec638b872927c4b Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Tue, 8 Oct 2024 16:01:47 +0100 Subject: [PATCH] fix: ensure generated historical state slot matches requested slot (#7135) --- .../src/chain/historicalState/getHistoricalState.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/beacon-node/src/chain/historicalState/getHistoricalState.ts b/packages/beacon-node/src/chain/historicalState/getHistoricalState.ts index 1f352b3d683a..a9f254dea3f2 100644 --- a/packages/beacon-node/src/chain/historicalState/getHistoricalState.ts +++ b/packages/beacon-node/src/chain/historicalState/getHistoricalState.ts @@ -102,6 +102,10 @@ export async function getHistoricalState( metrics?.stateTransitionBlocks.observe(blockCount); transitionTimer?.(); + if (state.slot !== slot) { + throw Error(`Failed to generate historical state for slot ${slot}`); + } + const serializeTimer = metrics?.stateSerializationTime.startTimer(); const stateBytes = state.serialize(); serializeTimer?.();