@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.
@@ -4290,12 +4290,13 @@ class bytes_BytesBlob {
4290
4290
  }
4291
4291
  /** Display a hex-encoded version of this byte blob, but truncated if it's large. */
4292
4292
  toStringTruncated() {
4293
+ const bytes = `${this.raw.length} ${this.raw.length === 1 ? "byte" : "bytes"}`;
4293
4294
  if (this.raw.length > 32) {
4294
4295
  const start = bytesToHexString(this.raw.subarray(0, 16));
4295
4296
  const end = bytesToHexString(this.raw.subarray(this.raw.length - 16));
4296
- return `${start}...${end.substring(2)} (${this.raw.length} bytes)`;
4297
+ return `${start}...${end.substring(2)} (${bytes})`;
4297
4298
  }
4298
- return this.toString();
4299
+ return `${this.toString()} (${bytes})`;
4299
4300
  }
4300
4301
  toJSON() {
4301
4302
  return this.toString();
@@ -19714,10 +19715,10 @@ class Info {
19714
19715
  const chunk = encodedInfo.raw.subarray(Number(offset), Number(offset + length));
19715
19716
  const writeResult = memory.storeFrom(outputStart, chunk);
19716
19717
  if (writeResult.isError) {
19717
- logger_logger.trace `INFO(${serviceId}) <- PANIC`;
19718
+ logger_logger.trace `INFO(${serviceId}, off: ${offset}, len: ${length}) <- PANIC`;
19718
19719
  return PvmExecution.Panic;
19719
19720
  }
19720
- logger_logger.trace `INFO(${serviceId}) <- ${bytes_BytesBlob.blobFrom(chunk)}`;
19721
+ logger_logger.trace `INFO(${serviceId}, off: ${offset}, len: ${length}) <- ${bytes_BytesBlob.blobFrom(chunk)}`;
19721
19722
  if (accountInfo === null) {
19722
19723
  regs.set(IN_OUT_REG, HostCallResult.NONE);
19723
19724
  return;
@@ -21275,7 +21276,7 @@ class Bless {
21275
21276
  decoder.resetTo(0);
21276
21277
  const memoryReadResult = memory.loadInto(result, memIndex);
21277
21278
  if (memoryReadResult.isError) {
21278
- logger_logger.trace `BLESS(${manager}, ${delegator}, ${registrar}) <- PANIC`;
21279
+ logger_logger.trace `BLESS(m: ${manager}, v: ${delegator}, r: ${registrar}) <- PANIC`;
21279
21280
  return PvmExecution.Panic;
21280
21281
  }
21281
21282
  const { serviceId, gas } = decoder.object(serviceIdAndGasCodec);
@@ -21288,26 +21289,26 @@ class Bless {
21288
21289
  const authorizersDecoder = decoder_Decoder.fromBlob(res);
21289
21290
  const memoryReadResult = memory.loadInto(res, authorization);
21290
21291
  if (memoryReadResult.isError) {
21291
- logger_logger.trace `BLESS(${manager}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- PANIC`;
21292
+ logger_logger.trace `BLESS(m: ${manager}, v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- PANIC`;
21292
21293
  return PvmExecution.Panic;
21293
21294
  }
21294
21295
  // `a`
21295
21296
  const authorizers = tryAsPerCore(authorizersDecoder.sequenceFixLen(descriptors_codec.u32.asOpaque(), this.chainSpec.coresCount), this.chainSpec);
21296
21297
  const updateResult = this.partialState.updatePrivilegedServices(manager, authorizers, delegator, registrar, autoAccumulate);
21297
21298
  if (updateResult.isOk) {
21298
- logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- OK`;
21299
+ logger_logger.trace `BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- OK`;
21299
21300
  regs.set(bless_IN_OUT_REG, HostCallResult.OK);
21300
21301
  return;
21301
21302
  }
21302
21303
  const e = updateResult.error;
21303
21304
  // NOTE: `UpdatePrivilegesError.UnprivilegedService` won't happen in 0.7.1+
21304
21305
  if (e === UpdatePrivilegesError.UnprivilegedService) {
21305
- logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- HUH`;
21306
+ logger_logger.trace `BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- HUH`;
21306
21307
  regs.set(bless_IN_OUT_REG, HostCallResult.HUH);
21307
21308
  return;
21308
21309
  }
21309
21310
  if (e === UpdatePrivilegesError.InvalidServiceId) {
21310
- logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- WHO`;
21311
+ logger_logger.trace `BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- WHO`;
21311
21312
  regs.set(bless_IN_OUT_REG, HostCallResult.WHO);
21312
21313
  return;
21313
21314
  }
@@ -21685,9 +21686,11 @@ const IN_OUT_REG_1 = 7;
21685
21686
  const IN_OUT_REG_2 = 8;
21686
21687
  const UPPER_BITS_SHIFT = 32n;
21687
21688
  /**
21688
- * Query the state of the accumulator.
21689
+ * Query the state of the preimage.
21690
+ *
21691
+ * Get time slots for current preimage availability status.
21689
21692
  *
21690
- * https://graypaper.fluffylabs.dev/#/7e6ff6a/373002373002?v=0.6.7
21693
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/37cb0237cb02?v=0.7.2
21691
21694
  */
21692
21695
  class Query {
21693
21696
  currentServiceId;
@@ -21712,27 +21715,31 @@ class Query {
21712
21715
  return PvmExecution.Panic;
21713
21716
  }
21714
21717
  const result = this.partialState.checkPreimageStatus(hash.asOpaque(), length);
21715
- logger_logger.trace `QUERY(${hash}, ${length}) <- ${result}`;
21716
21718
  const zero = numbers_tryAsU64(0n);
21717
21719
  if (result === null) {
21720
+ logger_logger.trace `QUERY(${hash}, ${length}) <- NONE`;
21718
21721
  regs.set(IN_OUT_REG_1, HostCallResult.NONE);
21719
21722
  regs.set(IN_OUT_REG_2, zero);
21720
21723
  return;
21721
21724
  }
21722
21725
  switch (result.status) {
21723
21726
  case PreimageStatusKind.Requested:
21727
+ logger_logger.trace `QUERY(${hash}, ${length}) <- REQUESTED`;
21724
21728
  regs.set(IN_OUT_REG_1, zero);
21725
21729
  regs.set(IN_OUT_REG_2, zero);
21726
21730
  return;
21727
21731
  case PreimageStatusKind.Available:
21732
+ logger_logger.trace `QUERY(${hash}, ${length}) <- AVAILABLE [${result.data}]`;
21728
21733
  regs.set(IN_OUT_REG_1, numbers_tryAsU64((BigInt(result.data[0]) << UPPER_BITS_SHIFT) + 1n));
21729
21734
  regs.set(IN_OUT_REG_2, zero);
21730
21735
  return;
21731
21736
  case PreimageStatusKind.Unavailable:
21737
+ logger_logger.trace `QUERY(${hash}, ${length}) <- UNAVAILABLE [${result.data.join(", ")}]`;
21732
21738
  regs.set(IN_OUT_REG_1, numbers_tryAsU64((BigInt(result.data[0]) << UPPER_BITS_SHIFT) + 2n));
21733
21739
  regs.set(IN_OUT_REG_2, numbers_tryAsU64(result.data[1]));
21734
21740
  return;
21735
21741
  case PreimageStatusKind.Reavailable:
21742
+ logger_logger.trace `QUERY(${hash}, ${length}) <- REAVAILABLE [${result.data.join(", ")}]`;
21736
21743
  regs.set(IN_OUT_REG_1, numbers_tryAsU64((BigInt(result.data[0]) << UPPER_BITS_SHIFT) + 3n));
21737
21744
  regs.set(IN_OUT_REG_2, numbers_tryAsU64((BigInt(result.data[2]) << UPPER_BITS_SHIFT) + BigInt(result.data[1])));
21738
21745
  return;
@@ -22126,6 +22133,15 @@ var FetchKind;
22126
22133
 
22127
22134
 
22128
22135
  const decoder = new TextDecoder("utf8");
22136
+ var Levels;
22137
+ (function (Levels) {
22138
+ Levels[Levels["ERROR"] = 0] = "ERROR";
22139
+ Levels[Levels["WARNING"] = 1] = "WARNING";
22140
+ Levels[Levels["INFO"] = 2] = "INFO";
22141
+ Levels[Levels["DEBUG"] = 3] = "DEBUG";
22142
+ Levels[Levels["NIT"] = 4] = "NIT";
22143
+ Levels[Levels["UNKNOWN"] = 5] = "UNKNOWN";
22144
+ })(Levels || (Levels = {}));
22129
22145
  /**
22130
22146
  * Log message to the console
22131
22147
  *
@@ -22152,7 +22168,8 @@ class LogHostCall {
22152
22168
  memory.loadInto(target, targetStart);
22153
22169
  }
22154
22170
  memory.loadInto(message, msgStart);
22155
- logger_logger.trace `SERVICE [${this.currentServiceId}] [${lvl}] ${decoder.decode(target)} ${decoder.decode(message)}`;
22171
+ const level = clampU64ToU32(lvl);
22172
+ logger_logger.trace `LOG(${this.currentServiceId}, ${level < Levels.UNKNOWN ? Levels[level] : Levels[Levels.UNKNOWN]}(${lvl}), ${decoder.decode(target)}, ${decoder.decode(message)})`;
22156
22173
  return Promise.resolve(undefined);
22157
22174
  }
22158
22175
  }
@@ -22303,7 +22320,13 @@ class Read {
22303
22320
  regs.set(read_IN_OUT_REG, HostCallResult.NONE);
22304
22321
  return;
22305
22322
  }
22306
- logger_logger.trace `READ(${serviceId}, ${rawKey}) <- ${bytes_BytesBlob.blobFrom(chunk).toStringTruncated()}`;
22323
+ if (chunk.length > 0) {
22324
+ logger_logger.trace `READ(${serviceId}, ${rawKey}) <- ${bytes_BytesBlob.blobFrom(chunk).toStringTruncated()}`;
22325
+ }
22326
+ else {
22327
+ // just a query for length of stored data
22328
+ logger_logger.trace `READ(${serviceId}, ${rawKey}) <- (${valueLength} ${valueLength === 1n ? "byte" : "bytes"})`;
22329
+ }
22307
22330
  regs.set(read_IN_OUT_REG, valueLength);
22308
22331
  }
22309
22332
  }
@@ -22363,7 +22386,7 @@ class Write {
22363
22386
  const maybeValue = valueLength === 0n ? null : bytes_BytesBlob.blobFrom(value);
22364
22387
  // a
22365
22388
  const result = this.account.write(storageKey, maybeValue);
22366
- logger_logger.trace `WRITE(${storageKey}, ${maybeValue?.toStringTruncated()}) <- ${resultToString(result)}`;
22389
+ logger_logger.trace `WRITE(${storageKey}, ${maybeValue?.toStringTruncated() ?? "remove"}) <- ${resultToString(result)}`;
22367
22390
  if (result.isError) {
22368
22391
  regs.set(write_IN_OUT_REG, HostCallResult.FULL);
22369
22392
  return;