-
-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4566f49
commit c2ac67c
Showing
29 changed files
with
208 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,4 +83,7 @@ packages/cli/.git-data.json | |
.last_build_unixsec | ||
dictionary.dic | ||
|
||
temp/ | ||
temp/ | ||
|
||
# AI Agents | ||
.aider.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/beacon-node/src/chain/archiver/strategies/diffStateArchiveStrategy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import {CheckpointWithHex} from "@lodestar/fork-choice"; | ||
import {Logger} from "@lodestar/logger"; | ||
import {CachedBeaconStateAllForks, computeStartSlotAtEpoch} from "@lodestar/state-transition"; | ||
import {RootHex} from "@lodestar/types"; | ||
import {Metrics} from "../../../metrics/metrics.js"; | ||
import {IHistoricalStateRegen} from "../../historicalState/types.js"; | ||
import {IStateRegenerator} from "../../regen/interface.js"; | ||
import {StateArchiveStrategy} from "../interface.js"; | ||
|
||
export class DifferentialStateArchiveStrategy implements StateArchiveStrategy { | ||
constructor( | ||
protected modules: { | ||
historicalStateRegen: IHistoricalStateRegen | undefined; | ||
regen: IStateRegenerator; | ||
logger: Logger; | ||
} | ||
) {} | ||
|
||
archiveState(_finalized: CheckpointWithHex, _metrics?: Metrics | null): Promise<void> { | ||
throw new Error("Method not implemented."); | ||
} | ||
|
||
async onFinalizedCheckpoint(finalized: CheckpointWithHex, metrics?: Metrics | null): Promise<void> { | ||
await this.archiveState(finalized, metrics); | ||
} | ||
|
||
async onCheckpoint(_stateRoot: RootHex, _metrics?: Metrics | null): Promise<void> {} | ||
|
||
async maybeArchiveState(finalized: CheckpointWithHex, _metrics?: Metrics | null): Promise<void> { | ||
// starting from Mar 2024, the finalized state could be from disk or in memory | ||
const state = await this.modules.regen.getCheckpointStateOrBytes(finalized); | ||
if (state === null) { | ||
this.modules.logger.warn("Checkpoint state not available to archive.", { | ||
epoch: finalized.epoch, | ||
root: finalized.rootHex, | ||
}); | ||
return; | ||
} | ||
|
||
if (Array.isArray(state) && state.constructor === Uint8Array) { | ||
return this.modules.historicalStateRegen?.storeHistoricalState(computeStartSlotAtEpoch(finalized.epoch), state); | ||
} | ||
|
||
return this.modules.historicalStateRegen?.storeHistoricalState( | ||
(state as CachedBeaconStateAllForks).slot, | ||
(state as CachedBeaconStateAllForks).serialize() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/beacon-node/src/chain/historicalState/historicalState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/beacon-node/src/chain/historicalState/historicalStateRegen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from "./historicalStateRegen.js"; | ||
export * from "./types.js"; | ||
export * from "./diffLayers.js"; | ||
export * from "./diffLayers.js"; |
4 changes: 2 additions & 2 deletions
4
packages/beacon-node/src/chain/historicalState/utils/binaryDiffXDelta3Codec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.