@typeberry/lib 0.1.1-b537c8b → 0.1.1-e48de40

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