Skip to content

Commit

Permalink
Update the code as per feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Oct 21, 2024
1 parent ba31880 commit c9c5058
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 19 deletions.
7 changes: 5 additions & 2 deletions packages/beacon-node/src/chain/archiver/archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {Metrics} from "../../metrics/metrics.js";
import {FrequencyStateArchiveStrategy} from "./strategies/frequencyStateArchiveStrategy.js";
import {archiveBlocks} from "./archiveBlocks.js";
import {StateArchiveMode, ArchiverOpts, StateArchiveStrategy} from "./interface.js";
import {PROCESS_FINALIZED_CHECKPOINT_QUEUE_LEN} from "./constants.js";

export const DEFAULT_STATE_ARCHIVE_MODE = StateArchiveMode.Frequency;

export const PROCESS_FINALIZED_CHECKPOINT_QUEUE_LEN = 256;

/**
* Used for running tasks that depends on some events or are executed
Expand Down Expand Up @@ -61,7 +64,7 @@ export class Archiver {

/** Archive latest finalized state */
async persistToDisk(): Promise<void> {
await this.statesArchiverStrategy.maybeArchiveState(this.chain.forkChoice.getFinalizedCheckpoint());
return this.statesArchiverStrategy.maybeArchiveState(this.chain.forkChoice.getFinalizedCheckpoint());
}

private onFinalizedCheckpoint = async (finalized: CheckpointWithHex): Promise<void> => {
Expand Down
11 changes: 0 additions & 11 deletions packages/beacon-node/src/chain/archiver/constants.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/beacon-node/src/chain/archiver/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./archiver.js";
export * from "./interface.js";
export * from "./constants.js";
3 changes: 2 additions & 1 deletion packages/beacon-node/src/chain/archiver/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {RootHex} from "@lodestar/types";

export enum StateArchiveMode {
Frequency = "frequency",
// Specify only existing strategy
// New strategy to be implemented
// WIP: https://github.com/ChainSafe/lodestar/pull/7005
// Differential = "diff",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import {serializeState} from "../../serializeState.js";
import {AllocSource, BufferPool} from "../../../util/bufferPool.js";
import {Metrics} from "../../../metrics/metrics.js";
import {StateArchiveStrategy, StatesArchiverOpts} from "../interface.js";
import {PERSIST_TEMP_STATE_EVERY_EPOCHS} from "../constants.js";

/**
* Minimum number of epochs between single temp archived states
* These states will be pruned once a new state is persisted
*/
export const PERSIST_TEMP_STATE_EVERY_EPOCHS = 32;

/**
* Archives finalized states from active bucket to archive bucket.
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {ShufflingCacheOpts} from "./shufflingCache.js";
import {DEFAULT_MAX_BLOCK_STATES, FIFOBlockStateCacheOpts} from "./stateCache/fifoBlockStateCache.js";
import {PersistentCheckpointStateCacheOpts} from "./stateCache/persistentCheckpointsCache.js";
import {DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY} from "./stateCache/persistentCheckpointsCache.js";
import {DEFAULT_STATE_ARCHIVE_MODE} from "./archiver/constants.js";
import {DEFAULT_STATE_ARCHIVE_MODE} from "./archiver/archiver.js";
export {StateArchiveMode} from "./archiver/interface.js";

export type IChainOptions = BlockProcessOpts &
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/options/beaconNodeOptions/chain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "node:path";
import {StateArchiveMode, defaultOptions, IBeaconNodeOptions} from "@lodestar/beacon-node";
import {StateArchiveMode, defaultOptions, IBeaconNodeOptions, DEFAULT_STATE_ARCHIVE_MODE} from "@lodestar/beacon-node";
import {CliCommandOptions} from "@lodestar/utils";

export type ChainArgs = {
Expand Down Expand Up @@ -215,7 +215,7 @@ Will double processing times. Use only for debugging purposes.",
"chain.stateArchiveMode": {
hidden: true,
choices: Object.values(StateArchiveMode),
description: "Strategy to manage archive states",
description: `Strategy to manage archive states, only support ${DEFAULT_STATE_ARCHIVE_MODE} at this time`,
default: defaultOptions.chain.stateArchiveMode,
type: "string",
group: "chain",
Expand Down

0 comments on commit c9c5058

Please sign in to comment.