Skip to content

Commit 821c319

Browse files
authored
chore: assert as-sha256 is used as hasher by ssz (#7394)
**Motivation** Loading an incorrect hasher can cause strange regressions in performance which might not be immediately obvious, best to catch this at startup and exit as there is no reason for the beacon node to use any other hasher besides as-sha256 (at least right now). **Description** Assert as-sha256 is used as hasher by ssz
1 parent 42631de commit 821c319

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/cli/src/cmds/beacon/handler.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from "node:path";
22
import {getHeapStatistics} from "node:v8";
3+
import {hasher} from "@chainsafe/persistent-merkle-tree";
34
import {BeaconDb, BeaconNode} from "@lodestar/beacon-node";
45
import {ChainForkConfig, createBeaconConfig} from "@lodestar/config";
56
import {LevelDbController} from "@lodestar/db";
@@ -36,6 +37,10 @@ const EIGHT_GB = 8 * 1024 * 1024 * 1024;
3637
export async function beaconHandler(args: BeaconArgs & GlobalArgs): Promise<void> {
3738
const {config, options, beaconPaths, network, version, commit, peerId, logger} = await beaconHandlerInit(args);
3839

40+
if (hasher.name !== "as-sha256") {
41+
throw Error(`Loaded incorrect hasher ${hasher.name}, expected as-sha256`);
42+
}
43+
3944
const heapSizeLimit = getHeapStatistics().heap_size_limit;
4045
if (heapSizeLimit < EIGHT_GB) {
4146
logger.warn(

0 commit comments

Comments
 (0)