@typeberry/lib 0.0.1-7996e00 → 0.0.1-8a792cb
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 +229 -209
- package/index.js +127 -84
- 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
|
|
|
@@ -8772,31 +8776,18 @@ declare const ignoreValueWithDefault = <T>(defaultValue: T) =>
|
|
|
8772
8776
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/108301108301?v=0.6.7
|
|
8773
8777
|
*/
|
|
8774
8778
|
declare class ServiceAccountInfo extends WithDebug {
|
|
8775
|
-
static Codec =
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
})
|
|
8788
|
-
: codec.Class(ServiceAccountInfo, {
|
|
8789
|
-
codeHash: codec.bytes(HASH_SIZE).asOpaque<CodeHash>(),
|
|
8790
|
-
balance: codec.u64,
|
|
8791
|
-
accumulateMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
|
|
8792
|
-
onTransferMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
|
|
8793
|
-
storageUtilisationBytes: codec.u64,
|
|
8794
|
-
storageUtilisationCount: codec.u32,
|
|
8795
|
-
gratisStorage: ignoreValueWithDefault(tryAsU64(0)),
|
|
8796
|
-
created: ignoreValueWithDefault(tryAsTimeSlot(0)),
|
|
8797
|
-
lastAccumulation: ignoreValueWithDefault(tryAsTimeSlot(0)),
|
|
8798
|
-
parentService: ignoreValueWithDefault(tryAsServiceId(0)),
|
|
8799
|
-
});
|
|
8779
|
+
static Codec = codec.Class(ServiceAccountInfo, {
|
|
8780
|
+
codeHash: codec.bytes(HASH_SIZE).asOpaque<CodeHash>(),
|
|
8781
|
+
balance: codec.u64,
|
|
8782
|
+
accumulateMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
|
|
8783
|
+
onTransferMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
|
|
8784
|
+
storageUtilisationBytes: codec.u64,
|
|
8785
|
+
gratisStorage: codec.u64,
|
|
8786
|
+
storageUtilisationCount: codec.u32,
|
|
8787
|
+
created: codec.u32.convert((x) => x, tryAsTimeSlot),
|
|
8788
|
+
lastAccumulation: codec.u32.convert((x) => x, tryAsTimeSlot),
|
|
8789
|
+
parentService: codec.u32.convert((x) => x, tryAsServiceId),
|
|
8790
|
+
});
|
|
8800
8791
|
|
|
8801
8792
|
static create(a: CodecRecord<ServiceAccountInfo>) {
|
|
8802
8793
|
return new ServiceAccountInfo(
|
|
@@ -10390,7 +10381,7 @@ type StateCodec<T> = {
|
|
|
10390
10381
|
|
|
10391
10382
|
/** Serialization for particular state entries. */
|
|
10392
10383
|
declare namespace serialize {
|
|
10393
|
-
/** C(1): https://graypaper.fluffylabs.dev/#/
|
|
10384
|
+
/** C(1): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b15013b1501?v=0.6.7 */
|
|
10394
10385
|
export const authPools: StateCodec<State["authPools"]> = {
|
|
10395
10386
|
key: stateKeys.index(StateKeyIdx.Alpha),
|
|
10396
10387
|
Codec: codecPerCore(
|
|
@@ -10403,7 +10394,7 @@ declare namespace serialize {
|
|
|
10403
10394
|
extract: (s) => s.authPools,
|
|
10404
10395
|
};
|
|
10405
10396
|
|
|
10406
|
-
/** C(2): https://graypaper.fluffylabs.dev/#/
|
|
10397
|
+
/** C(2): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b31013b3101?v=0.6.7 */
|
|
10407
10398
|
export const authQueues: StateCodec<State["authQueues"]> = {
|
|
10408
10399
|
key: stateKeys.index(StateKeyIdx.Phi),
|
|
10409
10400
|
Codec: codecPerCore(
|
|
@@ -10414,7 +10405,6 @@ declare namespace serialize {
|
|
|
10414
10405
|
|
|
10415
10406
|
/**
|
|
10416
10407
|
* C(3): Recent blocks with compatibility
|
|
10417
|
-
* https://graypaper.fluffylabs.dev/#/85129da/38cb0138cb01?v=0.6.3
|
|
10418
10408
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e013b3e01?v=0.6.7
|
|
10419
10409
|
*/
|
|
10420
10410
|
export const recentBlocks: StateCodec<State["recentBlocks"]> = {
|
|
@@ -10423,7 +10413,7 @@ declare namespace serialize {
|
|
|
10423
10413
|
extract: (s) => s.recentBlocks,
|
|
10424
10414
|
};
|
|
10425
10415
|
|
|
10426
|
-
/** C(4): https://graypaper.fluffylabs.dev/#/
|
|
10416
|
+
/** C(4): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b63013b6301?v=0.6.7 */
|
|
10427
10417
|
export const safrole: StateCodec<SafroleData> = {
|
|
10428
10418
|
key: stateKeys.index(StateKeyIdx.Gamma),
|
|
10429
10419
|
Codec: SafroleData.Codec,
|
|
@@ -10436,63 +10426,63 @@ declare namespace serialize {
|
|
|
10436
10426
|
}),
|
|
10437
10427
|
};
|
|
10438
10428
|
|
|
10439
|
-
/** C(5): https://graypaper.fluffylabs.dev/#/
|
|
10429
|
+
/** C(5): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bba013bba01?v=0.6.7 */
|
|
10440
10430
|
export const disputesRecords: StateCodec<State["disputesRecords"]> = {
|
|
10441
10431
|
key: stateKeys.index(StateKeyIdx.Psi),
|
|
10442
10432
|
Codec: DisputesRecords.Codec,
|
|
10443
10433
|
extract: (s) => s.disputesRecords,
|
|
10444
10434
|
};
|
|
10445
10435
|
|
|
10446
|
-
/** C(6): https://graypaper.fluffylabs.dev/#/
|
|
10436
|
+
/** C(6): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bf3013bf301?v=0.6.7 */
|
|
10447
10437
|
export const entropy: StateCodec<State["entropy"]> = {
|
|
10448
10438
|
key: stateKeys.index(StateKeyIdx.Eta),
|
|
10449
10439
|
Codec: codecFixedSizeArray(codec.bytes(HASH_SIZE).asOpaque<EntropyHash>(), ENTROPY_ENTRIES),
|
|
10450
10440
|
extract: (s) => s.entropy,
|
|
10451
10441
|
};
|
|
10452
10442
|
|
|
10453
|
-
/** C(7): https://graypaper.fluffylabs.dev/#/
|
|
10443
|
+
/** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
|
|
10454
10444
|
export const designatedValidators: StateCodec<State["designatedValidatorData"]> = {
|
|
10455
10445
|
key: stateKeys.index(StateKeyIdx.Iota),
|
|
10456
10446
|
Codec: codecPerValidator(ValidatorData.Codec),
|
|
10457
10447
|
extract: (s) => s.designatedValidatorData,
|
|
10458
10448
|
};
|
|
10459
10449
|
|
|
10460
|
-
/** C(8): https://graypaper.fluffylabs.dev/#/
|
|
10450
|
+
/** C(8): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b0d023b0d02?v=0.6.7 */
|
|
10461
10451
|
export const currentValidators: StateCodec<State["currentValidatorData"]> = {
|
|
10462
10452
|
key: stateKeys.index(StateKeyIdx.Kappa),
|
|
10463
10453
|
Codec: codecPerValidator(ValidatorData.Codec),
|
|
10464
10454
|
extract: (s) => s.currentValidatorData,
|
|
10465
10455
|
};
|
|
10466
10456
|
|
|
10467
|
-
/** C(9): https://graypaper.fluffylabs.dev/#/
|
|
10457
|
+
/** C(9): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b1a023b1a02?v=0.6.7 */
|
|
10468
10458
|
export const previousValidators: StateCodec<State["previousValidatorData"]> = {
|
|
10469
10459
|
key: stateKeys.index(StateKeyIdx.Lambda),
|
|
10470
10460
|
Codec: codecPerValidator(ValidatorData.Codec),
|
|
10471
10461
|
extract: (s) => s.previousValidatorData,
|
|
10472
10462
|
};
|
|
10473
10463
|
|
|
10474
|
-
/** C(10): https://graypaper.fluffylabs.dev/#/
|
|
10464
|
+
/** C(10): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b27023b2702?v=0.6.7 */
|
|
10475
10465
|
export const availabilityAssignment: StateCodec<State["availabilityAssignment"]> = {
|
|
10476
10466
|
key: stateKeys.index(StateKeyIdx.Rho),
|
|
10477
10467
|
Codec: codecPerCore(codec.optional(AvailabilityAssignment.Codec)),
|
|
10478
10468
|
extract: (s) => s.availabilityAssignment,
|
|
10479
10469
|
};
|
|
10480
10470
|
|
|
10481
|
-
/** C(11): https://graypaper.fluffylabs.dev/#/
|
|
10471
|
+
/** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
|
|
10482
10472
|
export const timeslot: StateCodec<State["timeslot"]> = {
|
|
10483
10473
|
key: stateKeys.index(StateKeyIdx.Tau),
|
|
10484
10474
|
Codec: codec.u32.asOpaque<TimeSlot>(),
|
|
10485
10475
|
extract: (s) => s.timeslot,
|
|
10486
10476
|
};
|
|
10487
10477
|
|
|
10488
|
-
/** C(12): https://graypaper.fluffylabs.dev/#/
|
|
10478
|
+
/** C(12): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b4c023b4c02?v=0.6.7 */
|
|
10489
10479
|
export const privilegedServices: StateCodec<State["privilegedServices"]> = {
|
|
10490
10480
|
key: stateKeys.index(StateKeyIdx.Chi),
|
|
10491
10481
|
Codec: PrivilegedServices.Codec,
|
|
10492
10482
|
extract: (s) => s.privilegedServices,
|
|
10493
10483
|
};
|
|
10494
10484
|
|
|
10495
|
-
/** C(13): https://graypaper.fluffylabs.dev/#/
|
|
10485
|
+
/** C(13): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b5e023b5e02?v=0.6.7 */
|
|
10496
10486
|
export const statistics: StateCodec<State["statistics"]> = {
|
|
10497
10487
|
key: stateKeys.index(StateKeyIdx.Pi),
|
|
10498
10488
|
Codec: StatisticsData.Codec,
|
|
@@ -10506,7 +10496,7 @@ declare namespace serialize {
|
|
|
10506
10496
|
extract: (s) => s.accumulationQueue,
|
|
10507
10497
|
};
|
|
10508
10498
|
|
|
10509
|
-
/** C(15): https://graypaper.fluffylabs.dev/#/
|
|
10499
|
+
/** C(15): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b96023b9602?v=0.6.7 */
|
|
10510
10500
|
export const recentlyAccumulated: StateCodec<State["recentlyAccumulated"]> = {
|
|
10511
10501
|
key: stateKeys.index(StateKeyIdx.Xi),
|
|
10512
10502
|
Codec: codecPerEpochBlock(
|
|
@@ -12614,6 +12604,173 @@ declare const HostCallResult = {
|
|
|
12614
12604
|
OK: tryAsU64(0n),
|
|
12615
12605
|
} as const;
|
|
12616
12606
|
|
|
12607
|
+
declare enum Level {
|
|
12608
|
+
INSANE = 1,
|
|
12609
|
+
TRACE = 2,
|
|
12610
|
+
LOG = 3,
|
|
12611
|
+
INFO = 4,
|
|
12612
|
+
WARN = 5,
|
|
12613
|
+
ERROR = 6,
|
|
12614
|
+
}
|
|
12615
|
+
|
|
12616
|
+
type Options = {
|
|
12617
|
+
defaultLevel: Level;
|
|
12618
|
+
workingDir: string;
|
|
12619
|
+
modules: Map<string, Level>;
|
|
12620
|
+
};
|
|
12621
|
+
|
|
12622
|
+
/**
|
|
12623
|
+
* A function to parse logger definition (including modules) given as a string.
|
|
12624
|
+
*
|
|
12625
|
+
* Examples
|
|
12626
|
+
* - `info` - setup default logging level to `info`.
|
|
12627
|
+
* - `trace` - default logging level set to `trace`.
|
|
12628
|
+
* - `debug;consensus=trace` - default level is set to `debug/log`, but consensus is in trace mode.
|
|
12629
|
+
*/
|
|
12630
|
+
declare function parseLoggerOptions(input: string, defaultLevel: Level, workingDir?: string): Options {
|
|
12631
|
+
const modules = new Map<string, Level>();
|
|
12632
|
+
const parts = input.toLowerCase().split(",");
|
|
12633
|
+
let defLevel = defaultLevel;
|
|
12634
|
+
|
|
12635
|
+
for (const p of parts) {
|
|
12636
|
+
const clean = p.trim();
|
|
12637
|
+
// skip empty objects (forgotten `,` removed)
|
|
12638
|
+
if (clean.length === 0) {
|
|
12639
|
+
continue;
|
|
12640
|
+
}
|
|
12641
|
+
// we just have the default level
|
|
12642
|
+
if (clean.includes("=")) {
|
|
12643
|
+
const [mod, lvl] = clean.split("=");
|
|
12644
|
+
modules.set(mod.trim(), parseLevel(lvl.trim()));
|
|
12645
|
+
} else {
|
|
12646
|
+
defLevel = parseLevel(clean);
|
|
12647
|
+
}
|
|
12648
|
+
}
|
|
12649
|
+
|
|
12650
|
+
// TODO [ToDr] Fix dirname for workers.
|
|
12651
|
+
const myDir = (import.meta.dirname ?? "").split("/");
|
|
12652
|
+
myDir.pop();
|
|
12653
|
+
myDir.pop();
|
|
12654
|
+
return {
|
|
12655
|
+
defaultLevel: defLevel,
|
|
12656
|
+
modules,
|
|
12657
|
+
workingDir: workingDir ?? myDir.join("/"),
|
|
12658
|
+
};
|
|
12659
|
+
}
|
|
12660
|
+
|
|
12661
|
+
declare const GLOBAL_CONFIG = {
|
|
12662
|
+
options: DEFAULT_OPTIONS,
|
|
12663
|
+
transport: ConsoleTransport.create(DEFAULT_OPTIONS.defaultLevel, DEFAULT_OPTIONS),
|
|
12664
|
+
};
|
|
12665
|
+
|
|
12666
|
+
/**
|
|
12667
|
+
* A logger instance.
|
|
12668
|
+
*/
|
|
12669
|
+
declare class Logger {
|
|
12670
|
+
/**
|
|
12671
|
+
* Create a new logger instance given filename and an optional module name.
|
|
12672
|
+
*
|
|
12673
|
+
* If the module name is not given, `fileName` becomes the module name.
|
|
12674
|
+
* The module name can be composed from multiple parts separated with `/`.
|
|
12675
|
+
*
|
|
12676
|
+
* The logger will use a global configuration which can be changed using
|
|
12677
|
+
* [`configureLogger`] function.
|
|
12678
|
+
*/
|
|
12679
|
+
static new(fileName?: string, moduleName?: string) {
|
|
12680
|
+
const fName = fileName ?? "unknown";
|
|
12681
|
+
return new Logger(moduleName ?? fName, fName, GLOBAL_CONFIG);
|
|
12682
|
+
}
|
|
12683
|
+
|
|
12684
|
+
/**
|
|
12685
|
+
* Return currently configured level for given module. */
|
|
12686
|
+
static getLevel(moduleName: string): Level {
|
|
12687
|
+
return findLevel(GLOBAL_CONFIG.options, moduleName);
|
|
12688
|
+
}
|
|
12689
|
+
|
|
12690
|
+
/**
|
|
12691
|
+
* Global configuration of all loggers.
|
|
12692
|
+
*
|
|
12693
|
+
* One can specify a default logging level (only logs with level >= default will be printed).
|
|
12694
|
+
* It's also possible to configure per-module logging level that takes precedence
|
|
12695
|
+
* over the default one.
|
|
12696
|
+
*
|
|
12697
|
+
* Changing the options affects all previously created loggers.
|
|
12698
|
+
*/
|
|
12699
|
+
static configureAllFromOptions(options: Options) {
|
|
12700
|
+
// find minimal level to optimise logging in case
|
|
12701
|
+
// we don't care about low-level logs.
|
|
12702
|
+
const minimalLevel = Array.from(options.modules.values()).reduce((level, modLevel) => {
|
|
12703
|
+
return level < modLevel ? level : modLevel;
|
|
12704
|
+
}, options.defaultLevel);
|
|
12705
|
+
|
|
12706
|
+
const transport = ConsoleTransport.create(minimalLevel, options);
|
|
12707
|
+
|
|
12708
|
+
// set the global config
|
|
12709
|
+
GLOBAL_CONFIG.options = options;
|
|
12710
|
+
GLOBAL_CONFIG.transport = transport;
|
|
12711
|
+
}
|
|
12712
|
+
|
|
12713
|
+
/**
|
|
12714
|
+
* Global configuration of all loggers.
|
|
12715
|
+
*
|
|
12716
|
+
* Parse configuration options from an input string typically obtained
|
|
12717
|
+
* from environment variable `JAM_LOG`.
|
|
12718
|
+
*/
|
|
12719
|
+
static configureAll(input: string, defaultLevel: Level, workingDir?: string) {
|
|
12720
|
+
const options = parseLoggerOptions(input, defaultLevel, workingDir);
|
|
12721
|
+
Logger.configureAllFromOptions(options);
|
|
12722
|
+
}
|
|
12723
|
+
|
|
12724
|
+
constructor(
|
|
12725
|
+
private readonly moduleName: string,
|
|
12726
|
+
private readonly fileName: string,
|
|
12727
|
+
private readonly config: typeof GLOBAL_CONFIG,
|
|
12728
|
+
) {}
|
|
12729
|
+
|
|
12730
|
+
/** Log a message with `INSANE` level. */
|
|
12731
|
+
insane(val: string) {
|
|
12732
|
+
this.config.transport.insane(this.moduleName, val);
|
|
12733
|
+
}
|
|
12734
|
+
|
|
12735
|
+
/** Log a message with `TRACE` level. */
|
|
12736
|
+
trace(val: string) {
|
|
12737
|
+
this.config.transport.trace(this.moduleName, val);
|
|
12738
|
+
}
|
|
12739
|
+
|
|
12740
|
+
/** Log a message with `DEBUG`/`LOG` level. */
|
|
12741
|
+
log(val: string) {
|
|
12742
|
+
this.config.transport.log(this.moduleName, val);
|
|
12743
|
+
}
|
|
12744
|
+
|
|
12745
|
+
/** Log a message with `INFO` level. */
|
|
12746
|
+
info(val: string) {
|
|
12747
|
+
this.config.transport.info(this.moduleName, val);
|
|
12748
|
+
}
|
|
12749
|
+
|
|
12750
|
+
/** Log a message with `WARN` level. */
|
|
12751
|
+
warn(val: string) {
|
|
12752
|
+
this.config.transport.warn(this.moduleName, val);
|
|
12753
|
+
}
|
|
12754
|
+
|
|
12755
|
+
/** Log a message with `ERROR` level. */
|
|
12756
|
+
error(val: string) {
|
|
12757
|
+
this.config.transport.error(this.moduleName, val);
|
|
12758
|
+
}
|
|
12759
|
+
}
|
|
12760
|
+
|
|
12761
|
+
type index$9_Level = Level;
|
|
12762
|
+
declare const index$9_Level: typeof Level;
|
|
12763
|
+
type index$9_Logger = Logger;
|
|
12764
|
+
declare const index$9_Logger: typeof Logger;
|
|
12765
|
+
declare const index$9_parseLoggerOptions: typeof parseLoggerOptions;
|
|
12766
|
+
declare namespace index$9 {
|
|
12767
|
+
export {
|
|
12768
|
+
index$9_Level as Level,
|
|
12769
|
+
index$9_Logger as Logger,
|
|
12770
|
+
index$9_parseLoggerOptions as parseLoggerOptions,
|
|
12771
|
+
};
|
|
12772
|
+
}
|
|
12773
|
+
|
|
12617
12774
|
/**
|
|
12618
12775
|
* Mask class is an implementation of skip function defined in GP.
|
|
12619
12776
|
*
|
|
@@ -13893,6 +14050,7 @@ declare enum AccessType {
|
|
|
13893
14050
|
READ = 0,
|
|
13894
14051
|
WRITE = 1,
|
|
13895
14052
|
}
|
|
14053
|
+
|
|
13896
14054
|
declare class Memory {
|
|
13897
14055
|
static fromInitialMemory(initialMemoryState: InitialMemoryState) {
|
|
13898
14056
|
return new Memory(
|
|
@@ -13929,6 +14087,7 @@ declare class Memory {
|
|
|
13929
14087
|
return Result.ok(OK);
|
|
13930
14088
|
}
|
|
13931
14089
|
|
|
14090
|
+
logger.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
|
|
13932
14091
|
const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
|
|
13933
14092
|
|
|
13934
14093
|
if (pagesResult.isError) {
|
|
@@ -14017,6 +14176,7 @@ declare class Memory {
|
|
|
14017
14176
|
bytesLeft -= bytesToRead;
|
|
14018
14177
|
}
|
|
14019
14178
|
|
|
14179
|
+
logger.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
|
|
14020
14180
|
return Result.ok(OK);
|
|
14021
14181
|
}
|
|
14022
14182
|
|
|
@@ -15016,6 +15176,10 @@ declare class JumpTable {
|
|
|
15016
15176
|
return new JumpTable(0, new Uint8Array());
|
|
15017
15177
|
}
|
|
15018
15178
|
|
|
15179
|
+
getSize() {
|
|
15180
|
+
return this.indices.length;
|
|
15181
|
+
}
|
|
15182
|
+
|
|
15019
15183
|
copyFrom(jt: JumpTable) {
|
|
15020
15184
|
this.indices = jt.indices;
|
|
15021
15185
|
}
|
|
@@ -15917,167 +16081,6 @@ declare class OneRegOneExtImmDispatcher {
|
|
|
15917
16081
|
}
|
|
15918
16082
|
}
|
|
15919
16083
|
|
|
15920
|
-
declare enum Level {
|
|
15921
|
-
TRACE = 1,
|
|
15922
|
-
LOG = 2,
|
|
15923
|
-
INFO = 3,
|
|
15924
|
-
WARN = 4,
|
|
15925
|
-
ERROR = 5,
|
|
15926
|
-
}
|
|
15927
|
-
|
|
15928
|
-
type Options = {
|
|
15929
|
-
defaultLevel: Level;
|
|
15930
|
-
workingDir: string;
|
|
15931
|
-
modules: Map<string, Level>;
|
|
15932
|
-
};
|
|
15933
|
-
|
|
15934
|
-
/**
|
|
15935
|
-
* A function to parse logger definition (including modules) given as a string.
|
|
15936
|
-
*
|
|
15937
|
-
* Examples
|
|
15938
|
-
* - `info` - setup default logging level to `info`.
|
|
15939
|
-
* - `trace` - default logging level set to `trace`.
|
|
15940
|
-
* - `debug;consensus=trace` - default level is set to `debug/log`, but consensus is in trace mode.
|
|
15941
|
-
*/
|
|
15942
|
-
declare function parseLoggerOptions(input: string, defaultLevel: Level, workingDir?: string): Options {
|
|
15943
|
-
const modules = new Map<string, Level>();
|
|
15944
|
-
const parts = input.toLowerCase().split(",");
|
|
15945
|
-
let defLevel = defaultLevel;
|
|
15946
|
-
|
|
15947
|
-
for (const p of parts) {
|
|
15948
|
-
const clean = p.trim();
|
|
15949
|
-
// skip empty objects (forgotten `,` removed)
|
|
15950
|
-
if (clean.length === 0) {
|
|
15951
|
-
continue;
|
|
15952
|
-
}
|
|
15953
|
-
// we just have the default level
|
|
15954
|
-
if (clean.includes("=")) {
|
|
15955
|
-
const [mod, lvl] = clean.split("=");
|
|
15956
|
-
modules.set(mod.trim(), parseLevel(lvl.trim()));
|
|
15957
|
-
} else {
|
|
15958
|
-
defLevel = parseLevel(clean);
|
|
15959
|
-
}
|
|
15960
|
-
}
|
|
15961
|
-
|
|
15962
|
-
// TODO [ToDr] Fix dirname for workers.
|
|
15963
|
-
const myDir = (import.meta.dirname ?? "").split("/");
|
|
15964
|
-
myDir.pop();
|
|
15965
|
-
myDir.pop();
|
|
15966
|
-
return {
|
|
15967
|
-
defaultLevel: defLevel,
|
|
15968
|
-
modules,
|
|
15969
|
-
workingDir: workingDir ?? myDir.join("/"),
|
|
15970
|
-
};
|
|
15971
|
-
}
|
|
15972
|
-
|
|
15973
|
-
declare const GLOBAL_CONFIG = {
|
|
15974
|
-
options: DEFAULT_OPTIONS,
|
|
15975
|
-
transport: ConsoleTransport.create(DEFAULT_OPTIONS.defaultLevel, DEFAULT_OPTIONS),
|
|
15976
|
-
};
|
|
15977
|
-
|
|
15978
|
-
/**
|
|
15979
|
-
* A logger instance.
|
|
15980
|
-
*/
|
|
15981
|
-
declare class Logger {
|
|
15982
|
-
/**
|
|
15983
|
-
* Create a new logger instance given filename and an optional module name.
|
|
15984
|
-
*
|
|
15985
|
-
* If the module name is not given, `fileName` becomes the module name.
|
|
15986
|
-
* The module name can be composed from multiple parts separated with `/`.
|
|
15987
|
-
*
|
|
15988
|
-
* The logger will use a global configuration which can be changed using
|
|
15989
|
-
* [`configureLogger`] function.
|
|
15990
|
-
*/
|
|
15991
|
-
static new(fileName?: string, moduleName?: string) {
|
|
15992
|
-
const fName = fileName ?? "unknown";
|
|
15993
|
-
return new Logger(moduleName ?? fName, fName, GLOBAL_CONFIG);
|
|
15994
|
-
}
|
|
15995
|
-
|
|
15996
|
-
/**
|
|
15997
|
-
* Return currently configured level for given module. */
|
|
15998
|
-
static getLevel(moduleName: string): Level {
|
|
15999
|
-
return findLevel(GLOBAL_CONFIG.options, moduleName);
|
|
16000
|
-
}
|
|
16001
|
-
|
|
16002
|
-
/**
|
|
16003
|
-
* Global configuration of all loggers.
|
|
16004
|
-
*
|
|
16005
|
-
* One can specify a default logging level (only logs with level >= default will be printed).
|
|
16006
|
-
* It's also possible to configure per-module logging level that takes precedence
|
|
16007
|
-
* over the default one.
|
|
16008
|
-
*
|
|
16009
|
-
* Changing the options affects all previously created loggers.
|
|
16010
|
-
*/
|
|
16011
|
-
static configureAllFromOptions(options: Options) {
|
|
16012
|
-
// find minimal level to optimise logging in case
|
|
16013
|
-
// we don't care about low-level logs.
|
|
16014
|
-
const minimalLevel = Array.from(options.modules.values()).reduce((level, modLevel) => {
|
|
16015
|
-
return level < modLevel ? level : modLevel;
|
|
16016
|
-
}, options.defaultLevel);
|
|
16017
|
-
|
|
16018
|
-
const transport = ConsoleTransport.create(minimalLevel, options);
|
|
16019
|
-
|
|
16020
|
-
// set the global config
|
|
16021
|
-
GLOBAL_CONFIG.options = options;
|
|
16022
|
-
GLOBAL_CONFIG.transport = transport;
|
|
16023
|
-
}
|
|
16024
|
-
|
|
16025
|
-
/**
|
|
16026
|
-
* Global configuration of all loggers.
|
|
16027
|
-
*
|
|
16028
|
-
* Parse configuration options from an input string typically obtained
|
|
16029
|
-
* from environment variable `JAM_LOG`.
|
|
16030
|
-
*/
|
|
16031
|
-
static configureAll(input: string, defaultLevel: Level, workingDir?: string) {
|
|
16032
|
-
const options = parseLoggerOptions(input, defaultLevel, workingDir);
|
|
16033
|
-
Logger.configureAllFromOptions(options);
|
|
16034
|
-
}
|
|
16035
|
-
|
|
16036
|
-
constructor(
|
|
16037
|
-
private readonly moduleName: string,
|
|
16038
|
-
private readonly fileName: string,
|
|
16039
|
-
private readonly config: typeof GLOBAL_CONFIG,
|
|
16040
|
-
) {}
|
|
16041
|
-
|
|
16042
|
-
/** Log a message with `TRACE` level. */
|
|
16043
|
-
trace(val: string) {
|
|
16044
|
-
this.config.transport.trace(this.moduleName, this.fileName, val);
|
|
16045
|
-
}
|
|
16046
|
-
|
|
16047
|
-
/** Log a message with `DEBUG`/`LOG` level. */
|
|
16048
|
-
log(val: string) {
|
|
16049
|
-
this.config.transport.log(this.moduleName, this.fileName, val);
|
|
16050
|
-
}
|
|
16051
|
-
|
|
16052
|
-
/** Log a message with `INFO` level. */
|
|
16053
|
-
info(val: string) {
|
|
16054
|
-
this.config.transport.info(this.moduleName, this.fileName, val);
|
|
16055
|
-
}
|
|
16056
|
-
|
|
16057
|
-
/** Log a message with `WARN` level. */
|
|
16058
|
-
warn(val: string) {
|
|
16059
|
-
this.config.transport.warn(this.moduleName, this.fileName, val);
|
|
16060
|
-
}
|
|
16061
|
-
|
|
16062
|
-
/** Log a message with `ERROR` level. */
|
|
16063
|
-
error(val: string) {
|
|
16064
|
-
this.config.transport.error(this.moduleName, this.fileName, val);
|
|
16065
|
-
}
|
|
16066
|
-
}
|
|
16067
|
-
|
|
16068
|
-
type index$9_Level = Level;
|
|
16069
|
-
declare const index$9_Level: typeof Level;
|
|
16070
|
-
type index$9_Logger = Logger;
|
|
16071
|
-
declare const index$9_Logger: typeof Logger;
|
|
16072
|
-
declare const index$9_parseLoggerOptions: typeof parseLoggerOptions;
|
|
16073
|
-
declare namespace index$9 {
|
|
16074
|
-
export {
|
|
16075
|
-
index$9_Level as Level,
|
|
16076
|
-
index$9_Logger as Logger,
|
|
16077
|
-
index$9_parseLoggerOptions as parseLoggerOptions,
|
|
16078
|
-
};
|
|
16079
|
-
}
|
|
16080
|
-
|
|
16081
16084
|
declare enum ProgramDecoderError {
|
|
16082
16085
|
InvalidProgramError = 0,
|
|
16083
16086
|
}
|
|
@@ -16160,6 +16163,8 @@ type InterpreterOptions = {
|
|
|
16160
16163
|
useSbrkGas?: boolean;
|
|
16161
16164
|
};
|
|
16162
16165
|
|
|
16166
|
+
declare const logger = Logger.new(import.meta.filename, "pvm");
|
|
16167
|
+
|
|
16163
16168
|
declare class Interpreter {
|
|
16164
16169
|
private readonly useSbrkGas: boolean;
|
|
16165
16170
|
private registers = new Registers();
|
|
@@ -16295,6 +16300,8 @@ declare class Interpreter {
|
|
|
16295
16300
|
const argsResult = this.argsDecodingResults[argsType];
|
|
16296
16301
|
this.argsDecoder.fillArgs(this.pc, argsResult);
|
|
16297
16302
|
|
|
16303
|
+
logger.insane(`[PC: ${this.pc}] ${Instruction[currentInstruction]}`);
|
|
16304
|
+
|
|
16298
16305
|
if (!isValidInstruction) {
|
|
16299
16306
|
this.instructionResult.status = Result.PANIC;
|
|
16300
16307
|
} else {
|
|
@@ -16370,6 +16377,7 @@ declare class Interpreter {
|
|
|
16370
16377
|
this.status = Status.HOST;
|
|
16371
16378
|
break;
|
|
16372
16379
|
}
|
|
16380
|
+
logger.insane(`[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}`);
|
|
16373
16381
|
return this.status;
|
|
16374
16382
|
}
|
|
16375
16383
|
|
|
@@ -16441,13 +16449,14 @@ declare const index$8_Registers: typeof Registers;
|
|
|
16441
16449
|
type index$8_SbrkIndex = SbrkIndex;
|
|
16442
16450
|
type index$8_SmallGas = SmallGas;
|
|
16443
16451
|
declare const index$8_gasCounter: typeof gasCounter;
|
|
16452
|
+
declare const index$8_logger: typeof logger;
|
|
16444
16453
|
declare const index$8_tryAsBigGas: typeof tryAsBigGas;
|
|
16445
16454
|
declare const index$8_tryAsGas: typeof tryAsGas;
|
|
16446
16455
|
declare const index$8_tryAsMemoryIndex: typeof tryAsMemoryIndex;
|
|
16447
16456
|
declare const index$8_tryAsSbrkIndex: typeof tryAsSbrkIndex;
|
|
16448
16457
|
declare const index$8_tryAsSmallGas: typeof tryAsSmallGas;
|
|
16449
16458
|
declare namespace index$8 {
|
|
16450
|
-
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 };
|
|
16459
|
+
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 };
|
|
16451
16460
|
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 };
|
|
16452
16461
|
}
|
|
16453
16462
|
|
|
@@ -16585,7 +16594,7 @@ declare class HostCallsManager {
|
|
|
16585
16594
|
return `r${idx}=${value} (0x${value.toString(16)})`;
|
|
16586
16595
|
})
|
|
16587
16596
|
.join(", ");
|
|
16588
|
-
logger.
|
|
16597
|
+
logger.insane(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
|
|
16589
16598
|
}
|
|
16590
16599
|
}
|
|
16591
16600
|
|
|
@@ -16706,14 +16715,15 @@ declare class HostCalls {
|
|
|
16706
16715
|
const gasCost = typeof hostCall.gasCost === "number" ? hostCall.gasCost : hostCall.gasCost(regs);
|
|
16707
16716
|
const underflow = gas.sub(gasCost);
|
|
16708
16717
|
|
|
16718
|
+
const pcLog = `[PC: ${pvmInstance.getPC()}]`;
|
|
16709
16719
|
if (underflow) {
|
|
16710
|
-
this.hostCalls.traceHostCall(
|
|
16720
|
+
this.hostCalls.traceHostCall(`${pcLog} OOG`, index, hostCall, regs, gas.get());
|
|
16711
16721
|
return ReturnValue.fromStatus(pvmInstance.getGasConsumed(), Status.OOG);
|
|
16712
16722
|
}
|
|
16713
|
-
this.hostCalls.traceHostCall(
|
|
16723
|
+
this.hostCalls.traceHostCall(`${pcLog} Invoking`, index, hostCall, regs, gasBefore);
|
|
16714
16724
|
const result = await hostCall.execute(gas, regs, memory);
|
|
16715
16725
|
this.hostCalls.traceHostCall(
|
|
16716
|
-
result === undefined ?
|
|
16726
|
+
result === undefined ? `${pcLog} Result` : `${pcLog} Status(${PvmExecution[result]})`,
|
|
16717
16727
|
index,
|
|
16718
16728
|
hostCall,
|
|
16719
16729
|
regs,
|
|
@@ -16725,8 +16735,18 @@ declare class HostCalls {
|
|
|
16725
16735
|
return this.getReturnValue(status, pvmInstance);
|
|
16726
16736
|
}
|
|
16727
16737
|
|
|
16728
|
-
|
|
16729
|
-
|
|
16738
|
+
if (result === PvmExecution.Panic) {
|
|
16739
|
+
status = Status.PANIC;
|
|
16740
|
+
return this.getReturnValue(status, pvmInstance);
|
|
16741
|
+
}
|
|
16742
|
+
|
|
16743
|
+
if (result === undefined) {
|
|
16744
|
+
pvmInstance.runProgram();
|
|
16745
|
+
status = pvmInstance.getStatus();
|
|
16746
|
+
continue;
|
|
16747
|
+
}
|
|
16748
|
+
|
|
16749
|
+
assertNever(result);
|
|
16730
16750
|
}
|
|
16731
16751
|
}
|
|
16732
16752
|
|
package/index.js
CHANGED
|
@@ -373,6 +373,7 @@ function callCompareFunction(object) {
|
|
|
373
373
|
}
|
|
374
374
|
return object;
|
|
375
375
|
}
|
|
376
|
+
let oomWarningPrinted = false;
|
|
376
377
|
/** Deeply compare `actual` and `expected` values. */
|
|
377
378
|
function deepEqual(actual, expected, { context = [], errorsCollector, ignore = [] } = {}) {
|
|
378
379
|
const ctx = Array.isArray(context) ? context : [context];
|
|
@@ -398,12 +399,13 @@ function deepEqual(actual, expected, { context = [], errorsCollector, ignore = [
|
|
|
398
399
|
assert.strictEqual(actualDisp, expectedDisp, message);
|
|
399
400
|
}
|
|
400
401
|
catch (e) {
|
|
401
|
-
if (isOoMWorkaroundNeeded) {
|
|
402
|
+
if (isOoMWorkaroundNeeded && !oomWarningPrinted) {
|
|
402
403
|
console.warn([
|
|
403
404
|
"Stacktrace may be crappy because of a problem in nodejs.",
|
|
404
405
|
"Use older version than 22.12.0 or check this issue: https://github.com/nodejs/node/issues/57242",
|
|
405
406
|
"Maybe we do not need it anymore",
|
|
406
407
|
].join("\n"));
|
|
408
|
+
oomWarningPrinted = true;
|
|
407
409
|
}
|
|
408
410
|
throw e;
|
|
409
411
|
}
|
|
@@ -8535,31 +8537,18 @@ class ServiceAccountInfo extends WithDebug {
|
|
|
8535
8537
|
created;
|
|
8536
8538
|
lastAccumulation;
|
|
8537
8539
|
parentService;
|
|
8538
|
-
static Codec =
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
})
|
|
8551
|
-
: codec$1.Class(ServiceAccountInfo, {
|
|
8552
|
-
codeHash: codec$1.bytes(HASH_SIZE).asOpaque(),
|
|
8553
|
-
balance: codec$1.u64,
|
|
8554
|
-
accumulateMinGas: codec$1.u64.convert((x) => x, tryAsServiceGas),
|
|
8555
|
-
onTransferMinGas: codec$1.u64.convert((x) => x, tryAsServiceGas),
|
|
8556
|
-
storageUtilisationBytes: codec$1.u64,
|
|
8557
|
-
storageUtilisationCount: codec$1.u32,
|
|
8558
|
-
gratisStorage: ignoreValueWithDefault(tryAsU64(0)),
|
|
8559
|
-
created: ignoreValueWithDefault(tryAsTimeSlot(0)),
|
|
8560
|
-
lastAccumulation: ignoreValueWithDefault(tryAsTimeSlot(0)),
|
|
8561
|
-
parentService: ignoreValueWithDefault(tryAsServiceId(0)),
|
|
8562
|
-
});
|
|
8540
|
+
static Codec = codec$1.Class(ServiceAccountInfo, {
|
|
8541
|
+
codeHash: codec$1.bytes(HASH_SIZE).asOpaque(),
|
|
8542
|
+
balance: codec$1.u64,
|
|
8543
|
+
accumulateMinGas: codec$1.u64.convert((x) => x, tryAsServiceGas),
|
|
8544
|
+
onTransferMinGas: codec$1.u64.convert((x) => x, tryAsServiceGas),
|
|
8545
|
+
storageUtilisationBytes: codec$1.u64,
|
|
8546
|
+
gratisStorage: codec$1.u64,
|
|
8547
|
+
storageUtilisationCount: codec$1.u32,
|
|
8548
|
+
created: codec$1.u32.convert((x) => x, tryAsTimeSlot),
|
|
8549
|
+
lastAccumulation: codec$1.u32.convert((x) => x, tryAsTimeSlot),
|
|
8550
|
+
parentService: codec$1.u32.convert((x) => x, tryAsServiceId),
|
|
8551
|
+
});
|
|
8563
8552
|
static create(a) {
|
|
8564
8553
|
return new ServiceAccountInfo(a.codeHash, a.balance, a.accumulateMinGas, a.onTransferMinGas, a.storageUtilisationBytes, a.gratisStorage, a.storageUtilisationCount, a.created, a.lastAccumulation, a.parentService);
|
|
8565
8554
|
}
|
|
@@ -9715,7 +9704,7 @@ function legacyServiceNested(serviceId, hash) {
|
|
|
9715
9704
|
/** Serialization for particular state entries. */
|
|
9716
9705
|
var serialize;
|
|
9717
9706
|
(function (serialize) {
|
|
9718
|
-
/** C(1): https://graypaper.fluffylabs.dev/#/
|
|
9707
|
+
/** C(1): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b15013b1501?v=0.6.7 */
|
|
9719
9708
|
serialize.authPools = {
|
|
9720
9709
|
key: stateKeys.index(StateKeyIdx.Alpha),
|
|
9721
9710
|
Codec: codecPerCore(codecKnownSizeArray(codec$1.bytes(HASH_SIZE).asOpaque(), {
|
|
@@ -9725,7 +9714,7 @@ var serialize;
|
|
|
9725
9714
|
})),
|
|
9726
9715
|
extract: (s) => s.authPools,
|
|
9727
9716
|
};
|
|
9728
|
-
/** C(2): https://graypaper.fluffylabs.dev/#/
|
|
9717
|
+
/** C(2): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b31013b3101?v=0.6.7 */
|
|
9729
9718
|
serialize.authQueues = {
|
|
9730
9719
|
key: stateKeys.index(StateKeyIdx.Phi),
|
|
9731
9720
|
Codec: codecPerCore(codecFixedSizeArray(codec$1.bytes(HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE)),
|
|
@@ -9733,7 +9722,6 @@ var serialize;
|
|
|
9733
9722
|
};
|
|
9734
9723
|
/**
|
|
9735
9724
|
* C(3): Recent blocks with compatibility
|
|
9736
|
-
* https://graypaper.fluffylabs.dev/#/85129da/38cb0138cb01?v=0.6.3
|
|
9737
9725
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e013b3e01?v=0.6.7
|
|
9738
9726
|
*/
|
|
9739
9727
|
serialize.recentBlocks = {
|
|
@@ -9741,7 +9729,7 @@ var serialize;
|
|
|
9741
9729
|
Codec: RecentBlocksHistory.Codec,
|
|
9742
9730
|
extract: (s) => s.recentBlocks,
|
|
9743
9731
|
};
|
|
9744
|
-
/** C(4): https://graypaper.fluffylabs.dev/#/
|
|
9732
|
+
/** C(4): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b63013b6301?v=0.6.7 */
|
|
9745
9733
|
serialize.safrole = {
|
|
9746
9734
|
key: stateKeys.index(StateKeyIdx.Gamma),
|
|
9747
9735
|
Codec: SafroleData.Codec,
|
|
@@ -9752,55 +9740,55 @@ var serialize;
|
|
|
9752
9740
|
ticketsAccumulator: s.ticketsAccumulator,
|
|
9753
9741
|
}),
|
|
9754
9742
|
};
|
|
9755
|
-
/** C(5): https://graypaper.fluffylabs.dev/#/
|
|
9743
|
+
/** C(5): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bba013bba01?v=0.6.7 */
|
|
9756
9744
|
serialize.disputesRecords = {
|
|
9757
9745
|
key: stateKeys.index(StateKeyIdx.Psi),
|
|
9758
9746
|
Codec: DisputesRecords.Codec,
|
|
9759
9747
|
extract: (s) => s.disputesRecords,
|
|
9760
9748
|
};
|
|
9761
|
-
/** C(6): https://graypaper.fluffylabs.dev/#/
|
|
9749
|
+
/** C(6): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bf3013bf301?v=0.6.7 */
|
|
9762
9750
|
serialize.entropy = {
|
|
9763
9751
|
key: stateKeys.index(StateKeyIdx.Eta),
|
|
9764
9752
|
Codec: codecFixedSizeArray(codec$1.bytes(HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
9765
9753
|
extract: (s) => s.entropy,
|
|
9766
9754
|
};
|
|
9767
|
-
/** C(7): https://graypaper.fluffylabs.dev/#/
|
|
9755
|
+
/** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
|
|
9768
9756
|
serialize.designatedValidators = {
|
|
9769
9757
|
key: stateKeys.index(StateKeyIdx.Iota),
|
|
9770
9758
|
Codec: codecPerValidator(ValidatorData.Codec),
|
|
9771
9759
|
extract: (s) => s.designatedValidatorData,
|
|
9772
9760
|
};
|
|
9773
|
-
/** C(8): https://graypaper.fluffylabs.dev/#/
|
|
9761
|
+
/** C(8): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b0d023b0d02?v=0.6.7 */
|
|
9774
9762
|
serialize.currentValidators = {
|
|
9775
9763
|
key: stateKeys.index(StateKeyIdx.Kappa),
|
|
9776
9764
|
Codec: codecPerValidator(ValidatorData.Codec),
|
|
9777
9765
|
extract: (s) => s.currentValidatorData,
|
|
9778
9766
|
};
|
|
9779
|
-
/** C(9): https://graypaper.fluffylabs.dev/#/
|
|
9767
|
+
/** C(9): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b1a023b1a02?v=0.6.7 */
|
|
9780
9768
|
serialize.previousValidators = {
|
|
9781
9769
|
key: stateKeys.index(StateKeyIdx.Lambda),
|
|
9782
9770
|
Codec: codecPerValidator(ValidatorData.Codec),
|
|
9783
9771
|
extract: (s) => s.previousValidatorData,
|
|
9784
9772
|
};
|
|
9785
|
-
/** C(10): https://graypaper.fluffylabs.dev/#/
|
|
9773
|
+
/** C(10): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b27023b2702?v=0.6.7 */
|
|
9786
9774
|
serialize.availabilityAssignment = {
|
|
9787
9775
|
key: stateKeys.index(StateKeyIdx.Rho),
|
|
9788
9776
|
Codec: codecPerCore(codec$1.optional(AvailabilityAssignment.Codec)),
|
|
9789
9777
|
extract: (s) => s.availabilityAssignment,
|
|
9790
9778
|
};
|
|
9791
|
-
/** C(11): https://graypaper.fluffylabs.dev/#/
|
|
9779
|
+
/** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
|
|
9792
9780
|
serialize.timeslot = {
|
|
9793
9781
|
key: stateKeys.index(StateKeyIdx.Tau),
|
|
9794
9782
|
Codec: codec$1.u32.asOpaque(),
|
|
9795
9783
|
extract: (s) => s.timeslot,
|
|
9796
9784
|
};
|
|
9797
|
-
/** C(12): https://graypaper.fluffylabs.dev/#/
|
|
9785
|
+
/** C(12): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b4c023b4c02?v=0.6.7 */
|
|
9798
9786
|
serialize.privilegedServices = {
|
|
9799
9787
|
key: stateKeys.index(StateKeyIdx.Chi),
|
|
9800
9788
|
Codec: PrivilegedServices.Codec,
|
|
9801
9789
|
extract: (s) => s.privilegedServices,
|
|
9802
9790
|
};
|
|
9803
|
-
/** C(13): https://graypaper.fluffylabs.dev/#/
|
|
9791
|
+
/** C(13): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b5e023b5e02?v=0.6.7 */
|
|
9804
9792
|
serialize.statistics = {
|
|
9805
9793
|
key: stateKeys.index(StateKeyIdx.Pi),
|
|
9806
9794
|
Codec: StatisticsData.Codec,
|
|
@@ -9812,7 +9800,7 @@ var serialize;
|
|
|
9812
9800
|
Codec: codecPerEpochBlock(readonlyArray(codec$1.sequenceVarLen(NotYetAccumulatedReport.Codec))),
|
|
9813
9801
|
extract: (s) => s.accumulationQueue,
|
|
9814
9802
|
};
|
|
9815
|
-
/** C(15): https://graypaper.fluffylabs.dev/#/
|
|
9803
|
+
/** C(15): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b96023b9602?v=0.6.7 */
|
|
9816
9804
|
serialize.recentlyAccumulated = {
|
|
9817
9805
|
key: stateKeys.index(StateKeyIdx.Xi),
|
|
9818
9806
|
Codec: codecPerEpochBlock(codec$1.sequenceVarLen(codec$1.bytes(HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => HashSet.from(x))),
|
|
@@ -12842,11 +12830,12 @@ var index$a = /*#__PURE__*/Object.freeze({
|
|
|
12842
12830
|
|
|
12843
12831
|
var Level;
|
|
12844
12832
|
(function (Level) {
|
|
12845
|
-
Level[Level["
|
|
12846
|
-
Level[Level["
|
|
12847
|
-
Level[Level["
|
|
12848
|
-
Level[Level["
|
|
12849
|
-
Level[Level["
|
|
12833
|
+
Level[Level["INSANE"] = 1] = "INSANE";
|
|
12834
|
+
Level[Level["TRACE"] = 2] = "TRACE";
|
|
12835
|
+
Level[Level["LOG"] = 3] = "LOG";
|
|
12836
|
+
Level[Level["INFO"] = 4] = "INFO";
|
|
12837
|
+
Level[Level["WARN"] = 5] = "WARN";
|
|
12838
|
+
Level[Level["ERROR"] = 6] = "ERROR";
|
|
12850
12839
|
})(Level || (Level = {}));
|
|
12851
12840
|
/**
|
|
12852
12841
|
* Find a configured log level for given module.
|
|
@@ -12915,7 +12904,7 @@ function parseLoggerOptions(input, defaultLevel, workingDir) {
|
|
|
12915
12904
|
function parseLevel(lvl) {
|
|
12916
12905
|
const typedLvl = lvl === "debug" ? "LOG" : lvl.toUpperCase();
|
|
12917
12906
|
if (Level[typedLvl] === undefined) {
|
|
12918
|
-
throw new Error(`Unknown logging level: "${lvl}". Use one of "trace", "debug", "log","info", "warn", "error"`);
|
|
12907
|
+
throw new Error(`Unknown logging level: "${lvl}". Use one of "trace", "debug", "log","info", "warn", "error" or "insane"`);
|
|
12919
12908
|
}
|
|
12920
12909
|
return Level[typedLvl];
|
|
12921
12910
|
}
|
|
@@ -12931,6 +12920,10 @@ class ConsoleTransport {
|
|
|
12931
12920
|
* `minimalLevel`.
|
|
12932
12921
|
*/
|
|
12933
12922
|
static create(minimalLevel, options) {
|
|
12923
|
+
// optimised transports if we don't care about trace/log levels
|
|
12924
|
+
if (minimalLevel === Level.INSANE) {
|
|
12925
|
+
return new InsaneConsoleLogger(options);
|
|
12926
|
+
}
|
|
12934
12927
|
// optimised transports if we don't care about trace/log levels
|
|
12935
12928
|
if (minimalLevel === Level.TRACE) {
|
|
12936
12929
|
return new TraceConsoleTransport(options);
|
|
@@ -12946,30 +12939,32 @@ class ConsoleTransport {
|
|
|
12946
12939
|
constructor(options) {
|
|
12947
12940
|
this.options = options;
|
|
12948
12941
|
}
|
|
12949
|
-
|
|
12942
|
+
insane(_moduleName, _val) {
|
|
12950
12943
|
/* no-op */
|
|
12951
12944
|
}
|
|
12952
|
-
|
|
12945
|
+
trace(_moduleName, _val) {
|
|
12953
12946
|
/* no-op */
|
|
12954
12947
|
}
|
|
12955
|
-
|
|
12948
|
+
log(_moduleName, _val) {
|
|
12956
12949
|
/* no-op */
|
|
12957
12950
|
}
|
|
12958
|
-
|
|
12959
|
-
|
|
12951
|
+
info(_moduleName, _val) {
|
|
12952
|
+
/* no-op */
|
|
12953
|
+
}
|
|
12954
|
+
warn(moduleName, val) {
|
|
12955
|
+
this.push(Level.WARN, moduleName, val);
|
|
12960
12956
|
}
|
|
12961
|
-
error(moduleName,
|
|
12962
|
-
this.push(Level.ERROR, moduleName,
|
|
12957
|
+
error(moduleName, val) {
|
|
12958
|
+
this.push(Level.ERROR, moduleName, val);
|
|
12963
12959
|
}
|
|
12964
|
-
push(level, moduleName,
|
|
12965
|
-
const shortName = fileName.replace(this.options.workingDir, "");
|
|
12960
|
+
push(level, moduleName, val) {
|
|
12966
12961
|
const shortModule = moduleName.replace(this.options.workingDir, "");
|
|
12967
12962
|
const configuredLevel = findLevel(this.options, moduleName);
|
|
12968
12963
|
const lvlText = Level[level].padEnd(5);
|
|
12969
12964
|
if (level < configuredLevel) {
|
|
12970
12965
|
return;
|
|
12971
12966
|
}
|
|
12972
|
-
const msg = `${lvlText} [${shortModule}] ${val}
|
|
12967
|
+
const msg = `${lvlText} [${shortModule}] ${val}`;
|
|
12973
12968
|
if (level === Level.WARN) {
|
|
12974
12969
|
console.warn(msg);
|
|
12975
12970
|
}
|
|
@@ -12981,46 +12976,72 @@ class ConsoleTransport {
|
|
|
12981
12976
|
}
|
|
12982
12977
|
}
|
|
12983
12978
|
}
|
|
12979
|
+
/**
|
|
12980
|
+
* Insane version of console logger - supports insane level.
|
|
12981
|
+
*/
|
|
12982
|
+
class InsaneConsoleLogger extends ConsoleTransport {
|
|
12983
|
+
insane(moduleName, val) {
|
|
12984
|
+
this.push(Level.INSANE, moduleName, val);
|
|
12985
|
+
}
|
|
12986
|
+
trace(moduleName, val) {
|
|
12987
|
+
this.push(Level.TRACE, moduleName, val);
|
|
12988
|
+
}
|
|
12989
|
+
log(moduleName, val) {
|
|
12990
|
+
this.push(Level.LOG, moduleName, val);
|
|
12991
|
+
}
|
|
12992
|
+
info(moduleName, val) {
|
|
12993
|
+
this.push(Level.INFO, moduleName, val);
|
|
12994
|
+
}
|
|
12995
|
+
}
|
|
12984
12996
|
/**
|
|
12985
12997
|
* A basic version of console logger - printing everything.
|
|
12986
12998
|
*/
|
|
12987
12999
|
class TraceConsoleTransport extends ConsoleTransport {
|
|
12988
|
-
|
|
12989
|
-
|
|
13000
|
+
insane(_moduleName, _val) {
|
|
13001
|
+
/* no-op */
|
|
13002
|
+
}
|
|
13003
|
+
trace(moduleName, val) {
|
|
13004
|
+
this.push(Level.TRACE, moduleName, val);
|
|
12990
13005
|
}
|
|
12991
|
-
log(moduleName,
|
|
12992
|
-
this.push(Level.LOG, moduleName,
|
|
13006
|
+
log(moduleName, val) {
|
|
13007
|
+
this.push(Level.LOG, moduleName, val);
|
|
12993
13008
|
}
|
|
12994
|
-
info(moduleName,
|
|
12995
|
-
this.push(Level.INFO, moduleName,
|
|
13009
|
+
info(moduleName, val) {
|
|
13010
|
+
this.push(Level.INFO, moduleName, val);
|
|
12996
13011
|
}
|
|
12997
13012
|
}
|
|
12998
13013
|
/**
|
|
12999
13014
|
* An optimized version of the logger - completely ignores `TRACE` level calls.
|
|
13000
13015
|
*/
|
|
13001
13016
|
class LogConsoleTransport extends ConsoleTransport {
|
|
13002
|
-
|
|
13017
|
+
insane(_moduleName, _val) {
|
|
13003
13018
|
/* no-op */
|
|
13004
13019
|
}
|
|
13005
|
-
|
|
13006
|
-
|
|
13020
|
+
trace(_moduleName, _val) {
|
|
13021
|
+
/* no-op */
|
|
13022
|
+
}
|
|
13023
|
+
log(moduleName, val) {
|
|
13024
|
+
this.push(Level.LOG, moduleName, val);
|
|
13007
13025
|
}
|
|
13008
|
-
info(moduleName,
|
|
13009
|
-
this.push(Level.INFO, moduleName,
|
|
13026
|
+
info(moduleName, val) {
|
|
13027
|
+
this.push(Level.INFO, moduleName, val);
|
|
13010
13028
|
}
|
|
13011
13029
|
}
|
|
13012
13030
|
/**
|
|
13013
13031
|
* An optimized version of the logger - completely ignores `TRACE` & `DEBUG` level calls.
|
|
13014
13032
|
*/
|
|
13015
13033
|
class InfoConsoleTransport extends ConsoleTransport {
|
|
13016
|
-
|
|
13034
|
+
insane(_moduleName, _val) {
|
|
13035
|
+
/* no-op */
|
|
13036
|
+
}
|
|
13037
|
+
trace(_moduleName, _val) {
|
|
13017
13038
|
/* no-op */
|
|
13018
13039
|
}
|
|
13019
|
-
log(_moduleName,
|
|
13040
|
+
log(_moduleName, _val) {
|
|
13020
13041
|
/* no-op */
|
|
13021
13042
|
}
|
|
13022
|
-
info(moduleName,
|
|
13023
|
-
this.push(Level.INFO, moduleName,
|
|
13043
|
+
info(moduleName, val) {
|
|
13044
|
+
this.push(Level.INFO, moduleName, val);
|
|
13024
13045
|
}
|
|
13025
13046
|
}
|
|
13026
13047
|
|
|
@@ -13093,25 +13114,29 @@ class Logger {
|
|
|
13093
13114
|
this.fileName = fileName;
|
|
13094
13115
|
this.config = config;
|
|
13095
13116
|
}
|
|
13117
|
+
/** Log a message with `INSANE` level. */
|
|
13118
|
+
insane(val) {
|
|
13119
|
+
this.config.transport.insane(this.moduleName, val);
|
|
13120
|
+
}
|
|
13096
13121
|
/** Log a message with `TRACE` level. */
|
|
13097
13122
|
trace(val) {
|
|
13098
|
-
this.config.transport.trace(this.moduleName,
|
|
13123
|
+
this.config.transport.trace(this.moduleName, val);
|
|
13099
13124
|
}
|
|
13100
13125
|
/** Log a message with `DEBUG`/`LOG` level. */
|
|
13101
13126
|
log(val) {
|
|
13102
|
-
this.config.transport.log(this.moduleName,
|
|
13127
|
+
this.config.transport.log(this.moduleName, val);
|
|
13103
13128
|
}
|
|
13104
13129
|
/** Log a message with `INFO` level. */
|
|
13105
13130
|
info(val) {
|
|
13106
|
-
this.config.transport.info(this.moduleName,
|
|
13131
|
+
this.config.transport.info(this.moduleName, val);
|
|
13107
13132
|
}
|
|
13108
13133
|
/** Log a message with `WARN` level. */
|
|
13109
13134
|
warn(val) {
|
|
13110
|
-
this.config.transport.warn(this.moduleName,
|
|
13135
|
+
this.config.transport.warn(this.moduleName, val);
|
|
13111
13136
|
}
|
|
13112
13137
|
/** Log a message with `ERROR` level. */
|
|
13113
13138
|
error(val) {
|
|
13114
|
-
this.config.transport.error(this.moduleName,
|
|
13139
|
+
this.config.transport.error(this.moduleName, val);
|
|
13115
13140
|
}
|
|
13116
13141
|
}
|
|
13117
13142
|
|
|
@@ -14667,6 +14692,7 @@ var AccessType;
|
|
|
14667
14692
|
AccessType[AccessType["READ"] = 0] = "READ";
|
|
14668
14693
|
AccessType[AccessType["WRITE"] = 1] = "WRITE";
|
|
14669
14694
|
})(AccessType || (AccessType = {}));
|
|
14695
|
+
const logger$3 = Logger.new(undefined, "pvm:mem");
|
|
14670
14696
|
class Memory {
|
|
14671
14697
|
sbrkIndex;
|
|
14672
14698
|
virtualSbrkIndex;
|
|
@@ -14697,6 +14723,7 @@ class Memory {
|
|
|
14697
14723
|
if (bytes.length === 0) {
|
|
14698
14724
|
return Result$1.ok(OK);
|
|
14699
14725
|
}
|
|
14726
|
+
logger$3.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
|
|
14700
14727
|
const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
|
|
14701
14728
|
if (pagesResult.isError) {
|
|
14702
14729
|
return Result$1.error(pagesResult.error);
|
|
@@ -14763,6 +14790,7 @@ class Memory {
|
|
|
14763
14790
|
currentPosition += bytesToRead;
|
|
14764
14791
|
bytesLeft -= bytesToRead;
|
|
14765
14792
|
}
|
|
14793
|
+
logger$3.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
|
|
14766
14794
|
return Result$1.ok(OK);
|
|
14767
14795
|
}
|
|
14768
14796
|
sbrk(length) {
|
|
@@ -16492,12 +16520,15 @@ class JumpTable {
|
|
|
16492
16520
|
static empty() {
|
|
16493
16521
|
return new JumpTable(0, new Uint8Array());
|
|
16494
16522
|
}
|
|
16523
|
+
getSize() {
|
|
16524
|
+
return this.indices.length;
|
|
16525
|
+
}
|
|
16495
16526
|
copyFrom(jt) {
|
|
16496
16527
|
this.indices = jt.indices;
|
|
16497
16528
|
}
|
|
16498
16529
|
}
|
|
16499
16530
|
|
|
16500
|
-
const logger$
|
|
16531
|
+
const logger$2 = Logger.new(undefined, "pvm-interpreter");
|
|
16501
16532
|
var ProgramDecoderError;
|
|
16502
16533
|
(function (ProgramDecoderError) {
|
|
16503
16534
|
ProgramDecoderError[ProgramDecoderError["InvalidProgramError"] = 0] = "InvalidProgramError";
|
|
@@ -16547,12 +16578,13 @@ class ProgramDecoder {
|
|
|
16547
16578
|
return Result$1.ok(new ProgramDecoder(program));
|
|
16548
16579
|
}
|
|
16549
16580
|
catch (e) {
|
|
16550
|
-
logger$
|
|
16581
|
+
logger$2.error(`Invalid program: ${e}`);
|
|
16551
16582
|
return Result$1.error(ProgramDecoderError.InvalidProgramError);
|
|
16552
16583
|
}
|
|
16553
16584
|
}
|
|
16554
16585
|
}
|
|
16555
16586
|
|
|
16587
|
+
const logger$1 = Logger.new(undefined, "pvm");
|
|
16556
16588
|
class Interpreter {
|
|
16557
16589
|
useSbrkGas;
|
|
16558
16590
|
registers = new Registers();
|
|
@@ -16670,6 +16702,7 @@ class Interpreter {
|
|
|
16670
16702
|
const argsType = instructionArgumentTypeMap[currentInstruction] ?? ArgumentType.NO_ARGUMENTS;
|
|
16671
16703
|
const argsResult = this.argsDecodingResults[argsType];
|
|
16672
16704
|
this.argsDecoder.fillArgs(this.pc, argsResult);
|
|
16705
|
+
logger$1.insane(`[PC: ${this.pc}] ${Instruction[currentInstruction]}`);
|
|
16673
16706
|
if (!isValidInstruction) {
|
|
16674
16707
|
this.instructionResult.status = Result.PANIC;
|
|
16675
16708
|
}
|
|
@@ -16741,6 +16774,7 @@ class Interpreter {
|
|
|
16741
16774
|
this.status = Status.HOST;
|
|
16742
16775
|
break;
|
|
16743
16776
|
}
|
|
16777
|
+
logger$1.insane(`[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}`);
|
|
16744
16778
|
return this.status;
|
|
16745
16779
|
}
|
|
16746
16780
|
this.pc = this.instructionResult.nextPc;
|
|
@@ -17163,19 +17197,28 @@ class HostCalls {
|
|
|
17163
17197
|
const gasBefore = gas.get();
|
|
17164
17198
|
const gasCost = typeof hostCall.gasCost === "number" ? hostCall.gasCost : hostCall.gasCost(regs);
|
|
17165
17199
|
const underflow = gas.sub(gasCost);
|
|
17200
|
+
const pcLog = `[PC: ${pvmInstance.getPC()}]`;
|
|
17166
17201
|
if (underflow) {
|
|
17167
|
-
this.hostCalls.traceHostCall(
|
|
17202
|
+
this.hostCalls.traceHostCall(`${pcLog} OOG`, index, hostCall, regs, gas.get());
|
|
17168
17203
|
return ReturnValue.fromStatus(pvmInstance.getGasConsumed(), Status.OOG);
|
|
17169
17204
|
}
|
|
17170
|
-
this.hostCalls.traceHostCall(
|
|
17205
|
+
this.hostCalls.traceHostCall(`${pcLog} Invoking`, index, hostCall, regs, gasBefore);
|
|
17171
17206
|
const result = await hostCall.execute(gas, regs, memory);
|
|
17172
|
-
this.hostCalls.traceHostCall(result === undefined ?
|
|
17207
|
+
this.hostCalls.traceHostCall(result === undefined ? `${pcLog} Result` : `${pcLog} Status(${PvmExecution[result]})`, index, hostCall, regs, gas.get());
|
|
17173
17208
|
if (result === PvmExecution.Halt) {
|
|
17174
17209
|
status = Status.HALT;
|
|
17175
17210
|
return this.getReturnValue(status, pvmInstance);
|
|
17176
17211
|
}
|
|
17177
|
-
|
|
17178
|
-
|
|
17212
|
+
if (result === PvmExecution.Panic) {
|
|
17213
|
+
status = Status.PANIC;
|
|
17214
|
+
return this.getReturnValue(status, pvmInstance);
|
|
17215
|
+
}
|
|
17216
|
+
if (result === undefined) {
|
|
17217
|
+
pvmInstance.runProgram();
|
|
17218
|
+
status = pvmInstance.getStatus();
|
|
17219
|
+
continue;
|
|
17220
|
+
}
|
|
17221
|
+
assertNever(result);
|
|
17179
17222
|
}
|
|
17180
17223
|
}
|
|
17181
17224
|
async runProgram(rawProgram, initialPc, initialGas, maybeRegisters, maybeMemory) {
|
|
@@ -17245,7 +17288,7 @@ class HostCallsManager {
|
|
|
17245
17288
|
return `r${idx}=${value} (0x${value.toString(16)})`;
|
|
17246
17289
|
})
|
|
17247
17290
|
.join(", ");
|
|
17248
|
-
logger.
|
|
17291
|
+
logger.insane(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
|
|
17249
17292
|
}
|
|
17250
17293
|
}
|
|
17251
17294
|
|