@typeberry/lib 0.1.1 → 0.1.2-60899f7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +205 -136
- package/index.d.ts +113 -57
- package/index.js +205 -136
- package/package.json +1 -1
- package/bin/lib/index.d.ts +0 -29
- package/configs/index.d.ts +0 -76
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var GpVersion;
|
|
|
7
7
|
GpVersion["V0_6_7"] = "0.6.7";
|
|
8
8
|
GpVersion["V0_7_0"] = "0.7.0";
|
|
9
9
|
GpVersion["V0_7_1"] = "0.7.1-preview";
|
|
10
|
+
GpVersion["V0_7_2"] = "0.7.2-preview";
|
|
10
11
|
})(GpVersion || (GpVersion = {}));
|
|
11
12
|
var TestSuite;
|
|
12
13
|
(function (TestSuite) {
|
|
@@ -14,29 +15,35 @@ var TestSuite;
|
|
|
14
15
|
TestSuite["JAMDUNA"] = "jamduna";
|
|
15
16
|
})(TestSuite || (TestSuite = {}));
|
|
16
17
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
17
|
-
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
|
|
18
|
-
const env = typeof process === "undefined" ? {} : process.env;
|
|
18
|
+
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
19
|
+
const env$1 = typeof process === "undefined" ? {} : process.env;
|
|
19
20
|
const DEFAULT_VERSION = GpVersion.V0_7_0;
|
|
20
|
-
let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
21
|
-
let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
21
|
+
let CURRENT_VERSION = parseCurrentVersion(env$1.GP_VERSION) ?? DEFAULT_VERSION;
|
|
22
|
+
let CURRENT_SUITE = parseCurrentSuite(env$1.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
22
23
|
function parseCurrentVersion(env) {
|
|
23
24
|
if (env === undefined) {
|
|
24
25
|
return undefined;
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
switch (env) {
|
|
28
|
+
case GpVersion.V0_6_7:
|
|
29
|
+
case GpVersion.V0_7_0:
|
|
30
|
+
case GpVersion.V0_7_1:
|
|
31
|
+
case GpVersion.V0_7_2:
|
|
32
|
+
return env;
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
29
35
|
}
|
|
30
|
-
return version;
|
|
31
36
|
}
|
|
32
37
|
function parseCurrentSuite(env) {
|
|
33
38
|
if (env === undefined)
|
|
34
39
|
return undefined;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
switch (env) {
|
|
41
|
+
case TestSuite.W3F_DAVXY:
|
|
42
|
+
case TestSuite.JAMDUNA:
|
|
43
|
+
return env;
|
|
44
|
+
default:
|
|
45
|
+
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
38
46
|
}
|
|
39
|
-
return val;
|
|
40
47
|
}
|
|
41
48
|
class Compatibility {
|
|
42
49
|
static override(version) {
|
|
@@ -197,6 +204,33 @@ class WithDebug {
|
|
|
197
204
|
}
|
|
198
205
|
}
|
|
199
206
|
|
|
207
|
+
const env = typeof process === "undefined" ? {} : process.env;
|
|
208
|
+
/**
|
|
209
|
+
* The function will produce relative path resolver that is adjusted
|
|
210
|
+
* for package location within the workspace.
|
|
211
|
+
*
|
|
212
|
+
* Example:
|
|
213
|
+
* $ npm start -w @typeberry/jam
|
|
214
|
+
*
|
|
215
|
+
* The above command will run `./bin/jam/index.js`, however we would
|
|
216
|
+
* still want relative paths to be resolved according to top-level workspace
|
|
217
|
+
* directory.
|
|
218
|
+
*
|
|
219
|
+
* So the caller, passes the absolute workspace path as argument and get's
|
|
220
|
+
* a function that can properly resolve relative paths.
|
|
221
|
+
*
|
|
222
|
+
* NOTE: the translation happens only for development build! When
|
|
223
|
+
* we build a single library from our project, we no longer mangle the paths.
|
|
224
|
+
*/
|
|
225
|
+
const workspacePathFix = env.NODE_ENV === "development"
|
|
226
|
+
? (workspacePath) => (p) => {
|
|
227
|
+
if (p.startsWith("/")) {
|
|
228
|
+
return p;
|
|
229
|
+
}
|
|
230
|
+
return `${workspacePath}/${p}`;
|
|
231
|
+
}
|
|
232
|
+
: () => (p) => p;
|
|
233
|
+
|
|
200
234
|
/**
|
|
201
235
|
* @fileoverview `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
|
|
202
236
|
* specified unique token Token. It means that base type cannot be assigned to unique type by accident.
|
|
@@ -549,7 +583,8 @@ var index$s = /*#__PURE__*/Object.freeze({
|
|
|
549
583
|
isBrowser: isBrowser,
|
|
550
584
|
measure: measure,
|
|
551
585
|
resultToString: resultToString,
|
|
552
|
-
seeThrough: seeThrough
|
|
586
|
+
seeThrough: seeThrough,
|
|
587
|
+
workspacePathFix: workspacePathFix
|
|
553
588
|
});
|
|
554
589
|
|
|
555
590
|
/**
|
|
@@ -5919,6 +5954,40 @@ var assurances = /*#__PURE__*/Object.freeze({
|
|
|
5919
5954
|
assurancesExtrinsicCodec: assurancesExtrinsicCodec
|
|
5920
5955
|
});
|
|
5921
5956
|
|
|
5957
|
+
/** Attempt to convert a number into `TimeSlot`. */
|
|
5958
|
+
const tryAsTimeSlot = (v) => asOpaqueType(tryAsU32(v));
|
|
5959
|
+
/** Attempt to convert a number into `ValidatorIndex`. */
|
|
5960
|
+
const tryAsValidatorIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
5961
|
+
/** Attempt to convert a number into `ServiceId`. */
|
|
5962
|
+
const tryAsServiceId = (v) => asOpaqueType(tryAsU32(v));
|
|
5963
|
+
const tryAsServiceGas = (v) => asOpaqueType(tryAsU64(v));
|
|
5964
|
+
/** Attempt to convert a number into `CoreIndex`. */
|
|
5965
|
+
const tryAsCoreIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
5966
|
+
/** Attempt to convert a number into `Epoch`. */
|
|
5967
|
+
const tryAsEpoch = (v) => asOpaqueType(tryAsU32(v));
|
|
5968
|
+
function tryAsPerValidator(array, spec) {
|
|
5969
|
+
check `
|
|
5970
|
+
${array.length === spec.validatorsCount}
|
|
5971
|
+
Invalid per-validator array length. Expected ${spec.validatorsCount}, got: ${array.length}
|
|
5972
|
+
`;
|
|
5973
|
+
return asKnownSize(array);
|
|
5974
|
+
}
|
|
5975
|
+
const codecPerValidator = (val) => codecWithContext((context) => {
|
|
5976
|
+
return codecKnownSizeArray(val, {
|
|
5977
|
+
fixedLength: context.validatorsCount,
|
|
5978
|
+
});
|
|
5979
|
+
});
|
|
5980
|
+
function tryAsPerEpochBlock(array, spec) {
|
|
5981
|
+
check `
|
|
5982
|
+
${array.length === spec.epochLength}
|
|
5983
|
+
Invalid per-epoch-block array length. Expected ${spec.epochLength}, got: ${array.length}
|
|
5984
|
+
`;
|
|
5985
|
+
return asKnownSize(array);
|
|
5986
|
+
}
|
|
5987
|
+
const codecPerEpochBlock = (val) => codecWithContext((context) => {
|
|
5988
|
+
return codecKnownSizeArray(val, { fixedLength: context.epochLength });
|
|
5989
|
+
});
|
|
5990
|
+
|
|
5922
5991
|
/**
|
|
5923
5992
|
* Proof of signing a contradictory [`Judgement`] of a work report.
|
|
5924
5993
|
*/
|
|
@@ -6110,40 +6179,6 @@ var disputes = /*#__PURE__*/Object.freeze({
|
|
|
6110
6179
|
Verdict: Verdict
|
|
6111
6180
|
});
|
|
6112
6181
|
|
|
6113
|
-
/** Attempt to convert a number into `TimeSlot`. */
|
|
6114
|
-
const tryAsTimeSlot = (v) => asOpaqueType(tryAsU32(v));
|
|
6115
|
-
/** Attempt to convert a number into `ValidatorIndex`. */
|
|
6116
|
-
const tryAsValidatorIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
6117
|
-
/** Attempt to convert a number into `ServiceId`. */
|
|
6118
|
-
const tryAsServiceId = (v) => asOpaqueType(tryAsU32(v));
|
|
6119
|
-
const tryAsServiceGas = (v) => asOpaqueType(tryAsU64(v));
|
|
6120
|
-
/** Attempt to convert a number into `CoreIndex`. */
|
|
6121
|
-
const tryAsCoreIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
6122
|
-
/** Attempt to convert a number into `Epoch`. */
|
|
6123
|
-
const tryAsEpoch = (v) => asOpaqueType(tryAsU32(v));
|
|
6124
|
-
function tryAsPerValidator(array, spec) {
|
|
6125
|
-
check `
|
|
6126
|
-
${array.length === spec.validatorsCount}
|
|
6127
|
-
Invalid per-validator array length. Expected ${spec.validatorsCount}, got: ${array.length}
|
|
6128
|
-
`;
|
|
6129
|
-
return asKnownSize(array);
|
|
6130
|
-
}
|
|
6131
|
-
const codecPerValidator = (val) => codecWithContext((context) => {
|
|
6132
|
-
return codecKnownSizeArray(val, {
|
|
6133
|
-
fixedLength: context.validatorsCount,
|
|
6134
|
-
});
|
|
6135
|
-
});
|
|
6136
|
-
function tryAsPerEpochBlock(array, spec) {
|
|
6137
|
-
check `
|
|
6138
|
-
${array.length === spec.epochLength}
|
|
6139
|
-
Invalid per-epoch-block array length. Expected ${spec.epochLength}, got: ${array.length}
|
|
6140
|
-
`;
|
|
6141
|
-
return asKnownSize(array);
|
|
6142
|
-
}
|
|
6143
|
-
const codecPerEpochBlock = (val) => codecWithContext((context) => {
|
|
6144
|
-
return codecKnownSizeArray(val, { fixedLength: context.epochLength });
|
|
6145
|
-
});
|
|
6146
|
-
|
|
6147
6182
|
/**
|
|
6148
6183
|
* Mapping between work package hash and root hash of it's exports.
|
|
6149
6184
|
*
|
|
@@ -7222,6 +7257,24 @@ class Block extends WithDebug {
|
|
|
7222
7257
|
this.extrinsic = extrinsic;
|
|
7223
7258
|
}
|
|
7224
7259
|
}
|
|
7260
|
+
function emptyBlock(slot = tryAsTimeSlot(0)) {
|
|
7261
|
+
const header = Header.empty();
|
|
7262
|
+
header.timeSlotIndex = slot;
|
|
7263
|
+
return Block.create({
|
|
7264
|
+
header,
|
|
7265
|
+
extrinsic: Extrinsic.create({
|
|
7266
|
+
tickets: asKnownSize([]),
|
|
7267
|
+
preimages: [],
|
|
7268
|
+
assurances: asKnownSize([]),
|
|
7269
|
+
guarantees: asKnownSize([]),
|
|
7270
|
+
disputes: {
|
|
7271
|
+
verdicts: [],
|
|
7272
|
+
culprits: [],
|
|
7273
|
+
faults: [],
|
|
7274
|
+
},
|
|
7275
|
+
}),
|
|
7276
|
+
});
|
|
7277
|
+
}
|
|
7225
7278
|
|
|
7226
7279
|
var index$j = /*#__PURE__*/Object.freeze({
|
|
7227
7280
|
__proto__: null,
|
|
@@ -7238,6 +7291,7 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
7238
7291
|
codecPerValidator: codecPerValidator,
|
|
7239
7292
|
codecUtils: codec,
|
|
7240
7293
|
disputes: disputes,
|
|
7294
|
+
emptyBlock: emptyBlock,
|
|
7241
7295
|
encodeUnsealedHeader: encodeUnsealedHeader,
|
|
7242
7296
|
guarantees: guarantees,
|
|
7243
7297
|
headerViewWithHashCodec: headerViewWithHashCodec,
|
|
@@ -8009,6 +8063,23 @@ function parseLevel(lvl) {
|
|
|
8009
8063
|
}
|
|
8010
8064
|
|
|
8011
8065
|
// biome-ignore-all lint/suspicious/noConsole: logger
|
|
8066
|
+
function print(level, levelAndName, strings, data) {
|
|
8067
|
+
if (level < levelAndName[0]) {
|
|
8068
|
+
return;
|
|
8069
|
+
}
|
|
8070
|
+
const lvlText = Level[level].padEnd(5);
|
|
8071
|
+
const val = strings.map((v, idx) => `${v}${idx < data.length ? data[idx] : ""}`);
|
|
8072
|
+
const msg = `${lvlText} [${levelAndName[1]}] ${val.join("")}`;
|
|
8073
|
+
if (level === Level.WARN) {
|
|
8074
|
+
console.warn(msg);
|
|
8075
|
+
}
|
|
8076
|
+
else if (level === Level.ERROR) {
|
|
8077
|
+
console.error(msg);
|
|
8078
|
+
}
|
|
8079
|
+
else {
|
|
8080
|
+
console.info(msg);
|
|
8081
|
+
}
|
|
8082
|
+
}
|
|
8012
8083
|
/** An optimized logger that ignores `TRACE`, `DEBUG` and `LOG` messages.
|
|
8013
8084
|
*
|
|
8014
8085
|
* Use the `create` method to instantiate the right instance of a more specialized logger.
|
|
@@ -8039,109 +8110,91 @@ class ConsoleTransport {
|
|
|
8039
8110
|
constructor(options) {
|
|
8040
8111
|
this.options = options;
|
|
8041
8112
|
}
|
|
8042
|
-
insane(
|
|
8113
|
+
insane(_levelAndName, _strings, _data) {
|
|
8043
8114
|
/* no-op */
|
|
8044
8115
|
}
|
|
8045
|
-
trace(
|
|
8116
|
+
trace(_levelAndName, _strings, _data) {
|
|
8046
8117
|
/* no-op */
|
|
8047
8118
|
}
|
|
8048
|
-
log(
|
|
8119
|
+
log(_levelAndName, _strings, _data) {
|
|
8049
8120
|
/* no-op */
|
|
8050
8121
|
}
|
|
8051
|
-
info(
|
|
8122
|
+
info(_levelAndName, _strings, _data) {
|
|
8052
8123
|
/* no-op */
|
|
8053
8124
|
}
|
|
8054
|
-
warn(
|
|
8055
|
-
|
|
8056
|
-
}
|
|
8057
|
-
error(moduleName, val) {
|
|
8058
|
-
this.push(Level.ERROR, moduleName, val);
|
|
8125
|
+
warn(levelAndName, strings, data) {
|
|
8126
|
+
print(Level.WARN, levelAndName, strings, data);
|
|
8059
8127
|
}
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
const configuredLevel = findLevel(this.options, moduleName);
|
|
8063
|
-
const lvlText = Level[level].padEnd(5);
|
|
8064
|
-
if (level < configuredLevel) {
|
|
8065
|
-
return;
|
|
8066
|
-
}
|
|
8067
|
-
const msg = `${lvlText} [${shortModule}] ${val}`;
|
|
8068
|
-
if (level === Level.WARN) {
|
|
8069
|
-
console.warn(msg);
|
|
8070
|
-
}
|
|
8071
|
-
else if (level === Level.ERROR) {
|
|
8072
|
-
console.error(msg);
|
|
8073
|
-
}
|
|
8074
|
-
else {
|
|
8075
|
-
console.info(msg);
|
|
8076
|
-
}
|
|
8128
|
+
error(levelAndName, strings, data) {
|
|
8129
|
+
print(Level.ERROR, levelAndName, strings, data);
|
|
8077
8130
|
}
|
|
8078
8131
|
}
|
|
8079
8132
|
/**
|
|
8080
8133
|
* Insane version of console logger - supports insane level.
|
|
8081
8134
|
*/
|
|
8082
8135
|
class InsaneConsoleLogger extends ConsoleTransport {
|
|
8083
|
-
insane(
|
|
8084
|
-
|
|
8136
|
+
insane(levelAndName, strings, data) {
|
|
8137
|
+
print(Level.INSANE, levelAndName, strings, data);
|
|
8085
8138
|
}
|
|
8086
|
-
trace(
|
|
8087
|
-
|
|
8139
|
+
trace(levelAndName, strings, data) {
|
|
8140
|
+
print(Level.TRACE, levelAndName, strings, data);
|
|
8088
8141
|
}
|
|
8089
|
-
log(
|
|
8090
|
-
|
|
8142
|
+
log(levelAndName, strings, data) {
|
|
8143
|
+
print(Level.LOG, levelAndName, strings, data);
|
|
8091
8144
|
}
|
|
8092
|
-
info(
|
|
8093
|
-
|
|
8145
|
+
info(levelAndName, strings, data) {
|
|
8146
|
+
print(Level.INFO, levelAndName, strings, data);
|
|
8094
8147
|
}
|
|
8095
8148
|
}
|
|
8096
8149
|
/**
|
|
8097
8150
|
* A basic version of console logger - printing everything.
|
|
8098
8151
|
*/
|
|
8099
8152
|
class TraceConsoleTransport extends ConsoleTransport {
|
|
8100
|
-
insane(
|
|
8153
|
+
insane(_levelAndName, _strings, _data) {
|
|
8101
8154
|
/* no-op */
|
|
8102
8155
|
}
|
|
8103
|
-
trace(
|
|
8104
|
-
|
|
8156
|
+
trace(levelAndName, strings, data) {
|
|
8157
|
+
print(Level.TRACE, levelAndName, strings, data);
|
|
8105
8158
|
}
|
|
8106
|
-
log(
|
|
8107
|
-
|
|
8159
|
+
log(levelAndName, strings, data) {
|
|
8160
|
+
print(Level.LOG, levelAndName, strings, data);
|
|
8108
8161
|
}
|
|
8109
|
-
info(
|
|
8110
|
-
|
|
8162
|
+
info(levelAndName, strings, data) {
|
|
8163
|
+
print(Level.INFO, levelAndName, strings, data);
|
|
8111
8164
|
}
|
|
8112
8165
|
}
|
|
8113
8166
|
/**
|
|
8114
8167
|
* An optimized version of the logger - completely ignores `TRACE` level calls.
|
|
8115
8168
|
*/
|
|
8116
8169
|
class LogConsoleTransport extends ConsoleTransport {
|
|
8117
|
-
insane(
|
|
8170
|
+
insane(_levelAndName, _strings, _data) {
|
|
8118
8171
|
/* no-op */
|
|
8119
8172
|
}
|
|
8120
|
-
trace(
|
|
8173
|
+
trace(_levelAndName, _strings, _data) {
|
|
8121
8174
|
/* no-op */
|
|
8122
8175
|
}
|
|
8123
|
-
log(
|
|
8124
|
-
|
|
8176
|
+
log(levelAndName, strings, data) {
|
|
8177
|
+
print(Level.LOG, levelAndName, strings, data);
|
|
8125
8178
|
}
|
|
8126
|
-
info(
|
|
8127
|
-
|
|
8179
|
+
info(levelAndName, strings, data) {
|
|
8180
|
+
print(Level.INFO, levelAndName, strings, data);
|
|
8128
8181
|
}
|
|
8129
8182
|
}
|
|
8130
8183
|
/**
|
|
8131
8184
|
* An optimized version of the logger - completely ignores `TRACE` & `DEBUG` level calls.
|
|
8132
8185
|
*/
|
|
8133
8186
|
class InfoConsoleTransport extends ConsoleTransport {
|
|
8134
|
-
insane(
|
|
8187
|
+
insane(_levelAndName, _strings, _data) {
|
|
8135
8188
|
/* no-op */
|
|
8136
8189
|
}
|
|
8137
|
-
trace(
|
|
8190
|
+
trace(_levelAndName, _strings, _data) {
|
|
8138
8191
|
/* no-op */
|
|
8139
8192
|
}
|
|
8140
|
-
log(
|
|
8193
|
+
log(_levelAndName, _strings, _data) {
|
|
8141
8194
|
/* no-op */
|
|
8142
8195
|
}
|
|
8143
|
-
info(
|
|
8144
|
-
|
|
8196
|
+
info(levelAndName, strings, data) {
|
|
8197
|
+
print(Level.INFO, levelAndName, strings, data);
|
|
8145
8198
|
}
|
|
8146
8199
|
}
|
|
8147
8200
|
|
|
@@ -8174,11 +8227,6 @@ class Logger {
|
|
|
8174
8227
|
const module = moduleName ?? fName;
|
|
8175
8228
|
return new Logger(module.padStart(8, " "), GLOBAL_CONFIG);
|
|
8176
8229
|
}
|
|
8177
|
-
/**
|
|
8178
|
-
* Return currently configured level for given module. */
|
|
8179
|
-
static getLevel(moduleName) {
|
|
8180
|
-
return findLevel(GLOBAL_CONFIG.options, moduleName);
|
|
8181
|
-
}
|
|
8182
8230
|
/**
|
|
8183
8231
|
* Global configuration of all loggers.
|
|
8184
8232
|
*
|
|
@@ -8209,33 +8257,46 @@ class Logger {
|
|
|
8209
8257
|
const options = parseLoggerOptions(input, defaultLevel, workingDir);
|
|
8210
8258
|
Logger.configureAllFromOptions(options);
|
|
8211
8259
|
}
|
|
8260
|
+
cachedLevelAndName;
|
|
8212
8261
|
constructor(moduleName, config) {
|
|
8213
8262
|
this.moduleName = moduleName;
|
|
8214
8263
|
this.config = config;
|
|
8215
8264
|
}
|
|
8265
|
+
/** Return currently configured level for given module. */
|
|
8266
|
+
getLevel() {
|
|
8267
|
+
return this.getLevelAndName()[0];
|
|
8268
|
+
}
|
|
8269
|
+
getLevelAndName() {
|
|
8270
|
+
if (this.cachedLevelAndName === undefined) {
|
|
8271
|
+
const level = findLevel(this.config.options, this.moduleName);
|
|
8272
|
+
const shortName = this.moduleName.replace(this.config.options.workingDir, "");
|
|
8273
|
+
this.cachedLevelAndName = [level, shortName];
|
|
8274
|
+
}
|
|
8275
|
+
return this.cachedLevelAndName;
|
|
8276
|
+
}
|
|
8216
8277
|
/** Log a message with `INSANE` level. */
|
|
8217
|
-
insane(
|
|
8218
|
-
this.config.transport.insane(this.
|
|
8278
|
+
insane(strings, ...data) {
|
|
8279
|
+
this.config.transport.insane(this.getLevelAndName(), strings, data);
|
|
8219
8280
|
}
|
|
8220
8281
|
/** Log a message with `TRACE` level. */
|
|
8221
|
-
trace(
|
|
8222
|
-
this.config.transport.trace(this.
|
|
8282
|
+
trace(strings, ...data) {
|
|
8283
|
+
this.config.transport.trace(this.getLevelAndName(), strings, data);
|
|
8223
8284
|
}
|
|
8224
8285
|
/** Log a message with `DEBUG`/`LOG` level. */
|
|
8225
|
-
log(
|
|
8226
|
-
this.config.transport.log(this.
|
|
8286
|
+
log(strings, ...data) {
|
|
8287
|
+
this.config.transport.log(this.getLevelAndName(), strings, data);
|
|
8227
8288
|
}
|
|
8228
8289
|
/** Log a message with `INFO` level. */
|
|
8229
|
-
info(
|
|
8230
|
-
this.config.transport.info(this.
|
|
8290
|
+
info(strings, ...data) {
|
|
8291
|
+
this.config.transport.info(this.getLevelAndName(), strings, data);
|
|
8231
8292
|
}
|
|
8232
8293
|
/** Log a message with `WARN` level. */
|
|
8233
|
-
warn(
|
|
8234
|
-
this.config.transport.warn(this.
|
|
8294
|
+
warn(strings, ...data) {
|
|
8295
|
+
this.config.transport.warn(this.getLevelAndName(), strings, data);
|
|
8235
8296
|
}
|
|
8236
8297
|
/** Log a message with `ERROR` level. */
|
|
8237
|
-
error(
|
|
8238
|
-
this.config.transport.error(this.
|
|
8298
|
+
error(strings, ...data) {
|
|
8299
|
+
this.config.transport.error(this.getLevelAndName(), strings, data);
|
|
8239
8300
|
}
|
|
8240
8301
|
}
|
|
8241
8302
|
|
|
@@ -8262,7 +8323,7 @@ class AuthorshipOptions {
|
|
|
8262
8323
|
}
|
|
8263
8324
|
}
|
|
8264
8325
|
|
|
8265
|
-
const logger$
|
|
8326
|
+
const logger$4 = Logger.new(import.meta.filename, "config");
|
|
8266
8327
|
/** Development config. Will accept unsealed blocks for now. */
|
|
8267
8328
|
const DEV_CONFIG = "dev";
|
|
8268
8329
|
/** Default config file. */
|
|
@@ -8321,15 +8382,15 @@ class NodeConfiguration {
|
|
|
8321
8382
|
}
|
|
8322
8383
|
function loadConfig(configPath) {
|
|
8323
8384
|
if (configPath === DEFAULT_CONFIG) {
|
|
8324
|
-
logger$
|
|
8385
|
+
logger$4.log `🔧 Loading DEFAULT config`;
|
|
8325
8386
|
return parseFromJson(configs.default, NodeConfiguration.fromJson);
|
|
8326
8387
|
}
|
|
8327
8388
|
if (configPath === DEV_CONFIG) {
|
|
8328
|
-
logger$
|
|
8389
|
+
logger$4.log `🔧 Loading DEV config`;
|
|
8329
8390
|
return parseFromJson(configs.dev, NodeConfiguration.fromJson);
|
|
8330
8391
|
}
|
|
8331
8392
|
try {
|
|
8332
|
-
logger$
|
|
8393
|
+
logger$4.log `🔧 Loading config from ${configPath}`;
|
|
8333
8394
|
const configFile = fs.readFileSync(configPath, "utf8");
|
|
8334
8395
|
const parsed = JSON.parse(configFile);
|
|
8335
8396
|
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
@@ -12359,16 +12420,12 @@ class PartiallyUpdatedState {
|
|
|
12359
12420
|
*
|
|
12360
12421
|
* NOTE the info may be updated compared to what is in the state.
|
|
12361
12422
|
*
|
|
12362
|
-
* Takes into account newly created services as well.
|
|
12423
|
+
* Takes into account ejected and newly created services as well.
|
|
12363
12424
|
*/
|
|
12364
12425
|
getServiceInfo(destination) {
|
|
12365
12426
|
if (destination === null) {
|
|
12366
12427
|
return null;
|
|
12367
12428
|
}
|
|
12368
|
-
const isEjected = this.stateUpdate.services.servicesRemoved.some((x) => x === destination);
|
|
12369
|
-
if (isEjected) {
|
|
12370
|
-
return null;
|
|
12371
|
-
}
|
|
12372
12429
|
const maybeNewService = this.stateUpdate.services.servicesUpdates.find((update) => update.serviceId === destination);
|
|
12373
12430
|
if (maybeNewService !== undefined) {
|
|
12374
12431
|
return maybeNewService.action.account;
|
|
@@ -14084,6 +14141,17 @@ class PageRange {
|
|
|
14084
14141
|
}
|
|
14085
14142
|
return new PageRange(start, length);
|
|
14086
14143
|
}
|
|
14144
|
+
/** Returns true if the page range is wrapped (`start` >= `end`) and is not empty */
|
|
14145
|
+
isWrapped() {
|
|
14146
|
+
return this.start >= this.end && !this.isEmpty();
|
|
14147
|
+
}
|
|
14148
|
+
/** Checks if given page number is within the range */
|
|
14149
|
+
isInRange(page) {
|
|
14150
|
+
if (this.isWrapped()) {
|
|
14151
|
+
return page >= this.start || page < this.end;
|
|
14152
|
+
}
|
|
14153
|
+
return page >= this.start && page < this.end;
|
|
14154
|
+
}
|
|
14087
14155
|
/** Checks if a range is empty (`length === 0`) */
|
|
14088
14156
|
isEmpty() {
|
|
14089
14157
|
return this.length === 0;
|
|
@@ -14191,7 +14259,7 @@ var AccessType;
|
|
|
14191
14259
|
AccessType[AccessType["READ"] = 0] = "READ";
|
|
14192
14260
|
AccessType[AccessType["WRITE"] = 1] = "WRITE";
|
|
14193
14261
|
})(AccessType || (AccessType = {}));
|
|
14194
|
-
|
|
14262
|
+
const logger$3 = Logger.new(import.meta.filename, "pvm:mem");
|
|
14195
14263
|
class Memory {
|
|
14196
14264
|
sbrkIndex;
|
|
14197
14265
|
virtualSbrkIndex;
|
|
@@ -14222,7 +14290,7 @@ class Memory {
|
|
|
14222
14290
|
if (bytes.length === 0) {
|
|
14223
14291
|
return Result$1.ok(OK);
|
|
14224
14292
|
}
|
|
14225
|
-
|
|
14293
|
+
logger$3.insane `MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`;
|
|
14226
14294
|
const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
|
|
14227
14295
|
if (pagesResult.isError) {
|
|
14228
14296
|
return Result$1.error(pagesResult.error);
|
|
@@ -14289,7 +14357,7 @@ class Memory {
|
|
|
14289
14357
|
currentPosition += bytesToRead;
|
|
14290
14358
|
bytesLeft -= bytesToRead;
|
|
14291
14359
|
}
|
|
14292
|
-
|
|
14360
|
+
logger$3.insane `MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`;
|
|
14293
14361
|
return Result$1.ok(OK);
|
|
14294
14362
|
}
|
|
14295
14363
|
sbrk(length) {
|
|
@@ -14424,10 +14492,11 @@ class MemoryBuilder {
|
|
|
14424
14492
|
startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
|
|
14425
14493
|
`;
|
|
14426
14494
|
this.ensureNotFinalized();
|
|
14427
|
-
const
|
|
14428
|
-
const
|
|
14429
|
-
|
|
14430
|
-
|
|
14495
|
+
const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
14496
|
+
const heapPagesRange = PageRange.fromMemoryRange(heapRange);
|
|
14497
|
+
const initializedPageNumbers = Array.from(this.initialMemory.keys());
|
|
14498
|
+
for (const pageNumber of initializedPageNumbers) {
|
|
14499
|
+
if (heapPagesRange.isInRange(pageNumber)) {
|
|
14431
14500
|
throw new IncorrectSbrkIndex();
|
|
14432
14501
|
}
|
|
14433
14502
|
}
|
|
@@ -16083,7 +16152,7 @@ class ProgramDecoder {
|
|
|
16083
16152
|
return Result$1.ok(new ProgramDecoder(program));
|
|
16084
16153
|
}
|
|
16085
16154
|
catch (e) {
|
|
16086
|
-
logger$2.error
|
|
16155
|
+
logger$2.error `Invalid program: ${e}`;
|
|
16087
16156
|
return Result$1.error(ProgramDecoderError.InvalidProgramError);
|
|
16088
16157
|
}
|
|
16089
16158
|
}
|
|
@@ -16208,7 +16277,7 @@ class Interpreter {
|
|
|
16208
16277
|
const argsType = instructionArgumentTypeMap[currentInstruction] ?? ArgumentType.NO_ARGUMENTS;
|
|
16209
16278
|
const argsResult = this.argsDecodingResults[argsType];
|
|
16210
16279
|
this.argsDecoder.fillArgs(this.pc, argsResult);
|
|
16211
|
-
logger$1.insane
|
|
16280
|
+
logger$1.insane `[PC: ${this.pc}] ${Instruction[currentInstruction]}`;
|
|
16212
16281
|
if (!isValidInstruction) {
|
|
16213
16282
|
this.instructionResult.status = Result.PANIC;
|
|
16214
16283
|
}
|
|
@@ -16280,7 +16349,7 @@ class Interpreter {
|
|
|
16280
16349
|
this.status = Status.HOST;
|
|
16281
16350
|
break;
|
|
16282
16351
|
}
|
|
16283
|
-
logger$1.insane
|
|
16352
|
+
logger$1.insane `[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}`;
|
|
16284
16353
|
return this.status;
|
|
16285
16354
|
}
|
|
16286
16355
|
this.pc = this.instructionResult.nextPc;
|
|
@@ -16514,7 +16583,7 @@ class HostCallsManager {
|
|
|
16514
16583
|
return `r${idx}=${value} (0x${value.toString(16)})`;
|
|
16515
16584
|
})
|
|
16516
16585
|
.join(", ");
|
|
16517
|
-
logger.insane
|
|
16586
|
+
logger.insane `[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`;
|
|
16518
16587
|
}
|
|
16519
16588
|
}
|
|
16520
16589
|
|
package/package.json
CHANGED
package/bin/lib/index.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export * as block from "@typeberry/block";
|
|
2
|
-
export * as block_json from "@typeberry/block-json";
|
|
3
|
-
export * as bytes from "@typeberry/bytes";
|
|
4
|
-
export * as codec from "@typeberry/codec";
|
|
5
|
-
export * as collections from "@typeberry/collections";
|
|
6
|
-
export * as config from "@typeberry/config";
|
|
7
|
-
export * as config_node from "@typeberry/config-node";
|
|
8
|
-
export * as crypto from "@typeberry/crypto";
|
|
9
|
-
export * as database from "@typeberry/database";
|
|
10
|
-
export * as erasure_coding from "@typeberry/erasure-coding";
|
|
11
|
-
export * as hash from "@typeberry/hash";
|
|
12
|
-
export * as jam_host_calls from "@typeberry/jam-host-calls";
|
|
13
|
-
export * as json_parser from "@typeberry/json-parser";
|
|
14
|
-
export * as logger from "@typeberry/logger";
|
|
15
|
-
export * as mmr from "@typeberry/mmr";
|
|
16
|
-
export * as numbers from "@typeberry/numbers";
|
|
17
|
-
export * as ordering from "@typeberry/ordering";
|
|
18
|
-
export * as pvm from "@typeberry/pvm-debugger-adapter";
|
|
19
|
-
export * as pvm_host_calls from "@typeberry/pvm-host-calls";
|
|
20
|
-
export * as pvm_interpreter from "@typeberry/pvm-interpreter";
|
|
21
|
-
export * as pvm_program from "@typeberry/pvm-program";
|
|
22
|
-
export * as pvm_spi_decoder from "@typeberry/pvm-spi-decoder";
|
|
23
|
-
export * as shuffling from "@typeberry/shuffling";
|
|
24
|
-
export * as state from "@typeberry/state";
|
|
25
|
-
export * as state_json from "@typeberry/state-json";
|
|
26
|
-
export * as state_merkleization from "@typeberry/state-merkleization";
|
|
27
|
-
export * as transition from "@typeberry/transition";
|
|
28
|
-
export * as trie from "@typeberry/trie";
|
|
29
|
-
export * as utils from "@typeberry/utils";
|