update utils to accept the metrics

This commit is contained in:
Nazar Hussain
2025-12-10 09:46:41 +01:00
parent 5bc81f3dea
commit 8bb2d87790
2 changed files with 7 additions and 7 deletions

View File

@@ -23,7 +23,7 @@ export async function regenerateState(
try {
const plan = buildStateRegenPlan(ctx.layers, target);
const artifacts = await fetchStateRegenArtifacts(ctx.db, plan, opts);
const artifacts = await fetchStateRegenArtifacts({db: ctx.db, metrics: ctx.metrics}, plan, opts);
const finalState = await applyStateRegenPlan(ctx, plan, artifacts);
const state = snapshotToBeaconState(ctx, finalState);
@@ -65,10 +65,10 @@ export async function storeDifferentialState(
const lastDiffSlot = plan.diffSlots.at(-1);
if (slot === lastDiffSlot) {
const artifacts = await fetchStateRegenArtifacts(db, plan);
const artifacts = await fetchStateRegenArtifacts({db: ctx.db, metrics: ctx.metrics}, plan);
const finalState = await applyStateRegenPlan(ctx, plan, artifacts);
const diffState = await computeStateDifferential(
{codec, config},
{codec, config, metrics: ctx.metrics},
config.getForkTypes(slot).BeaconState.deserialize(stateBytes),
finalState
);

View File

@@ -10,7 +10,7 @@ import {BeaconStateDifferential, BeaconStateSnapshot} from "./ssz.js";
* Compute the differential state between a base state and a target state view
*/
export function computeStateDifferential(
modules: {codec: IStateDiffCodec; config: ChainForkConfig; metrics?: DifferentialStateRegenMetrics},
modules: {codec: IStateDiffCodec; config: ChainForkConfig; metrics?: DifferentialStateRegenMetrics | null},
base: BeaconState,
target: BeaconStateSnapshot
): BeaconStateDifferential {
@@ -40,7 +40,7 @@ export function computeStateDifferential(
* Apply a differential state to a base state view
*/
export function applyStateDifferential(
modules: {codec: IStateDiffCodec; logger?: Logger; metrics?: DifferentialStateRegenMetrics},
modules: {codec: IStateDiffCodec; logger?: Logger; metrics?: DifferentialStateRegenMetrics | null},
base: BeaconStateSnapshot,
diff: BeaconStateDifferential
): BeaconStateSnapshot {
@@ -77,7 +77,7 @@ export function applyStateDifferential(
}
export async function replayStateDifferentials(
modules: {codec: IStateDiffCodec; logger?: Logger},
modules: {codec: IStateDiffCodec; logger?: Logger; metrics?: DifferentialStateRegenMetrics | null},
{
stateDifferentials,
stateSnapshot,
@@ -102,7 +102,7 @@ export async function getStateDifferential(
}
export async function getStateDifferentials(
modules: {db: IBeaconDb},
modules: {db: IBeaconDb; metrics?: DifferentialStateRegenMetrics | null},
{slots}: {slots: Slot[]}
): Promise<BeaconStateDifferential[]> {
const result: BeaconStateDifferential[] = [];