Skip to content

Commit

Permalink
fix: setHasher first
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Sep 19, 2023
1 parent cf71c29 commit 319b71b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 26 deletions.
21 changes: 10 additions & 11 deletions packages/cli/src/cmds/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// 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";
import {CliCommand} from "../util/index.js";
import {GlobalArgs} from "../options/index.js";
import {beacon} from "./beacon/index.js";
import {dev} from "./dev/index.js";
import {validator} from "./validator/index.js";
import {lightclient} from "./lightclient/index.js";
import {bootnode} from "./bootnode/index.js";

// without setting this first, persistent-merkle-tree will use noble instead
setHasher(hasher);
export const cmds: Required<CliCommand<GlobalArgs, Record<never, never>>>["subcommands"] = [
(await import("./beacon/index.js")).beacon,
(await import("./validator/index.js")).validator,
(await import("./lightclient/index.js")).lightclient,
(await import("./dev/index.js")).dev,
(await import("./bootnode/index.js")).bootnode,
beacon,
validator,
lightclient,
dev,
bootnode,
];
15 changes: 11 additions & 4 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/usr/bin/env node

// MUST import first to apply preset from args
import "./applyPreset.js";
import {YargsError} from "./util/index.js";
import {getLodestarCli, yarg} from "./cli.js";
// 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";
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
Expand Down
7 changes: 0 additions & 7 deletions packages/prover/src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// 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 not use `* as yargs`, see https://github.com/yargs/yargs/issues/1131
import yargs from "yargs";
import {hideBin} from "yargs/helpers";
Expand All @@ -10,9 +6,6 @@ import {getVersionData} from "../utils/version.js";
import {cmds} from "./cmds/index.js";
import {globalOptions} from "./options.js";

// without setting this first, persistent-merkle-tree will use noble instead
setHasher(hasher);

const {version} = getVersionData();
const topBanner = `🌟 Lodestar Prover Proxy: Ethereum RPC proxy for RPC responses, verified against the trusted block hashes.
* Version: ${version}
Expand Down
14 changes: 10 additions & 4 deletions packages/prover/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/usr/bin/env node

// MUST import first to apply preset from args
import "./applyPreset.js";
import {YargsError} from "../utils/errors.js";
import {getLodestarProverCli, yarg} from "./cli.js";
// 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";
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
Expand Down

0 comments on commit 319b71b

Please sign in to comment.