Skip to content

Commit

Permalink
chore: unrelated code cleanup (#5989)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nflaig authored Sep 23, 2023
1 parent 9618dd1 commit caa0250
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions packages/api/src/beacon/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/metrics/validatorMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/monitoring/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/test/unit/monitoring/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/cmds/validator/signers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/options/paramsOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/passphrase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?`
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/src/cache/pubkeyCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit caa0250

Please sign in to comment.