@typeberry/lib 0.1.1-e48de40 → 0.1.1
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 +84 -119
- package/index.d.ts +33 -66
- package/index.js +84 -119
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -18,10 +18,10 @@ var TestSuite;
|
|
|
18
18
|
})(TestSuite || (TestSuite = {}));
|
|
19
19
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
20
20
|
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
|
|
21
|
-
const env
|
|
21
|
+
const env = typeof process === "undefined" ? {} : process.env;
|
|
22
22
|
const DEFAULT_VERSION = GpVersion.V0_7_0;
|
|
23
|
-
let CURRENT_VERSION = parseCurrentVersion(env
|
|
24
|
-
let CURRENT_SUITE = parseCurrentSuite(env
|
|
23
|
+
let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
24
|
+
let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
25
25
|
function parseCurrentVersion(env) {
|
|
26
26
|
if (env === undefined) {
|
|
27
27
|
return undefined;
|
|
@@ -200,33 +200,6 @@ class WithDebug {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
const env = typeof process === "undefined" ? {} : process.env;
|
|
204
|
-
/**
|
|
205
|
-
* The function will produce relative path resolver that is adjusted
|
|
206
|
-
* for package location within the workspace.
|
|
207
|
-
*
|
|
208
|
-
* Example:
|
|
209
|
-
* $ npm start -w @typeberry/jam
|
|
210
|
-
*
|
|
211
|
-
* The above command will run `./bin/jam/index.js`, however we would
|
|
212
|
-
* still want relative paths to be resolved according to top-level workspace
|
|
213
|
-
* directory.
|
|
214
|
-
*
|
|
215
|
-
* So the caller, passes the absolute workspace path as argument and get's
|
|
216
|
-
* a function that can properly resolve relative paths.
|
|
217
|
-
*
|
|
218
|
-
* NOTE: the translation happens only for development build! When
|
|
219
|
-
* we build a single library from our project, we no longer mangle the paths.
|
|
220
|
-
*/
|
|
221
|
-
const workspacePathFix = env.NODE_ENV === "development"
|
|
222
|
-
? (workspacePath) => (p) => {
|
|
223
|
-
if (p.startsWith("/")) {
|
|
224
|
-
return p;
|
|
225
|
-
}
|
|
226
|
-
return `${workspacePath}/${p}`;
|
|
227
|
-
}
|
|
228
|
-
: () => (p) => p;
|
|
229
|
-
|
|
230
203
|
/**
|
|
231
204
|
* @fileoverview `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
|
|
232
205
|
* specified unique token Token. It means that base type cannot be assigned to unique type by accident.
|
|
@@ -579,8 +552,7 @@ var index$s = /*#__PURE__*/Object.freeze({
|
|
|
579
552
|
isBrowser: isBrowser,
|
|
580
553
|
measure: measure,
|
|
581
554
|
resultToString: resultToString,
|
|
582
|
-
seeThrough: seeThrough
|
|
583
|
-
workspacePathFix: workspacePathFix
|
|
555
|
+
seeThrough: seeThrough
|
|
584
556
|
});
|
|
585
557
|
|
|
586
558
|
/**
|
|
@@ -8040,23 +8012,6 @@ function parseLevel(lvl) {
|
|
|
8040
8012
|
}
|
|
8041
8013
|
|
|
8042
8014
|
// biome-ignore-all lint/suspicious/noConsole: logger
|
|
8043
|
-
function print(level, levelAndName, strings, data) {
|
|
8044
|
-
if (level < levelAndName[0]) {
|
|
8045
|
-
return;
|
|
8046
|
-
}
|
|
8047
|
-
const lvlText = Level[level].padEnd(5);
|
|
8048
|
-
const val = strings.map((v, idx) => `${v}${data[idx]}`);
|
|
8049
|
-
const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
|
|
8050
|
-
if (level === Level.WARN) {
|
|
8051
|
-
console.warn(msg);
|
|
8052
|
-
}
|
|
8053
|
-
else if (level === Level.ERROR) {
|
|
8054
|
-
console.error(msg);
|
|
8055
|
-
}
|
|
8056
|
-
else {
|
|
8057
|
-
console.info(msg);
|
|
8058
|
-
}
|
|
8059
|
-
}
|
|
8060
8015
|
/** An optimized logger that ignores `TRACE`, `DEBUG` and `LOG` messages.
|
|
8061
8016
|
*
|
|
8062
8017
|
* Use the `create` method to instantiate the right instance of a more specialized logger.
|
|
@@ -8087,91 +8042,109 @@ class ConsoleTransport {
|
|
|
8087
8042
|
constructor(options) {
|
|
8088
8043
|
this.options = options;
|
|
8089
8044
|
}
|
|
8090
|
-
insane(
|
|
8045
|
+
insane(_moduleName, _val) {
|
|
8091
8046
|
/* no-op */
|
|
8092
8047
|
}
|
|
8093
|
-
trace(
|
|
8048
|
+
trace(_moduleName, _val) {
|
|
8094
8049
|
/* no-op */
|
|
8095
8050
|
}
|
|
8096
|
-
log(
|
|
8051
|
+
log(_moduleName, _val) {
|
|
8097
8052
|
/* no-op */
|
|
8098
8053
|
}
|
|
8099
|
-
info(
|
|
8054
|
+
info(_moduleName, _val) {
|
|
8100
8055
|
/* no-op */
|
|
8101
8056
|
}
|
|
8102
|
-
warn(
|
|
8103
|
-
|
|
8057
|
+
warn(moduleName, val) {
|
|
8058
|
+
this.push(Level.WARN, moduleName, val);
|
|
8104
8059
|
}
|
|
8105
|
-
error(
|
|
8106
|
-
|
|
8060
|
+
error(moduleName, val) {
|
|
8061
|
+
this.push(Level.ERROR, moduleName, val);
|
|
8062
|
+
}
|
|
8063
|
+
push(level, moduleName, val) {
|
|
8064
|
+
const shortModule = moduleName.replace(this.options.workingDir, "");
|
|
8065
|
+
const configuredLevel = findLevel(this.options, moduleName);
|
|
8066
|
+
const lvlText = Level[level].padEnd(5);
|
|
8067
|
+
if (level < configuredLevel) {
|
|
8068
|
+
return;
|
|
8069
|
+
}
|
|
8070
|
+
const msg = `${lvlText} [${shortModule}] ${val}`;
|
|
8071
|
+
if (level === Level.WARN) {
|
|
8072
|
+
console.warn(msg);
|
|
8073
|
+
}
|
|
8074
|
+
else if (level === Level.ERROR) {
|
|
8075
|
+
console.error(msg);
|
|
8076
|
+
}
|
|
8077
|
+
else {
|
|
8078
|
+
console.info(msg);
|
|
8079
|
+
}
|
|
8107
8080
|
}
|
|
8108
8081
|
}
|
|
8109
8082
|
/**
|
|
8110
8083
|
* Insane version of console logger - supports insane level.
|
|
8111
8084
|
*/
|
|
8112
8085
|
class InsaneConsoleLogger extends ConsoleTransport {
|
|
8113
|
-
insane(
|
|
8114
|
-
|
|
8086
|
+
insane(moduleName, val) {
|
|
8087
|
+
this.push(Level.INSANE, moduleName, val);
|
|
8115
8088
|
}
|
|
8116
|
-
trace(
|
|
8117
|
-
|
|
8089
|
+
trace(moduleName, val) {
|
|
8090
|
+
this.push(Level.TRACE, moduleName, val);
|
|
8118
8091
|
}
|
|
8119
|
-
log(
|
|
8120
|
-
|
|
8092
|
+
log(moduleName, val) {
|
|
8093
|
+
this.push(Level.LOG, moduleName, val);
|
|
8121
8094
|
}
|
|
8122
|
-
info(
|
|
8123
|
-
|
|
8095
|
+
info(moduleName, val) {
|
|
8096
|
+
this.push(Level.INFO, moduleName, val);
|
|
8124
8097
|
}
|
|
8125
8098
|
}
|
|
8126
8099
|
/**
|
|
8127
8100
|
* A basic version of console logger - printing everything.
|
|
8128
8101
|
*/
|
|
8129
8102
|
class TraceConsoleTransport extends ConsoleTransport {
|
|
8130
|
-
insane(
|
|
8103
|
+
insane(_moduleName, _val) {
|
|
8131
8104
|
/* no-op */
|
|
8132
8105
|
}
|
|
8133
|
-
trace(
|
|
8134
|
-
|
|
8106
|
+
trace(moduleName, val) {
|
|
8107
|
+
this.push(Level.TRACE, moduleName, val);
|
|
8135
8108
|
}
|
|
8136
|
-
log(
|
|
8137
|
-
|
|
8109
|
+
log(moduleName, val) {
|
|
8110
|
+
this.push(Level.LOG, moduleName, val);
|
|
8138
8111
|
}
|
|
8139
|
-
info(
|
|
8140
|
-
|
|
8112
|
+
info(moduleName, val) {
|
|
8113
|
+
this.push(Level.INFO, moduleName, val);
|
|
8141
8114
|
}
|
|
8142
8115
|
}
|
|
8143
8116
|
/**
|
|
8144
8117
|
* An optimized version of the logger - completely ignores `TRACE` level calls.
|
|
8145
8118
|
*/
|
|
8146
8119
|
class LogConsoleTransport extends ConsoleTransport {
|
|
8147
|
-
insane(
|
|
8120
|
+
insane(_moduleName, _val) {
|
|
8148
8121
|
/* no-op */
|
|
8149
8122
|
}
|
|
8150
|
-
trace(
|
|
8123
|
+
trace(_moduleName, _val) {
|
|
8151
8124
|
/* no-op */
|
|
8152
8125
|
}
|
|
8153
|
-
log(
|
|
8154
|
-
|
|
8126
|
+
log(moduleName, val) {
|
|
8127
|
+
this.push(Level.LOG, moduleName, val);
|
|
8155
8128
|
}
|
|
8156
|
-
info(
|
|
8157
|
-
|
|
8129
|
+
info(moduleName, val) {
|
|
8130
|
+
this.push(Level.INFO, moduleName, val);
|
|
8158
8131
|
}
|
|
8159
8132
|
}
|
|
8160
8133
|
/**
|
|
8161
8134
|
* An optimized version of the logger - completely ignores `TRACE` & `DEBUG` level calls.
|
|
8162
8135
|
*/
|
|
8163
8136
|
class InfoConsoleTransport extends ConsoleTransport {
|
|
8164
|
-
insane(
|
|
8137
|
+
insane(_moduleName, _val) {
|
|
8165
8138
|
/* no-op */
|
|
8166
8139
|
}
|
|
8167
|
-
trace(
|
|
8140
|
+
trace(_moduleName, _val) {
|
|
8168
8141
|
/* no-op */
|
|
8169
8142
|
}
|
|
8170
|
-
log(
|
|
8143
|
+
log(_moduleName, _val) {
|
|
8171
8144
|
/* no-op */
|
|
8172
8145
|
}
|
|
8173
|
-
info(
|
|
8174
|
-
|
|
8146
|
+
info(moduleName, val) {
|
|
8147
|
+
this.push(Level.INFO, moduleName, val);
|
|
8175
8148
|
}
|
|
8176
8149
|
}
|
|
8177
8150
|
|
|
@@ -8204,6 +8177,11 @@ class Logger {
|
|
|
8204
8177
|
const module = moduleName ?? fName;
|
|
8205
8178
|
return new Logger(module.padStart(8, " "), GLOBAL_CONFIG);
|
|
8206
8179
|
}
|
|
8180
|
+
/**
|
|
8181
|
+
* Return currently configured level for given module. */
|
|
8182
|
+
static getLevel(moduleName) {
|
|
8183
|
+
return findLevel(GLOBAL_CONFIG.options, moduleName);
|
|
8184
|
+
}
|
|
8207
8185
|
/**
|
|
8208
8186
|
* Global configuration of all loggers.
|
|
8209
8187
|
*
|
|
@@ -8234,46 +8212,33 @@ class Logger {
|
|
|
8234
8212
|
const options = parseLoggerOptions(input, defaultLevel, workingDir);
|
|
8235
8213
|
Logger.configureAllFromOptions(options);
|
|
8236
8214
|
}
|
|
8237
|
-
cachedLevelAndName;
|
|
8238
8215
|
constructor(moduleName, config) {
|
|
8239
8216
|
this.moduleName = moduleName;
|
|
8240
8217
|
this.config = config;
|
|
8241
8218
|
}
|
|
8242
|
-
/** Return currently configured level for given module. */
|
|
8243
|
-
getLevel() {
|
|
8244
|
-
return this.getLevelAndName()[0];
|
|
8245
|
-
}
|
|
8246
|
-
getLevelAndName() {
|
|
8247
|
-
if (this.cachedLevelAndName === undefined) {
|
|
8248
|
-
const level = findLevel(this.config.options, this.moduleName);
|
|
8249
|
-
const shortName = this.moduleName.replace(this.config.options.workingDir, "");
|
|
8250
|
-
this.cachedLevelAndName = [level, shortName];
|
|
8251
|
-
}
|
|
8252
|
-
return this.cachedLevelAndName;
|
|
8253
|
-
}
|
|
8254
8219
|
/** Log a message with `INSANE` level. */
|
|
8255
|
-
insane(
|
|
8256
|
-
this.config.transport.insane(this.
|
|
8220
|
+
insane(val) {
|
|
8221
|
+
this.config.transport.insane(this.moduleName, val);
|
|
8257
8222
|
}
|
|
8258
8223
|
/** Log a message with `TRACE` level. */
|
|
8259
|
-
trace(
|
|
8260
|
-
this.config.transport.trace(this.
|
|
8224
|
+
trace(val) {
|
|
8225
|
+
this.config.transport.trace(this.moduleName, val);
|
|
8261
8226
|
}
|
|
8262
8227
|
/** Log a message with `DEBUG`/`LOG` level. */
|
|
8263
|
-
log(
|
|
8264
|
-
this.config.transport.log(this.
|
|
8228
|
+
log(val) {
|
|
8229
|
+
this.config.transport.log(this.moduleName, val);
|
|
8265
8230
|
}
|
|
8266
8231
|
/** Log a message with `INFO` level. */
|
|
8267
|
-
info(
|
|
8268
|
-
this.config.transport.info(this.
|
|
8232
|
+
info(val) {
|
|
8233
|
+
this.config.transport.info(this.moduleName, val);
|
|
8269
8234
|
}
|
|
8270
8235
|
/** Log a message with `WARN` level. */
|
|
8271
|
-
warn(
|
|
8272
|
-
this.config.transport.warn(this.
|
|
8236
|
+
warn(val) {
|
|
8237
|
+
this.config.transport.warn(this.moduleName, val);
|
|
8273
8238
|
}
|
|
8274
8239
|
/** Log a message with `ERROR` level. */
|
|
8275
|
-
error(
|
|
8276
|
-
this.config.transport.error(this.
|
|
8240
|
+
error(val) {
|
|
8241
|
+
this.config.transport.error(this.moduleName, val);
|
|
8277
8242
|
}
|
|
8278
8243
|
}
|
|
8279
8244
|
|
|
@@ -8300,7 +8265,7 @@ class AuthorshipOptions {
|
|
|
8300
8265
|
}
|
|
8301
8266
|
}
|
|
8302
8267
|
|
|
8303
|
-
const logger$
|
|
8268
|
+
const logger$3 = Logger.new(undefined, "config");
|
|
8304
8269
|
/** Development config. Will accept unsealed blocks for now. */
|
|
8305
8270
|
const DEV_CONFIG = "dev";
|
|
8306
8271
|
/** Default config file. */
|
|
@@ -8359,15 +8324,15 @@ class NodeConfiguration {
|
|
|
8359
8324
|
}
|
|
8360
8325
|
function loadConfig(configPath) {
|
|
8361
8326
|
if (configPath === DEFAULT_CONFIG) {
|
|
8362
|
-
logger$
|
|
8327
|
+
logger$3.log("🔧 Loading DEFAULT config");
|
|
8363
8328
|
return parseFromJson(configs.default, NodeConfiguration.fromJson);
|
|
8364
8329
|
}
|
|
8365
8330
|
if (configPath === DEV_CONFIG) {
|
|
8366
|
-
logger$
|
|
8331
|
+
logger$3.log("🔧 Loading DEV config");
|
|
8367
8332
|
return parseFromJson(configs.dev, NodeConfiguration.fromJson);
|
|
8368
8333
|
}
|
|
8369
8334
|
try {
|
|
8370
|
-
logger$
|
|
8335
|
+
logger$3.log(`🔧 Loading config from ${configPath}`);
|
|
8371
8336
|
const configFile = fs.readFileSync(configPath, "utf8");
|
|
8372
8337
|
const parsed = JSON.parse(configFile);
|
|
8373
8338
|
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
@@ -14229,7 +14194,7 @@ var AccessType;
|
|
|
14229
14194
|
AccessType[AccessType["READ"] = 0] = "READ";
|
|
14230
14195
|
AccessType[AccessType["WRITE"] = 1] = "WRITE";
|
|
14231
14196
|
})(AccessType || (AccessType = {}));
|
|
14232
|
-
const logger
|
|
14197
|
+
// const logger = Logger.new(import.meta.filename, "pvm:mem");
|
|
14233
14198
|
class Memory {
|
|
14234
14199
|
sbrkIndex;
|
|
14235
14200
|
virtualSbrkIndex;
|
|
@@ -14260,7 +14225,7 @@ class Memory {
|
|
|
14260
14225
|
if (bytes.length === 0) {
|
|
14261
14226
|
return Result$1.ok(OK);
|
|
14262
14227
|
}
|
|
14263
|
-
logger
|
|
14228
|
+
// logger.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
|
|
14264
14229
|
const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
|
|
14265
14230
|
if (pagesResult.isError) {
|
|
14266
14231
|
return Result$1.error(pagesResult.error);
|
|
@@ -14327,7 +14292,7 @@ class Memory {
|
|
|
14327
14292
|
currentPosition += bytesToRead;
|
|
14328
14293
|
bytesLeft -= bytesToRead;
|
|
14329
14294
|
}
|
|
14330
|
-
logger
|
|
14295
|
+
// logger.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
|
|
14331
14296
|
return Result$1.ok(OK);
|
|
14332
14297
|
}
|
|
14333
14298
|
sbrk(length) {
|
|
@@ -16121,7 +16086,7 @@ class ProgramDecoder {
|
|
|
16121
16086
|
return Result$1.ok(new ProgramDecoder(program));
|
|
16122
16087
|
}
|
|
16123
16088
|
catch (e) {
|
|
16124
|
-
logger$2.error
|
|
16089
|
+
logger$2.error(`Invalid program: ${e}`);
|
|
16125
16090
|
return Result$1.error(ProgramDecoderError.InvalidProgramError);
|
|
16126
16091
|
}
|
|
16127
16092
|
}
|
|
@@ -16246,7 +16211,7 @@ class Interpreter {
|
|
|
16246
16211
|
const argsType = instructionArgumentTypeMap[currentInstruction] ?? ArgumentType.NO_ARGUMENTS;
|
|
16247
16212
|
const argsResult = this.argsDecodingResults[argsType];
|
|
16248
16213
|
this.argsDecoder.fillArgs(this.pc, argsResult);
|
|
16249
|
-
logger$1.insane
|
|
16214
|
+
logger$1.insane(`[PC: ${this.pc}] ${Instruction[currentInstruction]}`);
|
|
16250
16215
|
if (!isValidInstruction) {
|
|
16251
16216
|
this.instructionResult.status = Result.PANIC;
|
|
16252
16217
|
}
|
|
@@ -16318,7 +16283,7 @@ class Interpreter {
|
|
|
16318
16283
|
this.status = Status.HOST;
|
|
16319
16284
|
break;
|
|
16320
16285
|
}
|
|
16321
|
-
logger$1.insane
|
|
16286
|
+
logger$1.insane(`[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}`);
|
|
16322
16287
|
return this.status;
|
|
16323
16288
|
}
|
|
16324
16289
|
this.pc = this.instructionResult.nextPc;
|
|
@@ -16552,7 +16517,7 @@ class HostCallsManager {
|
|
|
16552
16517
|
return `r${idx}=${value} (0x${value.toString(16)})`;
|
|
16553
16518
|
})
|
|
16554
16519
|
.join(", ");
|
|
16555
|
-
logger.insane
|
|
16520
|
+
logger.insane(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
|
|
16556
16521
|
}
|
|
16557
16522
|
}
|
|
16558
16523
|
|
package/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ declare enum TestSuite {
|
|
|
12
12
|
declare const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
13
13
|
|
|
14
14
|
declare const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
|
|
15
|
+
|
|
16
|
+
declare const env = typeof process === "undefined" ? {} : process.env;
|
|
15
17
|
declare const DEFAULT_VERSION = GpVersion.V0_7_0;
|
|
16
18
|
declare let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
17
19
|
declare let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
@@ -233,33 +235,6 @@ declare abstract class WithDebug {
|
|
|
233
235
|
}
|
|
234
236
|
}
|
|
235
237
|
|
|
236
|
-
/**
|
|
237
|
-
* The function will produce relative path resolver that is adjusted
|
|
238
|
-
* for package location within the workspace.
|
|
239
|
-
*
|
|
240
|
-
* Example:
|
|
241
|
-
* $ npm start -w @typeberry/jam
|
|
242
|
-
*
|
|
243
|
-
* The above command will run `./bin/jam/index.js`, however we would
|
|
244
|
-
* still want relative paths to be resolved according to top-level workspace
|
|
245
|
-
* directory.
|
|
246
|
-
*
|
|
247
|
-
* So the caller, passes the absolute workspace path as argument and get's
|
|
248
|
-
* a function that can properly resolve relative paths.
|
|
249
|
-
*
|
|
250
|
-
* NOTE: the translation happens only for development build! When
|
|
251
|
-
* we build a single library from our project, we no longer mangle the paths.
|
|
252
|
-
*/
|
|
253
|
-
declare const workspacePathFix =
|
|
254
|
-
env.NODE_ENV === "development"
|
|
255
|
-
? (workspacePath: string) => (p: string) => {
|
|
256
|
-
if (p.startsWith("/")) {
|
|
257
|
-
return p;
|
|
258
|
-
}
|
|
259
|
-
return `${workspacePath}/${p}`;
|
|
260
|
-
}
|
|
261
|
-
: () => (p: string) => p;
|
|
262
|
-
|
|
263
238
|
/**
|
|
264
239
|
* @fileoverview `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
|
|
265
240
|
* specified unique token Token. It means that base type cannot be assigned to unique type by accident.
|
|
@@ -737,6 +712,7 @@ declare const index$s_assertNever: typeof assertNever;
|
|
|
737
712
|
declare const index$s_callCompareFunction: typeof callCompareFunction;
|
|
738
713
|
declare const index$s_check: typeof check;
|
|
739
714
|
declare const index$s_deepEqual: typeof deepEqual;
|
|
715
|
+
declare const index$s_env: typeof env;
|
|
740
716
|
declare const index$s_getAllKeysSorted: typeof getAllKeysSorted;
|
|
741
717
|
declare const index$s_inspect: typeof inspect;
|
|
742
718
|
declare const index$s_isBrowser: typeof isBrowser;
|
|
@@ -750,9 +726,8 @@ declare const index$s_parseCurrentVersion: typeof parseCurrentVersion;
|
|
|
750
726
|
declare const index$s_resultToString: typeof resultToString;
|
|
751
727
|
declare const index$s_seeThrough: typeof seeThrough;
|
|
752
728
|
declare const index$s_trimStack: typeof trimStack;
|
|
753
|
-
declare const index$s_workspacePathFix: typeof workspacePathFix;
|
|
754
729
|
declare namespace index$s {
|
|
755
|
-
export { index$s_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$s_CURRENT_SUITE as CURRENT_SUITE, index$s_CURRENT_VERSION as CURRENT_VERSION, index$s_Compatibility as Compatibility, index$s_DEFAULT_SUITE as DEFAULT_SUITE, index$s_DEFAULT_VERSION as DEFAULT_VERSION, index$s_ErrorsCollector as ErrorsCollector, index$s_GpVersion as GpVersion, Result$2 as Result, index$s_RichTaggedError as RichTaggedError, index$s_TEST_COMPARE_USING as TEST_COMPARE_USING, index$s_TestSuite as TestSuite, index$s_WithDebug as WithDebug, index$s___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$s_asOpaqueType as asOpaqueType, index$s_assertEmpty as assertEmpty, index$s_assertNever as assertNever, index$s_callCompareFunction as callCompareFunction, index$s_check as check, index$s_deepEqual as deepEqual, index$s_getAllKeysSorted as getAllKeysSorted, index$s_inspect as inspect, index$s_isBrowser as isBrowser, index$s_isResult as isResult, index$s_isTaggedError as isTaggedError, index$s_maybeTaggedErrorToString as maybeTaggedErrorToString, index$s_measure as measure, index$s_oomWarningPrinted as oomWarningPrinted, index$s_parseCurrentSuite as parseCurrentSuite, index$s_parseCurrentVersion as parseCurrentVersion, index$s_resultToString as resultToString, index$s_seeThrough as seeThrough, index$s_trimStack as trimStack
|
|
730
|
+
export { index$s_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$s_CURRENT_SUITE as CURRENT_SUITE, index$s_CURRENT_VERSION as CURRENT_VERSION, index$s_Compatibility as Compatibility, index$s_DEFAULT_SUITE as DEFAULT_SUITE, index$s_DEFAULT_VERSION as DEFAULT_VERSION, index$s_ErrorsCollector as ErrorsCollector, index$s_GpVersion as GpVersion, Result$2 as Result, index$s_RichTaggedError as RichTaggedError, index$s_TEST_COMPARE_USING as TEST_COMPARE_USING, index$s_TestSuite as TestSuite, index$s_WithDebug as WithDebug, index$s___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$s_asOpaqueType as asOpaqueType, index$s_assertEmpty as assertEmpty, index$s_assertNever as assertNever, index$s_callCompareFunction as callCompareFunction, index$s_check as check, index$s_deepEqual as deepEqual, index$s_env as env, index$s_getAllKeysSorted as getAllKeysSorted, index$s_inspect as inspect, index$s_isBrowser as isBrowser, index$s_isResult as isResult, index$s_isTaggedError as isTaggedError, index$s_maybeTaggedErrorToString as maybeTaggedErrorToString, index$s_measure as measure, index$s_oomWarningPrinted as oomWarningPrinted, index$s_parseCurrentSuite as parseCurrentSuite, index$s_parseCurrentVersion as parseCurrentVersion, index$s_resultToString as resultToString, index$s_seeThrough as seeThrough, index$s_trimStack as trimStack };
|
|
756
731
|
export type { index$s_DeepEqualOptions as DeepEqualOptions, index$s_EnumMapping as EnumMapping, index$s_ErrorResult as ErrorResult, index$s_OK as OK, index$s_OkResult as OkResult, index$s_Opaque as Opaque, index$s_StringLiteral as StringLiteral, index$s_TaggedError as TaggedError, index$s_TokenOf as TokenOf, index$s_Uninstantiable as Uninstantiable, index$s_WithOpaque as WithOpaque };
|
|
757
732
|
}
|
|
758
733
|
|
|
@@ -7953,6 +7928,12 @@ declare class Logger {
|
|
|
7953
7928
|
return new Logger(module.padStart(8, " "), GLOBAL_CONFIG);
|
|
7954
7929
|
}
|
|
7955
7930
|
|
|
7931
|
+
/**
|
|
7932
|
+
* Return currently configured level for given module. */
|
|
7933
|
+
static getLevel(moduleName: string): Level {
|
|
7934
|
+
return findLevel(GLOBAL_CONFIG.options, moduleName);
|
|
7935
|
+
}
|
|
7936
|
+
|
|
7956
7937
|
/**
|
|
7957
7938
|
* Global configuration of all loggers.
|
|
7958
7939
|
*
|
|
@@ -7987,55 +7968,39 @@ declare class Logger {
|
|
|
7987
7968
|
Logger.configureAllFromOptions(options);
|
|
7988
7969
|
}
|
|
7989
7970
|
|
|
7990
|
-
private cachedLevelAndName?: readonly [Level, string];
|
|
7991
|
-
|
|
7992
7971
|
private constructor(
|
|
7993
7972
|
private readonly moduleName: string,
|
|
7994
7973
|
private readonly config: typeof GLOBAL_CONFIG,
|
|
7995
7974
|
) {}
|
|
7996
7975
|
|
|
7997
|
-
/** Return currently configured level for given module. */
|
|
7998
|
-
getLevel(): Level {
|
|
7999
|
-
return this.getLevelAndName()[0];
|
|
8000
|
-
}
|
|
8001
|
-
|
|
8002
|
-
private getLevelAndName(): readonly [Level, string] {
|
|
8003
|
-
if (this.cachedLevelAndName === undefined) {
|
|
8004
|
-
const level = findLevel(this.config.options, this.moduleName);
|
|
8005
|
-
const shortName = this.moduleName.replace(this.config.options.workingDir, "");
|
|
8006
|
-
this.cachedLevelAndName = [level, shortName];
|
|
8007
|
-
}
|
|
8008
|
-
return this.cachedLevelAndName;
|
|
8009
|
-
}
|
|
8010
|
-
|
|
8011
7976
|
/** Log a message with `INSANE` level. */
|
|
8012
|
-
insane(
|
|
8013
|
-
this.config.transport.insane(this.
|
|
7977
|
+
insane(val: string) {
|
|
7978
|
+
this.config.transport.insane(this.moduleName, val);
|
|
8014
7979
|
}
|
|
8015
7980
|
|
|
8016
7981
|
/** Log a message with `TRACE` level. */
|
|
8017
|
-
trace(
|
|
8018
|
-
this.config.transport.trace(this.
|
|
7982
|
+
trace(val: string) {
|
|
7983
|
+
this.config.transport.trace(this.moduleName, val);
|
|
8019
7984
|
}
|
|
8020
7985
|
|
|
8021
7986
|
/** Log a message with `DEBUG`/`LOG` level. */
|
|
8022
|
-
log(
|
|
8023
|
-
this.config.transport.log(this.
|
|
7987
|
+
log(val: string) {
|
|
7988
|
+
this.config.transport.log(this.moduleName, val);
|
|
8024
7989
|
}
|
|
8025
7990
|
|
|
8026
7991
|
/** Log a message with `INFO` level. */
|
|
8027
|
-
info(
|
|
8028
|
-
this.config.transport.info(this.
|
|
7992
|
+
info(val: string) {
|
|
7993
|
+
this.config.transport.info(this.moduleName, val);
|
|
8029
7994
|
}
|
|
8030
7995
|
|
|
8031
7996
|
/** Log a message with `WARN` level. */
|
|
8032
|
-
warn(
|
|
8033
|
-
this.config.transport.warn(this.
|
|
7997
|
+
warn(val: string) {
|
|
7998
|
+
this.config.transport.warn(this.moduleName, val);
|
|
8034
7999
|
}
|
|
8035
8000
|
|
|
8036
8001
|
/** Log a message with `ERROR` level. */
|
|
8037
|
-
error(
|
|
8038
|
-
this.config.transport.error(this.
|
|
8002
|
+
error(val: string) {
|
|
8003
|
+
this.config.transport.error(this.moduleName, val);
|
|
8039
8004
|
}
|
|
8040
8005
|
}
|
|
8041
8006
|
|
|
@@ -8134,17 +8099,17 @@ declare class NodeConfiguration {
|
|
|
8134
8099
|
|
|
8135
8100
|
declare function loadConfig(configPath: string): NodeConfiguration {
|
|
8136
8101
|
if (configPath === DEFAULT_CONFIG) {
|
|
8137
|
-
logger.log
|
|
8102
|
+
logger.log("🔧 Loading DEFAULT config");
|
|
8138
8103
|
return parseFromJson(configs.default, NodeConfiguration.fromJson);
|
|
8139
8104
|
}
|
|
8140
8105
|
|
|
8141
8106
|
if (configPath === DEV_CONFIG) {
|
|
8142
|
-
logger.log
|
|
8107
|
+
logger.log("🔧 Loading DEV config");
|
|
8143
8108
|
return parseFromJson(configs.dev, NodeConfiguration.fromJson);
|
|
8144
8109
|
}
|
|
8145
8110
|
|
|
8146
8111
|
try {
|
|
8147
|
-
logger.log`🔧 Loading config from ${configPath}
|
|
8112
|
+
logger.log(`🔧 Loading config from ${configPath}`);
|
|
8148
8113
|
const configFile = fs.readFileSync(configPath, "utf8");
|
|
8149
8114
|
const parsed = JSON.parse(configFile);
|
|
8150
8115
|
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
@@ -14481,6 +14446,8 @@ declare enum AccessType {
|
|
|
14481
14446
|
WRITE = 1,
|
|
14482
14447
|
}
|
|
14483
14448
|
|
|
14449
|
+
// const logger = Logger.new(import.meta.filename, "pvm:mem");
|
|
14450
|
+
|
|
14484
14451
|
declare class Memory {
|
|
14485
14452
|
static fromInitialMemory(initialMemoryState: InitialMemoryState) {
|
|
14486
14453
|
return new Memory(
|
|
@@ -14517,7 +14484,7 @@ declare class Memory {
|
|
|
14517
14484
|
return Result.ok(OK);
|
|
14518
14485
|
}
|
|
14519
14486
|
|
|
14520
|
-
logger.insane`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}
|
|
14487
|
+
// logger.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
|
|
14521
14488
|
const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
|
|
14522
14489
|
|
|
14523
14490
|
if (pagesResult.isError) {
|
|
@@ -14606,7 +14573,7 @@ declare class Memory {
|
|
|
14606
14573
|
bytesLeft -= bytesToRead;
|
|
14607
14574
|
}
|
|
14608
14575
|
|
|
14609
|
-
logger.insane`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}
|
|
14576
|
+
// logger.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
|
|
14610
14577
|
return Result.ok(OK);
|
|
14611
14578
|
}
|
|
14612
14579
|
|
|
@@ -16569,7 +16536,7 @@ declare class ProgramDecoder {
|
|
|
16569
16536
|
try {
|
|
16570
16537
|
return Result.ok(new ProgramDecoder(program));
|
|
16571
16538
|
} catch (e) {
|
|
16572
|
-
logger.error`Invalid program: ${e}
|
|
16539
|
+
logger.error(`Invalid program: ${e}`);
|
|
16573
16540
|
return Result.error(ProgramDecoderError.InvalidProgramError);
|
|
16574
16541
|
}
|
|
16575
16542
|
}
|
|
@@ -16731,7 +16698,7 @@ declare class Interpreter {
|
|
|
16731
16698
|
const argsResult = this.argsDecodingResults[argsType];
|
|
16732
16699
|
this.argsDecoder.fillArgs(this.pc, argsResult);
|
|
16733
16700
|
|
|
16734
|
-
logger.insane`[PC: ${this.pc}] ${Instruction[currentInstruction]}
|
|
16701
|
+
logger.insane(`[PC: ${this.pc}] ${Instruction[currentInstruction]}`);
|
|
16735
16702
|
|
|
16736
16703
|
if (!isValidInstruction) {
|
|
16737
16704
|
this.instructionResult.status = Result.PANIC;
|
|
@@ -16808,7 +16775,7 @@ declare class Interpreter {
|
|
|
16808
16775
|
this.status = Status.HOST;
|
|
16809
16776
|
break;
|
|
16810
16777
|
}
|
|
16811
|
-
logger.insane`[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}
|
|
16778
|
+
logger.insane(`[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}`);
|
|
16812
16779
|
return this.status;
|
|
16813
16780
|
}
|
|
16814
16781
|
|
|
@@ -17547,7 +17514,7 @@ declare class HostCallsManager {
|
|
|
17547
17514
|
return `r${idx}=${value} (0x${value.toString(16)})`;
|
|
17548
17515
|
})
|
|
17549
17516
|
.join(", ");
|
|
17550
|
-
logger.insane`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}
|
|
17517
|
+
logger.insane(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
|
|
17551
17518
|
}
|
|
17552
17519
|
}
|
|
17553
17520
|
|
package/index.js
CHANGED
|
@@ -15,10 +15,10 @@ var TestSuite;
|
|
|
15
15
|
})(TestSuite || (TestSuite = {}));
|
|
16
16
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
17
17
|
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
|
|
18
|
-
const env
|
|
18
|
+
const env = typeof process === "undefined" ? {} : process.env;
|
|
19
19
|
const DEFAULT_VERSION = GpVersion.V0_7_0;
|
|
20
|
-
let CURRENT_VERSION = parseCurrentVersion(env
|
|
21
|
-
let CURRENT_SUITE = parseCurrentSuite(env
|
|
20
|
+
let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
21
|
+
let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
22
22
|
function parseCurrentVersion(env) {
|
|
23
23
|
if (env === undefined) {
|
|
24
24
|
return undefined;
|
|
@@ -197,33 +197,6 @@ class WithDebug {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
const env = typeof process === "undefined" ? {} : process.env;
|
|
201
|
-
/**
|
|
202
|
-
* The function will produce relative path resolver that is adjusted
|
|
203
|
-
* for package location within the workspace.
|
|
204
|
-
*
|
|
205
|
-
* Example:
|
|
206
|
-
* $ npm start -w @typeberry/jam
|
|
207
|
-
*
|
|
208
|
-
* The above command will run `./bin/jam/index.js`, however we would
|
|
209
|
-
* still want relative paths to be resolved according to top-level workspace
|
|
210
|
-
* directory.
|
|
211
|
-
*
|
|
212
|
-
* So the caller, passes the absolute workspace path as argument and get's
|
|
213
|
-
* a function that can properly resolve relative paths.
|
|
214
|
-
*
|
|
215
|
-
* NOTE: the translation happens only for development build! When
|
|
216
|
-
* we build a single library from our project, we no longer mangle the paths.
|
|
217
|
-
*/
|
|
218
|
-
const workspacePathFix = env.NODE_ENV === "development"
|
|
219
|
-
? (workspacePath) => (p) => {
|
|
220
|
-
if (p.startsWith("/")) {
|
|
221
|
-
return p;
|
|
222
|
-
}
|
|
223
|
-
return `${workspacePath}/${p}`;
|
|
224
|
-
}
|
|
225
|
-
: () => (p) => p;
|
|
226
|
-
|
|
227
200
|
/**
|
|
228
201
|
* @fileoverview `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
|
|
229
202
|
* specified unique token Token. It means that base type cannot be assigned to unique type by accident.
|
|
@@ -576,8 +549,7 @@ var index$s = /*#__PURE__*/Object.freeze({
|
|
|
576
549
|
isBrowser: isBrowser,
|
|
577
550
|
measure: measure,
|
|
578
551
|
resultToString: resultToString,
|
|
579
|
-
seeThrough: seeThrough
|
|
580
|
-
workspacePathFix: workspacePathFix
|
|
552
|
+
seeThrough: seeThrough
|
|
581
553
|
});
|
|
582
554
|
|
|
583
555
|
/**
|
|
@@ -8037,23 +8009,6 @@ function parseLevel(lvl) {
|
|
|
8037
8009
|
}
|
|
8038
8010
|
|
|
8039
8011
|
// biome-ignore-all lint/suspicious/noConsole: logger
|
|
8040
|
-
function print(level, levelAndName, strings, data) {
|
|
8041
|
-
if (level < levelAndName[0]) {
|
|
8042
|
-
return;
|
|
8043
|
-
}
|
|
8044
|
-
const lvlText = Level[level].padEnd(5);
|
|
8045
|
-
const val = strings.map((v, idx) => `${v}${data[idx]}`);
|
|
8046
|
-
const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
|
|
8047
|
-
if (level === Level.WARN) {
|
|
8048
|
-
console.warn(msg);
|
|
8049
|
-
}
|
|
8050
|
-
else if (level === Level.ERROR) {
|
|
8051
|
-
console.error(msg);
|
|
8052
|
-
}
|
|
8053
|
-
else {
|
|
8054
|
-
console.info(msg);
|
|
8055
|
-
}
|
|
8056
|
-
}
|
|
8057
8012
|
/** An optimized logger that ignores `TRACE`, `DEBUG` and `LOG` messages.
|
|
8058
8013
|
*
|
|
8059
8014
|
* Use the `create` method to instantiate the right instance of a more specialized logger.
|
|
@@ -8084,91 +8039,109 @@ class ConsoleTransport {
|
|
|
8084
8039
|
constructor(options) {
|
|
8085
8040
|
this.options = options;
|
|
8086
8041
|
}
|
|
8087
|
-
insane(
|
|
8042
|
+
insane(_moduleName, _val) {
|
|
8088
8043
|
/* no-op */
|
|
8089
8044
|
}
|
|
8090
|
-
trace(
|
|
8045
|
+
trace(_moduleName, _val) {
|
|
8091
8046
|
/* no-op */
|
|
8092
8047
|
}
|
|
8093
|
-
log(
|
|
8048
|
+
log(_moduleName, _val) {
|
|
8094
8049
|
/* no-op */
|
|
8095
8050
|
}
|
|
8096
|
-
info(
|
|
8051
|
+
info(_moduleName, _val) {
|
|
8097
8052
|
/* no-op */
|
|
8098
8053
|
}
|
|
8099
|
-
warn(
|
|
8100
|
-
|
|
8054
|
+
warn(moduleName, val) {
|
|
8055
|
+
this.push(Level.WARN, moduleName, val);
|
|
8101
8056
|
}
|
|
8102
|
-
error(
|
|
8103
|
-
|
|
8057
|
+
error(moduleName, val) {
|
|
8058
|
+
this.push(Level.ERROR, moduleName, val);
|
|
8059
|
+
}
|
|
8060
|
+
push(level, moduleName, val) {
|
|
8061
|
+
const shortModule = moduleName.replace(this.options.workingDir, "");
|
|
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
|
+
}
|
|
8104
8077
|
}
|
|
8105
8078
|
}
|
|
8106
8079
|
/**
|
|
8107
8080
|
* Insane version of console logger - supports insane level.
|
|
8108
8081
|
*/
|
|
8109
8082
|
class InsaneConsoleLogger extends ConsoleTransport {
|
|
8110
|
-
insane(
|
|
8111
|
-
|
|
8083
|
+
insane(moduleName, val) {
|
|
8084
|
+
this.push(Level.INSANE, moduleName, val);
|
|
8112
8085
|
}
|
|
8113
|
-
trace(
|
|
8114
|
-
|
|
8086
|
+
trace(moduleName, val) {
|
|
8087
|
+
this.push(Level.TRACE, moduleName, val);
|
|
8115
8088
|
}
|
|
8116
|
-
log(
|
|
8117
|
-
|
|
8089
|
+
log(moduleName, val) {
|
|
8090
|
+
this.push(Level.LOG, moduleName, val);
|
|
8118
8091
|
}
|
|
8119
|
-
info(
|
|
8120
|
-
|
|
8092
|
+
info(moduleName, val) {
|
|
8093
|
+
this.push(Level.INFO, moduleName, val);
|
|
8121
8094
|
}
|
|
8122
8095
|
}
|
|
8123
8096
|
/**
|
|
8124
8097
|
* A basic version of console logger - printing everything.
|
|
8125
8098
|
*/
|
|
8126
8099
|
class TraceConsoleTransport extends ConsoleTransport {
|
|
8127
|
-
insane(
|
|
8100
|
+
insane(_moduleName, _val) {
|
|
8128
8101
|
/* no-op */
|
|
8129
8102
|
}
|
|
8130
|
-
trace(
|
|
8131
|
-
|
|
8103
|
+
trace(moduleName, val) {
|
|
8104
|
+
this.push(Level.TRACE, moduleName, val);
|
|
8132
8105
|
}
|
|
8133
|
-
log(
|
|
8134
|
-
|
|
8106
|
+
log(moduleName, val) {
|
|
8107
|
+
this.push(Level.LOG, moduleName, val);
|
|
8135
8108
|
}
|
|
8136
|
-
info(
|
|
8137
|
-
|
|
8109
|
+
info(moduleName, val) {
|
|
8110
|
+
this.push(Level.INFO, moduleName, val);
|
|
8138
8111
|
}
|
|
8139
8112
|
}
|
|
8140
8113
|
/**
|
|
8141
8114
|
* An optimized version of the logger - completely ignores `TRACE` level calls.
|
|
8142
8115
|
*/
|
|
8143
8116
|
class LogConsoleTransport extends ConsoleTransport {
|
|
8144
|
-
insane(
|
|
8117
|
+
insane(_moduleName, _val) {
|
|
8145
8118
|
/* no-op */
|
|
8146
8119
|
}
|
|
8147
|
-
trace(
|
|
8120
|
+
trace(_moduleName, _val) {
|
|
8148
8121
|
/* no-op */
|
|
8149
8122
|
}
|
|
8150
|
-
log(
|
|
8151
|
-
|
|
8123
|
+
log(moduleName, val) {
|
|
8124
|
+
this.push(Level.LOG, moduleName, val);
|
|
8152
8125
|
}
|
|
8153
|
-
info(
|
|
8154
|
-
|
|
8126
|
+
info(moduleName, val) {
|
|
8127
|
+
this.push(Level.INFO, moduleName, val);
|
|
8155
8128
|
}
|
|
8156
8129
|
}
|
|
8157
8130
|
/**
|
|
8158
8131
|
* An optimized version of the logger - completely ignores `TRACE` & `DEBUG` level calls.
|
|
8159
8132
|
*/
|
|
8160
8133
|
class InfoConsoleTransport extends ConsoleTransport {
|
|
8161
|
-
insane(
|
|
8134
|
+
insane(_moduleName, _val) {
|
|
8162
8135
|
/* no-op */
|
|
8163
8136
|
}
|
|
8164
|
-
trace(
|
|
8137
|
+
trace(_moduleName, _val) {
|
|
8165
8138
|
/* no-op */
|
|
8166
8139
|
}
|
|
8167
|
-
log(
|
|
8140
|
+
log(_moduleName, _val) {
|
|
8168
8141
|
/* no-op */
|
|
8169
8142
|
}
|
|
8170
|
-
info(
|
|
8171
|
-
|
|
8143
|
+
info(moduleName, val) {
|
|
8144
|
+
this.push(Level.INFO, moduleName, val);
|
|
8172
8145
|
}
|
|
8173
8146
|
}
|
|
8174
8147
|
|
|
@@ -8201,6 +8174,11 @@ class Logger {
|
|
|
8201
8174
|
const module = moduleName ?? fName;
|
|
8202
8175
|
return new Logger(module.padStart(8, " "), GLOBAL_CONFIG);
|
|
8203
8176
|
}
|
|
8177
|
+
/**
|
|
8178
|
+
* Return currently configured level for given module. */
|
|
8179
|
+
static getLevel(moduleName) {
|
|
8180
|
+
return findLevel(GLOBAL_CONFIG.options, moduleName);
|
|
8181
|
+
}
|
|
8204
8182
|
/**
|
|
8205
8183
|
* Global configuration of all loggers.
|
|
8206
8184
|
*
|
|
@@ -8231,46 +8209,33 @@ class Logger {
|
|
|
8231
8209
|
const options = parseLoggerOptions(input, defaultLevel, workingDir);
|
|
8232
8210
|
Logger.configureAllFromOptions(options);
|
|
8233
8211
|
}
|
|
8234
|
-
cachedLevelAndName;
|
|
8235
8212
|
constructor(moduleName, config) {
|
|
8236
8213
|
this.moduleName = moduleName;
|
|
8237
8214
|
this.config = config;
|
|
8238
8215
|
}
|
|
8239
|
-
/** Return currently configured level for given module. */
|
|
8240
|
-
getLevel() {
|
|
8241
|
-
return this.getLevelAndName()[0];
|
|
8242
|
-
}
|
|
8243
|
-
getLevelAndName() {
|
|
8244
|
-
if (this.cachedLevelAndName === undefined) {
|
|
8245
|
-
const level = findLevel(this.config.options, this.moduleName);
|
|
8246
|
-
const shortName = this.moduleName.replace(this.config.options.workingDir, "");
|
|
8247
|
-
this.cachedLevelAndName = [level, shortName];
|
|
8248
|
-
}
|
|
8249
|
-
return this.cachedLevelAndName;
|
|
8250
|
-
}
|
|
8251
8216
|
/** Log a message with `INSANE` level. */
|
|
8252
|
-
insane(
|
|
8253
|
-
this.config.transport.insane(this.
|
|
8217
|
+
insane(val) {
|
|
8218
|
+
this.config.transport.insane(this.moduleName, val);
|
|
8254
8219
|
}
|
|
8255
8220
|
/** Log a message with `TRACE` level. */
|
|
8256
|
-
trace(
|
|
8257
|
-
this.config.transport.trace(this.
|
|
8221
|
+
trace(val) {
|
|
8222
|
+
this.config.transport.trace(this.moduleName, val);
|
|
8258
8223
|
}
|
|
8259
8224
|
/** Log a message with `DEBUG`/`LOG` level. */
|
|
8260
|
-
log(
|
|
8261
|
-
this.config.transport.log(this.
|
|
8225
|
+
log(val) {
|
|
8226
|
+
this.config.transport.log(this.moduleName, val);
|
|
8262
8227
|
}
|
|
8263
8228
|
/** Log a message with `INFO` level. */
|
|
8264
|
-
info(
|
|
8265
|
-
this.config.transport.info(this.
|
|
8229
|
+
info(val) {
|
|
8230
|
+
this.config.transport.info(this.moduleName, val);
|
|
8266
8231
|
}
|
|
8267
8232
|
/** Log a message with `WARN` level. */
|
|
8268
|
-
warn(
|
|
8269
|
-
this.config.transport.warn(this.
|
|
8233
|
+
warn(val) {
|
|
8234
|
+
this.config.transport.warn(this.moduleName, val);
|
|
8270
8235
|
}
|
|
8271
8236
|
/** Log a message with `ERROR` level. */
|
|
8272
|
-
error(
|
|
8273
|
-
this.config.transport.error(this.
|
|
8237
|
+
error(val) {
|
|
8238
|
+
this.config.transport.error(this.moduleName, val);
|
|
8274
8239
|
}
|
|
8275
8240
|
}
|
|
8276
8241
|
|
|
@@ -8297,7 +8262,7 @@ class AuthorshipOptions {
|
|
|
8297
8262
|
}
|
|
8298
8263
|
}
|
|
8299
8264
|
|
|
8300
|
-
const logger$
|
|
8265
|
+
const logger$3 = Logger.new(import.meta.filename, "config");
|
|
8301
8266
|
/** Development config. Will accept unsealed blocks for now. */
|
|
8302
8267
|
const DEV_CONFIG = "dev";
|
|
8303
8268
|
/** Default config file. */
|
|
@@ -8356,15 +8321,15 @@ class NodeConfiguration {
|
|
|
8356
8321
|
}
|
|
8357
8322
|
function loadConfig(configPath) {
|
|
8358
8323
|
if (configPath === DEFAULT_CONFIG) {
|
|
8359
|
-
logger$
|
|
8324
|
+
logger$3.log("🔧 Loading DEFAULT config");
|
|
8360
8325
|
return parseFromJson(configs.default, NodeConfiguration.fromJson);
|
|
8361
8326
|
}
|
|
8362
8327
|
if (configPath === DEV_CONFIG) {
|
|
8363
|
-
logger$
|
|
8328
|
+
logger$3.log("🔧 Loading DEV config");
|
|
8364
8329
|
return parseFromJson(configs.dev, NodeConfiguration.fromJson);
|
|
8365
8330
|
}
|
|
8366
8331
|
try {
|
|
8367
|
-
logger$
|
|
8332
|
+
logger$3.log(`🔧 Loading config from ${configPath}`);
|
|
8368
8333
|
const configFile = fs.readFileSync(configPath, "utf8");
|
|
8369
8334
|
const parsed = JSON.parse(configFile);
|
|
8370
8335
|
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
@@ -14226,7 +14191,7 @@ var AccessType;
|
|
|
14226
14191
|
AccessType[AccessType["READ"] = 0] = "READ";
|
|
14227
14192
|
AccessType[AccessType["WRITE"] = 1] = "WRITE";
|
|
14228
14193
|
})(AccessType || (AccessType = {}));
|
|
14229
|
-
const logger
|
|
14194
|
+
// const logger = Logger.new(import.meta.filename, "pvm:mem");
|
|
14230
14195
|
class Memory {
|
|
14231
14196
|
sbrkIndex;
|
|
14232
14197
|
virtualSbrkIndex;
|
|
@@ -14257,7 +14222,7 @@ class Memory {
|
|
|
14257
14222
|
if (bytes.length === 0) {
|
|
14258
14223
|
return Result$1.ok(OK);
|
|
14259
14224
|
}
|
|
14260
|
-
logger
|
|
14225
|
+
// logger.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
|
|
14261
14226
|
const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
|
|
14262
14227
|
if (pagesResult.isError) {
|
|
14263
14228
|
return Result$1.error(pagesResult.error);
|
|
@@ -14324,7 +14289,7 @@ class Memory {
|
|
|
14324
14289
|
currentPosition += bytesToRead;
|
|
14325
14290
|
bytesLeft -= bytesToRead;
|
|
14326
14291
|
}
|
|
14327
|
-
logger
|
|
14292
|
+
// logger.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
|
|
14328
14293
|
return Result$1.ok(OK);
|
|
14329
14294
|
}
|
|
14330
14295
|
sbrk(length) {
|
|
@@ -16118,7 +16083,7 @@ class ProgramDecoder {
|
|
|
16118
16083
|
return Result$1.ok(new ProgramDecoder(program));
|
|
16119
16084
|
}
|
|
16120
16085
|
catch (e) {
|
|
16121
|
-
logger$2.error
|
|
16086
|
+
logger$2.error(`Invalid program: ${e}`);
|
|
16122
16087
|
return Result$1.error(ProgramDecoderError.InvalidProgramError);
|
|
16123
16088
|
}
|
|
16124
16089
|
}
|
|
@@ -16243,7 +16208,7 @@ class Interpreter {
|
|
|
16243
16208
|
const argsType = instructionArgumentTypeMap[currentInstruction] ?? ArgumentType.NO_ARGUMENTS;
|
|
16244
16209
|
const argsResult = this.argsDecodingResults[argsType];
|
|
16245
16210
|
this.argsDecoder.fillArgs(this.pc, argsResult);
|
|
16246
|
-
logger$1.insane
|
|
16211
|
+
logger$1.insane(`[PC: ${this.pc}] ${Instruction[currentInstruction]}`);
|
|
16247
16212
|
if (!isValidInstruction) {
|
|
16248
16213
|
this.instructionResult.status = Result.PANIC;
|
|
16249
16214
|
}
|
|
@@ -16315,7 +16280,7 @@ class Interpreter {
|
|
|
16315
16280
|
this.status = Status.HOST;
|
|
16316
16281
|
break;
|
|
16317
16282
|
}
|
|
16318
|
-
logger$1.insane
|
|
16283
|
+
logger$1.insane(`[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}`);
|
|
16319
16284
|
return this.status;
|
|
16320
16285
|
}
|
|
16321
16286
|
this.pc = this.instructionResult.nextPc;
|
|
@@ -16549,7 +16514,7 @@ class HostCallsManager {
|
|
|
16549
16514
|
return `r${idx}=${value} (0x${value.toString(16)})`;
|
|
16550
16515
|
})
|
|
16551
16516
|
.join(", ");
|
|
16552
|
-
logger.insane
|
|
16517
|
+
logger.insane(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
|
|
16553
16518
|
}
|
|
16554
16519
|
}
|
|
16555
16520
|
|