mirror of
https://github.com/ChainSafe/lodestar.git
synced 2026-01-09 15:48:08 -05:00
* Add package skeleton * Add implementation for the verification * Update package versions * Update teh provdier structure to store full execution payload * Add a test script * Split the utils to scoped files * Add multiple web3 providers * Add a proxy factory method * Add the CLI for the prover proxy * Rename few functions to make those consistent * Add some required unit tests * Add unit tests * Add e2e tests * Fix duplicate Buffer error * Fix lint error * Fix lint errors * Update the lightclient to sync in background * Validate the execution payload * Update initWithRest to init * Update the max limit for the payloads to not cross finalized slot * Remove the usage for finalizedPayloadHeaders tracking * Rename update to lcHeader * Update the code as per feedback * Fix readme * Update the payload store logic * Add the cleanup logic to payload store * Update the code as per feedback * Fix few types in the tests * Move the usage to isForkWithdrawls * Fix a unit test
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import {LogData, Logger, LoggerChildOpts} from "@lodestar/utils";
|
|
import {ELRequestPayload} from "../types.js";
|
|
|
|
const printLogData = (data: LogData): string => {
|
|
if (!Array.isArray(data) && data !== null && typeof data === "object") {
|
|
return Object.entries(data)
|
|
.map(([key, value]) => `${key}=${value}`)
|
|
.join(" ");
|
|
}
|
|
return JSON.stringify(data);
|
|
};
|
|
|
|
const stdLogHandler = (level: string): ((message: string, context?: LogData, error?: Error | undefined) => void) => {
|
|
if (process === undefined) {
|
|
return (message: string, context?: LogData, error?: Error | undefined): void => {
|
|
// eslint-disable-next-line no-console
|
|
console.log(
|
|
`${level}: ${message} ${context === undefined ? "" : printLogData(context)} ${error ? error.stack : ""}`
|
|
);
|
|
};
|
|
}
|
|
return (message: string, context?: LogData, error?: Error | undefined): void => {
|
|
const stream = level === "error" ? process.stderr : process.stdout;
|
|
stream.write(
|
|
`${level}: ${message} ${context === undefined ? "" : printLogData(context)} ${error ? error.stack : ""}\n`
|
|
);
|
|
};
|
|
};
|
|
|
|
export const stdLogger: Logger = {
|
|
error: stdLogHandler("error"),
|
|
warn: stdLogHandler("warn"),
|
|
info: stdLogHandler("info"),
|
|
debug: stdLogHandler("debug"),
|
|
verbose: stdLogHandler("verb"),
|
|
// eslint-disable-next-line func-names
|
|
child: function (_options: LoggerChildOpts): Logger {
|
|
throw new Error("Not supported.");
|
|
},
|
|
};
|
|
|
|
export function logRequest({logger, payload}: {logger: Logger; payload: ELRequestPayload}): void {
|
|
logger.debug(
|
|
`Req method=${payload.method} params=${payload.params === undefined ? "" : JSON.stringify(payload.params)}`
|
|
);
|
|
}
|