@typeberry/lib 0.4.1-bb6dbac → 0.4.1-c2b0fdd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +989 -108
- package/index.d.ts +99 -10
- package/index.js +989 -108
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -180,6 +180,15 @@ declare class Compatibility {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
declare function isBrowser(): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Get current time in milliseconds (works in both Node and browser).
|
|
185
|
+
*
|
|
186
|
+
* Node.js implementation converts hrtime bigint nanoseconds to milliseconds.
|
|
187
|
+
* This is safe because dividing nanoseconds by 1_000_000 yields milliseconds,
|
|
188
|
+
* which remain well below Number.MAX_SAFE_INTEGER for practical runtimes
|
|
189
|
+
* (would take ~285 years to overflow).
|
|
190
|
+
*/
|
|
191
|
+
declare const now: () => number;
|
|
183
192
|
/**
|
|
184
193
|
* A function to perform runtime assertions.
|
|
185
194
|
*
|
|
@@ -212,7 +221,7 @@ declare function assertEmpty<T extends Record<string, never>>(value: T): void;
|
|
|
212
221
|
/** Debug print an object. */
|
|
213
222
|
declare function inspect<T>(val: T): string;
|
|
214
223
|
/** Utility function to measure time taken for some operation [ms]. */
|
|
215
|
-
declare
|
|
224
|
+
declare function measure(id: string): () => string;
|
|
216
225
|
/** A class that adds `toString` method that prints all properties of an object. */
|
|
217
226
|
declare abstract class WithDebug {
|
|
218
227
|
toString(): string;
|
|
@@ -240,6 +249,8 @@ declare function lazyInspect<T>(obj: T): {
|
|
|
240
249
|
*/
|
|
241
250
|
declare const workspacePathFix: (workspacePath: string) => (p: string) => string;
|
|
242
251
|
|
|
252
|
+
declare const env: NodeJS.ProcessEnv;
|
|
253
|
+
|
|
243
254
|
/**
|
|
244
255
|
* `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
|
|
245
256
|
* specified unique token Token. It means that base type cannot be assigned to unique type by accident.
|
|
@@ -400,16 +411,18 @@ declare const index$w_assertEmpty: typeof assertEmpty;
|
|
|
400
411
|
declare const index$w_assertNever: typeof assertNever;
|
|
401
412
|
declare const index$w_check: typeof check;
|
|
402
413
|
declare const index$w_deepEqual: typeof deepEqual;
|
|
414
|
+
declare const index$w_env: typeof env;
|
|
403
415
|
declare const index$w_inspect: typeof inspect;
|
|
404
416
|
declare const index$w_isBrowser: typeof isBrowser;
|
|
405
417
|
declare const index$w_lazyInspect: typeof lazyInspect;
|
|
406
418
|
declare const index$w_measure: typeof measure;
|
|
419
|
+
declare const index$w_now: typeof now;
|
|
407
420
|
declare const index$w_resultToString: typeof resultToString;
|
|
408
421
|
declare const index$w_safeAllocUint8Array: typeof safeAllocUint8Array;
|
|
409
422
|
declare const index$w_seeThrough: typeof seeThrough;
|
|
410
423
|
declare const index$w_workspacePathFix: typeof workspacePathFix;
|
|
411
424
|
declare namespace index$w {
|
|
412
|
-
export { index$w_CURRENT_SUITE as CURRENT_SUITE, index$w_CURRENT_VERSION as CURRENT_VERSION, index$w_Compatibility as Compatibility, index$w_DEFAULT_SUITE as DEFAULT_SUITE, index$w_DEFAULT_VERSION as DEFAULT_VERSION, index$w_ErrorsCollector as ErrorsCollector, index$w_GpVersion as GpVersion, index$w_MAX_LENGTH as MAX_LENGTH, index$w_Result as Result, index$w_TEST_COMPARE_USING as TEST_COMPARE_USING, index$w_TestSuite as TestSuite, index$w_WithDebug as WithDebug, index$w___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$w_asOpaqueType as asOpaqueType, index$w_assertEmpty as assertEmpty, index$w_assertNever as assertNever, index$w_check as check, index$w_deepEqual as deepEqual, index$w_inspect as inspect, index$w_isBrowser as isBrowser, index$w_lazyInspect as lazyInspect, index$w_measure as measure, index$w_resultToString as resultToString, index$w_safeAllocUint8Array as safeAllocUint8Array, index$w_seeThrough as seeThrough, index$w_workspacePathFix as workspacePathFix };
|
|
425
|
+
export { index$w_CURRENT_SUITE as CURRENT_SUITE, index$w_CURRENT_VERSION as CURRENT_VERSION, index$w_Compatibility as Compatibility, index$w_DEFAULT_SUITE as DEFAULT_SUITE, index$w_DEFAULT_VERSION as DEFAULT_VERSION, index$w_ErrorsCollector as ErrorsCollector, index$w_GpVersion as GpVersion, index$w_MAX_LENGTH as MAX_LENGTH, index$w_Result as Result, index$w_TEST_COMPARE_USING as TEST_COMPARE_USING, index$w_TestSuite as TestSuite, index$w_WithDebug as WithDebug, index$w___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$w_asOpaqueType as asOpaqueType, index$w_assertEmpty as assertEmpty, index$w_assertNever as assertNever, index$w_check as check, index$w_deepEqual as deepEqual, index$w_env as env, index$w_inspect as inspect, index$w_isBrowser as isBrowser, index$w_lazyInspect as lazyInspect, index$w_measure as measure, index$w_now as now, index$w_resultToString as resultToString, index$w_safeAllocUint8Array as safeAllocUint8Array, index$w_seeThrough as seeThrough, index$w_workspacePathFix as workspacePathFix };
|
|
413
426
|
export type { index$w_DeepEqualOptions as DeepEqualOptions, index$w_ErrorResult as ErrorResult, index$w_OK as OK, index$w_OkResult as OkResult, index$w_Opaque as Opaque, index$w_TaggedError as TaggedError, index$w_TokenOf as TokenOf, index$w_WithOpaque as WithOpaque };
|
|
414
427
|
}
|
|
415
428
|
|
|
@@ -7200,6 +7213,8 @@ declare class Channel {
|
|
|
7200
7213
|
|
|
7201
7214
|
/** Standardized worker config. */
|
|
7202
7215
|
interface WorkerConfig<TParams = void, TBlocks = BlocksDb, TStates = StatesDb> {
|
|
7216
|
+
/** Node name. */
|
|
7217
|
+
readonly nodeName: string;
|
|
7203
7218
|
/** Chain spec. */
|
|
7204
7219
|
readonly chainSpec: ChainSpec;
|
|
7205
7220
|
/** Worker parameters. */
|
|
@@ -7213,11 +7228,13 @@ interface WorkerConfig<TParams = void, TBlocks = BlocksDb, TStates = StatesDb> {
|
|
|
7213
7228
|
* Worker config with in-thread database.
|
|
7214
7229
|
*/
|
|
7215
7230
|
declare class DirectWorkerConfig<TParams = void, TBlocks = BlocksDb, TStates = StatesDb> implements WorkerConfig<TParams, TBlocks, TStates> {
|
|
7231
|
+
readonly nodeName: string;
|
|
7216
7232
|
readonly chainSpec: ChainSpec;
|
|
7217
7233
|
readonly workerParams: TParams;
|
|
7218
7234
|
private readonly blocksDb;
|
|
7219
7235
|
private readonly statesDb;
|
|
7220
|
-
static new<T, B, S>({ chainSpec, blocksDb, statesDb, params, }: {
|
|
7236
|
+
static new<T, B, S>({ nodeName, chainSpec, blocksDb, statesDb, params, }: {
|
|
7237
|
+
nodeName: string;
|
|
7221
7238
|
chainSpec: ChainSpec;
|
|
7222
7239
|
blocksDb: B;
|
|
7223
7240
|
statesDb: S;
|
|
@@ -7282,6 +7299,20 @@ type Options = {
|
|
|
7282
7299
|
workingDir: string;
|
|
7283
7300
|
modules: Map<string, Level>;
|
|
7284
7301
|
};
|
|
7302
|
+
/**
|
|
7303
|
+
* Find a configured log level for given module.
|
|
7304
|
+
*
|
|
7305
|
+
* The function will attempt to find the most detailed level for given module
|
|
7306
|
+
* by checking if logging is configured for it's parent modules if it's not for
|
|
7307
|
+
* the specific name.
|
|
7308
|
+
*
|
|
7309
|
+
* E.g. `consensus/voting`
|
|
7310
|
+
*
|
|
7311
|
+
* We can have no level configured for `consensus/voting`, but if there is a `WARN`
|
|
7312
|
+
* level for `consensus`, this function would return `Level.WARN` even though
|
|
7313
|
+
* the default log level might be `Level.LOG`.
|
|
7314
|
+
*/
|
|
7315
|
+
declare function findLevel(options: Options, moduleName: string): Level;
|
|
7285
7316
|
/**
|
|
7286
7317
|
* A function to parse logger definition (including modules) given as a string.
|
|
7287
7318
|
*
|
|
@@ -7292,6 +7323,45 @@ type Options = {
|
|
|
7292
7323
|
*/
|
|
7293
7324
|
declare function parseLoggerOptions(input: string, defaultLevel: Level, workingDir?: string): Options;
|
|
7294
7325
|
|
|
7326
|
+
type TransportBuilder = (minLevel: Level, options: Options) => Transport;
|
|
7327
|
+
/**
|
|
7328
|
+
* An interface for the logger `Transport`.
|
|
7329
|
+
*/
|
|
7330
|
+
interface Transport {
|
|
7331
|
+
/** INSANE message */
|
|
7332
|
+
insane(levelAndName: readonly [Level, string], _strings: TemplateStringsArray, _data: unknown[]): void;
|
|
7333
|
+
/** TRACE message */
|
|
7334
|
+
trace(levelAndName: readonly [Level, string], strings: TemplateStringsArray, data: unknown[]): void;
|
|
7335
|
+
/** DEBUG/LOG message */
|
|
7336
|
+
log(levelAndName: readonly [Level, string], strings: TemplateStringsArray, data: unknown[]): void;
|
|
7337
|
+
/** INFO message */
|
|
7338
|
+
info(levelAndName: readonly [Level, string], strings: TemplateStringsArray, data: unknown[]): void;
|
|
7339
|
+
/** WARN message */
|
|
7340
|
+
warn(levelAndName: readonly [Level, string], strings: TemplateStringsArray, data: unknown[]): void;
|
|
7341
|
+
/** ERROR message */
|
|
7342
|
+
error(levelAndName: readonly [Level, string], strings: TemplateStringsArray, data: unknown[]): void;
|
|
7343
|
+
}
|
|
7344
|
+
|
|
7345
|
+
/** An optimized logger that ignores `TRACE`, `DEBUG` and `LOG` messages.
|
|
7346
|
+
*
|
|
7347
|
+
* Use the `create` method to instantiate the right instance of a more specialized logger.
|
|
7348
|
+
*/
|
|
7349
|
+
declare class ConsoleTransport implements Transport {
|
|
7350
|
+
protected options: Options;
|
|
7351
|
+
/**
|
|
7352
|
+
* Creates a new optimized logger which ignores messages that are below the
|
|
7353
|
+
* `minimalLevel`.
|
|
7354
|
+
*/
|
|
7355
|
+
static create(minimalLevel: Level, options: Options): ConsoleTransport;
|
|
7356
|
+
protected constructor(options: Options);
|
|
7357
|
+
insane(_levelAndName: readonly [Level, string], _strings: TemplateStringsArray, _data: unknown[]): void;
|
|
7358
|
+
trace(_levelAndName: readonly [Level, string], _strings: TemplateStringsArray, _data: unknown[]): void;
|
|
7359
|
+
log(_levelAndName: readonly [Level, string], _strings: TemplateStringsArray, _data: unknown[]): void;
|
|
7360
|
+
info(_levelAndName: readonly [Level, string], _strings: TemplateStringsArray, _data: unknown[]): void;
|
|
7361
|
+
warn(levelAndName: readonly [Level, string], strings: TemplateStringsArray, data: unknown[]): void;
|
|
7362
|
+
error(levelAndName: readonly [Level, string], strings: TemplateStringsArray, data: unknown[]): void;
|
|
7363
|
+
}
|
|
7364
|
+
|
|
7295
7365
|
/**
|
|
7296
7366
|
* A logger instance.
|
|
7297
7367
|
*/
|
|
@@ -7317,7 +7387,7 @@ declare class Logger {
|
|
|
7317
7387
|
*
|
|
7318
7388
|
* Changing the options affects all previously created loggers.
|
|
7319
7389
|
*/
|
|
7320
|
-
static configureAllFromOptions(options: Options): void;
|
|
7390
|
+
static configureAllFromOptions(options: Options, createTransport?: TransportBuilder): void;
|
|
7321
7391
|
/**
|
|
7322
7392
|
* Global configuration of all loggers.
|
|
7323
7393
|
*
|
|
@@ -7344,17 +7414,20 @@ declare class Logger {
|
|
|
7344
7414
|
error(strings: TemplateStringsArray, ...data: unknown[]): void;
|
|
7345
7415
|
}
|
|
7346
7416
|
|
|
7417
|
+
type index$c_ConsoleTransport = ConsoleTransport;
|
|
7418
|
+
declare const index$c_ConsoleTransport: typeof ConsoleTransport;
|
|
7347
7419
|
type index$c_Level = Level;
|
|
7348
7420
|
declare const index$c_Level: typeof Level;
|
|
7349
7421
|
type index$c_Logger = Logger;
|
|
7350
7422
|
declare const index$c_Logger: typeof Logger;
|
|
7423
|
+
type index$c_Options = Options;
|
|
7424
|
+
type index$c_Transport = Transport;
|
|
7425
|
+
type index$c_TransportBuilder = TransportBuilder;
|
|
7426
|
+
declare const index$c_findLevel: typeof findLevel;
|
|
7351
7427
|
declare const index$c_parseLoggerOptions: typeof parseLoggerOptions;
|
|
7352
7428
|
declare namespace index$c {
|
|
7353
|
-
export {
|
|
7354
|
-
|
|
7355
|
-
index$c_Logger as Logger,
|
|
7356
|
-
index$c_parseLoggerOptions as parseLoggerOptions,
|
|
7357
|
-
};
|
|
7429
|
+
export { index$c_ConsoleTransport as ConsoleTransport, index$c_Level as Level, index$c_Logger as Logger, index$c_findLevel as findLevel, index$c_parseLoggerOptions as parseLoggerOptions };
|
|
7430
|
+
export type { index$c_Options as Options, index$c_Transport as Transport, index$c_TransportBuilder as TransportBuilder };
|
|
7358
7431
|
}
|
|
7359
7432
|
|
|
7360
7433
|
/** Size of the transfer memo. */
|
|
@@ -9438,6 +9511,7 @@ declare class Importer {
|
|
|
9438
9511
|
private readonly stf;
|
|
9439
9512
|
private readonly state;
|
|
9440
9513
|
private currentHash;
|
|
9514
|
+
private readonly metrics;
|
|
9441
9515
|
constructor(spec: ChainSpec, pvm: PvmBackend, hasher: TransitionHasher, logger: Logger, blocks: BlocksDb, states: StatesDb<SerializedState<LeafDb>>);
|
|
9442
9516
|
/** Do some extra work for preparation for the next epoch. */
|
|
9443
9517
|
prepareForNextEpoch(): Promise<void>;
|
|
@@ -9812,6 +9886,20 @@ declare function createImporter(config: Config): Promise<{
|
|
|
9812
9886
|
*/
|
|
9813
9887
|
declare function main(config: Config, comms: ImporterInternal): Promise<void>;
|
|
9814
9888
|
|
|
9889
|
+
/**
|
|
9890
|
+
* Block importer metrics for JAM implementation.
|
|
9891
|
+
*
|
|
9892
|
+
* https://github.com/polkadot-fellows/JIPs/blob/main/JIP-3.md#block-authoringimporting-events
|
|
9893
|
+
*/
|
|
9894
|
+
declare function createMetrics(): {
|
|
9895
|
+
recordBlockImportComplete(totalDurationMs: number, success: boolean): void;
|
|
9896
|
+
recordBlockImportingStarted(slot: number): void;
|
|
9897
|
+
recordBlockVerificationFailed(reason: string): void;
|
|
9898
|
+
recordBlockVerified(durationMs: number): void;
|
|
9899
|
+
recordBlockExecutionFailed(reason: string): void;
|
|
9900
|
+
recordBlockExecuted(durationMs: number, cost: number): void;
|
|
9901
|
+
};
|
|
9902
|
+
|
|
9815
9903
|
declare const WORKER: url.URL;
|
|
9816
9904
|
|
|
9817
9905
|
type index$6_Config = Config;
|
|
@@ -9821,10 +9909,11 @@ declare const index$6_ImporterConfig: typeof ImporterConfig;
|
|
|
9821
9909
|
type index$6_ImporterInternal = ImporterInternal;
|
|
9822
9910
|
declare const index$6_WORKER: typeof WORKER;
|
|
9823
9911
|
declare const index$6_createImporter: typeof createImporter;
|
|
9912
|
+
declare const index$6_createMetrics: typeof createMetrics;
|
|
9824
9913
|
declare const index$6_main: typeof main;
|
|
9825
9914
|
declare const index$6_protocol: typeof protocol;
|
|
9826
9915
|
declare namespace index$6 {
|
|
9827
|
-
export { index$6_ImporterConfig as ImporterConfig, index$6_WORKER as WORKER, index$6_createImporter as createImporter, index$6_main as main, index$6_protocol as protocol };
|
|
9916
|
+
export { index$6_ImporterConfig as ImporterConfig, index$6_WORKER as WORKER, index$6_createImporter as createImporter, index$6_createMetrics as createMetrics, index$6_main as main, index$6_protocol as protocol };
|
|
9828
9917
|
export type { index$6_Config as Config, index$6_ImporterApi as ImporterApi, index$6_ImporterInternal as ImporterInternal };
|
|
9829
9918
|
}
|
|
9830
9919
|
|