From 68357abd796ebbff30902f14daf8ba3a33cae715 Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Fri, 8 Nov 2024 22:27:21 +0800 Subject: [PATCH] fix: archive finalized state when shutting down beacon node (#7221) --- packages/beacon-node/src/chain/archiver/archiver.ts | 2 +- packages/beacon-node/src/chain/archiver/interface.ts | 1 + .../chain/archiver/strategies/frequencyStateArchiveStrategy.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/beacon-node/src/chain/archiver/archiver.ts b/packages/beacon-node/src/chain/archiver/archiver.ts index 2d79f584ea79..007eeeed0c94 100644 --- a/packages/beacon-node/src/chain/archiver/archiver.ts +++ b/packages/beacon-node/src/chain/archiver/archiver.ts @@ -64,7 +64,7 @@ export class Archiver { /** Archive latest finalized state */ async persistToDisk(): Promise { - return this.statesArchiverStrategy.maybeArchiveState(this.chain.forkChoice.getFinalizedCheckpoint()); + return this.statesArchiverStrategy.archiveState(this.chain.forkChoice.getFinalizedCheckpoint()); } private onFinalizedCheckpoint = async (finalized: CheckpointWithHex): Promise => { diff --git a/packages/beacon-node/src/chain/archiver/interface.ts b/packages/beacon-node/src/chain/archiver/interface.ts index 48c930c78cd3..d5ac3dac8790 100644 --- a/packages/beacon-node/src/chain/archiver/interface.ts +++ b/packages/beacon-node/src/chain/archiver/interface.ts @@ -44,4 +44,5 @@ export interface StateArchiveStrategy { onCheckpoint(stateRoot: RootHex, metrics?: Metrics | null): Promise; onFinalizedCheckpoint(finalized: CheckpointWithHex, metrics?: Metrics | null): Promise; maybeArchiveState(finalized: CheckpointWithHex, metrics?: Metrics | null): Promise; + archiveState(finalized: CheckpointWithHex, metrics?: Metrics | null): Promise; } diff --git a/packages/beacon-node/src/chain/archiver/strategies/frequencyStateArchiveStrategy.ts b/packages/beacon-node/src/chain/archiver/strategies/frequencyStateArchiveStrategy.ts index a701da5b22ec..c6e4dccfbf6c 100644 --- a/packages/beacon-node/src/chain/archiver/strategies/frequencyStateArchiveStrategy.ts +++ b/packages/beacon-node/src/chain/archiver/strategies/frequencyStateArchiveStrategy.ts @@ -84,7 +84,7 @@ export class FrequencyStateArchiveStrategy implements StateArchiveStrategy { * Archives finalized states from active bucket to archive bucket. * Only the new finalized state is stored to disk */ - private async archiveState(finalized: CheckpointWithHex, metrics?: Metrics | null): Promise { + async archiveState(finalized: CheckpointWithHex, metrics?: Metrics | null): Promise { // starting from Mar 2024, the finalized state could be from disk or in memory const finalizedStateOrBytes = await this.regen.getCheckpointStateOrBytes(finalized); const {rootHex} = finalized;