diff --git a/packages/beacon-node/src/chain/stateCache/stateContextCache.ts b/packages/beacon-node/src/chain/stateCache/stateContextCache.ts index 52f1b32ce8c1..500fccbb56f6 100644 --- a/packages/beacon-node/src/chain/stateCache/stateContextCache.ts +++ b/packages/beacon-node/src/chain/stateCache/stateContextCache.ts @@ -39,15 +39,11 @@ export class StateContextCache { get(rootHex: RootHex): CachedBeaconStateAllForks | null { this.metrics?.lookups.inc(); - const item = this.cache.get(rootHex); + const item = this.head?.stateRoot === rootHex ? this.head.state : this.cache.get(rootHex); if (!item) { return null; } - if (this.head?.stateRoot === rootHex) { - return this.head.state; - } - this.metrics?.hits.inc(); this.metrics?.stateClonedCount.observe(item.clonedCount);