Skip to content

Commit

Permalink
Fix some code after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Sep 12, 2024
1 parent d60857e commit bad4039
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/beacon-node/src/chain/historicalState/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export function getMetrics(metricsRegister: RegistryMetricCreator): HistoricalSt
buckets: [0.05, 0.1, 0.2, 0.5, 1, 1.5],
labelNames: ["source"],
}),
numEffectiveBalanceUpdates: metricsRegister.gauge({
name: "lodestar_historical_state_stfn_effective_balance_updates_count",
help: "Total count of effective balance updates",
}),
preStateBalancesNodesPopulatedMiss: metricsRegister.gauge<{source: StateCloneSource}>({
name: "lodestar_historical_state_stfn_balances_nodes_populated_miss_total",
help: "Total count state.balances nodesPopulated is false on stfn",
Expand Down
19 changes: 13 additions & 6 deletions packages/cli/src/cmds/beacon/initBeaconState.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {ssz} from "@lodestar/types";
import {createBeaconConfig, BeaconConfig, ChainForkConfig} from "@lodestar/config";
import {Logger} from "@lodestar/utils";
import {formatBytes, Logger} from "@lodestar/utils";
import {
isWithinWeakSubjectivityPeriod,
ensureWithinWeakSubjectivityPeriod,
BeaconStateAllForks,
loadState,
loadStateAndValidators,
} from "@lodestar/state-transition";
import {
IBeaconDb,
Expand Down Expand Up @@ -103,11 +104,17 @@ export async function initBeaconState(
// fetch the latest state stored in the db which will be used in all cases, if it exists, either
// i) used directly as the anchor state
// ii) used during verification of a weak subjectivity state,
const {stateBytes: lastDbStateBytes, slot: lastDbSlot} = await getLastStoredState({db, diffLayers: new DiffLayers()});
const lastDbState =
lastDbStateBytes && lastDbSlot !== null && lastDbSlot !== undefined
? chainForkConfig.getForkTypes(lastDbSlot).BeaconState.deserializeToViewDU(lastDbStateBytes)
: null;
const {stateBytes, slot: lastDbSlot} = await getLastStoredState({db, diffLayers: new DiffLayers()});
let lastDbState: BeaconStateAllForks | null = null;
let lastDbValidatorsBytes: Uint8Array | null = null;
let lastDbStateWithBytes: StateWithBytes | null = null;
if (stateBytes) {
logger.verbose("Found the last archived state", {slot: lastDbSlot, size: formatBytes(stateBytes.length)});
const {state, validatorsBytes} = loadStateAndValidators(chainForkConfig, stateBytes);
lastDbState = state;
lastDbValidatorsBytes = validatorsBytes;
lastDbStateWithBytes = {state, stateBytes: stateBytes};
}

if (lastDbState) {
const config = createBeaconConfig(chainForkConfig, lastDbState.genesisValidatorsRoot);
Expand Down

0 comments on commit bad4039

Please sign in to comment.