@typeberry/jam 0.2.0-661fe38 → 0.2.0-663eeb1

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.js CHANGED
@@ -25334,12 +25334,13 @@ class bytes_BytesBlob {
25334
25334
  }
25335
25335
  /** Display a hex-encoded version of this byte blob, but truncated if it's large. */
25336
25336
  toStringTruncated() {
25337
+ const bytes = `${this.raw.length} ${this.raw.length === 1 ? "byte" : "bytes"}`;
25337
25338
  if (this.raw.length > 32) {
25338
25339
  const start = bytesToHexString(this.raw.subarray(0, 16));
25339
25340
  const end = bytesToHexString(this.raw.subarray(this.raw.length - 16));
25340
- return `${start}...${end.substring(2)} (${this.raw.length} bytes)`;
25341
+ return `${start}...${end.substring(2)} (${bytes})`;
25341
25342
  }
25342
- return this.toString();
25343
+ return `${this.toString()} (${bytes})`;
25343
25344
  }
25344
25345
  toJSON() {
25345
25346
  return this.toString();
@@ -44454,10 +44455,10 @@ class Info {
44454
44455
  const chunk = encodedInfo.raw.subarray(Number(offset), Number(offset + length));
44455
44456
  const writeResult = memory.storeFrom(outputStart, chunk);
44456
44457
  if (writeResult.isError) {
44457
- logger_logger.trace `INFO(${serviceId}) <- PANIC`;
44458
+ logger_logger.trace `INFO(${serviceId}, off: ${offset}, len: ${length}) <- PANIC`;
44458
44459
  return PvmExecution.Panic;
44459
44460
  }
44460
- logger_logger.trace `INFO(${serviceId}) <- ${bytes_BytesBlob.blobFrom(chunk)}`;
44461
+ logger_logger.trace `INFO(${serviceId}, off: ${offset}, len: ${length}) <- ${bytes_BytesBlob.blobFrom(chunk)}`;
44461
44462
  if (accountInfo === null) {
44462
44463
  regs.set(IN_OUT_REG, HostCallResult.NONE);
44463
44464
  return;
@@ -46015,7 +46016,7 @@ class Bless {
46015
46016
  decoder.resetTo(0);
46016
46017
  const memoryReadResult = memory.loadInto(result, memIndex);
46017
46018
  if (memoryReadResult.isError) {
46018
- logger_logger.trace `BLESS(${manager}, ${delegator}, ${registrar}) <- PANIC`;
46019
+ logger_logger.trace `BLESS(m: ${manager}, v: ${delegator}, r: ${registrar}) <- PANIC`;
46019
46020
  return PvmExecution.Panic;
46020
46021
  }
46021
46022
  const { serviceId, gas } = decoder.object(serviceIdAndGasCodec);
@@ -46028,26 +46029,26 @@ class Bless {
46028
46029
  const authorizersDecoder = decoder_Decoder.fromBlob(res);
46029
46030
  const memoryReadResult = memory.loadInto(res, authorization);
46030
46031
  if (memoryReadResult.isError) {
46031
- logger_logger.trace `BLESS(${manager}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- PANIC`;
46032
+ logger_logger.trace `BLESS(m: ${manager}, v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- PANIC`;
46032
46033
  return PvmExecution.Panic;
46033
46034
  }
46034
46035
  // `a`
46035
46036
  const authorizers = tryAsPerCore(authorizersDecoder.sequenceFixLen(descriptors_codec.u32.asOpaque(), this.chainSpec.coresCount), this.chainSpec);
46036
46037
  const updateResult = this.partialState.updatePrivilegedServices(manager, authorizers, delegator, registrar, autoAccumulate);
46037
46038
  if (updateResult.isOk) {
46038
- logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- OK`;
46039
+ logger_logger.trace `BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- OK`;
46039
46040
  regs.set(bless_IN_OUT_REG, HostCallResult.OK);
46040
46041
  return;
46041
46042
  }
46042
46043
  const e = updateResult.error;
46043
46044
  // NOTE: `UpdatePrivilegesError.UnprivilegedService` won't happen in 0.7.1+
46044
46045
  if (e === UpdatePrivilegesError.UnprivilegedService) {
46045
- logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- HUH`;
46046
+ logger_logger.trace `BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- HUH`;
46046
46047
  regs.set(bless_IN_OUT_REG, HostCallResult.HUH);
46047
46048
  return;
46048
46049
  }
46049
46050
  if (e === UpdatePrivilegesError.InvalidServiceId) {
46050
- logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- WHO`;
46051
+ logger_logger.trace `BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- WHO`;
46051
46052
  regs.set(bless_IN_OUT_REG, HostCallResult.WHO);
46052
46053
  return;
46053
46054
  }
@@ -46425,9 +46426,11 @@ const IN_OUT_REG_1 = 7;
46425
46426
  const IN_OUT_REG_2 = 8;
46426
46427
  const UPPER_BITS_SHIFT = 32n;
46427
46428
  /**
46428
- * Query the state of the accumulator.
46429
+ * Query the state of the preimage.
46430
+ *
46431
+ * Get time slots for current preimage availability status.
46429
46432
  *
46430
- * https://graypaper.fluffylabs.dev/#/7e6ff6a/373002373002?v=0.6.7
46433
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/37cb0237cb02?v=0.7.2
46431
46434
  */
46432
46435
  class Query {
46433
46436
  currentServiceId;
@@ -46452,27 +46455,31 @@ class Query {
46452
46455
  return PvmExecution.Panic;
46453
46456
  }
46454
46457
  const result = this.partialState.checkPreimageStatus(hash.asOpaque(), length);
46455
- logger_logger.trace `QUERY(${hash}, ${length}) <- ${result}`;
46456
46458
  const zero = numbers_tryAsU64(0n);
46457
46459
  if (result === null) {
46460
+ logger_logger.trace `QUERY(${hash}, ${length}) <- NONE`;
46458
46461
  regs.set(IN_OUT_REG_1, HostCallResult.NONE);
46459
46462
  regs.set(IN_OUT_REG_2, zero);
46460
46463
  return;
46461
46464
  }
46462
46465
  switch (result.status) {
46463
46466
  case PreimageStatusKind.Requested:
46467
+ logger_logger.trace `QUERY(${hash}, ${length}) <- REQUESTED`;
46464
46468
  regs.set(IN_OUT_REG_1, zero);
46465
46469
  regs.set(IN_OUT_REG_2, zero);
46466
46470
  return;
46467
46471
  case PreimageStatusKind.Available:
46472
+ logger_logger.trace `QUERY(${hash}, ${length}) <- AVAILABLE [${result.data}]`;
46468
46473
  regs.set(IN_OUT_REG_1, numbers_tryAsU64((BigInt(result.data[0]) << UPPER_BITS_SHIFT) + 1n));
46469
46474
  regs.set(IN_OUT_REG_2, zero);
46470
46475
  return;
46471
46476
  case PreimageStatusKind.Unavailable:
46477
+ logger_logger.trace `QUERY(${hash}, ${length}) <- UNAVAILABLE [${result.data.join(", ")}]`;
46472
46478
  regs.set(IN_OUT_REG_1, numbers_tryAsU64((BigInt(result.data[0]) << UPPER_BITS_SHIFT) + 2n));
46473
46479
  regs.set(IN_OUT_REG_2, numbers_tryAsU64(result.data[1]));
46474
46480
  return;
46475
46481
  case PreimageStatusKind.Reavailable:
46482
+ logger_logger.trace `QUERY(${hash}, ${length}) <- REAVAILABLE [${result.data.join(", ")}]`;
46476
46483
  regs.set(IN_OUT_REG_1, numbers_tryAsU64((BigInt(result.data[0]) << UPPER_BITS_SHIFT) + 3n));
46477
46484
  regs.set(IN_OUT_REG_2, numbers_tryAsU64((BigInt(result.data[2]) << UPPER_BITS_SHIFT) + BigInt(result.data[1])));
46478
46485
  return;
@@ -46866,6 +46873,15 @@ var FetchKind;
46866
46873
 
46867
46874
 
46868
46875
  const decoder = new TextDecoder("utf8");
46876
+ var Levels;
46877
+ (function (Levels) {
46878
+ Levels[Levels["ERROR"] = 0] = "ERROR";
46879
+ Levels[Levels["WARNING"] = 1] = "WARNING";
46880
+ Levels[Levels["INFO"] = 2] = "INFO";
46881
+ Levels[Levels["DEBUG"] = 3] = "DEBUG";
46882
+ Levels[Levels["NIT"] = 4] = "NIT";
46883
+ Levels[Levels["UNKNOWN"] = 5] = "UNKNOWN";
46884
+ })(Levels || (Levels = {}));
46869
46885
  /**
46870
46886
  * Log message to the console
46871
46887
  *
@@ -46892,7 +46908,8 @@ class LogHostCall {
46892
46908
  memory.loadInto(target, targetStart);
46893
46909
  }
46894
46910
  memory.loadInto(message, msgStart);
46895
- logger_logger.trace `SERVICE [${this.currentServiceId}] [${lvl}] ${decoder.decode(target)} ${decoder.decode(message)}`;
46911
+ const level = clampU64ToU32(lvl);
46912
+ logger_logger.trace `LOG(${this.currentServiceId}, ${level < Levels.UNKNOWN ? Levels[level] : Levels[Levels.UNKNOWN]}(${lvl}), ${decoder.decode(target)}, ${decoder.decode(message)})`;
46896
46913
  return Promise.resolve(undefined);
46897
46914
  }
46898
46915
  }
@@ -47043,7 +47060,13 @@ class Read {
47043
47060
  regs.set(read_IN_OUT_REG, HostCallResult.NONE);
47044
47061
  return;
47045
47062
  }
47046
- logger_logger.trace `READ(${serviceId}, ${rawKey}) <- ${bytes_BytesBlob.blobFrom(chunk).toStringTruncated()}`;
47063
+ if (chunk.length > 0) {
47064
+ logger_logger.trace `READ(${serviceId}, ${rawKey}) <- ${bytes_BytesBlob.blobFrom(chunk).toStringTruncated()}`;
47065
+ }
47066
+ else {
47067
+ // just a query for length of stored data
47068
+ logger_logger.trace `READ(${serviceId}, ${rawKey}) <- (${valueLength} ${valueLength === 1n ? "byte" : "bytes"})`;
47069
+ }
47047
47070
  regs.set(read_IN_OUT_REG, valueLength);
47048
47071
  }
47049
47072
  }
@@ -47103,7 +47126,7 @@ class Write {
47103
47126
  const maybeValue = valueLength === 0n ? null : bytes_BytesBlob.blobFrom(value);
47104
47127
  // a
47105
47128
  const result = this.account.write(storageKey, maybeValue);
47106
- logger_logger.trace `WRITE(${storageKey}, ${maybeValue?.toStringTruncated()}) <- ${result_resultToString(result)}`;
47129
+ logger_logger.trace `WRITE(${storageKey}, ${maybeValue?.toStringTruncated() ?? "remove"}) <- ${result_resultToString(result)}`;
47107
47130
  if (result.isError) {
47108
47131
  regs.set(write_IN_OUT_REG, HostCallResult.FULL);
47109
47132
  return;