From ff2fb5c60784d959dd4c1c2e53b46183fe2e3ec4 Mon Sep 17 00:00:00 2001 From: Cayman Date: Mon, 2 Oct 2023 11:06:03 -0400 Subject: [PATCH] chore: move setHasher to applyPreset.ts --- packages/cli/src/applyPreset.ts | 9 +++++++++ packages/cli/src/index.ts | 15 ++++----------- packages/prover/src/cli/applyPreset.ts | 9 +++++++++ packages/prover/src/cli/index.ts | 14 ++++---------- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/packages/cli/src/applyPreset.ts b/packages/cli/src/applyPreset.ts index f0f784f8ae61..760c18dbbcd7 100644 --- a/packages/cli/src/applyPreset.ts +++ b/packages/cli/src/applyPreset.ts @@ -1,4 +1,13 @@ // MUST import this file first before anything and not import any Lodestar code. + +// eslint-disable-next-line no-restricted-imports, import/no-extraneous-dependencies +import {hasher} from "@chainsafe/persistent-merkle-tree/lib/hasher/as-sha256.js"; +// eslint-disable-next-line no-restricted-imports, import/no-extraneous-dependencies +import {setHasher} from "@chainsafe/persistent-merkle-tree/lib/hasher/index.js"; + +// without setting this first, persistent-merkle-tree will use noble instead +setHasher(hasher); + // // ## Rationale // diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 294211426ed5..25e968c1c72c 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,18 +1,11 @@ #!/usr/bin/env node -// eslint-disable-next-line no-restricted-imports, import/no-extraneous-dependencies -import {hasher} from "@chainsafe/persistent-merkle-tree/lib/hasher/as-sha256.js"; -// eslint-disable-next-line no-restricted-imports, import/no-extraneous-dependencies -import {setHasher} from "@chainsafe/persistent-merkle-tree/lib/hasher/index.js"; +// MUST import first to apply preset from args and set ssz hasher +import("./applyPreset.js"); +import {YargsError} from "./util/index.js"; +import {getLodestarCli, yarg} from "./cli.js"; import "source-map-support/register.js"; -// without setting this first, persistent-merkle-tree will use noble instead -setHasher(hasher); - -// MUST import second to apply preset from args -await import("./applyPreset.js"); -const {YargsError} = await import("./util/index.js"); -const {getLodestarCli, yarg} = await import("./cli.js"); const lodestar = getLodestarCli(); void lodestar diff --git a/packages/prover/src/cli/applyPreset.ts b/packages/prover/src/cli/applyPreset.ts index a6a3568c5f91..158e05243ec7 100644 --- a/packages/prover/src/cli/applyPreset.ts +++ b/packages/prover/src/cli/applyPreset.ts @@ -1,4 +1,13 @@ // MUST import this file first before anything and not import any Lodestar code. + +// eslint-disable-next-line no-restricted-imports, import/no-extraneous-dependencies +import {hasher} from "@chainsafe/persistent-merkle-tree/lib/hasher/as-sha256.js"; +// eslint-disable-next-line no-restricted-imports, import/no-extraneous-dependencies +import {setHasher} from "@chainsafe/persistent-merkle-tree/lib/hasher/index.js"; + +// without setting this first, persistent-merkle-tree will use noble instead +setHasher(hasher); + // // ## Rationale // diff --git a/packages/prover/src/cli/index.ts b/packages/prover/src/cli/index.ts index f40bdff2e353..f5644f02f8f1 100644 --- a/packages/prover/src/cli/index.ts +++ b/packages/prover/src/cli/index.ts @@ -1,17 +1,11 @@ #!/usr/bin/env node -// eslint-disable-next-line no-restricted-imports, import/no-extraneous-dependencies -import {hasher} from "@chainsafe/persistent-merkle-tree/lib/hasher/as-sha256.js"; -// eslint-disable-next-line no-restricted-imports, import/no-extraneous-dependencies -import {setHasher} from "@chainsafe/persistent-merkle-tree/lib/hasher/index.js"; +// MUST import first to apply preset from args and set ssz hasher +import("./applyPreset.js"); +import {YargsError} from "../utils/errors.js"; +import {getLodestarProverCli, yarg} from "./cli.js"; import "source-map-support/register.js"; -// without setting this first, persistent-merkle-tree will use noble instead -setHasher(hasher); -// MUST import second to apply preset from args -await import("./applyPreset.js"); -const {getLodestarProverCli, yarg} = await import("./cli.js"); -const {YargsError} = await import("../utils/errors.js"); const prover = getLodestarProverCli(); void prover