|
1 | 1 | import {routes} from "@lodestar/api";
|
2 | 2 | import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
|
3 |
| -import {CachedBeaconStateAllForks, UnfinalizedPubkeyIndexMap, computeEpochAtSlot} from "@lodestar/state-transition"; |
| 3 | +import {CachedBeaconStateAllForks, computeEpochAtSlot} from "@lodestar/state-transition"; |
4 | 4 | import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types";
|
5 | 5 | import {Logger, toRootHex} from "@lodestar/utils";
|
6 | 6 | import {Metrics} from "../../metrics/index.js";
|
@@ -206,54 +206,6 @@ export class QueuedStateRegenerator implements IStateRegenerator {
|
206 | 206 | return this.checkpointStateCache.updatePreComputedCheckpoint(rootHex, epoch);
|
207 | 207 | }
|
208 | 208 |
|
209 |
| - /** |
210 |
| - * Remove `validators` from all unfinalized cache's epochCtx.UnfinalizedPubkey2Index, |
211 |
| - * and add them to epochCtx.pubkey2index and epochCtx.index2pubkey |
212 |
| - */ |
213 |
| - updateUnfinalizedPubkeys(validators: UnfinalizedPubkeyIndexMap): void { |
214 |
| - let numStatesUpdated = 0; |
215 |
| - const states = this.blockStateCache.getStates(); |
216 |
| - const cpStates = this.checkpointStateCache.getStates(); |
217 |
| - |
218 |
| - // Add finalized pubkeys to all states. |
219 |
| - const addTimer = this.metrics?.regenFnAddPubkeyTime.startTimer(); |
220 |
| - |
221 |
| - // We only need to add pubkeys to any one of the states since the finalized caches is shared globally across all states |
222 |
| - const firstState = (states.next().value ?? cpStates.next().value) as CachedBeaconStateAllForks | undefined; |
223 |
| - |
224 |
| - if (firstState !== undefined) { |
225 |
| - firstState.epochCtx.addFinalizedPubkeys(validators, this.metrics?.epochCache ?? undefined); |
226 |
| - } else { |
227 |
| - this.logger.warn("Attempt to delete finalized pubkey from unfinalized pubkey cache. But no state is available"); |
228 |
| - } |
229 |
| - |
230 |
| - addTimer?.(); |
231 |
| - |
232 |
| - // Delete finalized pubkeys from unfinalized pubkey cache for all states |
233 |
| - const deleteTimer = this.metrics?.regenFnDeletePubkeyTime.startTimer(); |
234 |
| - const pubkeysToDelete = Array.from(validators.keys()); |
235 |
| - |
236 |
| - for (const s of states) { |
237 |
| - s.epochCtx.deleteUnfinalizedPubkeys(pubkeysToDelete); |
238 |
| - numStatesUpdated++; |
239 |
| - } |
240 |
| - |
241 |
| - for (const s of cpStates) { |
242 |
| - s.epochCtx.deleteUnfinalizedPubkeys(pubkeysToDelete); |
243 |
| - numStatesUpdated++; |
244 |
| - } |
245 |
| - |
246 |
| - // Since first state is consumed from the iterator. Will need to perform delete explicitly |
247 |
| - if (firstState !== undefined) { |
248 |
| - firstState?.epochCtx.deleteUnfinalizedPubkeys(pubkeysToDelete); |
249 |
| - numStatesUpdated++; |
250 |
| - } |
251 |
| - |
252 |
| - deleteTimer?.(); |
253 |
| - |
254 |
| - this.metrics?.regenFnNumStatesUpdated.observe(numStatesUpdated); |
255 |
| - } |
256 |
| - |
257 | 209 | /**
|
258 | 210 | * Get the state to run with `block`.
|
259 | 211 | * - State after `block.parentRoot` dialed forward to block.slot
|
|
0 commit comments