From 649602da17849db9c73b98371fceac8a80b00417 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 1f352b3d683..a9f254dea3f 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?.();