From caa025095f5f15a665b82d533126bca2a8b31532 Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Sat, 23 Sep 2023 21:28:19 +0200 Subject: [PATCH] chore: unrelated code cleanup (#5989) * Deduplicate remote host in abort and timeout monitoring errors * Add {once: true} to decrypt keystores terminate listener * Fix typo in canonical * Fix typo in passphrase file format error * Fix typoes in reasoning about API definitions * Fix more typos --- packages/api/src/beacon/routes/index.ts | 6 +++--- packages/beacon-node/src/metrics/validatorMonitor.ts | 4 ++-- packages/beacon-node/src/monitoring/service.ts | 4 ++-- packages/beacon-node/test/unit/monitoring/service.test.ts | 4 ++-- .../validator/keymanager/decryptKeystores/threadPool.ts | 2 +- packages/cli/src/cmds/validator/signers/index.ts | 4 ++-- packages/cli/src/options/paramsOptions.ts | 2 +- packages/cli/src/util/passphrase.ts | 2 +- packages/state-transition/src/cache/pubkeyCache.ts | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/api/src/beacon/routes/index.ts b/packages/api/src/beacon/routes/index.ts index f6d2b38b3457..81eb0cd3276c 100644 --- a/packages/api/src/beacon/routes/index.ts +++ b/packages/api/src/beacon/routes/index.ts @@ -45,7 +45,7 @@ export type Api = { // In our case we define the client in the exact same interface as the API executor layer. // Therefore we only need to define how to translate args <-> request, and return <-> response. // -// All files in the /routes directory provide succint definitions to do those transformations plus: +// All files in the /routes directory provide succinct definitions to do those transformations plus: // - URL + method, for each route ID // - Runtime schema, for each route ID // @@ -54,14 +54,14 @@ export type Api = { // routes that need non-JSON serialization (like debug.getState and lightclient.getProof) // // With this approach Typescript help us ensure that the client and server are compatible at build -// time, ensure there are tests for all routes and makes it very cheap to mantain and add new routes. +// time, ensure there are tests for all routes and makes it very cheap to maintain and add new routes. // // // How to add new routes // ===================== // // 1. Add the route function signature to the `Api` type. The function name MUST match the routeId from the spec. -// The arguments should use spec types if approapriate. Non-spec types MUST be defined in before the Api type +// The arguments should use spec types if appropriate. Non-spec types MUST be defined in before the Api type // so they are scoped by routes namespace. The all arguments MUST use camelCase casing. // 2. Add URL + METHOD in `routesData` matching the spec. // 3. Declare request serializers in `getReqSerializers()`. You MAY use `RouteReqTypeGenerator` to declare the diff --git a/packages/beacon-node/src/metrics/validatorMonitor.ts b/packages/beacon-node/src/metrics/validatorMonitor.ts index 83d0647ea7fc..de350c36ccbe 100644 --- a/packages/beacon-node/src/metrics/validatorMonitor.ts +++ b/packages/beacon-node/src/metrics/validatorMonitor.ts @@ -968,8 +968,8 @@ function renderBlockProposalSummary( } if (rootCache.getBlockRootAtSlot(proposalSlot) === proposal.blockRoot) { - // Cannonical state includes our block - return "cannonical"; + // Canonical state includes our block + return "canonical"; } let out = "orphaned"; diff --git a/packages/beacon-node/src/monitoring/service.ts b/packages/beacon-node/src/monitoring/service.ts index 66ed14ee42d0..f50f992ebe1f 100644 --- a/packages/beacon-node/src/monitoring/service.ts +++ b/packages/beacon-node/src/monitoring/service.ts @@ -186,9 +186,9 @@ export class MonitoringService { // error was thrown by abort signal if (signal.reason === FetchAbortReason.Close) { - throw new ErrorAborted(`request to ${this.remoteServiceHost}`); + throw new ErrorAborted("request"); } else if (signal.reason === FetchAbortReason.Timeout) { - throw new TimeoutError(`reached for request to ${this.remoteServiceHost}`); + throw new TimeoutError("request"); } else { throw e; } diff --git a/packages/beacon-node/test/unit/monitoring/service.test.ts b/packages/beacon-node/test/unit/monitoring/service.test.ts index e698e6609959..e0f208d27c3e 100644 --- a/packages/beacon-node/test/unit/monitoring/service.test.ts +++ b/packages/beacon-node/test/unit/monitoring/service.test.ts @@ -210,7 +210,7 @@ describe("monitoring / service", () => { await service.send(); - assertError({message: new TimeoutError(`reached for request to ${remoteServiceUrl.host}`).message}); + assertError({message: new TimeoutError("request").message}); }); it("should abort pending requests if monitoring service is closed", (done) => { @@ -219,7 +219,7 @@ describe("monitoring / service", () => { service.send().finally(() => { try { - assertError({message: new ErrorAborted(`request to ${remoteServiceUrl.host}`).message}); + assertError({message: new ErrorAborted("request").message}); done(); } catch (e) { done(e); diff --git a/packages/cli/src/cmds/validator/keymanager/decryptKeystores/threadPool.ts b/packages/cli/src/cmds/validator/keymanager/decryptKeystores/threadPool.ts index 09f2326a5a2f..90b502d79ac3 100644 --- a/packages/cli/src/cmds/validator/keymanager/decryptKeystores/threadPool.ts +++ b/packages/cli/src/cmds/validator/keymanager/decryptKeystores/threadPool.ts @@ -32,7 +32,7 @@ export class DecryptKeystoresThreadPool { this.terminatePoolHandler = () => { void this.pool.terminate(true); }; - signal.addEventListener("abort", this.terminatePoolHandler); + signal.addEventListener("abort", this.terminatePoolHandler, {once: true}); } /** diff --git a/packages/cli/src/cmds/validator/signers/index.ts b/packages/cli/src/cmds/validator/signers/index.ts index a441d14099d5..3fdf2460d1c6 100644 --- a/packages/cli/src/cmds/validator/signers/index.ts +++ b/packages/cli/src/cmds/validator/signers/index.ts @@ -17,7 +17,7 @@ import {importKeystoreDefinitionsFromExternalDir, readPassphraseOrPrompt} from " const KEYSTORE_IMPORT_PROGRESS_MS = 10000; /** - * Options processing heriarchy + * Options processing hierarchy * --interopIndexes * --fromMnemonic, then requires --mnemonicIndexes * --importKeystores, then requires --importKeystoresPassword @@ -31,7 +31,7 @@ const KEYSTORE_IMPORT_PROGRESS_MS = 10000; * - Remote: a URL that supports EIP-3030 (BLS Remote Signer HTTP API) * * Local secret keys can be gathered from: - * - Local keystores existant on disk + * - Local keystores existent on disk * - Local keystores imported via keymanager api * - Derived from a mnemonic (TESTING ONLY) * - Derived from interop keys (TESTING ONLY) diff --git a/packages/cli/src/options/paramsOptions.ts b/packages/cli/src/options/paramsOptions.ts index a23808ee6600..49ddc1b563f5 100644 --- a/packages/cli/src/options/paramsOptions.ts +++ b/packages/cli/src/options/paramsOptions.ts @@ -4,7 +4,7 @@ import {IBeaconParamsUnparsed} from "../config/types.js"; import {ObjectKeys, CliCommandOptions} from "../util/index.js"; // No options are statically declared -// If an arbitraty key notation is used, it removes typesafety on most of this CLI arg parsing code. +// If an arbitrary key notation is used, it removes type safety on most of this CLI arg parsing code. // Params will be parsed from an args object assuming to contain the required keys export type ITerminalPowArgs = { diff --git a/packages/cli/src/util/passphrase.ts b/packages/cli/src/util/passphrase.ts index 6f666211cc13..405d57442ce1 100644 --- a/packages/cli/src/util/passphrase.ts +++ b/packages/cli/src/util/passphrase.ts @@ -17,7 +17,7 @@ export function readPassphraseFile(passphraseFile: string): string { if (passphrase.length > 512) throw Error("is really long"); } catch (e) { throw new Error( - `passphraseFile ${passphraseFile} ${(e as Error).message}. Is this a well-formated passphraseFile?` + `passphraseFile ${passphraseFile} ${(e as Error).message}. Is this a well-formatted passphraseFile?` ); } diff --git a/packages/state-transition/src/cache/pubkeyCache.ts b/packages/state-transition/src/cache/pubkeyCache.ts index 130a9cd29d87..64a3f4f23c8f 100644 --- a/packages/state-transition/src/cache/pubkeyCache.ts +++ b/packages/state-transition/src/cache/pubkeyCache.ts @@ -8,7 +8,7 @@ export type Index2PubkeyCache = PublicKey[]; type PubkeyHex = string; /** - * toHexString() creates hex strings via string concatenation, which are very memory inneficient. + * toHexString() creates hex strings via string concatenation, which are very memory inefficient. * Memory benchmarks show that Buffer.toString("hex") produces strings with 10x less memory. * * Does not prefix to save memory, thus the prefix is removed from an already string representation.