@typeberry/lib 0.0.1-9d0368d → 0.0.1-be13f8e
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.d.ts +209 -385
- package/index.js +106 -177
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -493,6 +493,8 @@ type DeepEqualOptions = {
|
|
|
493
493
|
errorsCollector?: ErrorsCollector;
|
|
494
494
|
};
|
|
495
495
|
|
|
496
|
+
declare let oomWarningPrinted = false;
|
|
497
|
+
|
|
496
498
|
/** Deeply compare `actual` and `expected` values. */
|
|
497
499
|
declare function deepEqual<T>(
|
|
498
500
|
actual: T | undefined,
|
|
@@ -525,7 +527,7 @@ declare function deepEqual<T>(
|
|
|
525
527
|
try {
|
|
526
528
|
assert.strictEqual(actualDisp, expectedDisp, message);
|
|
527
529
|
} catch (e) {
|
|
528
|
-
if (isOoMWorkaroundNeeded) {
|
|
530
|
+
if (isOoMWorkaroundNeeded && !oomWarningPrinted) {
|
|
529
531
|
console.warn(
|
|
530
532
|
[
|
|
531
533
|
"Stacktrace may be crappy because of a problem in nodejs.",
|
|
@@ -533,6 +535,7 @@ declare function deepEqual<T>(
|
|
|
533
535
|
"Maybe we do not need it anymore",
|
|
534
536
|
].join("\n"),
|
|
535
537
|
);
|
|
538
|
+
oomWarningPrinted = true;
|
|
536
539
|
}
|
|
537
540
|
throw e;
|
|
538
541
|
}
|
|
@@ -786,13 +789,14 @@ declare const index$r_isResult: typeof isResult;
|
|
|
786
789
|
declare const index$r_isTaggedError: typeof isTaggedError;
|
|
787
790
|
declare const index$r_maybeTaggedErrorToString: typeof maybeTaggedErrorToString;
|
|
788
791
|
declare const index$r_measure: typeof measure;
|
|
792
|
+
declare const index$r_oomWarningPrinted: typeof oomWarningPrinted;
|
|
789
793
|
declare const index$r_parseCurrentSuite: typeof parseCurrentSuite;
|
|
790
794
|
declare const index$r_parseCurrentVersion: typeof parseCurrentVersion;
|
|
791
795
|
declare const index$r_resultToString: typeof resultToString;
|
|
792
796
|
declare const index$r_seeThrough: typeof seeThrough;
|
|
793
797
|
declare const index$r_trimStack: typeof trimStack;
|
|
794
798
|
declare namespace index$r {
|
|
795
|
-
export { index$r_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$r_CURRENT_SUITE as CURRENT_SUITE, index$r_CURRENT_VERSION as CURRENT_VERSION, index$r_Compatibility as Compatibility, index$r_DEFAULT_SUITE as DEFAULT_SUITE, index$r_DEFAULT_VERSION as DEFAULT_VERSION, index$r_ErrorsCollector as ErrorsCollector, index$r_GpVersion as GpVersion, Result$2 as Result, index$r_RichTaggedError as RichTaggedError, index$r_TEST_COMPARE_USING as TEST_COMPARE_USING, index$r_TestSuite as TestSuite, index$r_WithDebug as WithDebug, index$r___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$r_asOpaqueType as asOpaqueType, index$r_assertEmpty as assertEmpty, index$r_assertNever as assertNever, index$r_callCompareFunction as callCompareFunction, index$r_cast as cast, index$r_check as check, index$r_deepEqual as deepEqual, index$r_ensure as ensure, index$r_env as env, index$r_getAllKeysSorted as getAllKeysSorted, index$r_inspect as inspect, index$r_isBrowser as isBrowser, index$r_isResult as isResult, index$r_isTaggedError as isTaggedError, index$r_maybeTaggedErrorToString as maybeTaggedErrorToString, index$r_measure as measure, index$r_parseCurrentSuite as parseCurrentSuite, index$r_parseCurrentVersion as parseCurrentVersion, index$r_resultToString as resultToString, index$r_seeThrough as seeThrough, index$r_trimStack as trimStack };
|
|
799
|
+
export { index$r_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$r_CURRENT_SUITE as CURRENT_SUITE, index$r_CURRENT_VERSION as CURRENT_VERSION, index$r_Compatibility as Compatibility, index$r_DEFAULT_SUITE as DEFAULT_SUITE, index$r_DEFAULT_VERSION as DEFAULT_VERSION, index$r_ErrorsCollector as ErrorsCollector, index$r_GpVersion as GpVersion, Result$2 as Result, index$r_RichTaggedError as RichTaggedError, index$r_TEST_COMPARE_USING as TEST_COMPARE_USING, index$r_TestSuite as TestSuite, index$r_WithDebug as WithDebug, index$r___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$r_asOpaqueType as asOpaqueType, index$r_assertEmpty as assertEmpty, index$r_assertNever as assertNever, index$r_callCompareFunction as callCompareFunction, index$r_cast as cast, index$r_check as check, index$r_deepEqual as deepEqual, index$r_ensure as ensure, index$r_env as env, index$r_getAllKeysSorted as getAllKeysSorted, index$r_inspect as inspect, index$r_isBrowser as isBrowser, index$r_isResult as isResult, index$r_isTaggedError as isTaggedError, index$r_maybeTaggedErrorToString as maybeTaggedErrorToString, index$r_measure as measure, index$r_oomWarningPrinted as oomWarningPrinted, index$r_parseCurrentSuite as parseCurrentSuite, index$r_parseCurrentVersion as parseCurrentVersion, index$r_resultToString as resultToString, index$r_seeThrough as seeThrough, index$r_trimStack as trimStack };
|
|
796
800
|
export type { index$r_DeepEqualOptions as DeepEqualOptions, index$r_EnumMapping as EnumMapping, index$r_ErrorResult as ErrorResult, index$r_OK as OK, index$r_OkResult as OkResult, index$r_Opaque as Opaque, index$r_StringLiteral as StringLiteral, index$r_TaggedError as TaggedError, index$r_TokenOf as TokenOf, index$r_Uninstantiable as Uninstantiable, index$r_WithOpaque as WithOpaque };
|
|
797
801
|
}
|
|
798
802
|
|
|
@@ -8249,20 +8253,7 @@ declare class AutoAccumulate {
|
|
|
8249
8253
|
declare class PrivilegedServices {
|
|
8250
8254
|
static Codec = codec.Class(PrivilegedServices, {
|
|
8251
8255
|
manager: codec.u32.asOpaque<ServiceId>(),
|
|
8252
|
-
authManager:
|
|
8253
|
-
? codecPerCore(codec.u32.asOpaque<ServiceId>())
|
|
8254
|
-
: codecWithContext((ctx) =>
|
|
8255
|
-
codec.u32.asOpaque<ServiceId>().convert(
|
|
8256
|
-
// NOTE: [MaSo] In a compatibility mode we are always updating all entries
|
|
8257
|
-
// (all the entries are the same)
|
|
8258
|
-
// so it doesn't matter which one we take here.
|
|
8259
|
-
(perCore: PerCore<ServiceId>) => perCore[0],
|
|
8260
|
-
(serviceId: ServiceId) => {
|
|
8261
|
-
const array = new Array(ctx.coresCount).fill(serviceId);
|
|
8262
|
-
return tryAsPerCore(array, ctx);
|
|
8263
|
-
},
|
|
8264
|
-
),
|
|
8265
|
-
),
|
|
8256
|
+
authManager: codecPerCore(codec.u32.asOpaque<ServiceId>()),
|
|
8266
8257
|
validatorsManager: codec.u32.asOpaque<ServiceId>(),
|
|
8267
8258
|
autoAccumulateServices: readonlyArray(codec.sequenceVarLen(AutoAccumulate.Codec)),
|
|
8268
8259
|
});
|
|
@@ -8805,11 +8796,6 @@ declare class ServiceAccountInfo extends WithDebug {
|
|
|
8805
8796
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/119e01119e01?v=0.6.7
|
|
8806
8797
|
*/
|
|
8807
8798
|
static calculateThresholdBalance(items: U32, bytes: U64, gratisStorage: U64): U64 {
|
|
8808
|
-
check(
|
|
8809
|
-
gratisStorage === tryAsU64(0) || Compatibility.isGreaterOrEqual(GpVersion.V0_6_7),
|
|
8810
|
-
"Gratis storage cannot be non-zero before 0.6.7",
|
|
8811
|
-
);
|
|
8812
|
-
|
|
8813
8799
|
const storageCost =
|
|
8814
8800
|
BASE_SERVICE_BALANCE + ELECTIVE_ITEM_BALANCE * BigInt(items) + ELECTIVE_BYTE_BALANCE * bytes - gratisStorage;
|
|
8815
8801
|
|
|
@@ -10588,27 +10574,17 @@ declare function* serializeRemovedServices(servicesRemoved: ServiceId[] | undefi
|
|
|
10588
10574
|
}
|
|
10589
10575
|
}
|
|
10590
10576
|
|
|
10591
|
-
declare function getLegacyKey(serviceId: ServiceId, rawKey: StorageKey): StorageKey {
|
|
10592
|
-
const SERVICE_ID_BYTES = 4;
|
|
10593
|
-
const serviceIdAndKey = new Uint8Array(SERVICE_ID_BYTES + rawKey.length);
|
|
10594
|
-
serviceIdAndKey.set(u32AsLeBytes(serviceId));
|
|
10595
|
-
serviceIdAndKey.set(rawKey.raw, SERVICE_ID_BYTES);
|
|
10596
|
-
return asOpaqueType(BytesBlob.blobFrom(blake2b.hashBytes(serviceIdAndKey).raw));
|
|
10597
|
-
}
|
|
10598
|
-
|
|
10599
10577
|
declare function* serializeStorage(storage: UpdateStorage[] | undefined): Generator<StateEntryUpdate> {
|
|
10600
10578
|
for (const { action, serviceId } of storage ?? []) {
|
|
10601
10579
|
switch (action.kind) {
|
|
10602
10580
|
case UpdateStorageKind.Set: {
|
|
10603
|
-
const key =
|
|
10604
|
-
? action.storage.key
|
|
10605
|
-
: getLegacyKey(serviceId, action.storage.key);
|
|
10581
|
+
const key = action.storage.key;
|
|
10606
10582
|
const codec = serialize.serviceStorage(serviceId, key);
|
|
10607
10583
|
yield [StateEntryUpdateAction.Insert, codec.key, action.storage.value];
|
|
10608
10584
|
break;
|
|
10609
10585
|
}
|
|
10610
10586
|
case UpdateStorageKind.Remove: {
|
|
10611
|
-
const key =
|
|
10587
|
+
const key = action.key;
|
|
10612
10588
|
const codec = serialize.serviceStorage(serviceId, key);
|
|
10613
10589
|
yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
10614
10590
|
break;
|
|
@@ -10748,7 +10724,7 @@ declare function* serializeBasicKeys(spec: ChainSpec, update: Partial<State>) {
|
|
|
10748
10724
|
yield doSerialize(update.recentlyAccumulated, serialize.recentlyAccumulated); // C(15)
|
|
10749
10725
|
}
|
|
10750
10726
|
|
|
10751
|
-
if (update.accumulationOutputLog !== undefined
|
|
10727
|
+
if (update.accumulationOutputLog !== undefined) {
|
|
10752
10728
|
yield doSerialize(update.accumulationOutputLog, serialize.accumulationOutputLog); // C(16)
|
|
10753
10729
|
}
|
|
10754
10730
|
}
|
|
@@ -11543,9 +11519,7 @@ declare function convertInMemoryStateToDictionary(
|
|
|
11543
11519
|
doSerialize(serialize.statistics); // C(13)
|
|
11544
11520
|
doSerialize(serialize.accumulationQueue); // C(14)
|
|
11545
11521
|
doSerialize(serialize.recentlyAccumulated); // C(15)
|
|
11546
|
-
|
|
11547
|
-
doSerialize(serialize.accumulationOutputLog); // C(16)
|
|
11548
|
-
}
|
|
11522
|
+
doSerialize(serialize.accumulationOutputLog); // C(16)
|
|
11549
11523
|
|
|
11550
11524
|
// services
|
|
11551
11525
|
for (const [serviceId, service] of state.services.entries()) {
|
|
@@ -11736,10 +11710,7 @@ declare class SerializedState<T extends SerializedStateBackend = SerializedState
|
|
|
11736
11710
|
}
|
|
11737
11711
|
|
|
11738
11712
|
get accumulationOutputLog(): State["accumulationOutputLog"] {
|
|
11739
|
-
|
|
11740
|
-
return this.retrieve(serialize.accumulationOutputLog, "accumulationOutputLog");
|
|
11741
|
-
}
|
|
11742
|
-
return [];
|
|
11713
|
+
return this.retrieve(serialize.accumulationOutputLog, "accumulationOutputLog");
|
|
11743
11714
|
}
|
|
11744
11715
|
}
|
|
11745
11716
|
|
|
@@ -11886,7 +11857,6 @@ declare const index$c_U32_BYTES: typeof U32_BYTES;
|
|
|
11886
11857
|
declare const index$c_binaryMerkleization: typeof binaryMerkleization;
|
|
11887
11858
|
declare const index$c_convertInMemoryStateToDictionary: typeof convertInMemoryStateToDictionary;
|
|
11888
11859
|
declare const index$c_dumpCodec: typeof dumpCodec;
|
|
11889
|
-
declare const index$c_getLegacyKey: typeof getLegacyKey;
|
|
11890
11860
|
declare const index$c_getSafroleData: typeof getSafroleData;
|
|
11891
11861
|
declare const index$c_legacyServiceNested: typeof legacyServiceNested;
|
|
11892
11862
|
declare const index$c_loadState: typeof loadState;
|
|
@@ -11900,7 +11870,7 @@ declare const index$c_serializeStorage: typeof serializeStorage;
|
|
|
11900
11870
|
declare const index$c_stateEntriesSequenceCodec: typeof stateEntriesSequenceCodec;
|
|
11901
11871
|
import index$c_stateKeys = stateKeys;
|
|
11902
11872
|
declare namespace index$c {
|
|
11903
|
-
export { index$c_EMPTY_BLOB as EMPTY_BLOB, index$c_SerializedService as SerializedService, index$c_SerializedState as SerializedState, index$c_StateEntries as StateEntries, index$c_StateEntryUpdateAction as StateEntryUpdateAction, index$c_StateKeyIdx as StateKeyIdx, index$c_TYPICAL_STATE_ITEMS as TYPICAL_STATE_ITEMS, index$c_TYPICAL_STATE_ITEM_LEN as TYPICAL_STATE_ITEM_LEN, index$c_U32_BYTES as U32_BYTES, index$c_binaryMerkleization as binaryMerkleization, index$c_convertInMemoryStateToDictionary as convertInMemoryStateToDictionary, index$c_dumpCodec as dumpCodec, index$
|
|
11873
|
+
export { index$c_EMPTY_BLOB as EMPTY_BLOB, index$c_SerializedService as SerializedService, index$c_SerializedState as SerializedState, index$c_StateEntries as StateEntries, index$c_StateEntryUpdateAction as StateEntryUpdateAction, index$c_StateKeyIdx as StateKeyIdx, index$c_TYPICAL_STATE_ITEMS as TYPICAL_STATE_ITEMS, index$c_TYPICAL_STATE_ITEM_LEN as TYPICAL_STATE_ITEM_LEN, index$c_U32_BYTES as U32_BYTES, index$c_binaryMerkleization as binaryMerkleization, index$c_convertInMemoryStateToDictionary as convertInMemoryStateToDictionary, index$c_dumpCodec as dumpCodec, index$c_getSafroleData as getSafroleData, index$c_legacyServiceNested as legacyServiceNested, index$c_loadState as loadState, index$c_serialize as serialize, index$c_serializeBasicKeys as serializeBasicKeys, index$c_serializePreimages as serializePreimages, index$c_serializeRemovedServices as serializeRemovedServices, index$c_serializeServiceUpdates as serializeServiceUpdates, index$c_serializeStateUpdate as serializeStateUpdate, index$c_serializeStorage as serializeStorage, index$c_stateEntriesSequenceCodec as stateEntriesSequenceCodec, index$c_stateKeys as stateKeys };
|
|
11904
11874
|
export type { index$c_EncodeFun as EncodeFun, index$c_KeyAndCodec as KeyAndCodec, index$c_SerializedStateBackend as SerializedStateBackend, index$c_StateCodec as StateCodec, index$c_StateEntryUpdate as StateEntryUpdate, StateKey$1 as StateKey };
|
|
11905
11875
|
}
|
|
11906
11876
|
|
|
@@ -12600,6 +12570,173 @@ declare const HostCallResult = {
|
|
|
12600
12570
|
OK: tryAsU64(0n),
|
|
12601
12571
|
} as const;
|
|
12602
12572
|
|
|
12573
|
+
declare enum Level {
|
|
12574
|
+
INSANE = 1,
|
|
12575
|
+
TRACE = 2,
|
|
12576
|
+
LOG = 3,
|
|
12577
|
+
INFO = 4,
|
|
12578
|
+
WARN = 5,
|
|
12579
|
+
ERROR = 6,
|
|
12580
|
+
}
|
|
12581
|
+
|
|
12582
|
+
type Options = {
|
|
12583
|
+
defaultLevel: Level;
|
|
12584
|
+
workingDir: string;
|
|
12585
|
+
modules: Map<string, Level>;
|
|
12586
|
+
};
|
|
12587
|
+
|
|
12588
|
+
/**
|
|
12589
|
+
* A function to parse logger definition (including modules) given as a string.
|
|
12590
|
+
*
|
|
12591
|
+
* Examples
|
|
12592
|
+
* - `info` - setup default logging level to `info`.
|
|
12593
|
+
* - `trace` - default logging level set to `trace`.
|
|
12594
|
+
* - `debug;consensus=trace` - default level is set to `debug/log`, but consensus is in trace mode.
|
|
12595
|
+
*/
|
|
12596
|
+
declare function parseLoggerOptions(input: string, defaultLevel: Level, workingDir?: string): Options {
|
|
12597
|
+
const modules = new Map<string, Level>();
|
|
12598
|
+
const parts = input.toLowerCase().split(",");
|
|
12599
|
+
let defLevel = defaultLevel;
|
|
12600
|
+
|
|
12601
|
+
for (const p of parts) {
|
|
12602
|
+
const clean = p.trim();
|
|
12603
|
+
// skip empty objects (forgotten `,` removed)
|
|
12604
|
+
if (clean.length === 0) {
|
|
12605
|
+
continue;
|
|
12606
|
+
}
|
|
12607
|
+
// we just have the default level
|
|
12608
|
+
if (clean.includes("=")) {
|
|
12609
|
+
const [mod, lvl] = clean.split("=");
|
|
12610
|
+
modules.set(mod.trim(), parseLevel(lvl.trim()));
|
|
12611
|
+
} else {
|
|
12612
|
+
defLevel = parseLevel(clean);
|
|
12613
|
+
}
|
|
12614
|
+
}
|
|
12615
|
+
|
|
12616
|
+
// TODO [ToDr] Fix dirname for workers.
|
|
12617
|
+
const myDir = (import.meta.dirname ?? "").split("/");
|
|
12618
|
+
myDir.pop();
|
|
12619
|
+
myDir.pop();
|
|
12620
|
+
return {
|
|
12621
|
+
defaultLevel: defLevel,
|
|
12622
|
+
modules,
|
|
12623
|
+
workingDir: workingDir ?? myDir.join("/"),
|
|
12624
|
+
};
|
|
12625
|
+
}
|
|
12626
|
+
|
|
12627
|
+
declare const GLOBAL_CONFIG = {
|
|
12628
|
+
options: DEFAULT_OPTIONS,
|
|
12629
|
+
transport: ConsoleTransport.create(DEFAULT_OPTIONS.defaultLevel, DEFAULT_OPTIONS),
|
|
12630
|
+
};
|
|
12631
|
+
|
|
12632
|
+
/**
|
|
12633
|
+
* A logger instance.
|
|
12634
|
+
*/
|
|
12635
|
+
declare class Logger {
|
|
12636
|
+
/**
|
|
12637
|
+
* Create a new logger instance given filename and an optional module name.
|
|
12638
|
+
*
|
|
12639
|
+
* If the module name is not given, `fileName` becomes the module name.
|
|
12640
|
+
* The module name can be composed from multiple parts separated with `/`.
|
|
12641
|
+
*
|
|
12642
|
+
* The logger will use a global configuration which can be changed using
|
|
12643
|
+
* [`configureLogger`] function.
|
|
12644
|
+
*/
|
|
12645
|
+
static new(fileName?: string, moduleName?: string) {
|
|
12646
|
+
const fName = fileName ?? "unknown";
|
|
12647
|
+
return new Logger(moduleName ?? fName, fName, GLOBAL_CONFIG);
|
|
12648
|
+
}
|
|
12649
|
+
|
|
12650
|
+
/**
|
|
12651
|
+
* Return currently configured level for given module. */
|
|
12652
|
+
static getLevel(moduleName: string): Level {
|
|
12653
|
+
return findLevel(GLOBAL_CONFIG.options, moduleName);
|
|
12654
|
+
}
|
|
12655
|
+
|
|
12656
|
+
/**
|
|
12657
|
+
* Global configuration of all loggers.
|
|
12658
|
+
*
|
|
12659
|
+
* One can specify a default logging level (only logs with level >= default will be printed).
|
|
12660
|
+
* It's also possible to configure per-module logging level that takes precedence
|
|
12661
|
+
* over the default one.
|
|
12662
|
+
*
|
|
12663
|
+
* Changing the options affects all previously created loggers.
|
|
12664
|
+
*/
|
|
12665
|
+
static configureAllFromOptions(options: Options) {
|
|
12666
|
+
// find minimal level to optimise logging in case
|
|
12667
|
+
// we don't care about low-level logs.
|
|
12668
|
+
const minimalLevel = Array.from(options.modules.values()).reduce((level, modLevel) => {
|
|
12669
|
+
return level < modLevel ? level : modLevel;
|
|
12670
|
+
}, options.defaultLevel);
|
|
12671
|
+
|
|
12672
|
+
const transport = ConsoleTransport.create(minimalLevel, options);
|
|
12673
|
+
|
|
12674
|
+
// set the global config
|
|
12675
|
+
GLOBAL_CONFIG.options = options;
|
|
12676
|
+
GLOBAL_CONFIG.transport = transport;
|
|
12677
|
+
}
|
|
12678
|
+
|
|
12679
|
+
/**
|
|
12680
|
+
* Global configuration of all loggers.
|
|
12681
|
+
*
|
|
12682
|
+
* Parse configuration options from an input string typically obtained
|
|
12683
|
+
* from environment variable `JAM_LOG`.
|
|
12684
|
+
*/
|
|
12685
|
+
static configureAll(input: string, defaultLevel: Level, workingDir?: string) {
|
|
12686
|
+
const options = parseLoggerOptions(input, defaultLevel, workingDir);
|
|
12687
|
+
Logger.configureAllFromOptions(options);
|
|
12688
|
+
}
|
|
12689
|
+
|
|
12690
|
+
constructor(
|
|
12691
|
+
private readonly moduleName: string,
|
|
12692
|
+
private readonly fileName: string,
|
|
12693
|
+
private readonly config: typeof GLOBAL_CONFIG,
|
|
12694
|
+
) {}
|
|
12695
|
+
|
|
12696
|
+
/** Log a message with `INSANE` level. */
|
|
12697
|
+
insane(val: string) {
|
|
12698
|
+
this.config.transport.insane(this.moduleName, val);
|
|
12699
|
+
}
|
|
12700
|
+
|
|
12701
|
+
/** Log a message with `TRACE` level. */
|
|
12702
|
+
trace(val: string) {
|
|
12703
|
+
this.config.transport.trace(this.moduleName, val);
|
|
12704
|
+
}
|
|
12705
|
+
|
|
12706
|
+
/** Log a message with `DEBUG`/`LOG` level. */
|
|
12707
|
+
log(val: string) {
|
|
12708
|
+
this.config.transport.log(this.moduleName, val);
|
|
12709
|
+
}
|
|
12710
|
+
|
|
12711
|
+
/** Log a message with `INFO` level. */
|
|
12712
|
+
info(val: string) {
|
|
12713
|
+
this.config.transport.info(this.moduleName, val);
|
|
12714
|
+
}
|
|
12715
|
+
|
|
12716
|
+
/** Log a message with `WARN` level. */
|
|
12717
|
+
warn(val: string) {
|
|
12718
|
+
this.config.transport.warn(this.moduleName, val);
|
|
12719
|
+
}
|
|
12720
|
+
|
|
12721
|
+
/** Log a message with `ERROR` level. */
|
|
12722
|
+
error(val: string) {
|
|
12723
|
+
this.config.transport.error(this.moduleName, val);
|
|
12724
|
+
}
|
|
12725
|
+
}
|
|
12726
|
+
|
|
12727
|
+
type index$9_Level = Level;
|
|
12728
|
+
declare const index$9_Level: typeof Level;
|
|
12729
|
+
type index$9_Logger = Logger;
|
|
12730
|
+
declare const index$9_Logger: typeof Logger;
|
|
12731
|
+
declare const index$9_parseLoggerOptions: typeof parseLoggerOptions;
|
|
12732
|
+
declare namespace index$9 {
|
|
12733
|
+
export {
|
|
12734
|
+
index$9_Level as Level,
|
|
12735
|
+
index$9_Logger as Logger,
|
|
12736
|
+
index$9_parseLoggerOptions as parseLoggerOptions,
|
|
12737
|
+
};
|
|
12738
|
+
}
|
|
12739
|
+
|
|
12603
12740
|
/**
|
|
12604
12741
|
* Mask class is an implementation of skip function defined in GP.
|
|
12605
12742
|
*
|
|
@@ -13879,6 +14016,7 @@ declare enum AccessType {
|
|
|
13879
14016
|
READ = 0,
|
|
13880
14017
|
WRITE = 1,
|
|
13881
14018
|
}
|
|
14019
|
+
|
|
13882
14020
|
declare class Memory {
|
|
13883
14021
|
static fromInitialMemory(initialMemoryState: InitialMemoryState) {
|
|
13884
14022
|
return new Memory(
|
|
@@ -13915,6 +14053,7 @@ declare class Memory {
|
|
|
13915
14053
|
return Result.ok(OK);
|
|
13916
14054
|
}
|
|
13917
14055
|
|
|
14056
|
+
logger.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
|
|
13918
14057
|
const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
|
|
13919
14058
|
|
|
13920
14059
|
if (pagesResult.isError) {
|
|
@@ -14003,6 +14142,7 @@ declare class Memory {
|
|
|
14003
14142
|
bytesLeft -= bytesToRead;
|
|
14004
14143
|
}
|
|
14005
14144
|
|
|
14145
|
+
logger.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
|
|
14006
14146
|
return Result.ok(OK);
|
|
14007
14147
|
}
|
|
14008
14148
|
|
|
@@ -15002,6 +15142,10 @@ declare class JumpTable {
|
|
|
15002
15142
|
return new JumpTable(0, new Uint8Array());
|
|
15003
15143
|
}
|
|
15004
15144
|
|
|
15145
|
+
getSize() {
|
|
15146
|
+
return this.indices.length;
|
|
15147
|
+
}
|
|
15148
|
+
|
|
15005
15149
|
copyFrom(jt: JumpTable) {
|
|
15006
15150
|
this.indices = jt.indices;
|
|
15007
15151
|
}
|
|
@@ -15903,167 +16047,6 @@ declare class OneRegOneExtImmDispatcher {
|
|
|
15903
16047
|
}
|
|
15904
16048
|
}
|
|
15905
16049
|
|
|
15906
|
-
declare enum Level {
|
|
15907
|
-
TRACE = 1,
|
|
15908
|
-
LOG = 2,
|
|
15909
|
-
INFO = 3,
|
|
15910
|
-
WARN = 4,
|
|
15911
|
-
ERROR = 5,
|
|
15912
|
-
}
|
|
15913
|
-
|
|
15914
|
-
type Options = {
|
|
15915
|
-
defaultLevel: Level;
|
|
15916
|
-
workingDir: string;
|
|
15917
|
-
modules: Map<string, Level>;
|
|
15918
|
-
};
|
|
15919
|
-
|
|
15920
|
-
/**
|
|
15921
|
-
* A function to parse logger definition (including modules) given as a string.
|
|
15922
|
-
*
|
|
15923
|
-
* Examples
|
|
15924
|
-
* - `info` - setup default logging level to `info`.
|
|
15925
|
-
* - `trace` - default logging level set to `trace`.
|
|
15926
|
-
* - `debug;consensus=trace` - default level is set to `debug/log`, but consensus is in trace mode.
|
|
15927
|
-
*/
|
|
15928
|
-
declare function parseLoggerOptions(input: string, defaultLevel: Level, workingDir?: string): Options {
|
|
15929
|
-
const modules = new Map<string, Level>();
|
|
15930
|
-
const parts = input.toLowerCase().split(",");
|
|
15931
|
-
let defLevel = defaultLevel;
|
|
15932
|
-
|
|
15933
|
-
for (const p of parts) {
|
|
15934
|
-
const clean = p.trim();
|
|
15935
|
-
// skip empty objects (forgotten `,` removed)
|
|
15936
|
-
if (clean.length === 0) {
|
|
15937
|
-
continue;
|
|
15938
|
-
}
|
|
15939
|
-
// we just have the default level
|
|
15940
|
-
if (clean.includes("=")) {
|
|
15941
|
-
const [mod, lvl] = clean.split("=");
|
|
15942
|
-
modules.set(mod.trim(), parseLevel(lvl.trim()));
|
|
15943
|
-
} else {
|
|
15944
|
-
defLevel = parseLevel(clean);
|
|
15945
|
-
}
|
|
15946
|
-
}
|
|
15947
|
-
|
|
15948
|
-
// TODO [ToDr] Fix dirname for workers.
|
|
15949
|
-
const myDir = (import.meta.dirname ?? "").split("/");
|
|
15950
|
-
myDir.pop();
|
|
15951
|
-
myDir.pop();
|
|
15952
|
-
return {
|
|
15953
|
-
defaultLevel: defLevel,
|
|
15954
|
-
modules,
|
|
15955
|
-
workingDir: workingDir ?? myDir.join("/"),
|
|
15956
|
-
};
|
|
15957
|
-
}
|
|
15958
|
-
|
|
15959
|
-
declare const GLOBAL_CONFIG = {
|
|
15960
|
-
options: DEFAULT_OPTIONS,
|
|
15961
|
-
transport: ConsoleTransport.create(DEFAULT_OPTIONS.defaultLevel, DEFAULT_OPTIONS),
|
|
15962
|
-
};
|
|
15963
|
-
|
|
15964
|
-
/**
|
|
15965
|
-
* A logger instance.
|
|
15966
|
-
*/
|
|
15967
|
-
declare class Logger {
|
|
15968
|
-
/**
|
|
15969
|
-
* Create a new logger instance given filename and an optional module name.
|
|
15970
|
-
*
|
|
15971
|
-
* If the module name is not given, `fileName` becomes the module name.
|
|
15972
|
-
* The module name can be composed from multiple parts separated with `/`.
|
|
15973
|
-
*
|
|
15974
|
-
* The logger will use a global configuration which can be changed using
|
|
15975
|
-
* [`configureLogger`] function.
|
|
15976
|
-
*/
|
|
15977
|
-
static new(fileName?: string, moduleName?: string) {
|
|
15978
|
-
const fName = fileName ?? "unknown";
|
|
15979
|
-
return new Logger(moduleName ?? fName, fName, GLOBAL_CONFIG);
|
|
15980
|
-
}
|
|
15981
|
-
|
|
15982
|
-
/**
|
|
15983
|
-
* Return currently configured level for given module. */
|
|
15984
|
-
static getLevel(moduleName: string): Level {
|
|
15985
|
-
return findLevel(GLOBAL_CONFIG.options, moduleName);
|
|
15986
|
-
}
|
|
15987
|
-
|
|
15988
|
-
/**
|
|
15989
|
-
* Global configuration of all loggers.
|
|
15990
|
-
*
|
|
15991
|
-
* One can specify a default logging level (only logs with level >= default will be printed).
|
|
15992
|
-
* It's also possible to configure per-module logging level that takes precedence
|
|
15993
|
-
* over the default one.
|
|
15994
|
-
*
|
|
15995
|
-
* Changing the options affects all previously created loggers.
|
|
15996
|
-
*/
|
|
15997
|
-
static configureAllFromOptions(options: Options) {
|
|
15998
|
-
// find minimal level to optimise logging in case
|
|
15999
|
-
// we don't care about low-level logs.
|
|
16000
|
-
const minimalLevel = Array.from(options.modules.values()).reduce((level, modLevel) => {
|
|
16001
|
-
return level < modLevel ? level : modLevel;
|
|
16002
|
-
}, options.defaultLevel);
|
|
16003
|
-
|
|
16004
|
-
const transport = ConsoleTransport.create(minimalLevel, options);
|
|
16005
|
-
|
|
16006
|
-
// set the global config
|
|
16007
|
-
GLOBAL_CONFIG.options = options;
|
|
16008
|
-
GLOBAL_CONFIG.transport = transport;
|
|
16009
|
-
}
|
|
16010
|
-
|
|
16011
|
-
/**
|
|
16012
|
-
* Global configuration of all loggers.
|
|
16013
|
-
*
|
|
16014
|
-
* Parse configuration options from an input string typically obtained
|
|
16015
|
-
* from environment variable `JAM_LOG`.
|
|
16016
|
-
*/
|
|
16017
|
-
static configureAll(input: string, defaultLevel: Level, workingDir?: string) {
|
|
16018
|
-
const options = parseLoggerOptions(input, defaultLevel, workingDir);
|
|
16019
|
-
Logger.configureAllFromOptions(options);
|
|
16020
|
-
}
|
|
16021
|
-
|
|
16022
|
-
constructor(
|
|
16023
|
-
private readonly moduleName: string,
|
|
16024
|
-
private readonly fileName: string,
|
|
16025
|
-
private readonly config: typeof GLOBAL_CONFIG,
|
|
16026
|
-
) {}
|
|
16027
|
-
|
|
16028
|
-
/** Log a message with `TRACE` level. */
|
|
16029
|
-
trace(val: string) {
|
|
16030
|
-
this.config.transport.trace(this.moduleName, this.fileName, val);
|
|
16031
|
-
}
|
|
16032
|
-
|
|
16033
|
-
/** Log a message with `DEBUG`/`LOG` level. */
|
|
16034
|
-
log(val: string) {
|
|
16035
|
-
this.config.transport.log(this.moduleName, this.fileName, val);
|
|
16036
|
-
}
|
|
16037
|
-
|
|
16038
|
-
/** Log a message with `INFO` level. */
|
|
16039
|
-
info(val: string) {
|
|
16040
|
-
this.config.transport.info(this.moduleName, this.fileName, val);
|
|
16041
|
-
}
|
|
16042
|
-
|
|
16043
|
-
/** Log a message with `WARN` level. */
|
|
16044
|
-
warn(val: string) {
|
|
16045
|
-
this.config.transport.warn(this.moduleName, this.fileName, val);
|
|
16046
|
-
}
|
|
16047
|
-
|
|
16048
|
-
/** Log a message with `ERROR` level. */
|
|
16049
|
-
error(val: string) {
|
|
16050
|
-
this.config.transport.error(this.moduleName, this.fileName, val);
|
|
16051
|
-
}
|
|
16052
|
-
}
|
|
16053
|
-
|
|
16054
|
-
type index$9_Level = Level;
|
|
16055
|
-
declare const index$9_Level: typeof Level;
|
|
16056
|
-
type index$9_Logger = Logger;
|
|
16057
|
-
declare const index$9_Logger: typeof Logger;
|
|
16058
|
-
declare const index$9_parseLoggerOptions: typeof parseLoggerOptions;
|
|
16059
|
-
declare namespace index$9 {
|
|
16060
|
-
export {
|
|
16061
|
-
index$9_Level as Level,
|
|
16062
|
-
index$9_Logger as Logger,
|
|
16063
|
-
index$9_parseLoggerOptions as parseLoggerOptions,
|
|
16064
|
-
};
|
|
16065
|
-
}
|
|
16066
|
-
|
|
16067
16050
|
declare enum ProgramDecoderError {
|
|
16068
16051
|
InvalidProgramError = 0,
|
|
16069
16052
|
}
|
|
@@ -16146,6 +16129,8 @@ type InterpreterOptions = {
|
|
|
16146
16129
|
useSbrkGas?: boolean;
|
|
16147
16130
|
};
|
|
16148
16131
|
|
|
16132
|
+
declare const logger = Logger.new(import.meta.filename, "pvm");
|
|
16133
|
+
|
|
16149
16134
|
declare class Interpreter {
|
|
16150
16135
|
private readonly useSbrkGas: boolean;
|
|
16151
16136
|
private registers = new Registers();
|
|
@@ -16281,6 +16266,8 @@ declare class Interpreter {
|
|
|
16281
16266
|
const argsResult = this.argsDecodingResults[argsType];
|
|
16282
16267
|
this.argsDecoder.fillArgs(this.pc, argsResult);
|
|
16283
16268
|
|
|
16269
|
+
logger.insane(`[PC: ${this.pc}] ${Instruction[currentInstruction]}`);
|
|
16270
|
+
|
|
16284
16271
|
if (!isValidInstruction) {
|
|
16285
16272
|
this.instructionResult.status = Result.PANIC;
|
|
16286
16273
|
} else {
|
|
@@ -16356,6 +16343,7 @@ declare class Interpreter {
|
|
|
16356
16343
|
this.status = Status.HOST;
|
|
16357
16344
|
break;
|
|
16358
16345
|
}
|
|
16346
|
+
logger.insane(`[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}`);
|
|
16359
16347
|
return this.status;
|
|
16360
16348
|
}
|
|
16361
16349
|
|
|
@@ -16427,13 +16415,14 @@ declare const index$8_Registers: typeof Registers;
|
|
|
16427
16415
|
type index$8_SbrkIndex = SbrkIndex;
|
|
16428
16416
|
type index$8_SmallGas = SmallGas;
|
|
16429
16417
|
declare const index$8_gasCounter: typeof gasCounter;
|
|
16418
|
+
declare const index$8_logger: typeof logger;
|
|
16430
16419
|
declare const index$8_tryAsBigGas: typeof tryAsBigGas;
|
|
16431
16420
|
declare const index$8_tryAsGas: typeof tryAsGas;
|
|
16432
16421
|
declare const index$8_tryAsMemoryIndex: typeof tryAsMemoryIndex;
|
|
16433
16422
|
declare const index$8_tryAsSbrkIndex: typeof tryAsSbrkIndex;
|
|
16434
16423
|
declare const index$8_tryAsSmallGas: typeof tryAsSmallGas;
|
|
16435
16424
|
declare namespace index$8 {
|
|
16436
|
-
export { index$8_Interpreter as Interpreter, index$8_Memory as Memory, index$8_MemoryBuilder as MemoryBuilder, index$8_Registers as Registers, index$8_gasCounter as gasCounter, index$8_tryAsBigGas as tryAsBigGas, index$8_tryAsGas as tryAsGas, index$8_tryAsMemoryIndex as tryAsMemoryIndex, index$8_tryAsSbrkIndex as tryAsSbrkIndex, index$8_tryAsSmallGas as tryAsSmallGas };
|
|
16425
|
+
export { index$8_Interpreter as Interpreter, index$8_Memory as Memory, index$8_MemoryBuilder as MemoryBuilder, index$8_Registers as Registers, index$8_gasCounter as gasCounter, index$8_logger as logger, index$8_tryAsBigGas as tryAsBigGas, index$8_tryAsGas as tryAsGas, index$8_tryAsMemoryIndex as tryAsMemoryIndex, index$8_tryAsSbrkIndex as tryAsSbrkIndex, index$8_tryAsSmallGas as tryAsSmallGas };
|
|
16437
16426
|
export type { index$8_BigGas as BigGas, index$8_Gas as Gas, index$8_GasCounter as GasCounter, index$8_InterpreterOptions as InterpreterOptions, index$8_MemoryIndex as MemoryIndex, index$8_SbrkIndex as SbrkIndex, index$8_SmallGas as SmallGas };
|
|
16438
16427
|
}
|
|
16439
16428
|
|
|
@@ -16571,7 +16560,7 @@ declare class HostCallsManager {
|
|
|
16571
16560
|
return `r${idx}=${value} (0x${value.toString(16)})`;
|
|
16572
16561
|
})
|
|
16573
16562
|
.join(", ");
|
|
16574
|
-
logger.
|
|
16563
|
+
logger.insane(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
|
|
16575
16564
|
}
|
|
16576
16565
|
}
|
|
16577
16566
|
|
|
@@ -16692,14 +16681,15 @@ declare class HostCalls {
|
|
|
16692
16681
|
const gasCost = typeof hostCall.gasCost === "number" ? hostCall.gasCost : hostCall.gasCost(regs);
|
|
16693
16682
|
const underflow = gas.sub(gasCost);
|
|
16694
16683
|
|
|
16684
|
+
const pcLog = `[PC: ${pvmInstance.getPC()}]`;
|
|
16695
16685
|
if (underflow) {
|
|
16696
|
-
this.hostCalls.traceHostCall(
|
|
16686
|
+
this.hostCalls.traceHostCall(`${pcLog} OOG`, index, hostCall, regs, gas.get());
|
|
16697
16687
|
return ReturnValue.fromStatus(pvmInstance.getGasConsumed(), Status.OOG);
|
|
16698
16688
|
}
|
|
16699
|
-
this.hostCalls.traceHostCall(
|
|
16689
|
+
this.hostCalls.traceHostCall(`${pcLog} Invoking`, index, hostCall, regs, gasBefore);
|
|
16700
16690
|
const result = await hostCall.execute(gas, regs, memory);
|
|
16701
16691
|
this.hostCalls.traceHostCall(
|
|
16702
|
-
result === undefined ?
|
|
16692
|
+
result === undefined ? `${pcLog} Result` : `${pcLog} Status(${PvmExecution[result]})`,
|
|
16703
16693
|
index,
|
|
16704
16694
|
hostCall,
|
|
16705
16695
|
regs,
|
|
@@ -18112,41 +18102,7 @@ declare namespace index$2 {
|
|
|
18112
18102
|
};
|
|
18113
18103
|
}
|
|
18114
18104
|
|
|
18115
|
-
declare class
|
|
18116
|
-
static fromJson = json.object<JsonServiceInfoPre067, ServiceAccountInfo>(
|
|
18117
|
-
{
|
|
18118
|
-
code_hash: fromJson.bytes32(),
|
|
18119
|
-
balance: json.fromNumber((x) => tryAsU64(x)),
|
|
18120
|
-
min_item_gas: json.fromNumber((x) => tryAsServiceGas(x)),
|
|
18121
|
-
min_memo_gas: json.fromNumber((x) => tryAsServiceGas(x)),
|
|
18122
|
-
bytes: json.fromNumber((x) => tryAsU64(x)),
|
|
18123
|
-
items: "number",
|
|
18124
|
-
},
|
|
18125
|
-
({ code_hash, balance, min_item_gas, min_memo_gas, bytes, items }) => {
|
|
18126
|
-
return ServiceAccountInfo.create({
|
|
18127
|
-
codeHash: code_hash,
|
|
18128
|
-
balance,
|
|
18129
|
-
accumulateMinGas: min_item_gas,
|
|
18130
|
-
onTransferMinGas: min_memo_gas,
|
|
18131
|
-
storageUtilisationBytes: bytes,
|
|
18132
|
-
storageUtilisationCount: items,
|
|
18133
|
-
gratisStorage: tryAsU64(0),
|
|
18134
|
-
created: tryAsTimeSlot(0),
|
|
18135
|
-
lastAccumulation: tryAsTimeSlot(0),
|
|
18136
|
-
parentService: tryAsServiceId(0),
|
|
18137
|
-
});
|
|
18138
|
-
},
|
|
18139
|
-
);
|
|
18140
|
-
|
|
18141
|
-
code_hash!: CodeHash;
|
|
18142
|
-
balance!: U64;
|
|
18143
|
-
min_item_gas!: ServiceGas;
|
|
18144
|
-
min_memo_gas!: ServiceGas;
|
|
18145
|
-
bytes!: U64;
|
|
18146
|
-
items!: U32;
|
|
18147
|
-
}
|
|
18148
|
-
|
|
18149
|
-
declare class JsonServiceInfo extends JsonServiceInfoPre067 {
|
|
18105
|
+
declare class JsonServiceInfo {
|
|
18150
18106
|
static fromJson = json.object<JsonServiceInfo, ServiceAccountInfo>(
|
|
18151
18107
|
{
|
|
18152
18108
|
code_hash: fromJson.bytes32(),
|
|
@@ -18187,6 +18143,12 @@ declare class JsonServiceInfo extends JsonServiceInfoPre067 {
|
|
|
18187
18143
|
},
|
|
18188
18144
|
);
|
|
18189
18145
|
|
|
18146
|
+
code_hash!: CodeHash;
|
|
18147
|
+
balance!: U64;
|
|
18148
|
+
min_item_gas!: ServiceGas;
|
|
18149
|
+
min_memo_gas!: ServiceGas;
|
|
18150
|
+
bytes!: U64;
|
|
18151
|
+
items!: U32;
|
|
18190
18152
|
creation_slot!: TimeSlot;
|
|
18191
18153
|
deposit_offset!: U64;
|
|
18192
18154
|
last_accumulation_slot!: TimeSlot;
|
|
@@ -18240,9 +18202,7 @@ declare class JsonService {
|
|
|
18240
18202
|
{
|
|
18241
18203
|
id: "number",
|
|
18242
18204
|
data: {
|
|
18243
|
-
service:
|
|
18244
|
-
? JsonServiceInfo.fromJson
|
|
18245
|
-
: JsonServiceInfoPre067.fromJson,
|
|
18205
|
+
service: JsonServiceInfo.fromJson,
|
|
18246
18206
|
preimages: json.optional(json.array(JsonPreimageItem.fromJson)),
|
|
18247
18207
|
storage: json.optional(json.array(JsonStorageItem.fromJson)),
|
|
18248
18208
|
lookup_meta: json.optional(json.array(lookupMetaFromJson)),
|
|
@@ -18745,138 +18705,6 @@ declare const fullStateDumpFromJson = (spec: ChainSpec) =>
|
|
|
18745
18705
|
},
|
|
18746
18706
|
);
|
|
18747
18707
|
|
|
18748
|
-
type JsonStateDumpPre067 = {
|
|
18749
|
-
alpha: AuthorizerHash[][];
|
|
18750
|
-
varphi: AuthorizerHash[][];
|
|
18751
|
-
beta: State["recentBlocks"] | null;
|
|
18752
|
-
gamma: {
|
|
18753
|
-
gamma_k: State["nextValidatorData"];
|
|
18754
|
-
gamma_z: State["epochRoot"];
|
|
18755
|
-
gamma_s: TicketsOrKeys;
|
|
18756
|
-
gamma_a: State["ticketsAccumulator"];
|
|
18757
|
-
};
|
|
18758
|
-
psi: State["disputesRecords"];
|
|
18759
|
-
eta: State["entropy"];
|
|
18760
|
-
iota: State["designatedValidatorData"];
|
|
18761
|
-
kappa: State["currentValidatorData"];
|
|
18762
|
-
lambda: State["previousValidatorData"];
|
|
18763
|
-
rho: State["availabilityAssignment"];
|
|
18764
|
-
tau: State["timeslot"];
|
|
18765
|
-
chi: {
|
|
18766
|
-
chi_m: PrivilegedServices["manager"];
|
|
18767
|
-
chi_a: ServiceId; // NOTE: [MaSo] pre067
|
|
18768
|
-
chi_v: PrivilegedServices["validatorsManager"];
|
|
18769
|
-
chi_g: PrivilegedServices["autoAccumulateServices"] | null;
|
|
18770
|
-
};
|
|
18771
|
-
pi: JsonStatisticsData;
|
|
18772
|
-
theta: State["accumulationQueue"];
|
|
18773
|
-
xi: PerEpochBlock<WorkPackageHash[]>;
|
|
18774
|
-
accounts: InMemoryService[];
|
|
18775
|
-
};
|
|
18776
|
-
|
|
18777
|
-
declare const fullStateDumpFromJsonPre067 = (spec: ChainSpec) =>
|
|
18778
|
-
json.object<JsonStateDumpPre067, InMemoryState>(
|
|
18779
|
-
{
|
|
18780
|
-
alpha: json.array(json.array(fromJson.bytes32<AuthorizerHash>())),
|
|
18781
|
-
varphi: json.array(json.array(fromJson.bytes32<AuthorizerHash>())),
|
|
18782
|
-
beta: json.nullable(recentBlocksHistoryFromJson),
|
|
18783
|
-
gamma: {
|
|
18784
|
-
gamma_k: json.array(validatorDataFromJson),
|
|
18785
|
-
gamma_a: json.array(ticketFromJson),
|
|
18786
|
-
gamma_s: TicketsOrKeys.fromJson,
|
|
18787
|
-
gamma_z: json.fromString((v) => Bytes.parseBytes(v, BANDERSNATCH_RING_ROOT_BYTES).asOpaque()),
|
|
18788
|
-
},
|
|
18789
|
-
psi: disputesRecordsFromJson,
|
|
18790
|
-
eta: json.array(fromJson.bytes32<EntropyHash>()),
|
|
18791
|
-
iota: json.array(validatorDataFromJson),
|
|
18792
|
-
kappa: json.array(validatorDataFromJson),
|
|
18793
|
-
lambda: json.array(validatorDataFromJson),
|
|
18794
|
-
rho: json.array(json.nullable(availabilityAssignmentFromJson)),
|
|
18795
|
-
tau: "number",
|
|
18796
|
-
chi: {
|
|
18797
|
-
chi_m: "number",
|
|
18798
|
-
chi_a: "number",
|
|
18799
|
-
chi_v: "number",
|
|
18800
|
-
chi_g: json.nullable(
|
|
18801
|
-
json.array({
|
|
18802
|
-
service: "number",
|
|
18803
|
-
gasLimit: json.fromNumber((v) => tryAsServiceGas(v)),
|
|
18804
|
-
}),
|
|
18805
|
-
),
|
|
18806
|
-
},
|
|
18807
|
-
pi: JsonStatisticsData.fromJson,
|
|
18808
|
-
theta: json.array(json.array(notYetAccumulatedFromJson)),
|
|
18809
|
-
xi: json.array(json.array(fromJson.bytes32())),
|
|
18810
|
-
accounts: json.array(JsonService.fromJson),
|
|
18811
|
-
},
|
|
18812
|
-
({
|
|
18813
|
-
alpha,
|
|
18814
|
-
varphi,
|
|
18815
|
-
beta,
|
|
18816
|
-
gamma,
|
|
18817
|
-
psi,
|
|
18818
|
-
eta,
|
|
18819
|
-
iota,
|
|
18820
|
-
kappa,
|
|
18821
|
-
lambda,
|
|
18822
|
-
rho,
|
|
18823
|
-
tau,
|
|
18824
|
-
chi,
|
|
18825
|
-
pi,
|
|
18826
|
-
theta,
|
|
18827
|
-
xi,
|
|
18828
|
-
accounts,
|
|
18829
|
-
}): InMemoryState => {
|
|
18830
|
-
return InMemoryState.create({
|
|
18831
|
-
authPools: tryAsPerCore(
|
|
18832
|
-
alpha.map((perCore) => {
|
|
18833
|
-
if (perCore.length > MAX_AUTH_POOL_SIZE) {
|
|
18834
|
-
throw new Error(`AuthPools: expected less than ${MAX_AUTH_POOL_SIZE}, got ${perCore.length}`);
|
|
18835
|
-
}
|
|
18836
|
-
return asKnownSize(perCore);
|
|
18837
|
-
}),
|
|
18838
|
-
spec,
|
|
18839
|
-
),
|
|
18840
|
-
authQueues: tryAsPerCore(
|
|
18841
|
-
varphi.map((perCore) => {
|
|
18842
|
-
if (perCore.length !== AUTHORIZATION_QUEUE_SIZE) {
|
|
18843
|
-
throw new Error(`AuthQueues: expected ${AUTHORIZATION_QUEUE_SIZE}, got: ${perCore.length}`);
|
|
18844
|
-
}
|
|
18845
|
-
return asKnownSize(perCore);
|
|
18846
|
-
}),
|
|
18847
|
-
spec,
|
|
18848
|
-
),
|
|
18849
|
-
recentBlocks: beta ?? RecentBlocksHistory.empty(),
|
|
18850
|
-
nextValidatorData: gamma.gamma_k,
|
|
18851
|
-
epochRoot: gamma.gamma_z,
|
|
18852
|
-
sealingKeySeries: TicketsOrKeys.toSafroleSealingKeys(gamma.gamma_s, spec),
|
|
18853
|
-
ticketsAccumulator: gamma.gamma_a,
|
|
18854
|
-
disputesRecords: psi,
|
|
18855
|
-
entropy: eta,
|
|
18856
|
-
designatedValidatorData: iota,
|
|
18857
|
-
currentValidatorData: kappa,
|
|
18858
|
-
previousValidatorData: lambda,
|
|
18859
|
-
availabilityAssignment: rho,
|
|
18860
|
-
timeslot: tau,
|
|
18861
|
-
privilegedServices: PrivilegedServices.create({
|
|
18862
|
-
manager: chi.chi_m,
|
|
18863
|
-
authManager: tryAsPerCore(new Array(spec.coresCount).fill(chi.chi_a), spec),
|
|
18864
|
-
validatorsManager: chi.chi_v,
|
|
18865
|
-
autoAccumulateServices: chi.chi_g ?? [],
|
|
18866
|
-
}),
|
|
18867
|
-
statistics: JsonStatisticsData.toStatisticsData(spec, pi),
|
|
18868
|
-
accumulationQueue: theta,
|
|
18869
|
-
recentlyAccumulated: tryAsPerEpochBlock(
|
|
18870
|
-
xi.map((x) => HashSet.from(x)),
|
|
18871
|
-
spec,
|
|
18872
|
-
),
|
|
18873
|
-
services: new Map(accounts.map((x) => [x.serviceId, x])),
|
|
18874
|
-
// NOTE Field not present in pre067, added here for compatibility reasons
|
|
18875
|
-
accumulationOutputLog: [],
|
|
18876
|
-
});
|
|
18877
|
-
},
|
|
18878
|
-
);
|
|
18879
|
-
|
|
18880
18708
|
type index$1_JsonAvailabilityAssignment = JsonAvailabilityAssignment;
|
|
18881
18709
|
type index$1_JsonCoreStatistics = JsonCoreStatistics;
|
|
18882
18710
|
declare const index$1_JsonCoreStatistics: typeof JsonCoreStatistics;
|
|
@@ -18892,12 +18720,9 @@ type index$1_JsonService = JsonService;
|
|
|
18892
18720
|
declare const index$1_JsonService: typeof JsonService;
|
|
18893
18721
|
type index$1_JsonServiceInfo = JsonServiceInfo;
|
|
18894
18722
|
declare const index$1_JsonServiceInfo: typeof JsonServiceInfo;
|
|
18895
|
-
type index$1_JsonServiceInfoPre067 = JsonServiceInfoPre067;
|
|
18896
|
-
declare const index$1_JsonServiceInfoPre067: typeof JsonServiceInfoPre067;
|
|
18897
18723
|
type index$1_JsonServiceStatistics = JsonServiceStatistics;
|
|
18898
18724
|
declare const index$1_JsonServiceStatistics: typeof JsonServiceStatistics;
|
|
18899
18725
|
type index$1_JsonStateDump = JsonStateDump;
|
|
18900
|
-
type index$1_JsonStateDumpPre067 = JsonStateDumpPre067;
|
|
18901
18726
|
type index$1_JsonStatisticsData = JsonStatisticsData;
|
|
18902
18727
|
declare const index$1_JsonStatisticsData: typeof JsonStatisticsData;
|
|
18903
18728
|
type index$1_JsonStorageItem = JsonStorageItem;
|
|
@@ -18910,7 +18735,6 @@ declare const index$1_TicketsOrKeys: typeof TicketsOrKeys;
|
|
|
18910
18735
|
declare const index$1_availabilityAssignmentFromJson: typeof availabilityAssignmentFromJson;
|
|
18911
18736
|
declare const index$1_disputesRecordsFromJson: typeof disputesRecordsFromJson;
|
|
18912
18737
|
declare const index$1_fullStateDumpFromJson: typeof fullStateDumpFromJson;
|
|
18913
|
-
declare const index$1_fullStateDumpFromJsonPre067: typeof fullStateDumpFromJsonPre067;
|
|
18914
18738
|
declare const index$1_lookupMetaFromJson: typeof lookupMetaFromJson;
|
|
18915
18739
|
declare const index$1_notYetAccumulatedFromJson: typeof notYetAccumulatedFromJson;
|
|
18916
18740
|
declare const index$1_recentBlockStateFromJson: typeof recentBlockStateFromJson;
|
|
@@ -18920,8 +18744,8 @@ declare const index$1_serviceStatisticsEntryFromJson: typeof serviceStatisticsEn
|
|
|
18920
18744
|
declare const index$1_ticketFromJson: typeof ticketFromJson;
|
|
18921
18745
|
declare const index$1_validatorDataFromJson: typeof validatorDataFromJson;
|
|
18922
18746
|
declare namespace index$1 {
|
|
18923
|
-
export { index$1_JsonCoreStatistics as JsonCoreStatistics, index$1_JsonDisputesRecords as JsonDisputesRecords, index$1_JsonPreimageItem as JsonPreimageItem, index$1_JsonService as JsonService, index$1_JsonServiceInfo as JsonServiceInfo, index$
|
|
18924
|
-
export type { index$1_JsonAvailabilityAssignment as JsonAvailabilityAssignment, index$1_JsonLookupMeta as JsonLookupMeta, index$1_JsonRecentBlockState as JsonRecentBlockState, index$1_JsonRecentBlocks as JsonRecentBlocks, index$1_JsonReportedWorkPackageInfo as JsonReportedWorkPackageInfo, index$1_JsonStateDump as JsonStateDump, index$
|
|
18747
|
+
export { index$1_JsonCoreStatistics as JsonCoreStatistics, index$1_JsonDisputesRecords as JsonDisputesRecords, index$1_JsonPreimageItem as JsonPreimageItem, index$1_JsonService as JsonService, index$1_JsonServiceInfo as JsonServiceInfo, index$1_JsonServiceStatistics as JsonServiceStatistics, index$1_JsonStatisticsData as JsonStatisticsData, index$1_JsonStorageItem as JsonStorageItem, index$1_JsonValidatorStatistics as JsonValidatorStatistics, index$1_TicketsOrKeys as TicketsOrKeys, index$1_availabilityAssignmentFromJson as availabilityAssignmentFromJson, index$1_disputesRecordsFromJson as disputesRecordsFromJson, index$1_fullStateDumpFromJson as fullStateDumpFromJson, index$1_lookupMetaFromJson as lookupMetaFromJson, index$1_notYetAccumulatedFromJson as notYetAccumulatedFromJson, index$1_recentBlockStateFromJson as recentBlockStateFromJson, index$1_recentBlocksHistoryFromJson as recentBlocksHistoryFromJson, index$1_reportedWorkPackageFromJson as reportedWorkPackageFromJson, index$1_serviceStatisticsEntryFromJson as serviceStatisticsEntryFromJson, index$1_ticketFromJson as ticketFromJson, index$1_validatorDataFromJson as validatorDataFromJson };
|
|
18748
|
+
export type { index$1_JsonAvailabilityAssignment as JsonAvailabilityAssignment, index$1_JsonLookupMeta as JsonLookupMeta, index$1_JsonRecentBlockState as JsonRecentBlockState, index$1_JsonRecentBlocks as JsonRecentBlocks, index$1_JsonReportedWorkPackageInfo as JsonReportedWorkPackageInfo, index$1_JsonStateDump as JsonStateDump, index$1_ServiceStatisticsEntry as ServiceStatisticsEntry };
|
|
18925
18749
|
}
|
|
18926
18750
|
|
|
18927
18751
|
/** Helper function to create most used hashes in the block */
|