@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.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
|
}
|
|
@@ -8201,16 +8203,7 @@ class PrivilegedServices {
|
|
|
8201
8203
|
autoAccumulateServices;
|
|
8202
8204
|
static Codec = codec$1.Class(PrivilegedServices, {
|
|
8203
8205
|
manager: codec$1.u32.asOpaque(),
|
|
8204
|
-
authManager:
|
|
8205
|
-
? codecPerCore(codec$1.u32.asOpaque())
|
|
8206
|
-
: codecWithContext((ctx) => codec$1.u32.asOpaque().convert(
|
|
8207
|
-
// NOTE: [MaSo] In a compatibility mode we are always updating all entries
|
|
8208
|
-
// (all the entries are the same)
|
|
8209
|
-
// so it doesn't matter which one we take here.
|
|
8210
|
-
(perCore) => perCore[0], (serviceId) => {
|
|
8211
|
-
const array = new Array(ctx.coresCount).fill(serviceId);
|
|
8212
|
-
return tryAsPerCore(array, ctx);
|
|
8213
|
-
})),
|
|
8206
|
+
authManager: codecPerCore(codec$1.u32.asOpaque()),
|
|
8214
8207
|
validatorsManager: codec$1.u32.asOpaque(),
|
|
8215
8208
|
autoAccumulateServices: readonlyArray(codec$1.sequenceVarLen(AutoAccumulate.Codec)),
|
|
8216
8209
|
});
|
|
@@ -8555,7 +8548,6 @@ class ServiceAccountInfo extends WithDebug {
|
|
|
8555
8548
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/119e01119e01?v=0.6.7
|
|
8556
8549
|
*/
|
|
8557
8550
|
static calculateThresholdBalance(items, bytes, gratisStorage) {
|
|
8558
|
-
check(gratisStorage === tryAsU64(0) || Compatibility.isGreaterOrEqual(GpVersion.V0_6_7), "Gratis storage cannot be non-zero before 0.6.7");
|
|
8559
8551
|
const storageCost = BASE_SERVICE_BALANCE + ELECTIVE_ITEM_BALANCE * BigInt(items) + ELECTIVE_BYTE_BALANCE * bytes - gratisStorage;
|
|
8560
8552
|
if (storageCost < 0n) {
|
|
8561
8553
|
return tryAsU64(0);
|
|
@@ -9867,26 +9859,17 @@ function* serializeRemovedServices(servicesRemoved) {
|
|
|
9867
9859
|
yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
9868
9860
|
}
|
|
9869
9861
|
}
|
|
9870
|
-
function getLegacyKey(serviceId, rawKey) {
|
|
9871
|
-
const SERVICE_ID_BYTES = 4;
|
|
9872
|
-
const serviceIdAndKey = new Uint8Array(SERVICE_ID_BYTES + rawKey.length);
|
|
9873
|
-
serviceIdAndKey.set(u32AsLeBytes(serviceId));
|
|
9874
|
-
serviceIdAndKey.set(rawKey.raw, SERVICE_ID_BYTES);
|
|
9875
|
-
return asOpaqueType(BytesBlob.blobFrom(hashBytes(serviceIdAndKey).raw));
|
|
9876
|
-
}
|
|
9877
9862
|
function* serializeStorage(storage) {
|
|
9878
9863
|
for (const { action, serviceId } of storage ?? []) {
|
|
9879
9864
|
switch (action.kind) {
|
|
9880
9865
|
case UpdateStorageKind.Set: {
|
|
9881
|
-
const key =
|
|
9882
|
-
? action.storage.key
|
|
9883
|
-
: getLegacyKey(serviceId, action.storage.key);
|
|
9866
|
+
const key = action.storage.key;
|
|
9884
9867
|
const codec = serialize.serviceStorage(serviceId, key);
|
|
9885
9868
|
yield [StateEntryUpdateAction.Insert, codec.key, action.storage.value];
|
|
9886
9869
|
break;
|
|
9887
9870
|
}
|
|
9888
9871
|
case UpdateStorageKind.Remove: {
|
|
9889
|
-
const key =
|
|
9872
|
+
const key = action.key;
|
|
9890
9873
|
const codec = serialize.serviceStorage(serviceId, key);
|
|
9891
9874
|
yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
9892
9875
|
break;
|
|
@@ -9995,7 +9978,7 @@ function* serializeBasicKeys(spec, update) {
|
|
|
9995
9978
|
if (update.recentlyAccumulated !== undefined) {
|
|
9996
9979
|
yield doSerialize(update.recentlyAccumulated, serialize.recentlyAccumulated); // C(15)
|
|
9997
9980
|
}
|
|
9998
|
-
if (update.accumulationOutputLog !== undefined
|
|
9981
|
+
if (update.accumulationOutputLog !== undefined) {
|
|
9999
9982
|
yield doSerialize(update.accumulationOutputLog, serialize.accumulationOutputLog); // C(16)
|
|
10000
9983
|
}
|
|
10001
9984
|
}
|
|
@@ -10135,10 +10118,7 @@ class SerializedState {
|
|
|
10135
10118
|
return this.retrieve(serialize.privilegedServices, "privilegedServices");
|
|
10136
10119
|
}
|
|
10137
10120
|
get accumulationOutputLog() {
|
|
10138
|
-
|
|
10139
|
-
return this.retrieve(serialize.accumulationOutputLog, "accumulationOutputLog");
|
|
10140
|
-
}
|
|
10141
|
-
return [];
|
|
10121
|
+
return this.retrieve(serialize.accumulationOutputLog, "accumulationOutputLog");
|
|
10142
10122
|
}
|
|
10143
10123
|
}
|
|
10144
10124
|
/** Service data representation on a serialized state. */
|
|
@@ -10839,9 +10819,7 @@ function convertInMemoryStateToDictionary(spec, state) {
|
|
|
10839
10819
|
doSerialize(serialize.statistics); // C(13)
|
|
10840
10820
|
doSerialize(serialize.accumulationQueue); // C(14)
|
|
10841
10821
|
doSerialize(serialize.recentlyAccumulated); // C(15)
|
|
10842
|
-
|
|
10843
|
-
doSerialize(serialize.accumulationOutputLog); // C(16)
|
|
10844
|
-
}
|
|
10822
|
+
doSerialize(serialize.accumulationOutputLog); // C(16)
|
|
10845
10823
|
// services
|
|
10846
10824
|
for (const [serviceId, service] of state.services.entries()) {
|
|
10847
10825
|
// data
|
|
@@ -12828,11 +12806,12 @@ var index$a = /*#__PURE__*/Object.freeze({
|
|
|
12828
12806
|
|
|
12829
12807
|
var Level;
|
|
12830
12808
|
(function (Level) {
|
|
12831
|
-
Level[Level["
|
|
12832
|
-
Level[Level["
|
|
12833
|
-
Level[Level["
|
|
12834
|
-
Level[Level["
|
|
12835
|
-
Level[Level["
|
|
12809
|
+
Level[Level["INSANE"] = 1] = "INSANE";
|
|
12810
|
+
Level[Level["TRACE"] = 2] = "TRACE";
|
|
12811
|
+
Level[Level["LOG"] = 3] = "LOG";
|
|
12812
|
+
Level[Level["INFO"] = 4] = "INFO";
|
|
12813
|
+
Level[Level["WARN"] = 5] = "WARN";
|
|
12814
|
+
Level[Level["ERROR"] = 6] = "ERROR";
|
|
12836
12815
|
})(Level || (Level = {}));
|
|
12837
12816
|
/**
|
|
12838
12817
|
* Find a configured log level for given module.
|
|
@@ -12901,7 +12880,7 @@ function parseLoggerOptions(input, defaultLevel, workingDir) {
|
|
|
12901
12880
|
function parseLevel(lvl) {
|
|
12902
12881
|
const typedLvl = lvl === "debug" ? "LOG" : lvl.toUpperCase();
|
|
12903
12882
|
if (Level[typedLvl] === undefined) {
|
|
12904
|
-
throw new Error(`Unknown logging level: "${lvl}". Use one of "trace", "debug", "log","info", "warn", "error"`);
|
|
12883
|
+
throw new Error(`Unknown logging level: "${lvl}". Use one of "trace", "debug", "log","info", "warn", "error" or "insane"`);
|
|
12905
12884
|
}
|
|
12906
12885
|
return Level[typedLvl];
|
|
12907
12886
|
}
|
|
@@ -12917,6 +12896,10 @@ class ConsoleTransport {
|
|
|
12917
12896
|
* `minimalLevel`.
|
|
12918
12897
|
*/
|
|
12919
12898
|
static create(minimalLevel, options) {
|
|
12899
|
+
// optimised transports if we don't care about trace/log levels
|
|
12900
|
+
if (minimalLevel === Level.INSANE) {
|
|
12901
|
+
return new InsaneConsoleLogger(options);
|
|
12902
|
+
}
|
|
12920
12903
|
// optimised transports if we don't care about trace/log levels
|
|
12921
12904
|
if (minimalLevel === Level.TRACE) {
|
|
12922
12905
|
return new TraceConsoleTransport(options);
|
|
@@ -12932,30 +12915,32 @@ class ConsoleTransport {
|
|
|
12932
12915
|
constructor(options) {
|
|
12933
12916
|
this.options = options;
|
|
12934
12917
|
}
|
|
12935
|
-
|
|
12918
|
+
insane(_moduleName, _val) {
|
|
12919
|
+
/* no-op */
|
|
12920
|
+
}
|
|
12921
|
+
trace(_moduleName, _val) {
|
|
12936
12922
|
/* no-op */
|
|
12937
12923
|
}
|
|
12938
|
-
log(_moduleName,
|
|
12924
|
+
log(_moduleName, _val) {
|
|
12939
12925
|
/* no-op */
|
|
12940
12926
|
}
|
|
12941
|
-
info(_moduleName,
|
|
12927
|
+
info(_moduleName, _val) {
|
|
12942
12928
|
/* no-op */
|
|
12943
12929
|
}
|
|
12944
|
-
warn(moduleName,
|
|
12945
|
-
this.push(Level.WARN, moduleName,
|
|
12930
|
+
warn(moduleName, val) {
|
|
12931
|
+
this.push(Level.WARN, moduleName, val);
|
|
12946
12932
|
}
|
|
12947
|
-
error(moduleName,
|
|
12948
|
-
this.push(Level.ERROR, moduleName,
|
|
12933
|
+
error(moduleName, val) {
|
|
12934
|
+
this.push(Level.ERROR, moduleName, val);
|
|
12949
12935
|
}
|
|
12950
|
-
push(level, moduleName,
|
|
12951
|
-
const shortName = fileName.replace(this.options.workingDir, "");
|
|
12936
|
+
push(level, moduleName, val) {
|
|
12952
12937
|
const shortModule = moduleName.replace(this.options.workingDir, "");
|
|
12953
12938
|
const configuredLevel = findLevel(this.options, moduleName);
|
|
12954
12939
|
const lvlText = Level[level].padEnd(5);
|
|
12955
12940
|
if (level < configuredLevel) {
|
|
12956
12941
|
return;
|
|
12957
12942
|
}
|
|
12958
|
-
const msg = `${lvlText} [${shortModule}] ${val}
|
|
12943
|
+
const msg = `${lvlText} [${shortModule}] ${val}`;
|
|
12959
12944
|
if (level === Level.WARN) {
|
|
12960
12945
|
console.warn(msg);
|
|
12961
12946
|
}
|
|
@@ -12967,46 +12952,72 @@ class ConsoleTransport {
|
|
|
12967
12952
|
}
|
|
12968
12953
|
}
|
|
12969
12954
|
}
|
|
12955
|
+
/**
|
|
12956
|
+
* Insane version of console logger - supports insane level.
|
|
12957
|
+
*/
|
|
12958
|
+
class InsaneConsoleLogger extends ConsoleTransport {
|
|
12959
|
+
insane(moduleName, val) {
|
|
12960
|
+
this.push(Level.INSANE, moduleName, val);
|
|
12961
|
+
}
|
|
12962
|
+
trace(moduleName, val) {
|
|
12963
|
+
this.push(Level.TRACE, moduleName, val);
|
|
12964
|
+
}
|
|
12965
|
+
log(moduleName, val) {
|
|
12966
|
+
this.push(Level.LOG, moduleName, val);
|
|
12967
|
+
}
|
|
12968
|
+
info(moduleName, val) {
|
|
12969
|
+
this.push(Level.INFO, moduleName, val);
|
|
12970
|
+
}
|
|
12971
|
+
}
|
|
12970
12972
|
/**
|
|
12971
12973
|
* A basic version of console logger - printing everything.
|
|
12972
12974
|
*/
|
|
12973
12975
|
class TraceConsoleTransport extends ConsoleTransport {
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
+
insane(_moduleName, _val) {
|
|
12977
|
+
/* no-op */
|
|
12976
12978
|
}
|
|
12977
|
-
|
|
12978
|
-
this.push(Level.
|
|
12979
|
+
trace(moduleName, val) {
|
|
12980
|
+
this.push(Level.TRACE, moduleName, val);
|
|
12979
12981
|
}
|
|
12980
|
-
|
|
12981
|
-
this.push(Level.
|
|
12982
|
+
log(moduleName, val) {
|
|
12983
|
+
this.push(Level.LOG, moduleName, val);
|
|
12984
|
+
}
|
|
12985
|
+
info(moduleName, val) {
|
|
12986
|
+
this.push(Level.INFO, moduleName, val);
|
|
12982
12987
|
}
|
|
12983
12988
|
}
|
|
12984
12989
|
/**
|
|
12985
12990
|
* An optimized version of the logger - completely ignores `TRACE` level calls.
|
|
12986
12991
|
*/
|
|
12987
12992
|
class LogConsoleTransport extends ConsoleTransport {
|
|
12988
|
-
|
|
12993
|
+
insane(_moduleName, _val) {
|
|
12994
|
+
/* no-op */
|
|
12995
|
+
}
|
|
12996
|
+
trace(_moduleName, _val) {
|
|
12989
12997
|
/* no-op */
|
|
12990
12998
|
}
|
|
12991
|
-
log(moduleName,
|
|
12992
|
-
this.push(Level.LOG, moduleName,
|
|
12999
|
+
log(moduleName, val) {
|
|
13000
|
+
this.push(Level.LOG, moduleName, val);
|
|
12993
13001
|
}
|
|
12994
|
-
info(moduleName,
|
|
12995
|
-
this.push(Level.INFO, moduleName,
|
|
13002
|
+
info(moduleName, val) {
|
|
13003
|
+
this.push(Level.INFO, moduleName, val);
|
|
12996
13004
|
}
|
|
12997
13005
|
}
|
|
12998
13006
|
/**
|
|
12999
13007
|
* An optimized version of the logger - completely ignores `TRACE` & `DEBUG` level calls.
|
|
13000
13008
|
*/
|
|
13001
13009
|
class InfoConsoleTransport extends ConsoleTransport {
|
|
13002
|
-
|
|
13010
|
+
insane(_moduleName, _val) {
|
|
13003
13011
|
/* no-op */
|
|
13004
13012
|
}
|
|
13005
|
-
|
|
13013
|
+
trace(_moduleName, _val) {
|
|
13006
13014
|
/* no-op */
|
|
13007
13015
|
}
|
|
13008
|
-
|
|
13009
|
-
|
|
13016
|
+
log(_moduleName, _val) {
|
|
13017
|
+
/* no-op */
|
|
13018
|
+
}
|
|
13019
|
+
info(moduleName, val) {
|
|
13020
|
+
this.push(Level.INFO, moduleName, val);
|
|
13010
13021
|
}
|
|
13011
13022
|
}
|
|
13012
13023
|
|
|
@@ -13079,25 +13090,29 @@ class Logger {
|
|
|
13079
13090
|
this.fileName = fileName;
|
|
13080
13091
|
this.config = config;
|
|
13081
13092
|
}
|
|
13093
|
+
/** Log a message with `INSANE` level. */
|
|
13094
|
+
insane(val) {
|
|
13095
|
+
this.config.transport.insane(this.moduleName, val);
|
|
13096
|
+
}
|
|
13082
13097
|
/** Log a message with `TRACE` level. */
|
|
13083
13098
|
trace(val) {
|
|
13084
|
-
this.config.transport.trace(this.moduleName,
|
|
13099
|
+
this.config.transport.trace(this.moduleName, val);
|
|
13085
13100
|
}
|
|
13086
13101
|
/** Log a message with `DEBUG`/`LOG` level. */
|
|
13087
13102
|
log(val) {
|
|
13088
|
-
this.config.transport.log(this.moduleName,
|
|
13103
|
+
this.config.transport.log(this.moduleName, val);
|
|
13089
13104
|
}
|
|
13090
13105
|
/** Log a message with `INFO` level. */
|
|
13091
13106
|
info(val) {
|
|
13092
|
-
this.config.transport.info(this.moduleName,
|
|
13107
|
+
this.config.transport.info(this.moduleName, val);
|
|
13093
13108
|
}
|
|
13094
13109
|
/** Log a message with `WARN` level. */
|
|
13095
13110
|
warn(val) {
|
|
13096
|
-
this.config.transport.warn(this.moduleName,
|
|
13111
|
+
this.config.transport.warn(this.moduleName, val);
|
|
13097
13112
|
}
|
|
13098
13113
|
/** Log a message with `ERROR` level. */
|
|
13099
13114
|
error(val) {
|
|
13100
|
-
this.config.transport.error(this.moduleName,
|
|
13115
|
+
this.config.transport.error(this.moduleName, val);
|
|
13101
13116
|
}
|
|
13102
13117
|
}
|
|
13103
13118
|
|
|
@@ -14653,6 +14668,7 @@ var AccessType;
|
|
|
14653
14668
|
AccessType[AccessType["READ"] = 0] = "READ";
|
|
14654
14669
|
AccessType[AccessType["WRITE"] = 1] = "WRITE";
|
|
14655
14670
|
})(AccessType || (AccessType = {}));
|
|
14671
|
+
const logger$3 = Logger.new(undefined, "pvm:mem");
|
|
14656
14672
|
class Memory {
|
|
14657
14673
|
sbrkIndex;
|
|
14658
14674
|
virtualSbrkIndex;
|
|
@@ -14683,6 +14699,7 @@ class Memory {
|
|
|
14683
14699
|
if (bytes.length === 0) {
|
|
14684
14700
|
return Result$1.ok(OK);
|
|
14685
14701
|
}
|
|
14702
|
+
logger$3.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
|
|
14686
14703
|
const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
|
|
14687
14704
|
if (pagesResult.isError) {
|
|
14688
14705
|
return Result$1.error(pagesResult.error);
|
|
@@ -14749,6 +14766,7 @@ class Memory {
|
|
|
14749
14766
|
currentPosition += bytesToRead;
|
|
14750
14767
|
bytesLeft -= bytesToRead;
|
|
14751
14768
|
}
|
|
14769
|
+
logger$3.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
|
|
14752
14770
|
return Result$1.ok(OK);
|
|
14753
14771
|
}
|
|
14754
14772
|
sbrk(length) {
|
|
@@ -16478,12 +16496,15 @@ class JumpTable {
|
|
|
16478
16496
|
static empty() {
|
|
16479
16497
|
return new JumpTable(0, new Uint8Array());
|
|
16480
16498
|
}
|
|
16499
|
+
getSize() {
|
|
16500
|
+
return this.indices.length;
|
|
16501
|
+
}
|
|
16481
16502
|
copyFrom(jt) {
|
|
16482
16503
|
this.indices = jt.indices;
|
|
16483
16504
|
}
|
|
16484
16505
|
}
|
|
16485
16506
|
|
|
16486
|
-
const logger$
|
|
16507
|
+
const logger$2 = Logger.new(undefined, "pvm-interpreter");
|
|
16487
16508
|
var ProgramDecoderError;
|
|
16488
16509
|
(function (ProgramDecoderError) {
|
|
16489
16510
|
ProgramDecoderError[ProgramDecoderError["InvalidProgramError"] = 0] = "InvalidProgramError";
|
|
@@ -16533,12 +16554,13 @@ class ProgramDecoder {
|
|
|
16533
16554
|
return Result$1.ok(new ProgramDecoder(program));
|
|
16534
16555
|
}
|
|
16535
16556
|
catch (e) {
|
|
16536
|
-
logger$
|
|
16557
|
+
logger$2.error(`Invalid program: ${e}`);
|
|
16537
16558
|
return Result$1.error(ProgramDecoderError.InvalidProgramError);
|
|
16538
16559
|
}
|
|
16539
16560
|
}
|
|
16540
16561
|
}
|
|
16541
16562
|
|
|
16563
|
+
const logger$1 = Logger.new(undefined, "pvm");
|
|
16542
16564
|
class Interpreter {
|
|
16543
16565
|
useSbrkGas;
|
|
16544
16566
|
registers = new Registers();
|
|
@@ -16656,6 +16678,7 @@ class Interpreter {
|
|
|
16656
16678
|
const argsType = instructionArgumentTypeMap[currentInstruction] ?? ArgumentType.NO_ARGUMENTS;
|
|
16657
16679
|
const argsResult = this.argsDecodingResults[argsType];
|
|
16658
16680
|
this.argsDecoder.fillArgs(this.pc, argsResult);
|
|
16681
|
+
logger$1.insane(`[PC: ${this.pc}] ${Instruction[currentInstruction]}`);
|
|
16659
16682
|
if (!isValidInstruction) {
|
|
16660
16683
|
this.instructionResult.status = Result.PANIC;
|
|
16661
16684
|
}
|
|
@@ -16727,6 +16750,7 @@ class Interpreter {
|
|
|
16727
16750
|
this.status = Status.HOST;
|
|
16728
16751
|
break;
|
|
16729
16752
|
}
|
|
16753
|
+
logger$1.insane(`[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}`);
|
|
16730
16754
|
return this.status;
|
|
16731
16755
|
}
|
|
16732
16756
|
this.pc = this.instructionResult.nextPc;
|
|
@@ -17149,13 +17173,14 @@ class HostCalls {
|
|
|
17149
17173
|
const gasBefore = gas.get();
|
|
17150
17174
|
const gasCost = typeof hostCall.gasCost === "number" ? hostCall.gasCost : hostCall.gasCost(regs);
|
|
17151
17175
|
const underflow = gas.sub(gasCost);
|
|
17176
|
+
const pcLog = `[PC: ${pvmInstance.getPC()}]`;
|
|
17152
17177
|
if (underflow) {
|
|
17153
|
-
this.hostCalls.traceHostCall(
|
|
17178
|
+
this.hostCalls.traceHostCall(`${pcLog} OOG`, index, hostCall, regs, gas.get());
|
|
17154
17179
|
return ReturnValue.fromStatus(pvmInstance.getGasConsumed(), Status.OOG);
|
|
17155
17180
|
}
|
|
17156
|
-
this.hostCalls.traceHostCall(
|
|
17181
|
+
this.hostCalls.traceHostCall(`${pcLog} Invoking`, index, hostCall, regs, gasBefore);
|
|
17157
17182
|
const result = await hostCall.execute(gas, regs, memory);
|
|
17158
|
-
this.hostCalls.traceHostCall(result === undefined ?
|
|
17183
|
+
this.hostCalls.traceHostCall(result === undefined ? `${pcLog} Result` : `${pcLog} Status(${PvmExecution[result]})`, index, hostCall, regs, gas.get());
|
|
17159
17184
|
if (result === PvmExecution.Halt) {
|
|
17160
17185
|
status = Status.HALT;
|
|
17161
17186
|
return this.getReturnValue(status, pvmInstance);
|
|
@@ -17239,7 +17264,7 @@ class HostCallsManager {
|
|
|
17239
17264
|
return `r${idx}=${value} (0x${value.toString(16)})`;
|
|
17240
17265
|
})
|
|
17241
17266
|
.join(", ");
|
|
17242
|
-
logger.
|
|
17267
|
+
logger.insane(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
|
|
17243
17268
|
}
|
|
17244
17269
|
}
|
|
17245
17270
|
|
|
@@ -17372,36 +17397,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
17372
17397
|
fisherYatesShuffle: fisherYatesShuffle
|
|
17373
17398
|
});
|
|
17374
17399
|
|
|
17375
|
-
class
|
|
17376
|
-
static fromJson = json.object({
|
|
17377
|
-
code_hash: fromJson.bytes32(),
|
|
17378
|
-
balance: json.fromNumber((x) => tryAsU64(x)),
|
|
17379
|
-
min_item_gas: json.fromNumber((x) => tryAsServiceGas(x)),
|
|
17380
|
-
min_memo_gas: json.fromNumber((x) => tryAsServiceGas(x)),
|
|
17381
|
-
bytes: json.fromNumber((x) => tryAsU64(x)),
|
|
17382
|
-
items: "number",
|
|
17383
|
-
}, ({ code_hash, balance, min_item_gas, min_memo_gas, bytes, items }) => {
|
|
17384
|
-
return ServiceAccountInfo.create({
|
|
17385
|
-
codeHash: code_hash,
|
|
17386
|
-
balance,
|
|
17387
|
-
accumulateMinGas: min_item_gas,
|
|
17388
|
-
onTransferMinGas: min_memo_gas,
|
|
17389
|
-
storageUtilisationBytes: bytes,
|
|
17390
|
-
storageUtilisationCount: items,
|
|
17391
|
-
gratisStorage: tryAsU64(0),
|
|
17392
|
-
created: tryAsTimeSlot(0),
|
|
17393
|
-
lastAccumulation: tryAsTimeSlot(0),
|
|
17394
|
-
parentService: tryAsServiceId(0),
|
|
17395
|
-
});
|
|
17396
|
-
});
|
|
17397
|
-
code_hash;
|
|
17398
|
-
balance;
|
|
17399
|
-
min_item_gas;
|
|
17400
|
-
min_memo_gas;
|
|
17401
|
-
bytes;
|
|
17402
|
-
items;
|
|
17403
|
-
}
|
|
17404
|
-
class JsonServiceInfo extends JsonServiceInfoPre067 {
|
|
17400
|
+
class JsonServiceInfo {
|
|
17405
17401
|
static fromJson = json.object({
|
|
17406
17402
|
code_hash: fromJson.bytes32(),
|
|
17407
17403
|
balance: json.fromNumber((x) => tryAsU64(x)),
|
|
@@ -17427,6 +17423,12 @@ class JsonServiceInfo extends JsonServiceInfoPre067 {
|
|
|
17427
17423
|
parentService: parent_service,
|
|
17428
17424
|
});
|
|
17429
17425
|
});
|
|
17426
|
+
code_hash;
|
|
17427
|
+
balance;
|
|
17428
|
+
min_item_gas;
|
|
17429
|
+
min_memo_gas;
|
|
17430
|
+
bytes;
|
|
17431
|
+
items;
|
|
17430
17432
|
creation_slot;
|
|
17431
17433
|
deposit_offset;
|
|
17432
17434
|
last_accumulation_slot;
|
|
@@ -17459,9 +17461,7 @@ class JsonService {
|
|
|
17459
17461
|
static fromJson = json.object({
|
|
17460
17462
|
id: "number",
|
|
17461
17463
|
data: {
|
|
17462
|
-
service:
|
|
17463
|
-
? JsonServiceInfo.fromJson
|
|
17464
|
-
: JsonServiceInfoPre067.fromJson,
|
|
17464
|
+
service: JsonServiceInfo.fromJson,
|
|
17465
17465
|
preimages: json.optional(json.array(JsonPreimageItem.fromJson)),
|
|
17466
17466
|
storage: json.optional(json.array(JsonStorageItem.fromJson)),
|
|
17467
17467
|
lookup_meta: json.optional(json.array(lookupMetaFromJson)),
|
|
@@ -17781,76 +17781,6 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
17781
17781
|
services: new Map(accounts.map((x) => [x.serviceId, x])),
|
|
17782
17782
|
});
|
|
17783
17783
|
});
|
|
17784
|
-
const fullStateDumpFromJsonPre067 = (spec) => json.object({
|
|
17785
|
-
alpha: json.array(json.array(fromJson.bytes32())),
|
|
17786
|
-
varphi: json.array(json.array(fromJson.bytes32())),
|
|
17787
|
-
beta: json.nullable(recentBlocksHistoryFromJson),
|
|
17788
|
-
gamma: {
|
|
17789
|
-
gamma_k: json.array(validatorDataFromJson),
|
|
17790
|
-
gamma_a: json.array(ticketFromJson),
|
|
17791
|
-
gamma_s: TicketsOrKeys.fromJson,
|
|
17792
|
-
gamma_z: json.fromString((v) => Bytes.parseBytes(v, BANDERSNATCH_RING_ROOT_BYTES).asOpaque()),
|
|
17793
|
-
},
|
|
17794
|
-
psi: disputesRecordsFromJson,
|
|
17795
|
-
eta: json.array(fromJson.bytes32()),
|
|
17796
|
-
iota: json.array(validatorDataFromJson),
|
|
17797
|
-
kappa: json.array(validatorDataFromJson),
|
|
17798
|
-
lambda: json.array(validatorDataFromJson),
|
|
17799
|
-
rho: json.array(json.nullable(availabilityAssignmentFromJson)),
|
|
17800
|
-
tau: "number",
|
|
17801
|
-
chi: {
|
|
17802
|
-
chi_m: "number",
|
|
17803
|
-
chi_a: "number",
|
|
17804
|
-
chi_v: "number",
|
|
17805
|
-
chi_g: json.nullable(json.array({
|
|
17806
|
-
service: "number",
|
|
17807
|
-
gasLimit: json.fromNumber((v) => tryAsServiceGas(v)),
|
|
17808
|
-
})),
|
|
17809
|
-
},
|
|
17810
|
-
pi: JsonStatisticsData.fromJson,
|
|
17811
|
-
theta: json.array(json.array(notYetAccumulatedFromJson)),
|
|
17812
|
-
xi: json.array(json.array(fromJson.bytes32())),
|
|
17813
|
-
accounts: json.array(JsonService.fromJson),
|
|
17814
|
-
}, ({ alpha, varphi, beta, gamma, psi, eta, iota, kappa, lambda, rho, tau, chi, pi, theta, xi, accounts, }) => {
|
|
17815
|
-
return InMemoryState.create({
|
|
17816
|
-
authPools: tryAsPerCore(alpha.map((perCore) => {
|
|
17817
|
-
if (perCore.length > MAX_AUTH_POOL_SIZE) {
|
|
17818
|
-
throw new Error(`AuthPools: expected less than ${MAX_AUTH_POOL_SIZE}, got ${perCore.length}`);
|
|
17819
|
-
}
|
|
17820
|
-
return asKnownSize(perCore);
|
|
17821
|
-
}), spec),
|
|
17822
|
-
authQueues: tryAsPerCore(varphi.map((perCore) => {
|
|
17823
|
-
if (perCore.length !== AUTHORIZATION_QUEUE_SIZE) {
|
|
17824
|
-
throw new Error(`AuthQueues: expected ${AUTHORIZATION_QUEUE_SIZE}, got: ${perCore.length}`);
|
|
17825
|
-
}
|
|
17826
|
-
return asKnownSize(perCore);
|
|
17827
|
-
}), spec),
|
|
17828
|
-
recentBlocks: beta ?? RecentBlocksHistory.empty(),
|
|
17829
|
-
nextValidatorData: gamma.gamma_k,
|
|
17830
|
-
epochRoot: gamma.gamma_z,
|
|
17831
|
-
sealingKeySeries: TicketsOrKeys.toSafroleSealingKeys(gamma.gamma_s, spec),
|
|
17832
|
-
ticketsAccumulator: gamma.gamma_a,
|
|
17833
|
-
disputesRecords: psi,
|
|
17834
|
-
entropy: eta,
|
|
17835
|
-
designatedValidatorData: iota,
|
|
17836
|
-
currentValidatorData: kappa,
|
|
17837
|
-
previousValidatorData: lambda,
|
|
17838
|
-
availabilityAssignment: rho,
|
|
17839
|
-
timeslot: tau,
|
|
17840
|
-
privilegedServices: PrivilegedServices.create({
|
|
17841
|
-
manager: chi.chi_m,
|
|
17842
|
-
authManager: tryAsPerCore(new Array(spec.coresCount).fill(chi.chi_a), spec),
|
|
17843
|
-
validatorsManager: chi.chi_v,
|
|
17844
|
-
autoAccumulateServices: chi.chi_g ?? [],
|
|
17845
|
-
}),
|
|
17846
|
-
statistics: JsonStatisticsData.toStatisticsData(spec, pi),
|
|
17847
|
-
accumulationQueue: theta,
|
|
17848
|
-
recentlyAccumulated: tryAsPerEpochBlock(xi.map((x) => HashSet.from(x)), spec),
|
|
17849
|
-
services: new Map(accounts.map((x) => [x.serviceId, x])),
|
|
17850
|
-
// NOTE Field not present in pre067, added here for compatibility reasons
|
|
17851
|
-
accumulationOutputLog: [],
|
|
17852
|
-
});
|
|
17853
|
-
});
|
|
17854
17784
|
|
|
17855
17785
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
17856
17786
|
__proto__: null,
|
|
@@ -17862,7 +17792,6 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
17862
17792
|
availabilityAssignmentFromJson: availabilityAssignmentFromJson,
|
|
17863
17793
|
disputesRecordsFromJson: disputesRecordsFromJson,
|
|
17864
17794
|
fullStateDumpFromJson: fullStateDumpFromJson,
|
|
17865
|
-
fullStateDumpFromJsonPre067: fullStateDumpFromJsonPre067,
|
|
17866
17795
|
notYetAccumulatedFromJson: notYetAccumulatedFromJson,
|
|
17867
17796
|
recentBlocksHistoryFromJson: recentBlocksHistoryFromJson,
|
|
17868
17797
|
reportedWorkPackageFromJson: reportedWorkPackageFromJson,
|