@typeberry/jam 0.2.0-0e2cdac → 0.2.0-262995a

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.
@@ -24782,12 +24782,13 @@ class bytes_BytesBlob {
24782
24782
  }
24783
24783
  /** Display a hex-encoded version of this byte blob, but truncated if it's large. */
24784
24784
  toStringTruncated() {
24785
+ const bytes = `${this.raw.length} ${this.raw.length === 1 ? "byte" : "bytes"}`;
24785
24786
  if (this.raw.length > 32) {
24786
24787
  const start = bytesToHexString(this.raw.subarray(0, 16));
24787
24788
  const end = bytesToHexString(this.raw.subarray(this.raw.length - 16));
24788
- return `${start}...${end.substring(2)} (${this.raw.length} bytes)`;
24789
+ return `${start}...${end.substring(2)} (${bytes})`;
24789
24790
  }
24790
- return this.toString();
24791
+ return `${this.toString()} (${bytes})`;
24791
24792
  }
24792
24793
  toJSON() {
24793
24794
  return this.toString();
@@ -28624,6 +28625,8 @@ const EC_SEGMENT_SIZE = 4104;
28624
28625
  * Additional data that has to be passed to the codec to correctly parse incoming bytes.
28625
28626
  */
28626
28627
  class ChainSpec extends WithDebug {
28628
+ /** Human-readable name of the chain spec. */
28629
+ name;
28627
28630
  /** Number of validators. */
28628
28631
  validatorsCount;
28629
28632
  /** 1/3 of number of validators */
@@ -28666,6 +28669,7 @@ class ChainSpec extends WithDebug {
28666
28669
  maxLookupAnchorAge;
28667
28670
  constructor(data) {
28668
28671
  super();
28672
+ this.name = data.name;
28669
28673
  this.validatorsCount = data.validatorsCount;
28670
28674
  this.thirdOfValidators = numbers_tryAsU16(Math.floor(data.validatorsCount / 3));
28671
28675
  this.validatorsSuperMajority = numbers_tryAsU16(Math.floor(data.validatorsCount / 3) * 2 + 1);
@@ -28686,6 +28690,7 @@ class ChainSpec extends WithDebug {
28686
28690
  }
28687
28691
  /** Set of values for "tiny" chain as defined in JAM test vectors. */
28688
28692
  const tinyChainSpec = new ChainSpec({
28693
+ name: "tiny",
28689
28694
  validatorsCount: numbers_tryAsU16(6),
28690
28695
  coresCount: numbers_tryAsU16(2),
28691
28696
  epochLength: numbers_tryAsU32(12),
@@ -28707,6 +28712,7 @@ const tinyChainSpec = new ChainSpec({
28707
28712
  * Please note that only validatorsCount and epochLength are "full", the rest is copied from "tiny".
28708
28713
  */
28709
28714
  const fullChainSpec = new ChainSpec({
28715
+ name: "full",
28710
28716
  validatorsCount: numbers_tryAsU16(1023),
28711
28717
  coresCount: numbers_tryAsU16(341),
28712
28718
  epochLength: numbers_tryAsU32(600),
@@ -29081,6 +29087,19 @@ var descriptors_json;
29081
29087
  return ["number", parser];
29082
29088
  }
29083
29089
  json.fromNumber = fromNumber;
29090
+ /** Parse a JSON bigint or number into the expected type. */
29091
+ function fromBigInt(parser) {
29092
+ return [
29093
+ "object",
29094
+ (x) => {
29095
+ if (typeof x === "number" || typeof x === "bigint") {
29096
+ return parser(BigInt(x));
29097
+ }
29098
+ throw new Error(`Expected number or bigint got: ${typeof x} (${x})`);
29099
+ },
29100
+ ];
29101
+ }
29102
+ json.fromBigInt = fromBigInt;
29084
29103
  /** Cast the JSON number into the expected type. */
29085
29104
  function castNumber() {
29086
29105
  return fromNumber((v) => v);
@@ -30687,7 +30706,7 @@ const workResultFromJson = descriptors_json.object({
30687
30706
  service_id: "number",
30688
30707
  code_hash: common_fromJson.bytes32(),
30689
30708
  payload_hash: common_fromJson.bytes32(),
30690
- accumulate_gas: descriptors_json.fromNumber((x) => tryAsServiceGas(x)),
30709
+ accumulate_gas: descriptors_json.fromBigInt((x) => tryAsServiceGas(x)),
30691
30710
  result: workExecResultFromJson,
30692
30711
  refine_load: workRefineLoadFromJson,
30693
30712
  }, ({ service_id, code_hash, payload_hash, accumulate_gas, result, refine_load }) => WorkResult.create({
@@ -30735,7 +30754,7 @@ const workReportFromJson = descriptors_json.object({
30735
30754
  auth_output: descriptors_json.fromString(bytes_BytesBlob.parseBlob),
30736
30755
  segment_root_lookup: descriptors_json.array(segmentRootLookupItemFromJson),
30737
30756
  results: descriptors_json.array(workResultFromJson),
30738
- auth_gas_used: descriptors_json.fromNumber((x) => tryAsServiceGas(x)),
30757
+ auth_gas_used: descriptors_json.fromBigInt((x) => tryAsServiceGas(x)),
30739
30758
  }, ({ package_spec, context, core_index, authorizer_hash, auth_output, results, segment_root_lookup, auth_gas_used, }) => {
30740
30759
  const fixedSizeResults = sized_array_FixedSizeArray.new(results, tryAsWorkItemsCount(results.length));
30741
30760
  return WorkReport.create({
@@ -31325,7 +31344,7 @@ const DEFAULT_CONFIG = "default";
31325
31344
  const NODE_DEFAULTS = {
31326
31345
  name: isBrowser() ? "browser" : external_node_os_default().hostname(),
31327
31346
  config: [DEFAULT_CONFIG],
31328
- pvm: PvmBackend.BuiltIn,
31347
+ pvm: PvmBackend.Ananas,
31329
31348
  };
31330
31349
  /** Chain spec chooser. */
31331
31350
  var KnownChainSpec;