Skip to content

Commit

Permalink
chore: move setHasher to applyPreset.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain committed Oct 2, 2023
1 parent 96e319c commit ff2fb5c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
9 changes: 9 additions & 0 deletions packages/cli/src/applyPreset.ts
Original file line number Diff line number Diff line change
@@ -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
//
Expand Down
15 changes: 4 additions & 11 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 9 additions & 0 deletions packages/prover/src/cli/applyPreset.ts
Original file line number Diff line number Diff line change
@@ -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
//
Expand Down
14 changes: 4 additions & 10 deletions packages/prover/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit ff2fb5c

Please sign in to comment.