@typeberry/lib 0.0.1-4a742e9 → 0.0.1-4d4d1b9

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/configs/index.d.ts +74 -0
  2. package/index.d.ts +425 -524
  3. package/index.js +1465 -765
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -160,6 +160,10 @@ declare class Compatibility {
160
160
  }
161
161
  }
162
162
 
163
+ declare function isBrowser() {
164
+ return typeof process === "undefined" || typeof process.abort === "undefined";
165
+ }
166
+
163
167
  /**
164
168
  * A function to perform runtime assertions.
165
169
  *
@@ -278,20 +282,19 @@ declare function inspect<T>(val: T): string {
278
282
  }
279
283
 
280
284
  /** Utility function to measure time taken for some operation [ms]. */
281
- declare const measure =
282
- typeof process === "undefined"
283
- ? (id: string) => {
284
- const start = performance.now();
285
- return () => `${id} took ${performance.now() - start}ms`;
286
- }
287
- : (id: string) => {
288
- const start = process.hrtime.bigint();
289
- return () => {
290
- const tookNano = process.hrtime.bigint() - start;
291
- const tookMilli = Number(tookNano / 1_000_000n).toFixed(2);
292
- return `${id} took ${tookMilli}ms`;
293
- };
285
+ declare const measure = isBrowser()
286
+ ? (id: string) => {
287
+ const start = performance.now();
288
+ return () => `${id} took ${performance.now() - start}ms`;
289
+ }
290
+ : (id: string) => {
291
+ const start = process.hrtime.bigint();
292
+ return () => {
293
+ const tookNano = process.hrtime.bigint() - start;
294
+ const tookMilli = Number(tookNano / 1_000_000n).toFixed(2);
295
+ return `${id} took ${tookMilli}ms`;
294
296
  };
297
+ };
295
298
 
296
299
  /** A class that adds `toString` method that prints all properties of an object. */
297
300
  declare abstract class WithDebug {
@@ -490,6 +493,8 @@ type DeepEqualOptions = {
490
493
  errorsCollector?: ErrorsCollector;
491
494
  };
492
495
 
496
+ declare let oomWarningPrinted = false;
497
+
493
498
  /** Deeply compare `actual` and `expected` values. */
494
499
  declare function deepEqual<T>(
495
500
  actual: T | undefined,
@@ -522,7 +527,7 @@ declare function deepEqual<T>(
522
527
  try {
523
528
  assert.strictEqual(actualDisp, expectedDisp, message);
524
529
  } catch (e) {
525
- if (isOoMWorkaroundNeeded) {
530
+ if (isOoMWorkaroundNeeded && !oomWarningPrinted) {
526
531
  console.warn(
527
532
  [
528
533
  "Stacktrace may be crappy because of a problem in nodejs.",
@@ -530,6 +535,7 @@ declare function deepEqual<T>(
530
535
  "Maybe we do not need it anymore",
531
536
  ].join("\n"),
532
537
  );
538
+ oomWarningPrinted = true;
533
539
  }
534
540
  throw e;
535
541
  }
@@ -778,17 +784,19 @@ declare const index$r_ensure: typeof ensure;
778
784
  declare const index$r_env: typeof env;
779
785
  declare const index$r_getAllKeysSorted: typeof getAllKeysSorted;
780
786
  declare const index$r_inspect: typeof inspect;
787
+ declare const index$r_isBrowser: typeof isBrowser;
781
788
  declare const index$r_isResult: typeof isResult;
782
789
  declare const index$r_isTaggedError: typeof isTaggedError;
783
790
  declare const index$r_maybeTaggedErrorToString: typeof maybeTaggedErrorToString;
784
791
  declare const index$r_measure: typeof measure;
792
+ declare const index$r_oomWarningPrinted: typeof oomWarningPrinted;
785
793
  declare const index$r_parseCurrentSuite: typeof parseCurrentSuite;
786
794
  declare const index$r_parseCurrentVersion: typeof parseCurrentVersion;
787
795
  declare const index$r_resultToString: typeof resultToString;
788
796
  declare const index$r_seeThrough: typeof seeThrough;
789
797
  declare const index$r_trimStack: typeof trimStack;
790
798
  declare namespace index$r {
791
- export { index$r_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$r_CURRENT_SUITE as CURRENT_SUITE, index$r_CURRENT_VERSION as CURRENT_VERSION, index$r_Compatibility as Compatibility, index$r_DEFAULT_SUITE as DEFAULT_SUITE, index$r_DEFAULT_VERSION as DEFAULT_VERSION, index$r_ErrorsCollector as ErrorsCollector, index$r_GpVersion as GpVersion, Result$2 as Result, index$r_RichTaggedError as RichTaggedError, index$r_TEST_COMPARE_USING as TEST_COMPARE_USING, index$r_TestSuite as TestSuite, index$r_WithDebug as WithDebug, index$r___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$r_asOpaqueType as asOpaqueType, index$r_assertEmpty as assertEmpty, index$r_assertNever as assertNever, index$r_callCompareFunction as callCompareFunction, index$r_cast as cast, index$r_check as check, index$r_deepEqual as deepEqual, index$r_ensure as ensure, index$r_env as env, index$r_getAllKeysSorted as getAllKeysSorted, index$r_inspect as inspect, index$r_isResult as isResult, index$r_isTaggedError as isTaggedError, index$r_maybeTaggedErrorToString as maybeTaggedErrorToString, index$r_measure as measure, index$r_parseCurrentSuite as parseCurrentSuite, index$r_parseCurrentVersion as parseCurrentVersion, index$r_resultToString as resultToString, index$r_seeThrough as seeThrough, index$r_trimStack as trimStack };
799
+ export { index$r_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$r_CURRENT_SUITE as CURRENT_SUITE, index$r_CURRENT_VERSION as CURRENT_VERSION, index$r_Compatibility as Compatibility, index$r_DEFAULT_SUITE as DEFAULT_SUITE, index$r_DEFAULT_VERSION as DEFAULT_VERSION, index$r_ErrorsCollector as ErrorsCollector, index$r_GpVersion as GpVersion, Result$2 as Result, index$r_RichTaggedError as RichTaggedError, index$r_TEST_COMPARE_USING as TEST_COMPARE_USING, index$r_TestSuite as TestSuite, index$r_WithDebug as WithDebug, index$r___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$r_asOpaqueType as asOpaqueType, index$r_assertEmpty as assertEmpty, index$r_assertNever as assertNever, index$r_callCompareFunction as callCompareFunction, index$r_cast as cast, index$r_check as check, index$r_deepEqual as deepEqual, index$r_ensure as ensure, index$r_env as env, index$r_getAllKeysSorted as getAllKeysSorted, index$r_inspect as inspect, index$r_isBrowser as isBrowser, index$r_isResult as isResult, index$r_isTaggedError as isTaggedError, index$r_maybeTaggedErrorToString as maybeTaggedErrorToString, index$r_measure as measure, index$r_oomWarningPrinted as oomWarningPrinted, index$r_parseCurrentSuite as parseCurrentSuite, index$r_parseCurrentVersion as parseCurrentVersion, index$r_resultToString as resultToString, index$r_seeThrough as seeThrough, index$r_trimStack as trimStack };
792
800
  export type { index$r_DeepEqualOptions as DeepEqualOptions, index$r_EnumMapping as EnumMapping, index$r_ErrorResult as ErrorResult, index$r_OK as OK, index$r_OkResult as OkResult, index$r_Opaque as Opaque, index$r_StringLiteral as StringLiteral, index$r_TaggedError as TaggedError, index$r_TokenOf as TokenOf, index$r_Uninstantiable as Uninstantiable, index$r_WithOpaque as WithOpaque };
793
801
  }
794
802
 
@@ -4456,6 +4464,84 @@ declare namespace index$m {
4456
4464
  export type { index$m_HashWithZeroedBit as HashWithZeroedBit, index$m_ImmutableHashDictionary as ImmutableHashDictionary, index$m_ImmutableHashSet as ImmutableHashSet, index$m_ImmutableSortedArray as ImmutableSortedArray, index$m_ImmutableSortedSet as ImmutableSortedSet, index$m_KeyMapper as KeyMapper, index$m_KeyMappers as KeyMappers, index$m_KnownSize as KnownSize, index$m_KnownSizeArray as KnownSizeArray, index$m_KnownSizeId as KnownSizeId, index$m_NestedMaps as NestedMaps };
4457
4465
  }
4458
4466
 
4467
+ declare namespace bandersnatch_d_exports {
4468
+ export { batch_verify_tickets, __wbg_init$2 as default, derive_public_key, initSync$2 as initSync, ring_commitment, verify_seal };
4469
+ export type { InitInput$2 as InitInput, InitOutput$2 as InitOutput, SyncInitInput$2 as SyncInitInput };
4470
+ }
4471
+ /* tslint:disable */
4472
+ /* eslint-disable */
4473
+ /**
4474
+ * @param {Uint8Array} keys
4475
+ * @returns {Uint8Array}
4476
+ */
4477
+ declare function ring_commitment(keys: Uint8Array): Uint8Array;
4478
+ /**
4479
+ * Derive Private and Public Key from Seed
4480
+ *
4481
+ * returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
4482
+ * @param {Uint8Array} seed
4483
+ * @returns {Uint8Array}
4484
+ */
4485
+ declare function derive_public_key(seed: Uint8Array): Uint8Array;
4486
+ /**
4487
+ * Seal verification as defined in:
4488
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0eff000eff00?v=0.6.4
4489
+ * or
4490
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0e54010e5401?v=0.6.4
4491
+ * @param {Uint8Array} keys
4492
+ * @param {number} signer_key_index
4493
+ * @param {Uint8Array} seal_data
4494
+ * @param {Uint8Array} payload
4495
+ * @param {Uint8Array} aux_data
4496
+ * @returns {Uint8Array}
4497
+ */
4498
+ declare function verify_seal(keys: Uint8Array, signer_key_index: number, seal_data: Uint8Array, payload: Uint8Array, aux_data: Uint8Array): Uint8Array;
4499
+ /**
4500
+ * Verify multiple tickets at once as defined in:
4501
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0f3e000f3e00?v=0.6.4
4502
+ *
4503
+ * NOTE: the aux_data of VRF function is empty!
4504
+ * @param {Uint8Array} keys
4505
+ * @param {Uint8Array} tickets_data
4506
+ * @param {number} vrf_input_data_len
4507
+ * @returns {Uint8Array}
4508
+ */
4509
+ declare function batch_verify_tickets(keys: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
4510
+ type InitInput$2 = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
4511
+ interface InitOutput$2 {
4512
+ readonly memory: WebAssembly.Memory;
4513
+ readonly ring_commitment: (a: number, b: number, c: number) => void;
4514
+ readonly derive_public_key: (a: number, b: number, c: number) => void;
4515
+ readonly verify_seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
4516
+ readonly batch_verify_tickets: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
4517
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
4518
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
4519
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
4520
+ }
4521
+ type SyncInitInput$2 = BufferSource | WebAssembly.Module;
4522
+ /**
4523
+ * Instantiates the given `module`, which can either be bytes or
4524
+ * a precompiled `WebAssembly.Module`.
4525
+ *
4526
+ * @param {SyncInitInput} module
4527
+ *
4528
+ * @returns {InitOutput}
4529
+ */
4530
+ declare function initSync$2(module: SyncInitInput$2): InitOutput$2;
4531
+
4532
+ /**
4533
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
4534
+ * for everything else, calls `WebAssembly.instantiate` directly.
4535
+ *
4536
+ * @param {InitInput | Promise<InitInput>} module_or_path
4537
+ *
4538
+ * @returns {Promise<InitOutput>}
4539
+ */
4540
+ declare function __wbg_init$2(module_or_path?: InitInput$2 | Promise<InitInput$2>): Promise<InitOutput$2>;
4541
+ //#endregion
4542
+ //#region native/index.d.ts
4543
+ declare function initAll(): Promise<void>;
4544
+
4459
4545
  /** ED25519 private key size. */
4460
4546
  declare const ED25519_PRIV_KEY_BYTES = 32;
4461
4547
  type ED25519_PRIV_KEY_BYTES = typeof ED25519_PRIV_KEY_BYTES;
@@ -4548,7 +4634,7 @@ declare async function verify<T extends BytesBlob>(input: Input<T>[]): Promise<b
4548
4634
  offset += messageLength;
4549
4635
  }
4550
4636
 
4551
- const result = Array.from(verify_ed25519(data)).map((x) => x === 1);
4637
+ const result = Array.from(ed25519.verify_ed25519(data)).map((x) => x === 1);
4552
4638
  return Promise.resolve(result);
4553
4639
  }
4554
4640
 
@@ -4570,7 +4656,7 @@ declare async function verifyBatch<T extends BytesBlob>(input: Input<T>[]): Prom
4570
4656
 
4571
4657
  const data = BytesBlob.blobFromParts(first, ...rest).raw;
4572
4658
 
4573
- return Promise.resolve(verify_ed25519_batch(data));
4659
+ return Promise.resolve(ed25519.verify_ed25519_batch(data));
4574
4660
  }
4575
4661
 
4576
4662
  type ed25519_ED25519_KEY_BYTES = ED25519_KEY_BYTES;
@@ -4590,59 +4676,6 @@ declare namespace ed25519 {
4590
4676
  export type { ed25519_ED25519_KEY_BYTES as ED25519_KEY_BYTES, ed25519_ED25519_PRIV_KEY_BYTES as ED25519_PRIV_KEY_BYTES, ed25519_ED25519_SIGNATURE_BYTES as ED25519_SIGNATURE_BYTES, ed25519_Ed25519Key as Ed25519Key, ed25519_Ed25519Signature as Ed25519Signature, ed25519_Input as Input };
4591
4677
  }
4592
4678
 
4593
- /* tslint:disable */
4594
- /* eslint-disable */
4595
- /**
4596
- * @param {Uint8Array} keys
4597
- * @returns {Uint8Array}
4598
- */
4599
- declare function ring_commitment(keys: Uint8Array): Uint8Array;
4600
- /**
4601
- * Derive Private and Public Key from Seed
4602
- *
4603
- * returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
4604
- * @param {Uint8Array} seed
4605
- * @returns {Uint8Array}
4606
- */
4607
- declare function derive_public_key(seed: Uint8Array): Uint8Array;
4608
- /**
4609
- * Seal verification as defined in:
4610
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0eff000eff00?v=0.6.4
4611
- * or
4612
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0e54010e5401?v=0.6.4
4613
- * @param {Uint8Array} keys
4614
- * @param {number} signer_key_index
4615
- * @param {Uint8Array} seal_data
4616
- * @param {Uint8Array} payload
4617
- * @param {Uint8Array} aux_data
4618
- * @returns {Uint8Array}
4619
- */
4620
- declare function verify_seal(keys: Uint8Array, signer_key_index: number, seal_data: Uint8Array, payload: Uint8Array, aux_data: Uint8Array): Uint8Array;
4621
- /**
4622
- * Verify multiple tickets at once as defined in:
4623
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0f3e000f3e00?v=0.6.4
4624
- *
4625
- * NOTE: the aux_data of VRF function is empty!
4626
- * @param {Uint8Array} keys
4627
- * @param {Uint8Array} tickets_data
4628
- * @param {number} vrf_input_data_len
4629
- * @returns {Uint8Array}
4630
- */
4631
- declare function batch_verify_tickets(keys: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
4632
-
4633
- declare const bandersnatch_d_batch_verify_tickets: typeof batch_verify_tickets;
4634
- declare const bandersnatch_d_derive_public_key: typeof derive_public_key;
4635
- declare const bandersnatch_d_ring_commitment: typeof ring_commitment;
4636
- declare const bandersnatch_d_verify_seal: typeof verify_seal;
4637
- declare namespace bandersnatch_d {
4638
- export {
4639
- bandersnatch_d_batch_verify_tickets as batch_verify_tickets,
4640
- bandersnatch_d_derive_public_key as derive_public_key,
4641
- bandersnatch_d_ring_commitment as ring_commitment,
4642
- bandersnatch_d_verify_seal as verify_seal,
4643
- };
4644
- }
4645
-
4646
4679
  /** Bandersnatch public key size. */
4647
4680
  declare const BANDERSNATCH_KEY_BYTES = 32;
4648
4681
  type BANDERSNATCH_KEY_BYTES = typeof BANDERSNATCH_KEY_BYTES;
@@ -4700,7 +4733,7 @@ type BlsKey = Opaque<Bytes<BLS_KEY_BYTES>, "BlsKey">;
4700
4733
 
4701
4734
  /** Derive a Bandersnatch public key from a seed. */
4702
4735
  declare function publicKey(seed: Uint8Array): BandersnatchKey {
4703
- const key = derive_public_key(seed);
4736
+ const key = bandersnatch.derive_public_key(seed);
4704
4737
 
4705
4738
  check(key[0] === 0, "Invalid Bandersnatch public key derived from seed");
4706
4739
 
@@ -4826,7 +4859,7 @@ declare const index$l_bandersnatch: typeof bandersnatch;
4826
4859
  declare const index$l_ed25519: typeof ed25519;
4827
4860
  declare const index$l_keyDerivation: typeof keyDerivation;
4828
4861
  declare namespace index$l {
4829
- export { index$l_Ed25519Pair as Ed25519Pair, index$l_bandersnatch as bandersnatch, bandersnatch_d as bandersnatchWasm, index$l_ed25519 as ed25519, index$l_keyDerivation as keyDerivation };
4862
+ export { index$l_Ed25519Pair as Ed25519Pair, index$l_bandersnatch as bandersnatch, bandersnatch_d_exports as bandersnatchWasm, index$l_ed25519 as ed25519, initAll as initWasm, index$l_keyDerivation as keyDerivation };
4830
4863
  export type { index$l_BANDERSNATCH_KEY_BYTES as BANDERSNATCH_KEY_BYTES, index$l_BANDERSNATCH_PROOF_BYTES as BANDERSNATCH_PROOF_BYTES, index$l_BANDERSNATCH_RING_ROOT_BYTES as BANDERSNATCH_RING_ROOT_BYTES, index$l_BANDERSNATCH_VRF_SIGNATURE_BYTES as BANDERSNATCH_VRF_SIGNATURE_BYTES, index$l_BLS_KEY_BYTES as BLS_KEY_BYTES, index$l_BandersnatchKey as BandersnatchKey, index$l_BandersnatchProof as BandersnatchProof, index$l_BandersnatchRingRoot as BandersnatchRingRoot, index$l_BandersnatchSecretSeed as BandersnatchSecretSeed, index$l_BandersnatchVrfSignature as BandersnatchVrfSignature, index$l_BlsKey as BlsKey, index$l_ED25519_KEY_BYTES as ED25519_KEY_BYTES, index$l_ED25519_PRIV_KEY_BYTES as ED25519_PRIV_KEY_BYTES, index$l_ED25519_SIGNATURE_BYTES as ED25519_SIGNATURE_BYTES, index$l_Ed25519Key as Ed25519Key, index$l_Ed25519SecretSeed as Ed25519SecretSeed, index$l_Ed25519Signature as Ed25519Signature, KeySeed as PublicKeySeed, index$l_SEED_SIZE as SEED_SIZE };
4831
4864
  }
4832
4865
 
@@ -4906,6 +4939,8 @@ declare class ChainSpec extends WithDebug {
4906
4939
  readonly maxBlockGas: U64;
4907
4940
  /** `G_R`: The gas allocated to invoke a work-package’s Refine logic. */
4908
4941
  readonly maxRefineGas: U64;
4942
+ /** `L`: The maximum age in timeslots of the lookup anchor. */
4943
+ readonly maxLookupAnchorAge: U32;
4909
4944
 
4910
4945
  constructor(data: Omit<ChainSpec, "validatorsSuperMajority" | "thirdOfValidators" | "erasureCodedPieceSize">) {
4911
4946
  super();
@@ -4925,6 +4960,7 @@ declare class ChainSpec extends WithDebug {
4925
4960
  this.erasureCodedPieceSize = tryAsU32(EC_SEGMENT_SIZE / data.numberECPiecesPerSegment);
4926
4961
  this.maxBlockGas = data.maxBlockGas;
4927
4962
  this.maxRefineGas = data.maxRefineGas;
4963
+ this.maxLookupAnchorAge = data.maxLookupAnchorAge;
4928
4964
  }
4929
4965
  }
4930
4966
 
@@ -4943,6 +4979,8 @@ declare const tinyChainSpec = new ChainSpec({
4943
4979
  preimageExpungePeriod: tryAsU32(32),
4944
4980
  maxBlockGas: tryAsU64(20_000_000),
4945
4981
  maxRefineGas: tryAsU64(1_000_000_000),
4982
+ // https://github.com/davxy/jam-conformance/pull/47/files#diff-27e26142b3a96e407dab40d388b63d553f5d9cdb66dec58cd93e63dd434f9e45R260
4983
+ maxLookupAnchorAge: tryAsU32(24),
4946
4984
  });
4947
4985
 
4948
4986
  /**
@@ -4962,6 +5000,7 @@ declare const fullChainSpec = new ChainSpec({
4962
5000
  preimageExpungePeriod: tryAsU32(19_200),
4963
5001
  maxBlockGas: tryAsU64(3_500_000_000),
4964
5002
  maxRefineGas: tryAsU64(5_000_000_000),
5003
+ maxLookupAnchorAge: tryAsU32(14_400),
4965
5004
  });
4966
5005
 
4967
5006
  /**
@@ -6509,6 +6548,22 @@ declare class ValidatorKeys extends WithDebug {
6509
6548
  }
6510
6549
  }
6511
6550
 
6551
+ declare class TicketsMarker extends WithDebug {
6552
+ static Codec = codec.Class(TicketsMarker, {
6553
+ tickets: codecPerEpochBlock(Ticket.Codec),
6554
+ });
6555
+
6556
+ static create({ tickets }: CodecRecord<TicketsMarker>) {
6557
+ return new TicketsMarker(tickets);
6558
+ }
6559
+
6560
+ private constructor(public readonly tickets: PerEpochBlock<Ticket>) {
6561
+ super();
6562
+ }
6563
+ }
6564
+
6565
+ type TicketsMarkerView = DescribedBy<typeof TicketsMarker.Codec.View>;
6566
+
6512
6567
  /**
6513
6568
  * For the first block in a new epoch, the epoch marker is set
6514
6569
  * and contains the epoch randomness and validator keys
@@ -6539,6 +6594,8 @@ declare class EpochMarker extends WithDebug {
6539
6594
  }
6540
6595
  }
6541
6596
 
6597
+ type EpochMarkerView = DescribedBy<typeof EpochMarker.Codec.View>;
6598
+
6542
6599
  /**
6543
6600
  * Return an encoded header without the seal components.
6544
6601
  *
@@ -6561,7 +6618,7 @@ declare const legacyDescriptor = {
6561
6618
  extrinsicHash: codec.bytes(HASH_SIZE).asOpaque<ExtrinsicHash>(),
6562
6619
  timeSlotIndex: codec.u32.asOpaque<TimeSlot>(),
6563
6620
  epochMarker: codec.optional(EpochMarker.Codec),
6564
- ticketsMarker: codec.optional(codecPerEpochBlock(Ticket.Codec)),
6621
+ ticketsMarker: codec.optional(TicketsMarker.Codec),
6565
6622
  offendersMarker: codec.sequenceVarLen(codec.bytes(ED25519_KEY_BYTES).asOpaque<Ed25519Key>()),
6566
6623
  bandersnatchBlockAuthorIndex: codec.u16.asOpaque<ValidatorIndex>(),
6567
6624
  entropySource: codec.bytes(BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque<BandersnatchVrfSignature>(),
@@ -6584,7 +6641,7 @@ declare class Header extends WithDebug {
6584
6641
  extrinsicHash: codec.bytes(HASH_SIZE).asOpaque<ExtrinsicHash>(),
6585
6642
  timeSlotIndex: codec.u32.asOpaque<TimeSlot>(),
6586
6643
  epochMarker: codec.optional(EpochMarker.Codec),
6587
- ticketsMarker: codec.optional(codecPerEpochBlock(Ticket.Codec)),
6644
+ ticketsMarker: codec.optional(TicketsMarker.Codec),
6588
6645
  bandersnatchBlockAuthorIndex: codec.u16.asOpaque<ValidatorIndex>(),
6589
6646
  entropySource: codec.bytes(BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque<BandersnatchVrfSignature>(),
6590
6647
  offendersMarker: codec.sequenceVarLen(codec.bytes(ED25519_KEY_BYTES).asOpaque<Ed25519Key>()),
@@ -6617,7 +6674,7 @@ declare class Header extends WithDebug {
6617
6674
  * `H_w`: Winning tickets provides the series of 600 slot sealing "tickets"
6618
6675
  * for the next epoch.
6619
6676
  */
6620
- public ticketsMarker: PerEpochBlock<Ticket> | null = null;
6677
+ public ticketsMarker: TicketsMarker | null = null;
6621
6678
  /** `H_i`: Block author's index in the current validator set. */
6622
6679
  public bandersnatchBlockAuthorIndex: ValidatorIndex = tryAsValidatorIndex(0);
6623
6680
  /** `H_v`: Entropy-yielding VRF signature. */
@@ -6802,6 +6859,7 @@ type index$j_EntropyHash = EntropyHash;
6802
6859
  type index$j_Epoch = Epoch;
6803
6860
  type index$j_EpochMarker = EpochMarker;
6804
6861
  declare const index$j_EpochMarker: typeof EpochMarker;
6862
+ type index$j_EpochMarkerView = EpochMarkerView;
6805
6863
  type index$j_Extrinsic = Extrinsic;
6806
6864
  declare const index$j_Extrinsic: typeof Extrinsic;
6807
6865
  type index$j_ExtrinsicHash = ExtrinsicHash;
@@ -6821,6 +6879,9 @@ type index$j_SegmentIndex = SegmentIndex;
6821
6879
  type index$j_ServiceGas = ServiceGas;
6822
6880
  type index$j_ServiceId = ServiceId;
6823
6881
  type index$j_StateRootHash = StateRootHash;
6882
+ type index$j_TicketsMarker = TicketsMarker;
6883
+ declare const index$j_TicketsMarker: typeof TicketsMarker;
6884
+ type index$j_TicketsMarkerView = TicketsMarkerView;
6824
6885
  type index$j_TimeSlot = TimeSlot;
6825
6886
  type index$j_ValidatorIndex = ValidatorIndex;
6826
6887
  type index$j_ValidatorKeys = ValidatorKeys;
@@ -6853,8 +6914,8 @@ declare const index$j_workPackage: typeof workPackage;
6853
6914
  declare const index$j_workReport: typeof workReport;
6854
6915
  declare const index$j_workResult: typeof workResult;
6855
6916
  declare namespace index$j {
6856
- export { index$j_Block as Block, index$j_EpochMarker as EpochMarker, index$j_Extrinsic as Extrinsic, index$j_Header as Header, index$j_HeaderViewWithHash as HeaderViewWithHash, index$j_MAX_NUMBER_OF_SEGMENTS as MAX_NUMBER_OF_SEGMENTS, index$j_ValidatorKeys as ValidatorKeys, index$j_W_E as W_E, index$j_W_S as W_S, index$j_assurances as assurances, index$j_codecPerEpochBlock as codecPerEpochBlock, index$j_codecPerValidator as codecPerValidator, codec as codecUtils, index$j_disputes as disputes, index$j_encodeUnsealedHeader as encodeUnsealedHeader, index$j_guarantees as guarantees, index$j_headerViewWithHashCodec as headerViewWithHashCodec, index$j_legacyDescriptor as legacyDescriptor, index$j_preimage as preimage, index$j_refineContext as refineContext, index$j_tickets as tickets, index$j_tryAsCoreIndex as tryAsCoreIndex, index$j_tryAsEpoch as tryAsEpoch, index$j_tryAsPerEpochBlock as tryAsPerEpochBlock, index$j_tryAsPerValidator as tryAsPerValidator, index$j_tryAsSegmentIndex as tryAsSegmentIndex, index$j_tryAsServiceGas as tryAsServiceGas, index$j_tryAsServiceId as tryAsServiceId, index$j_tryAsTimeSlot as tryAsTimeSlot, index$j_tryAsValidatorIndex as tryAsValidatorIndex, index$j_workItem as workItem, index$j_workPackage as workPackage, index$j_workReport as workReport, index$j_workResult as workResult };
6857
- export type { index$j_BlockView as BlockView, index$j_CodeHash as CodeHash, index$j_CoreIndex as CoreIndex, index$j_EntropyHash as EntropyHash, index$j_Epoch as Epoch, index$j_ExtrinsicHash as ExtrinsicHash, index$j_ExtrinsicView as ExtrinsicView, index$j_HeaderHash as HeaderHash, index$j_HeaderView as HeaderView, index$j_PerEpochBlock as PerEpochBlock, index$j_PerValidator as PerValidator, index$j_SEGMENT_BYTES as SEGMENT_BYTES, index$j_Segment as Segment, index$j_SegmentIndex as SegmentIndex, index$j_ServiceGas as ServiceGas, index$j_ServiceId as ServiceId, index$j_StateRootHash as StateRootHash, index$j_TimeSlot as TimeSlot, index$j_ValidatorIndex as ValidatorIndex, index$j_WorkReportHash as WorkReportHash };
6917
+ export { index$j_Block as Block, index$j_EpochMarker as EpochMarker, index$j_Extrinsic as Extrinsic, index$j_Header as Header, index$j_HeaderViewWithHash as HeaderViewWithHash, index$j_MAX_NUMBER_OF_SEGMENTS as MAX_NUMBER_OF_SEGMENTS, index$j_TicketsMarker as TicketsMarker, index$j_ValidatorKeys as ValidatorKeys, index$j_W_E as W_E, index$j_W_S as W_S, index$j_assurances as assurances, index$j_codecPerEpochBlock as codecPerEpochBlock, index$j_codecPerValidator as codecPerValidator, codec as codecUtils, index$j_disputes as disputes, index$j_encodeUnsealedHeader as encodeUnsealedHeader, index$j_guarantees as guarantees, index$j_headerViewWithHashCodec as headerViewWithHashCodec, index$j_legacyDescriptor as legacyDescriptor, index$j_preimage as preimage, index$j_refineContext as refineContext, index$j_tickets as tickets, index$j_tryAsCoreIndex as tryAsCoreIndex, index$j_tryAsEpoch as tryAsEpoch, index$j_tryAsPerEpochBlock as tryAsPerEpochBlock, index$j_tryAsPerValidator as tryAsPerValidator, index$j_tryAsSegmentIndex as tryAsSegmentIndex, index$j_tryAsServiceGas as tryAsServiceGas, index$j_tryAsServiceId as tryAsServiceId, index$j_tryAsTimeSlot as tryAsTimeSlot, index$j_tryAsValidatorIndex as tryAsValidatorIndex, index$j_workItem as workItem, index$j_workPackage as workPackage, index$j_workReport as workReport, index$j_workResult as workResult };
6918
+ export type { index$j_BlockView as BlockView, index$j_CodeHash as CodeHash, index$j_CoreIndex as CoreIndex, index$j_EntropyHash as EntropyHash, index$j_Epoch as Epoch, index$j_EpochMarkerView as EpochMarkerView, index$j_ExtrinsicHash as ExtrinsicHash, index$j_ExtrinsicView as ExtrinsicView, index$j_HeaderHash as HeaderHash, index$j_HeaderView as HeaderView, index$j_PerEpochBlock as PerEpochBlock, index$j_PerValidator as PerValidator, index$j_SEGMENT_BYTES as SEGMENT_BYTES, index$j_Segment as Segment, index$j_SegmentIndex as SegmentIndex, index$j_ServiceGas as ServiceGas, index$j_ServiceId as ServiceId, index$j_StateRootHash as StateRootHash, index$j_TicketsMarkerView as TicketsMarkerView, index$j_TimeSlot as TimeSlot, index$j_ValidatorIndex as ValidatorIndex, index$j_WorkReportHash as WorkReportHash };
6858
6919
  }
6859
6920
 
6860
6921
  /** A type that can be read from a JSON-parsed object. */
@@ -7596,7 +7657,7 @@ declare const epochMark = json.object<JsonEpochMarker, EpochMarker>(
7596
7657
  (x) => EpochMarker.create({ entropy: x.entropy, ticketsEntropy: x.tickets_entropy, validators: x.validators }),
7597
7658
  );
7598
7659
 
7599
- declare const ticketsMark = json.object<Ticket>(
7660
+ declare const ticket = json.object<Ticket>(
7600
7661
  {
7601
7662
  id: fromJson.bytes32(),
7602
7663
  attempt: fromJson.ticketAttempt,
@@ -7610,7 +7671,7 @@ type JsonHeader = {
7610
7671
  extrinsic_hash: ExtrinsicHash;
7611
7672
  slot: TimeSlot;
7612
7673
  epoch_mark?: EpochMarker;
7613
- tickets_mark?: KnownSizeArray<Ticket, "EpochLength">;
7674
+ tickets_mark?: Ticket[];
7614
7675
  offenders_mark: Ed25519Key[];
7615
7676
  author_index: ValidatorIndex;
7616
7677
  entropy_source: BandersnatchVrfSignature;
@@ -7624,7 +7685,7 @@ declare const headerFromJson = json.object<JsonHeader, Header>(
7624
7685
  extrinsic_hash: fromJson.bytes32(),
7625
7686
  slot: "number",
7626
7687
  epoch_mark: json.optional(epochMark),
7627
- tickets_mark: json.optional<Ticket[]>(json.array(ticketsMark)),
7688
+ tickets_mark: json.optional(json.array(ticket)),
7628
7689
  offenders_mark: json.array(fromJson.bytes32<Ed25519Key>()),
7629
7690
  author_index: "number",
7630
7691
  entropy_source: bandersnatchVrfSignature,
@@ -7648,7 +7709,10 @@ declare const headerFromJson = json.object<JsonHeader, Header>(
7648
7709
  header.extrinsicHash = extrinsic_hash;
7649
7710
  header.timeSlotIndex = slot;
7650
7711
  header.epochMarker = epoch_mark ?? null;
7651
- header.ticketsMarker = tickets_mark ?? null;
7712
+ header.ticketsMarker =
7713
+ tickets_mark === undefined || tickets_mark === null
7714
+ ? null
7715
+ : TicketsMarker.create({ tickets: asOpaqueType(tickets_mark) });
7652
7716
  header.offendersMarker = offenders_mark;
7653
7717
  header.bandersnatchBlockAuthorIndex = author_index;
7654
7718
  header.entropySource = entropy_source;
@@ -7698,9 +7762,9 @@ declare const index$h_preimagesExtrinsicFromJson: typeof preimagesExtrinsicFromJ
7698
7762
  declare const index$h_refineContextFromJson: typeof refineContextFromJson;
7699
7763
  declare const index$h_reportGuaranteeFromJson: typeof reportGuaranteeFromJson;
7700
7764
  declare const index$h_segmentRootLookupItemFromJson: typeof segmentRootLookupItemFromJson;
7765
+ declare const index$h_ticket: typeof ticket;
7701
7766
  declare const index$h_ticketEnvelopeFromJson: typeof ticketEnvelopeFromJson;
7702
7767
  declare const index$h_ticketsExtrinsicFromJson: typeof ticketsExtrinsicFromJson;
7703
- declare const index$h_ticketsMark: typeof ticketsMark;
7704
7768
  declare const index$h_validatorKeysFromJson: typeof validatorKeysFromJson;
7705
7769
  declare const index$h_validatorSignatureFromJson: typeof validatorSignatureFromJson;
7706
7770
  declare const index$h_verdictFromJson: typeof verdictFromJson;
@@ -7710,7 +7774,7 @@ declare const index$h_workRefineLoadFromJson: typeof workRefineLoadFromJson;
7710
7774
  declare const index$h_workReportFromJson: typeof workReportFromJson;
7711
7775
  declare const index$h_workResultFromJson: typeof workResultFromJson;
7712
7776
  declare namespace index$h {
7713
- export { index$h_bandersnatchVrfSignature as bandersnatchVrfSignature, index$h_blockFromJson as blockFromJson, index$h_culpritFromJson as culpritFromJson, index$h_disputesExtrinsicFromJson as disputesExtrinsicFromJson, index$h_epochMark as epochMark, index$h_faultFromJson as faultFromJson, index$h_fromJson as fromJson, index$h_getAssurancesExtrinsicFromJson as getAssurancesExtrinsicFromJson, index$h_getAvailabilityAssuranceFromJson as getAvailabilityAssuranceFromJson, index$h_getExtrinsicFromJson as getExtrinsicFromJson, index$h_guaranteesExtrinsicFromJson as guaranteesExtrinsicFromJson, index$h_headerFromJson as headerFromJson, index$h_judgementFromJson as judgementFromJson, index$h_preimageFromJson as preimageFromJson, index$h_preimagesExtrinsicFromJson as preimagesExtrinsicFromJson, index$h_refineContextFromJson as refineContextFromJson, index$h_reportGuaranteeFromJson as reportGuaranteeFromJson, index$h_segmentRootLookupItemFromJson as segmentRootLookupItemFromJson, index$h_ticketEnvelopeFromJson as ticketEnvelopeFromJson, index$h_ticketsExtrinsicFromJson as ticketsExtrinsicFromJson, index$h_ticketsMark as ticketsMark, index$h_validatorKeysFromJson as validatorKeysFromJson, index$h_validatorSignatureFromJson as validatorSignatureFromJson, index$h_verdictFromJson as verdictFromJson, index$h_workExecResultFromJson as workExecResultFromJson, index$h_workPackageSpecFromJson as workPackageSpecFromJson, index$h_workRefineLoadFromJson as workRefineLoadFromJson, index$h_workReportFromJson as workReportFromJson, index$h_workResultFromJson as workResultFromJson };
7777
+ export { index$h_bandersnatchVrfSignature as bandersnatchVrfSignature, index$h_blockFromJson as blockFromJson, index$h_culpritFromJson as culpritFromJson, index$h_disputesExtrinsicFromJson as disputesExtrinsicFromJson, index$h_epochMark as epochMark, index$h_faultFromJson as faultFromJson, index$h_fromJson as fromJson, index$h_getAssurancesExtrinsicFromJson as getAssurancesExtrinsicFromJson, index$h_getAvailabilityAssuranceFromJson as getAvailabilityAssuranceFromJson, index$h_getExtrinsicFromJson as getExtrinsicFromJson, index$h_guaranteesExtrinsicFromJson as guaranteesExtrinsicFromJson, index$h_headerFromJson as headerFromJson, index$h_judgementFromJson as judgementFromJson, index$h_preimageFromJson as preimageFromJson, index$h_preimagesExtrinsicFromJson as preimagesExtrinsicFromJson, index$h_refineContextFromJson as refineContextFromJson, index$h_reportGuaranteeFromJson as reportGuaranteeFromJson, index$h_segmentRootLookupItemFromJson as segmentRootLookupItemFromJson, index$h_ticket as ticket, index$h_ticketEnvelopeFromJson as ticketEnvelopeFromJson, index$h_ticketsExtrinsicFromJson as ticketsExtrinsicFromJson, index$h_validatorKeysFromJson as validatorKeysFromJson, index$h_validatorSignatureFromJson as validatorSignatureFromJson, index$h_verdictFromJson as verdictFromJson, index$h_workExecResultFromJson as workExecResultFromJson, index$h_workPackageSpecFromJson as workPackageSpecFromJson, index$h_workRefineLoadFromJson as workRefineLoadFromJson, index$h_workReportFromJson as workReportFromJson, index$h_workResultFromJson as workResultFromJson };
7714
7778
  export type { index$h_CamelToSnake as CamelToSnake, index$h_JsonCulprit as JsonCulprit, index$h_JsonEpochMarker as JsonEpochMarker, index$h_JsonFault as JsonFault, index$h_JsonHeader as JsonHeader, index$h_JsonJudgement as JsonJudgement, index$h_JsonObject as JsonObject, index$h_JsonRefineContext as JsonRefineContext, index$h_JsonReportGuarantee as JsonReportGuarantee, index$h_JsonVerdict as JsonVerdict, index$h_JsonWorkExecResult as JsonWorkExecResult, index$h_JsonWorkRefineLoad as JsonWorkRefineLoad, index$h_JsonWorkReport as JsonWorkReport, index$h_JsonWorkResult as JsonWorkResult };
7715
7779
  }
7716
7780
 
@@ -7820,7 +7884,7 @@ declare const DEV_CONFIG = "dev";
7820
7884
  declare const DEFAULT_CONFIG = "default";
7821
7885
 
7822
7886
  declare const NODE_DEFAULTS = {
7823
- name: os.hostname(),
7887
+ name: isBrowser() ? "browser" : os.hostname(),
7824
7888
  config: DEFAULT_CONFIG,
7825
7889
  };
7826
7890
 
@@ -7875,11 +7939,11 @@ declare class NodeConfiguration {
7875
7939
 
7876
7940
  declare function loadConfig(configPath: string): NodeConfiguration {
7877
7941
  if (configPath === DEFAULT_CONFIG) {
7878
- return parseFromJson(defaultConfigJson, NodeConfiguration.fromJson);
7942
+ return parseFromJson(configs.default, NodeConfiguration.fromJson);
7879
7943
  }
7880
7944
 
7881
7945
  if (configPath === DEV_CONFIG) {
7882
- return parseFromJson(devConfigJson, NodeConfiguration.fromJson);
7946
+ return parseFromJson(configs.dev, NodeConfiguration.fromJson);
7883
7947
  }
7884
7948
 
7885
7949
  try {
@@ -8220,20 +8284,7 @@ declare class AutoAccumulate {
8220
8284
  declare class PrivilegedServices {
8221
8285
  static Codec = codec.Class(PrivilegedServices, {
8222
8286
  manager: codec.u32.asOpaque<ServiceId>(),
8223
- authManager: Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)
8224
- ? codecPerCore(codec.u32.asOpaque<ServiceId>())
8225
- : codecWithContext((ctx) =>
8226
- codec.u32.asOpaque<ServiceId>().convert(
8227
- // NOTE: [MaSo] In a compatibility mode we are always updating all entries
8228
- // (all the entries are the same)
8229
- // so it doesn't matter which one we take here.
8230
- (perCore: PerCore<ServiceId>) => perCore[0],
8231
- (serviceId: ServiceId) => {
8232
- const array = new Array(ctx.coresCount).fill(serviceId);
8233
- return tryAsPerCore(array, ctx);
8234
- },
8235
- ),
8236
- ),
8287
+ authManager: codecPerCore(codec.u32.asOpaque<ServiceId>()),
8237
8288
  validatorsManager: codec.u32.asOpaque<ServiceId>(),
8238
8289
  autoAccumulateServices: readonlyArray(codec.sequenceVarLen(AutoAccumulate.Codec)),
8239
8290
  });
@@ -8776,11 +8827,6 @@ declare class ServiceAccountInfo extends WithDebug {
8776
8827
  * https://graypaper.fluffylabs.dev/#/7e6ff6a/119e01119e01?v=0.6.7
8777
8828
  */
8778
8829
  static calculateThresholdBalance(items: U32, bytes: U64, gratisStorage: U64): U64 {
8779
- check(
8780
- gratisStorage === tryAsU64(0) || Compatibility.isGreaterOrEqual(GpVersion.V0_6_7),
8781
- "Gratis storage cannot be non-zero before 0.6.7",
8782
- );
8783
-
8784
8830
  const storageCost =
8785
8831
  BASE_SERVICE_BALANCE + ELECTIVE_ITEM_BALANCE * BigInt(items) + ELECTIVE_BYTE_BALANCE * bytes - gratisStorage;
8786
8832
 
@@ -10559,27 +10605,17 @@ declare function* serializeRemovedServices(servicesRemoved: ServiceId[] | undefi
10559
10605
  }
10560
10606
  }
10561
10607
 
10562
- declare function getLegacyKey(serviceId: ServiceId, rawKey: StorageKey): StorageKey {
10563
- const SERVICE_ID_BYTES = 4;
10564
- const serviceIdAndKey = new Uint8Array(SERVICE_ID_BYTES + rawKey.length);
10565
- serviceIdAndKey.set(u32AsLeBytes(serviceId));
10566
- serviceIdAndKey.set(rawKey.raw, SERVICE_ID_BYTES);
10567
- return asOpaqueType(BytesBlob.blobFrom(blake2b.hashBytes(serviceIdAndKey).raw));
10568
- }
10569
-
10570
10608
  declare function* serializeStorage(storage: UpdateStorage[] | undefined): Generator<StateEntryUpdate> {
10571
10609
  for (const { action, serviceId } of storage ?? []) {
10572
10610
  switch (action.kind) {
10573
10611
  case UpdateStorageKind.Set: {
10574
- const key = Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)
10575
- ? action.storage.key
10576
- : getLegacyKey(serviceId, action.storage.key);
10612
+ const key = action.storage.key;
10577
10613
  const codec = serialize.serviceStorage(serviceId, key);
10578
10614
  yield [StateEntryUpdateAction.Insert, codec.key, action.storage.value];
10579
10615
  break;
10580
10616
  }
10581
10617
  case UpdateStorageKind.Remove: {
10582
- const key = Compatibility.isGreaterOrEqual(GpVersion.V0_6_7) ? action.key : getLegacyKey(serviceId, action.key);
10618
+ const key = action.key;
10583
10619
  const codec = serialize.serviceStorage(serviceId, key);
10584
10620
  yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
10585
10621
  break;
@@ -10719,7 +10755,7 @@ declare function* serializeBasicKeys(spec: ChainSpec, update: Partial<State>) {
10719
10755
  yield doSerialize(update.recentlyAccumulated, serialize.recentlyAccumulated); // C(15)
10720
10756
  }
10721
10757
 
10722
- if (update.accumulationOutputLog !== undefined && Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)) {
10758
+ if (update.accumulationOutputLog !== undefined) {
10723
10759
  yield doSerialize(update.accumulationOutputLog, serialize.accumulationOutputLog); // C(16)
10724
10760
  }
10725
10761
  }
@@ -11514,9 +11550,7 @@ declare function convertInMemoryStateToDictionary(
11514
11550
  doSerialize(serialize.statistics); // C(13)
11515
11551
  doSerialize(serialize.accumulationQueue); // C(14)
11516
11552
  doSerialize(serialize.recentlyAccumulated); // C(15)
11517
- if (Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)) {
11518
- doSerialize(serialize.accumulationOutputLog); // C(16)
11519
- }
11553
+ doSerialize(serialize.accumulationOutputLog); // C(16)
11520
11554
 
11521
11555
  // services
11522
11556
  for (const [serviceId, service] of state.services.entries()) {
@@ -11707,10 +11741,7 @@ declare class SerializedState<T extends SerializedStateBackend = SerializedState
11707
11741
  }
11708
11742
 
11709
11743
  get accumulationOutputLog(): State["accumulationOutputLog"] {
11710
- if (Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)) {
11711
- return this.retrieve(serialize.accumulationOutputLog, "accumulationOutputLog");
11712
- }
11713
- return [];
11744
+ return this.retrieve(serialize.accumulationOutputLog, "accumulationOutputLog");
11714
11745
  }
11715
11746
  }
11716
11747
 
@@ -11857,7 +11888,6 @@ declare const index$c_U32_BYTES: typeof U32_BYTES;
11857
11888
  declare const index$c_binaryMerkleization: typeof binaryMerkleization;
11858
11889
  declare const index$c_convertInMemoryStateToDictionary: typeof convertInMemoryStateToDictionary;
11859
11890
  declare const index$c_dumpCodec: typeof dumpCodec;
11860
- declare const index$c_getLegacyKey: typeof getLegacyKey;
11861
11891
  declare const index$c_getSafroleData: typeof getSafroleData;
11862
11892
  declare const index$c_legacyServiceNested: typeof legacyServiceNested;
11863
11893
  declare const index$c_loadState: typeof loadState;
@@ -11871,7 +11901,7 @@ declare const index$c_serializeStorage: typeof serializeStorage;
11871
11901
  declare const index$c_stateEntriesSequenceCodec: typeof stateEntriesSequenceCodec;
11872
11902
  import index$c_stateKeys = stateKeys;
11873
11903
  declare namespace index$c {
11874
- export { index$c_EMPTY_BLOB as EMPTY_BLOB, index$c_SerializedService as SerializedService, index$c_SerializedState as SerializedState, index$c_StateEntries as StateEntries, index$c_StateEntryUpdateAction as StateEntryUpdateAction, index$c_StateKeyIdx as StateKeyIdx, index$c_TYPICAL_STATE_ITEMS as TYPICAL_STATE_ITEMS, index$c_TYPICAL_STATE_ITEM_LEN as TYPICAL_STATE_ITEM_LEN, index$c_U32_BYTES as U32_BYTES, index$c_binaryMerkleization as binaryMerkleization, index$c_convertInMemoryStateToDictionary as convertInMemoryStateToDictionary, index$c_dumpCodec as dumpCodec, index$c_getLegacyKey as getLegacyKey, index$c_getSafroleData as getSafroleData, index$c_legacyServiceNested as legacyServiceNested, index$c_loadState as loadState, index$c_serialize as serialize, index$c_serializeBasicKeys as serializeBasicKeys, index$c_serializePreimages as serializePreimages, index$c_serializeRemovedServices as serializeRemovedServices, index$c_serializeServiceUpdates as serializeServiceUpdates, index$c_serializeStateUpdate as serializeStateUpdate, index$c_serializeStorage as serializeStorage, index$c_stateEntriesSequenceCodec as stateEntriesSequenceCodec, index$c_stateKeys as stateKeys };
11904
+ export { index$c_EMPTY_BLOB as EMPTY_BLOB, index$c_SerializedService as SerializedService, index$c_SerializedState as SerializedState, index$c_StateEntries as StateEntries, index$c_StateEntryUpdateAction as StateEntryUpdateAction, index$c_StateKeyIdx as StateKeyIdx, index$c_TYPICAL_STATE_ITEMS as TYPICAL_STATE_ITEMS, index$c_TYPICAL_STATE_ITEM_LEN as TYPICAL_STATE_ITEM_LEN, index$c_U32_BYTES as U32_BYTES, index$c_binaryMerkleization as binaryMerkleization, index$c_convertInMemoryStateToDictionary as convertInMemoryStateToDictionary, index$c_dumpCodec as dumpCodec, index$c_getSafroleData as getSafroleData, index$c_legacyServiceNested as legacyServiceNested, index$c_loadState as loadState, index$c_serialize as serialize, index$c_serializeBasicKeys as serializeBasicKeys, index$c_serializePreimages as serializePreimages, index$c_serializeRemovedServices as serializeRemovedServices, index$c_serializeServiceUpdates as serializeServiceUpdates, index$c_serializeStateUpdate as serializeStateUpdate, index$c_serializeStorage as serializeStorage, index$c_stateEntriesSequenceCodec as stateEntriesSequenceCodec, index$c_stateKeys as stateKeys };
11875
11905
  export type { index$c_EncodeFun as EncodeFun, index$c_KeyAndCodec as KeyAndCodec, index$c_SerializedStateBackend as SerializedStateBackend, index$c_StateCodec as StateCodec, index$c_StateEntryUpdate as StateEntryUpdate, StateKey$1 as StateKey };
11876
11906
  }
11877
11907
 
@@ -12231,8 +12261,8 @@ declare function encodePoints(input: Bytes<PIECE_SIZE>): FixedSizeArray<Bytes<PO
12231
12261
  }
12232
12262
 
12233
12263
  // encode and add redundancy shards
12234
- const points = new ShardsCollection(POINT_ALIGNMENT, data);
12235
- const encodedResult = encode(N_CHUNKS_REDUNDANCY, POINT_ALIGNMENT, points);
12264
+ const points = new reedSolomon.ShardsCollection(POINT_ALIGNMENT, data);
12265
+ const encodedResult = reedSolomon.encode(N_CHUNKS_REDUNDANCY, points);
12236
12266
  const encodedData = encodedResult.take_data();
12237
12267
 
12238
12268
  for (let i = 0; i < N_CHUNKS_REDUNDANCY; i++) {
@@ -12274,9 +12304,9 @@ declare function decodePiece(
12274
12304
  result.raw.set(points.raw, pointStartInResult);
12275
12305
  }
12276
12306
  }
12277
- const points = new ShardsCollection(POINT_ALIGNMENT, data, indices);
12307
+ const points = new reedSolomon.ShardsCollection(POINT_ALIGNMENT, data, indices);
12278
12308
 
12279
- const decodingResult = decode(N_CHUNKS_REQUIRED, N_CHUNKS_REDUNDANCY, POINT_ALIGNMENT, points);
12309
+ const decodingResult = reedSolomon.decode(N_CHUNKS_REQUIRED, N_CHUNKS_REDUNDANCY, points);
12280
12310
  const resultIndices = decodingResult.take_indices(); // it has to be called before take_data
12281
12311
  const resultData = decodingResult.take_data(); // it destroys the result object in rust
12282
12312
 
@@ -12513,6 +12543,10 @@ declare function chunksToShards(
12513
12543
  return tryAsPerValidator(result, spec);
12514
12544
  }
12515
12545
 
12546
+ declare const initEc = async () => {
12547
+ await init.reedSolomon();
12548
+ };
12549
+
12516
12550
  declare const index$a_HALF_POINT_SIZE: typeof HALF_POINT_SIZE;
12517
12551
  declare const index$a_N_CHUNKS_REDUNDANCY: typeof N_CHUNKS_REDUNDANCY;
12518
12552
  type index$a_N_CHUNKS_REQUIRED = N_CHUNKS_REQUIRED;
@@ -12526,6 +12560,7 @@ declare const index$a_decodeData: typeof decodeData;
12526
12560
  declare const index$a_decodeDataAndTrim: typeof decodeDataAndTrim;
12527
12561
  declare const index$a_decodePiece: typeof decodePiece;
12528
12562
  declare const index$a_encodePoints: typeof encodePoints;
12563
+ declare const index$a_initEc: typeof initEc;
12529
12564
  declare const index$a_join: typeof join;
12530
12565
  declare const index$a_lace: typeof lace;
12531
12566
  declare const index$a_padAndEncodeData: typeof padAndEncodeData;
@@ -12534,7 +12569,7 @@ declare const index$a_split: typeof split;
12534
12569
  declare const index$a_transpose: typeof transpose;
12535
12570
  declare const index$a_unzip: typeof unzip;
12536
12571
  declare namespace index$a {
12537
- export { index$a_HALF_POINT_SIZE as HALF_POINT_SIZE, index$a_N_CHUNKS_REDUNDANCY as N_CHUNKS_REDUNDANCY, index$a_POINT_ALIGNMENT as POINT_ALIGNMENT, index$a_chunkingFunction as chunkingFunction, index$a_chunksToShards as chunksToShards, index$a_decodeData as decodeData, index$a_decodeDataAndTrim as decodeDataAndTrim, index$a_decodePiece as decodePiece, index$a_encodePoints as encodePoints, index$a_join as join, index$a_lace as lace, index$a_padAndEncodeData as padAndEncodeData, index$a_shardsToChunks as shardsToChunks, index$a_split as split, index$a_transpose as transpose, index$a_unzip as unzip };
12572
+ export { index$a_HALF_POINT_SIZE as HALF_POINT_SIZE, index$a_N_CHUNKS_REDUNDANCY as N_CHUNKS_REDUNDANCY, index$a_POINT_ALIGNMENT as POINT_ALIGNMENT, index$a_chunkingFunction as chunkingFunction, index$a_chunksToShards as chunksToShards, index$a_decodeData as decodeData, index$a_decodeDataAndTrim as decodeDataAndTrim, index$a_decodePiece as decodePiece, index$a_encodePoints as encodePoints, index$a_initEc as initEc, index$a_join as join, index$a_lace as lace, index$a_padAndEncodeData as padAndEncodeData, index$a_shardsToChunks as shardsToChunks, index$a_split as split, index$a_transpose as transpose, index$a_unzip as unzip };
12538
12573
  export type { index$a_N_CHUNKS_REQUIRED as N_CHUNKS_REQUIRED, index$a_N_CHUNKS_TOTAL as N_CHUNKS_TOTAL, index$a_PIECE_SIZE as PIECE_SIZE, index$a_POINT_LENGTH as POINT_LENGTH };
12539
12574
  }
12540
12575
 
@@ -12566,61 +12601,228 @@ declare const HostCallResult = {
12566
12601
  OK: tryAsU64(0n),
12567
12602
  } as const;
12568
12603
 
12604
+ declare enum Level {
12605
+ INSANE = 1,
12606
+ TRACE = 2,
12607
+ LOG = 3,
12608
+ INFO = 4,
12609
+ WARN = 5,
12610
+ ERROR = 6,
12611
+ }
12612
+
12613
+ type Options = {
12614
+ defaultLevel: Level;
12615
+ workingDir: string;
12616
+ modules: Map<string, Level>;
12617
+ };
12618
+
12569
12619
  /**
12570
- * Mask class is an implementation of skip function defined in GP.
12620
+ * A function to parse logger definition (including modules) given as a string.
12571
12621
  *
12572
- * https://graypaper.fluffylabs.dev/#/5f542d7/237201239801
12622
+ * Examples
12623
+ * - `info` - setup default logging level to `info`.
12624
+ * - `trace` - default logging level set to `trace`.
12625
+ * - `debug;consensus=trace` - default level is set to `debug/log`, but consensus is in trace mode.
12573
12626
  */
12574
- declare class Mask {
12627
+ declare function parseLoggerOptions(input: string, defaultLevel: Level, workingDir?: string): Options {
12628
+ const modules = new Map<string, Level>();
12629
+ const parts = input.toLowerCase().split(",");
12630
+ let defLevel = defaultLevel;
12631
+
12632
+ for (const p of parts) {
12633
+ const clean = p.trim();
12634
+ // skip empty objects (forgotten `,` removed)
12635
+ if (clean.length === 0) {
12636
+ continue;
12637
+ }
12638
+ // we just have the default level
12639
+ if (clean.includes("=")) {
12640
+ const [mod, lvl] = clean.split("=");
12641
+ modules.set(mod.trim(), parseLevel(lvl.trim()));
12642
+ } else {
12643
+ defLevel = parseLevel(clean);
12644
+ }
12645
+ }
12646
+
12647
+ // TODO [ToDr] Fix dirname for workers.
12648
+ const myDir = (import.meta.dirname ?? "").split("/");
12649
+ myDir.pop();
12650
+ myDir.pop();
12651
+ return {
12652
+ defaultLevel: defLevel,
12653
+ modules,
12654
+ workingDir: workingDir ?? myDir.join("/"),
12655
+ };
12656
+ }
12657
+
12658
+ declare const GLOBAL_CONFIG = {
12659
+ options: DEFAULT_OPTIONS,
12660
+ transport: ConsoleTransport.create(DEFAULT_OPTIONS.defaultLevel, DEFAULT_OPTIONS),
12661
+ };
12662
+
12663
+ /**
12664
+ * A logger instance.
12665
+ */
12666
+ declare class Logger {
12575
12667
  /**
12576
- * The lookup table will have `0` at the index which corresponds to an instruction on the same index in the bytecode.
12577
- * In case the value is non-zero it signifies the offset to the index with next instruction.
12668
+ * Create a new logger instance given filename and an optional module name.
12578
12669
  *
12579
- * Example:
12580
- * ```
12581
- * 0..1..2..3..4..5..6..7..8..9 # Indices
12582
- * 0..2..1..0..1..0..3..2..1..0 # lookupTable forward values
12583
- * ```
12584
- * There are instructions at indices `0, 3, 5, 9`.
12670
+ * If the module name is not given, `fileName` becomes the module name.
12671
+ * The module name can be composed from multiple parts separated with `/`.
12672
+ *
12673
+ * The logger will use a global configuration which can be changed using
12674
+ * [`configureLogger`] function.
12585
12675
  */
12586
- private lookupTableForward: Uint8Array;
12587
-
12588
- constructor(mask: BitVec) {
12589
- this.lookupTableForward = this.buildLookupTableForward(mask);
12676
+ static new(fileName?: string, moduleName?: string) {
12677
+ const fName = fileName ?? "unknown";
12678
+ return new Logger(moduleName ?? fName, fName, GLOBAL_CONFIG);
12590
12679
  }
12591
12680
 
12592
- isInstruction(index: number) {
12593
- return this.lookupTableForward[index] === 0;
12681
+ /**
12682
+ * Return currently configured level for given module. */
12683
+ static getLevel(moduleName: string): Level {
12684
+ return findLevel(GLOBAL_CONFIG.options, moduleName);
12594
12685
  }
12595
12686
 
12596
- getNoOfBytesToNextInstruction(index: number) {
12597
- check(index >= 0, `index (${index}) cannot be a negative number`);
12598
- return Math.min(this.lookupTableForward[index] ?? 0, MAX_INSTRUCTION_DISTANCE);
12599
- }
12687
+ /**
12688
+ * Global configuration of all loggers.
12689
+ *
12690
+ * One can specify a default logging level (only logs with level >= default will be printed).
12691
+ * It's also possible to configure per-module logging level that takes precedence
12692
+ * over the default one.
12693
+ *
12694
+ * Changing the options affects all previously created loggers.
12695
+ */
12696
+ static configureAllFromOptions(options: Options) {
12697
+ // find minimal level to optimise logging in case
12698
+ // we don't care about low-level logs.
12699
+ const minimalLevel = Array.from(options.modules.values()).reduce((level, modLevel) => {
12700
+ return level < modLevel ? level : modLevel;
12701
+ }, options.defaultLevel);
12600
12702
 
12601
- private buildLookupTableForward(mask: BitVec) {
12602
- const table = new Uint8Array(mask.bitLength);
12603
- let lastInstructionOffset = 0;
12604
- for (let i = mask.bitLength - 1; i >= 0; i--) {
12605
- if (mask.isSet(i)) {
12606
- lastInstructionOffset = 0;
12607
- } else {
12608
- lastInstructionOffset++;
12609
- }
12610
- table[i] = lastInstructionOffset;
12611
- }
12612
- return table;
12703
+ const transport = ConsoleTransport.create(minimalLevel, options);
12704
+
12705
+ // set the global config
12706
+ GLOBAL_CONFIG.options = options;
12707
+ GLOBAL_CONFIG.transport = transport;
12613
12708
  }
12614
12709
 
12615
- static empty() {
12616
- return new Mask(BitVec.empty(0));
12710
+ /**
12711
+ * Global configuration of all loggers.
12712
+ *
12713
+ * Parse configuration options from an input string typically obtained
12714
+ * from environment variable `JAM_LOG`.
12715
+ */
12716
+ static configureAll(input: string, defaultLevel: Level, workingDir?: string) {
12717
+ const options = parseLoggerOptions(input, defaultLevel, workingDir);
12718
+ Logger.configureAllFromOptions(options);
12617
12719
  }
12618
- }
12619
12720
 
12620
- declare enum ArgumentType {
12621
- NO_ARGUMENTS = 0,
12622
- ONE_IMMEDIATE = 1,
12623
- TWO_IMMEDIATES = 2,
12721
+ constructor(
12722
+ private readonly moduleName: string,
12723
+ private readonly fileName: string,
12724
+ private readonly config: typeof GLOBAL_CONFIG,
12725
+ ) {}
12726
+
12727
+ /** Log a message with `INSANE` level. */
12728
+ insane(val: string) {
12729
+ this.config.transport.insane(this.moduleName, val);
12730
+ }
12731
+
12732
+ /** Log a message with `TRACE` level. */
12733
+ trace(val: string) {
12734
+ this.config.transport.trace(this.moduleName, val);
12735
+ }
12736
+
12737
+ /** Log a message with `DEBUG`/`LOG` level. */
12738
+ log(val: string) {
12739
+ this.config.transport.log(this.moduleName, val);
12740
+ }
12741
+
12742
+ /** Log a message with `INFO` level. */
12743
+ info(val: string) {
12744
+ this.config.transport.info(this.moduleName, val);
12745
+ }
12746
+
12747
+ /** Log a message with `WARN` level. */
12748
+ warn(val: string) {
12749
+ this.config.transport.warn(this.moduleName, val);
12750
+ }
12751
+
12752
+ /** Log a message with `ERROR` level. */
12753
+ error(val: string) {
12754
+ this.config.transport.error(this.moduleName, val);
12755
+ }
12756
+ }
12757
+
12758
+ type index$9_Level = Level;
12759
+ declare const index$9_Level: typeof Level;
12760
+ type index$9_Logger = Logger;
12761
+ declare const index$9_Logger: typeof Logger;
12762
+ declare const index$9_parseLoggerOptions: typeof parseLoggerOptions;
12763
+ declare namespace index$9 {
12764
+ export {
12765
+ index$9_Level as Level,
12766
+ index$9_Logger as Logger,
12767
+ index$9_parseLoggerOptions as parseLoggerOptions,
12768
+ };
12769
+ }
12770
+
12771
+ /**
12772
+ * Mask class is an implementation of skip function defined in GP.
12773
+ *
12774
+ * https://graypaper.fluffylabs.dev/#/5f542d7/237201239801
12775
+ */
12776
+ declare class Mask {
12777
+ /**
12778
+ * The lookup table will have `0` at the index which corresponds to an instruction on the same index in the bytecode.
12779
+ * In case the value is non-zero it signifies the offset to the index with next instruction.
12780
+ *
12781
+ * Example:
12782
+ * ```
12783
+ * 0..1..2..3..4..5..6..7..8..9 # Indices
12784
+ * 0..2..1..0..1..0..3..2..1..0 # lookupTable forward values
12785
+ * ```
12786
+ * There are instructions at indices `0, 3, 5, 9`.
12787
+ */
12788
+ private lookupTableForward: Uint8Array;
12789
+
12790
+ constructor(mask: BitVec) {
12791
+ this.lookupTableForward = this.buildLookupTableForward(mask);
12792
+ }
12793
+
12794
+ isInstruction(index: number) {
12795
+ return this.lookupTableForward[index] === 0;
12796
+ }
12797
+
12798
+ getNoOfBytesToNextInstruction(index: number) {
12799
+ check(index >= 0, `index (${index}) cannot be a negative number`);
12800
+ return Math.min(this.lookupTableForward[index] ?? 0, MAX_INSTRUCTION_DISTANCE);
12801
+ }
12802
+
12803
+ private buildLookupTableForward(mask: BitVec) {
12804
+ const table = new Uint8Array(mask.bitLength);
12805
+ let lastInstructionOffset = 0;
12806
+ for (let i = mask.bitLength - 1; i >= 0; i--) {
12807
+ if (mask.isSet(i)) {
12808
+ lastInstructionOffset = 0;
12809
+ } else {
12810
+ lastInstructionOffset++;
12811
+ }
12812
+ table[i] = lastInstructionOffset;
12813
+ }
12814
+ return table;
12815
+ }
12816
+
12817
+ static empty() {
12818
+ return new Mask(BitVec.empty(0));
12819
+ }
12820
+ }
12821
+
12822
+ declare enum ArgumentType {
12823
+ NO_ARGUMENTS = 0,
12824
+ ONE_IMMEDIATE = 1,
12825
+ TWO_IMMEDIATES = 2,
12624
12826
  ONE_OFFSET = 3,
12625
12827
  ONE_REGISTER_ONE_IMMEDIATE = 4,
12626
12828
  ONE_REGISTER_TWO_IMMEDIATES = 5,
@@ -13825,13 +14027,14 @@ declare abstract class MemoryPage {
13825
14027
  * And then a new version of TypeScript is released.
13826
14028
  */
13827
14029
  declare global {
13828
- interface ArrayBufferConstructor {
13829
- new (length: number, options?: { maxByteLength: number }): ArrayBuffer;
13830
- }
13831
-
13832
- interface ArrayBuffer {
13833
- resize(length: number): void;
13834
- }
14030
+ interface ArrayBufferConstructor {
14031
+ new (length: number, options?: {
14032
+ maxByteLength: number;
14033
+ }): ArrayBuffer;
14034
+ }
14035
+ interface ArrayBuffer {
14036
+ resize(length: number): void;
14037
+ }
13835
14038
  }
13836
14039
 
13837
14040
  type InitialMemoryState = {
@@ -13844,6 +14047,7 @@ declare enum AccessType {
13844
14047
  READ = 0,
13845
14048
  WRITE = 1,
13846
14049
  }
14050
+
13847
14051
  declare class Memory {
13848
14052
  static fromInitialMemory(initialMemoryState: InitialMemoryState) {
13849
14053
  return new Memory(
@@ -13880,6 +14084,7 @@ declare class Memory {
13880
14084
  return Result.ok(OK);
13881
14085
  }
13882
14086
 
14087
+ logger.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
13883
14088
  const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
13884
14089
 
13885
14090
  if (pagesResult.isError) {
@@ -13968,6 +14173,7 @@ declare class Memory {
13968
14173
  bytesLeft -= bytesToRead;
13969
14174
  }
13970
14175
 
14176
+ logger.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
13971
14177
  return Result.ok(OK);
13972
14178
  }
13973
14179
 
@@ -14967,6 +15173,10 @@ declare class JumpTable {
14967
15173
  return new JumpTable(0, new Uint8Array());
14968
15174
  }
14969
15175
 
15176
+ getSize() {
15177
+ return this.indices.length;
15178
+ }
15179
+
14970
15180
  copyFrom(jt: JumpTable) {
14971
15181
  this.indices = jt.indices;
14972
15182
  }
@@ -15868,167 +16078,6 @@ declare class OneRegOneExtImmDispatcher {
15868
16078
  }
15869
16079
  }
15870
16080
 
15871
- declare enum Level {
15872
- TRACE = 1,
15873
- LOG = 2,
15874
- INFO = 3,
15875
- WARN = 4,
15876
- ERROR = 5,
15877
- }
15878
-
15879
- type Options = {
15880
- defaultLevel: Level;
15881
- workingDir: string;
15882
- modules: Map<string, Level>;
15883
- };
15884
-
15885
- /**
15886
- * A function to parse logger definition (including modules) given as a string.
15887
- *
15888
- * Examples
15889
- * - `info` - setup default logging level to `info`.
15890
- * - `trace` - default logging level set to `trace`.
15891
- * - `debug;consensus=trace` - default level is set to `debug/log`, but consensus is in trace mode.
15892
- */
15893
- declare function parseLoggerOptions(input: string, defaultLevel: Level, workingDir?: string): Options {
15894
- const modules = new Map<string, Level>();
15895
- const parts = input.toLowerCase().split(",");
15896
- let defLevel = defaultLevel;
15897
-
15898
- for (const p of parts) {
15899
- const clean = p.trim();
15900
- // skip empty objects (forgotten `,` removed)
15901
- if (clean.length === 0) {
15902
- continue;
15903
- }
15904
- // we just have the default level
15905
- if (clean.includes("=")) {
15906
- const [mod, lvl] = clean.split("=");
15907
- modules.set(mod.trim(), parseLevel(lvl.trim()));
15908
- } else {
15909
- defLevel = parseLevel(clean);
15910
- }
15911
- }
15912
-
15913
- // TODO [ToDr] Fix dirname for workers.
15914
- const myDir = (import.meta.dirname ?? "").split("/");
15915
- myDir.pop();
15916
- myDir.pop();
15917
- return {
15918
- defaultLevel: defLevel,
15919
- modules,
15920
- workingDir: workingDir ?? myDir.join("/"),
15921
- };
15922
- }
15923
-
15924
- declare const GLOBAL_CONFIG = {
15925
- options: DEFAULT_OPTIONS,
15926
- transport: ConsoleTransport.create(DEFAULT_OPTIONS.defaultLevel, DEFAULT_OPTIONS),
15927
- };
15928
-
15929
- /**
15930
- * A logger instance.
15931
- */
15932
- declare class Logger {
15933
- /**
15934
- * Create a new logger instance given filename and an optional module name.
15935
- *
15936
- * If the module name is not given, `fileName` becomes the module name.
15937
- * The module name can be composed from multiple parts separated with `/`.
15938
- *
15939
- * The logger will use a global configuration which can be changed using
15940
- * [`configureLogger`] function.
15941
- */
15942
- static new(fileName?: string, moduleName?: string) {
15943
- const fName = fileName ?? "unknown";
15944
- return new Logger(moduleName ?? fName, fName, GLOBAL_CONFIG);
15945
- }
15946
-
15947
- /**
15948
- * Return currently configured level for given module. */
15949
- static getLevel(moduleName: string): Level {
15950
- return findLevel(GLOBAL_CONFIG.options, moduleName);
15951
- }
15952
-
15953
- /**
15954
- * Global configuration of all loggers.
15955
- *
15956
- * One can specify a default logging level (only logs with level >= default will be printed).
15957
- * It's also possible to configure per-module logging level that takes precedence
15958
- * over the default one.
15959
- *
15960
- * Changing the options affects all previously created loggers.
15961
- */
15962
- static configureAllFromOptions(options: Options) {
15963
- // find minimal level to optimise logging in case
15964
- // we don't care about low-level logs.
15965
- const minimalLevel = Array.from(options.modules.values()).reduce((level, modLevel) => {
15966
- return level < modLevel ? level : modLevel;
15967
- }, options.defaultLevel);
15968
-
15969
- const transport = ConsoleTransport.create(minimalLevel, options);
15970
-
15971
- // set the global config
15972
- GLOBAL_CONFIG.options = options;
15973
- GLOBAL_CONFIG.transport = transport;
15974
- }
15975
-
15976
- /**
15977
- * Global configuration of all loggers.
15978
- *
15979
- * Parse configuration options from an input string typically obtained
15980
- * from environment variable `JAM_LOG`.
15981
- */
15982
- static configureAll(input: string, defaultLevel: Level, workingDir?: string) {
15983
- const options = parseLoggerOptions(input, defaultLevel, workingDir);
15984
- Logger.configureAllFromOptions(options);
15985
- }
15986
-
15987
- constructor(
15988
- private readonly moduleName: string,
15989
- private readonly fileName: string,
15990
- private readonly config: typeof GLOBAL_CONFIG,
15991
- ) {}
15992
-
15993
- /** Log a message with `TRACE` level. */
15994
- trace(val: string) {
15995
- this.config.transport.trace(this.moduleName, this.fileName, val);
15996
- }
15997
-
15998
- /** Log a message with `DEBUG`/`LOG` level. */
15999
- log(val: string) {
16000
- this.config.transport.log(this.moduleName, this.fileName, val);
16001
- }
16002
-
16003
- /** Log a message with `INFO` level. */
16004
- info(val: string) {
16005
- this.config.transport.info(this.moduleName, this.fileName, val);
16006
- }
16007
-
16008
- /** Log a message with `WARN` level. */
16009
- warn(val: string) {
16010
- this.config.transport.warn(this.moduleName, this.fileName, val);
16011
- }
16012
-
16013
- /** Log a message with `ERROR` level. */
16014
- error(val: string) {
16015
- this.config.transport.error(this.moduleName, this.fileName, val);
16016
- }
16017
- }
16018
-
16019
- type index$9_Level = Level;
16020
- declare const index$9_Level: typeof Level;
16021
- type index$9_Logger = Logger;
16022
- declare const index$9_Logger: typeof Logger;
16023
- declare const index$9_parseLoggerOptions: typeof parseLoggerOptions;
16024
- declare namespace index$9 {
16025
- export {
16026
- index$9_Level as Level,
16027
- index$9_Logger as Logger,
16028
- index$9_parseLoggerOptions as parseLoggerOptions,
16029
- };
16030
- }
16031
-
16032
16081
  declare enum ProgramDecoderError {
16033
16082
  InvalidProgramError = 0,
16034
16083
  }
@@ -16111,6 +16160,8 @@ type InterpreterOptions = {
16111
16160
  useSbrkGas?: boolean;
16112
16161
  };
16113
16162
 
16163
+ declare const logger = Logger.new(import.meta.filename, "pvm");
16164
+
16114
16165
  declare class Interpreter {
16115
16166
  private readonly useSbrkGas: boolean;
16116
16167
  private registers = new Registers();
@@ -16246,6 +16297,8 @@ declare class Interpreter {
16246
16297
  const argsResult = this.argsDecodingResults[argsType];
16247
16298
  this.argsDecoder.fillArgs(this.pc, argsResult);
16248
16299
 
16300
+ logger.insane(`[PC: ${this.pc}] ${Instruction[currentInstruction]}`);
16301
+
16249
16302
  if (!isValidInstruction) {
16250
16303
  this.instructionResult.status = Result.PANIC;
16251
16304
  } else {
@@ -16321,6 +16374,7 @@ declare class Interpreter {
16321
16374
  this.status = Status.HOST;
16322
16375
  break;
16323
16376
  }
16377
+ logger.insane(`[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}`);
16324
16378
  return this.status;
16325
16379
  }
16326
16380
 
@@ -16392,13 +16446,14 @@ declare const index$8_Registers: typeof Registers;
16392
16446
  type index$8_SbrkIndex = SbrkIndex;
16393
16447
  type index$8_SmallGas = SmallGas;
16394
16448
  declare const index$8_gasCounter: typeof gasCounter;
16449
+ declare const index$8_logger: typeof logger;
16395
16450
  declare const index$8_tryAsBigGas: typeof tryAsBigGas;
16396
16451
  declare const index$8_tryAsGas: typeof tryAsGas;
16397
16452
  declare const index$8_tryAsMemoryIndex: typeof tryAsMemoryIndex;
16398
16453
  declare const index$8_tryAsSbrkIndex: typeof tryAsSbrkIndex;
16399
16454
  declare const index$8_tryAsSmallGas: typeof tryAsSmallGas;
16400
16455
  declare namespace index$8 {
16401
- export { index$8_Interpreter as Interpreter, index$8_Memory as Memory, index$8_MemoryBuilder as MemoryBuilder, index$8_Registers as Registers, index$8_gasCounter as gasCounter, index$8_tryAsBigGas as tryAsBigGas, index$8_tryAsGas as tryAsGas, index$8_tryAsMemoryIndex as tryAsMemoryIndex, index$8_tryAsSbrkIndex as tryAsSbrkIndex, index$8_tryAsSmallGas as tryAsSmallGas };
16456
+ export { index$8_Interpreter as Interpreter, index$8_Memory as Memory, index$8_MemoryBuilder as MemoryBuilder, index$8_Registers as Registers, index$8_gasCounter as gasCounter, index$8_logger as logger, index$8_tryAsBigGas as tryAsBigGas, index$8_tryAsGas as tryAsGas, index$8_tryAsMemoryIndex as tryAsMemoryIndex, index$8_tryAsSbrkIndex as tryAsSbrkIndex, index$8_tryAsSmallGas as tryAsSmallGas };
16402
16457
  export type { index$8_BigGas as BigGas, index$8_Gas as Gas, index$8_GasCounter as GasCounter, index$8_InterpreterOptions as InterpreterOptions, index$8_MemoryIndex as MemoryIndex, index$8_SbrkIndex as SbrkIndex, index$8_SmallGas as SmallGas };
16403
16458
  }
16404
16459
 
@@ -16536,7 +16591,7 @@ declare class HostCallsManager {
16536
16591
  return `r${idx}=${value} (0x${value.toString(16)})`;
16537
16592
  })
16538
16593
  .join(", ");
16539
- logger.trace(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
16594
+ logger.insane(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
16540
16595
  }
16541
16596
  }
16542
16597
 
@@ -16657,14 +16712,15 @@ declare class HostCalls {
16657
16712
  const gasCost = typeof hostCall.gasCost === "number" ? hostCall.gasCost : hostCall.gasCost(regs);
16658
16713
  const underflow = gas.sub(gasCost);
16659
16714
 
16715
+ const pcLog = `[PC: ${pvmInstance.getPC()}]`;
16660
16716
  if (underflow) {
16661
- this.hostCalls.traceHostCall("OOG", index, hostCall, regs, gas.get());
16717
+ this.hostCalls.traceHostCall(`${pcLog} OOG`, index, hostCall, regs, gas.get());
16662
16718
  return ReturnValue.fromStatus(pvmInstance.getGasConsumed(), Status.OOG);
16663
16719
  }
16664
- this.hostCalls.traceHostCall("Invoking", index, hostCall, regs, gasBefore);
16720
+ this.hostCalls.traceHostCall(`${pcLog} Invoking`, index, hostCall, regs, gasBefore);
16665
16721
  const result = await hostCall.execute(gas, regs, memory);
16666
16722
  this.hostCalls.traceHostCall(
16667
- result === undefined ? "Result" : `Status(${PvmExecution[result]})`,
16723
+ result === undefined ? `${pcLog} Result` : `${pcLog} Status(${PvmExecution[result]})`,
16668
16724
  index,
16669
16725
  hostCall,
16670
16726
  regs,
@@ -16676,8 +16732,18 @@ declare class HostCalls {
16676
16732
  return this.getReturnValue(status, pvmInstance);
16677
16733
  }
16678
16734
 
16679
- pvmInstance.runProgram();
16680
- status = pvmInstance.getStatus();
16735
+ if (result === PvmExecution.Panic) {
16736
+ status = Status.PANIC;
16737
+ return this.getReturnValue(status, pvmInstance);
16738
+ }
16739
+
16740
+ if (result === undefined) {
16741
+ pvmInstance.runProgram();
16742
+ status = pvmInstance.getStatus();
16743
+ continue;
16744
+ }
16745
+
16746
+ assertNever(result);
16681
16747
  }
16682
16748
  }
16683
16749
 
@@ -18016,6 +18082,7 @@ declare const index$3_getServiceId: typeof getServiceId;
18016
18082
  declare const index$3_getServiceIdOrCurrent: typeof getServiceIdOrCurrent;
18017
18083
  declare const index$3_inspect: typeof inspect;
18018
18084
  declare const index$3_instructionArgumentTypeMap: typeof instructionArgumentTypeMap;
18085
+ declare const index$3_isBrowser: typeof isBrowser;
18019
18086
  declare const index$3_isTaggedError: typeof isTaggedError;
18020
18087
  declare const index$3_maybeTaggedErrorToString: typeof maybeTaggedErrorToString;
18021
18088
  declare const index$3_measure: typeof measure;
@@ -18028,7 +18095,7 @@ declare const index$3_tryAsMachineId: typeof tryAsMachineId;
18028
18095
  declare const index$3_tryAsProgramCounter: typeof tryAsProgramCounter;
18029
18096
  declare const index$3_writeServiceIdAsLeBytes: typeof writeServiceIdAsLeBytes;
18030
18097
  declare namespace index$3 {
18031
- export { index$3_AccumulationStateUpdate as AccumulationStateUpdate, index$3_ArgsDecoder as ArgsDecoder, index$3_ArgumentType as ArgumentType, index$3_BasicBlocks as BasicBlocks, index$3_CURRENT_SERVICE_ID as CURRENT_SERVICE_ID, index$3_EjectError as EjectError, index$3_ExtendedWitdthImmediateDecoder as ExtendedWitdthImmediateDecoder, index$3_ForgetPreimageError as ForgetPreimageError, index$3_HostCallMemory as HostCallMemory, index$3_HostCallRegisters as HostCallRegisters, index$3_HostCallResult as HostCallResult, index$3_ImmediateDecoder as ImmediateDecoder, index$3_MAX_U32 as MAX_U32, index$3_MAX_U32_BIG_INT as MAX_U32_BIG_INT, index$3_MachineInstance as MachineInstance, index$3_Mask as Mask, index$3_MemoryOperation as MemoryOperation, index$3_MemorySegment as MemorySegment, NO_OF_REGISTERS$1 as NO_OF_REGISTERS, index$3_NewServiceError as NewServiceError, index$3_NibblesDecoder as NibblesDecoder, index$3_PagesError as PagesError, index$3_PartiallyUpdatedState as PartiallyUpdatedState, index$3_PeekPokeError as PeekPokeError, index$3_PendingTransfer as PendingTransfer, index$3_PreimageStatusKind as PreimageStatusKind, index$3_Program as Program, index$3_ProgramDecoder as ProgramDecoder, index$3_ProvidePreimageError as ProvidePreimageError, DebuggerAdapter as Pvm, index$3_Registers as Registers, index$3_RequestPreimageError as RequestPreimageError, Result$2 as Result, index$3_RichTaggedError as RichTaggedError, index$3_SERVICE_ID_BYTES as SERVICE_ID_BYTES, index$3_SpiMemory as SpiMemory, index$3_SpiProgram as SpiProgram, index$3_TransferError as TransferError, index$3_UpdatePrivilegesError as UpdatePrivilegesError, index$3_WithDebug as WithDebug, index$3_ZeroVoidError as ZeroVoidError, index$3___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$3_asOpaqueType as asOpaqueType, index$3_assertEmpty as assertEmpty, index$3_assertNever as assertNever, index$j as block, index$q as bytes, index$3_cast as cast, index$3_check as check, index$3_clampU64ToU32 as clampU64ToU32, index$3_createResults as createResults, index$3_decodeStandardProgram as decodeStandardProgram, index$3_ensure as ensure, index$3_extractCodeAndMetadata as extractCodeAndMetadata, index$3_getServiceId as getServiceId, index$3_getServiceIdOrCurrent as getServiceIdOrCurrent, index$n as hash, index$3_inspect as inspect, index$3_instructionArgumentTypeMap as instructionArgumentTypeMap, index$8 as interpreter, index$3_isTaggedError as isTaggedError, index$3_maybeTaggedErrorToString as maybeTaggedErrorToString, index$3_measure as measure, index$p as numbers, index$3_preimageLenAsU32 as preimageLenAsU32, index$3_resultToString as resultToString, index$3_seeThrough as seeThrough, index$3_slotsToPreimageStatus as slotsToPreimageStatus, index$3_toMemoryOperation as toMemoryOperation, index$3_tryAsMachineId as tryAsMachineId, index$3_tryAsProgramCounter as tryAsProgramCounter, index$3_writeServiceIdAsLeBytes as writeServiceIdAsLeBytes };
18098
+ export { index$3_AccumulationStateUpdate as AccumulationStateUpdate, index$3_ArgsDecoder as ArgsDecoder, index$3_ArgumentType as ArgumentType, index$3_BasicBlocks as BasicBlocks, index$3_CURRENT_SERVICE_ID as CURRENT_SERVICE_ID, index$3_EjectError as EjectError, index$3_ExtendedWitdthImmediateDecoder as ExtendedWitdthImmediateDecoder, index$3_ForgetPreimageError as ForgetPreimageError, index$3_HostCallMemory as HostCallMemory, index$3_HostCallRegisters as HostCallRegisters, index$3_HostCallResult as HostCallResult, index$3_ImmediateDecoder as ImmediateDecoder, index$3_MAX_U32 as MAX_U32, index$3_MAX_U32_BIG_INT as MAX_U32_BIG_INT, index$3_MachineInstance as MachineInstance, index$3_Mask as Mask, index$3_MemoryOperation as MemoryOperation, index$3_MemorySegment as MemorySegment, NO_OF_REGISTERS$1 as NO_OF_REGISTERS, index$3_NewServiceError as NewServiceError, index$3_NibblesDecoder as NibblesDecoder, index$3_PagesError as PagesError, index$3_PartiallyUpdatedState as PartiallyUpdatedState, index$3_PeekPokeError as PeekPokeError, index$3_PendingTransfer as PendingTransfer, index$3_PreimageStatusKind as PreimageStatusKind, index$3_Program as Program, index$3_ProgramDecoder as ProgramDecoder, index$3_ProvidePreimageError as ProvidePreimageError, DebuggerAdapter as Pvm, index$3_Registers as Registers, index$3_RequestPreimageError as RequestPreimageError, Result$2 as Result, index$3_RichTaggedError as RichTaggedError, index$3_SERVICE_ID_BYTES as SERVICE_ID_BYTES, index$3_SpiMemory as SpiMemory, index$3_SpiProgram as SpiProgram, index$3_TransferError as TransferError, index$3_UpdatePrivilegesError as UpdatePrivilegesError, index$3_WithDebug as WithDebug, index$3_ZeroVoidError as ZeroVoidError, index$3___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$3_asOpaqueType as asOpaqueType, index$3_assertEmpty as assertEmpty, index$3_assertNever as assertNever, index$j as block, index$q as bytes, index$3_cast as cast, index$3_check as check, index$3_clampU64ToU32 as clampU64ToU32, index$3_createResults as createResults, index$3_decodeStandardProgram as decodeStandardProgram, index$3_ensure as ensure, index$3_extractCodeAndMetadata as extractCodeAndMetadata, index$3_getServiceId as getServiceId, index$3_getServiceIdOrCurrent as getServiceIdOrCurrent, index$n as hash, index$3_inspect as inspect, index$3_instructionArgumentTypeMap as instructionArgumentTypeMap, index$8 as interpreter, index$3_isBrowser as isBrowser, index$3_isTaggedError as isTaggedError, index$3_maybeTaggedErrorToString as maybeTaggedErrorToString, index$3_measure as measure, index$p as numbers, index$3_preimageLenAsU32 as preimageLenAsU32, index$3_resultToString as resultToString, index$3_seeThrough as seeThrough, index$3_slotsToPreimageStatus as slotsToPreimageStatus, index$3_toMemoryOperation as toMemoryOperation, index$3_tryAsMachineId as tryAsMachineId, index$3_tryAsProgramCounter as tryAsProgramCounter, index$3_writeServiceIdAsLeBytes as writeServiceIdAsLeBytes };
18032
18099
  export type { index$3_Args as Args, index$3_EnumMapping as EnumMapping, index$3_ErrorResult as ErrorResult, index$3_IHostCallMemory as IHostCallMemory, index$3_IHostCallRegisters as IHostCallRegisters, index$3_InsufficientFundsError as InsufficientFundsError, index$3_MachineId as MachineId, index$3_MachineResult as MachineResult, index$3_MachineStatus as MachineStatus, index$3_NoMachineError as NoMachineError, index$3_OK as OK, index$3_OkResult as OkResult, index$3_Opaque as Opaque, index$3_PartialState as PartialState, index$3_PreimageStatus as PreimageStatus, index$3_ProgramCounter as ProgramCounter, index$3_RefineExternalities as RefineExternalities, index$3_SegmentExportError as SegmentExportError, index$3_ServiceStateUpdate as ServiceStateUpdate, index$3_StateSlice as StateSlice, index$3_StringLiteral as StringLiteral, index$3_TRANSFER_MEMO_BYTES as TRANSFER_MEMO_BYTES, index$3_TaggedError as TaggedError, index$3_TokenOf as TokenOf, index$3_Uninstantiable as Uninstantiable, index$3_UnprivilegedError as UnprivilegedError, index$3_WithOpaque as WithOpaque };
18033
18100
  }
18034
18101
 
@@ -18066,41 +18133,7 @@ declare namespace index$2 {
18066
18133
  };
18067
18134
  }
18068
18135
 
18069
- declare class JsonServiceInfoPre067 {
18070
- static fromJson = json.object<JsonServiceInfoPre067, ServiceAccountInfo>(
18071
- {
18072
- code_hash: fromJson.bytes32(),
18073
- balance: json.fromNumber((x) => tryAsU64(x)),
18074
- min_item_gas: json.fromNumber((x) => tryAsServiceGas(x)),
18075
- min_memo_gas: json.fromNumber((x) => tryAsServiceGas(x)),
18076
- bytes: json.fromNumber((x) => tryAsU64(x)),
18077
- items: "number",
18078
- },
18079
- ({ code_hash, balance, min_item_gas, min_memo_gas, bytes, items }) => {
18080
- return ServiceAccountInfo.create({
18081
- codeHash: code_hash,
18082
- balance,
18083
- accumulateMinGas: min_item_gas,
18084
- onTransferMinGas: min_memo_gas,
18085
- storageUtilisationBytes: bytes,
18086
- storageUtilisationCount: items,
18087
- gratisStorage: tryAsU64(0),
18088
- created: tryAsTimeSlot(0),
18089
- lastAccumulation: tryAsTimeSlot(0),
18090
- parentService: tryAsServiceId(0),
18091
- });
18092
- },
18093
- );
18094
-
18095
- code_hash!: CodeHash;
18096
- balance!: U64;
18097
- min_item_gas!: ServiceGas;
18098
- min_memo_gas!: ServiceGas;
18099
- bytes!: U64;
18100
- items!: U32;
18101
- }
18102
-
18103
- declare class JsonServiceInfo extends JsonServiceInfoPre067 {
18136
+ declare class JsonServiceInfo {
18104
18137
  static fromJson = json.object<JsonServiceInfo, ServiceAccountInfo>(
18105
18138
  {
18106
18139
  code_hash: fromJson.bytes32(),
@@ -18141,6 +18174,12 @@ declare class JsonServiceInfo extends JsonServiceInfoPre067 {
18141
18174
  },
18142
18175
  );
18143
18176
 
18177
+ code_hash!: CodeHash;
18178
+ balance!: U64;
18179
+ min_item_gas!: ServiceGas;
18180
+ min_memo_gas!: ServiceGas;
18181
+ bytes!: U64;
18182
+ items!: U32;
18144
18183
  creation_slot!: TimeSlot;
18145
18184
  deposit_offset!: U64;
18146
18185
  last_accumulation_slot!: TimeSlot;
@@ -18194,9 +18233,7 @@ declare class JsonService {
18194
18233
  {
18195
18234
  id: "number",
18196
18235
  data: {
18197
- service: Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)
18198
- ? JsonServiceInfo.fromJson
18199
- : JsonServiceInfoPre067.fromJson,
18236
+ service: JsonServiceInfo.fromJson,
18200
18237
  preimages: json.optional(json.array(JsonPreimageItem.fromJson)),
18201
18238
  storage: json.optional(json.array(JsonStorageItem.fromJson)),
18202
18239
  lookup_meta: json.optional(json.array(lookupMetaFromJson)),
@@ -18699,138 +18736,6 @@ declare const fullStateDumpFromJson = (spec: ChainSpec) =>
18699
18736
  },
18700
18737
  );
18701
18738
 
18702
- type JsonStateDumpPre067 = {
18703
- alpha: AuthorizerHash[][];
18704
- varphi: AuthorizerHash[][];
18705
- beta: State["recentBlocks"] | null;
18706
- gamma: {
18707
- gamma_k: State["nextValidatorData"];
18708
- gamma_z: State["epochRoot"];
18709
- gamma_s: TicketsOrKeys;
18710
- gamma_a: State["ticketsAccumulator"];
18711
- };
18712
- psi: State["disputesRecords"];
18713
- eta: State["entropy"];
18714
- iota: State["designatedValidatorData"];
18715
- kappa: State["currentValidatorData"];
18716
- lambda: State["previousValidatorData"];
18717
- rho: State["availabilityAssignment"];
18718
- tau: State["timeslot"];
18719
- chi: {
18720
- chi_m: PrivilegedServices["manager"];
18721
- chi_a: ServiceId; // NOTE: [MaSo] pre067
18722
- chi_v: PrivilegedServices["validatorsManager"];
18723
- chi_g: PrivilegedServices["autoAccumulateServices"] | null;
18724
- };
18725
- pi: JsonStatisticsData;
18726
- theta: State["accumulationQueue"];
18727
- xi: PerEpochBlock<WorkPackageHash[]>;
18728
- accounts: InMemoryService[];
18729
- };
18730
-
18731
- declare const fullStateDumpFromJsonPre067 = (spec: ChainSpec) =>
18732
- json.object<JsonStateDumpPre067, InMemoryState>(
18733
- {
18734
- alpha: json.array(json.array(fromJson.bytes32<AuthorizerHash>())),
18735
- varphi: json.array(json.array(fromJson.bytes32<AuthorizerHash>())),
18736
- beta: json.nullable(recentBlocksHistoryFromJson),
18737
- gamma: {
18738
- gamma_k: json.array(validatorDataFromJson),
18739
- gamma_a: json.array(ticketFromJson),
18740
- gamma_s: TicketsOrKeys.fromJson,
18741
- gamma_z: json.fromString((v) => Bytes.parseBytes(v, BANDERSNATCH_RING_ROOT_BYTES).asOpaque()),
18742
- },
18743
- psi: disputesRecordsFromJson,
18744
- eta: json.array(fromJson.bytes32<EntropyHash>()),
18745
- iota: json.array(validatorDataFromJson),
18746
- kappa: json.array(validatorDataFromJson),
18747
- lambda: json.array(validatorDataFromJson),
18748
- rho: json.array(json.nullable(availabilityAssignmentFromJson)),
18749
- tau: "number",
18750
- chi: {
18751
- chi_m: "number",
18752
- chi_a: "number",
18753
- chi_v: "number",
18754
- chi_g: json.nullable(
18755
- json.array({
18756
- service: "number",
18757
- gasLimit: json.fromNumber((v) => tryAsServiceGas(v)),
18758
- }),
18759
- ),
18760
- },
18761
- pi: JsonStatisticsData.fromJson,
18762
- theta: json.array(json.array(notYetAccumulatedFromJson)),
18763
- xi: json.array(json.array(fromJson.bytes32())),
18764
- accounts: json.array(JsonService.fromJson),
18765
- },
18766
- ({
18767
- alpha,
18768
- varphi,
18769
- beta,
18770
- gamma,
18771
- psi,
18772
- eta,
18773
- iota,
18774
- kappa,
18775
- lambda,
18776
- rho,
18777
- tau,
18778
- chi,
18779
- pi,
18780
- theta,
18781
- xi,
18782
- accounts,
18783
- }): InMemoryState => {
18784
- return InMemoryState.create({
18785
- authPools: tryAsPerCore(
18786
- alpha.map((perCore) => {
18787
- if (perCore.length > MAX_AUTH_POOL_SIZE) {
18788
- throw new Error(`AuthPools: expected less than ${MAX_AUTH_POOL_SIZE}, got ${perCore.length}`);
18789
- }
18790
- return asKnownSize(perCore);
18791
- }),
18792
- spec,
18793
- ),
18794
- authQueues: tryAsPerCore(
18795
- varphi.map((perCore) => {
18796
- if (perCore.length !== AUTHORIZATION_QUEUE_SIZE) {
18797
- throw new Error(`AuthQueues: expected ${AUTHORIZATION_QUEUE_SIZE}, got: ${perCore.length}`);
18798
- }
18799
- return asKnownSize(perCore);
18800
- }),
18801
- spec,
18802
- ),
18803
- recentBlocks: beta ?? RecentBlocksHistory.empty(),
18804
- nextValidatorData: gamma.gamma_k,
18805
- epochRoot: gamma.gamma_z,
18806
- sealingKeySeries: TicketsOrKeys.toSafroleSealingKeys(gamma.gamma_s, spec),
18807
- ticketsAccumulator: gamma.gamma_a,
18808
- disputesRecords: psi,
18809
- entropy: eta,
18810
- designatedValidatorData: iota,
18811
- currentValidatorData: kappa,
18812
- previousValidatorData: lambda,
18813
- availabilityAssignment: rho,
18814
- timeslot: tau,
18815
- privilegedServices: PrivilegedServices.create({
18816
- manager: chi.chi_m,
18817
- authManager: tryAsPerCore(new Array(spec.coresCount).fill(chi.chi_a), spec),
18818
- validatorsManager: chi.chi_v,
18819
- autoAccumulateServices: chi.chi_g ?? [],
18820
- }),
18821
- statistics: JsonStatisticsData.toStatisticsData(spec, pi),
18822
- accumulationQueue: theta,
18823
- recentlyAccumulated: tryAsPerEpochBlock(
18824
- xi.map((x) => HashSet.from(x)),
18825
- spec,
18826
- ),
18827
- services: new Map(accounts.map((x) => [x.serviceId, x])),
18828
- // NOTE Field not present in pre067, added here for compatibility reasons
18829
- accumulationOutputLog: [],
18830
- });
18831
- },
18832
- );
18833
-
18834
18739
  type index$1_JsonAvailabilityAssignment = JsonAvailabilityAssignment;
18835
18740
  type index$1_JsonCoreStatistics = JsonCoreStatistics;
18836
18741
  declare const index$1_JsonCoreStatistics: typeof JsonCoreStatistics;
@@ -18846,12 +18751,9 @@ type index$1_JsonService = JsonService;
18846
18751
  declare const index$1_JsonService: typeof JsonService;
18847
18752
  type index$1_JsonServiceInfo = JsonServiceInfo;
18848
18753
  declare const index$1_JsonServiceInfo: typeof JsonServiceInfo;
18849
- type index$1_JsonServiceInfoPre067 = JsonServiceInfoPre067;
18850
- declare const index$1_JsonServiceInfoPre067: typeof JsonServiceInfoPre067;
18851
18754
  type index$1_JsonServiceStatistics = JsonServiceStatistics;
18852
18755
  declare const index$1_JsonServiceStatistics: typeof JsonServiceStatistics;
18853
18756
  type index$1_JsonStateDump = JsonStateDump;
18854
- type index$1_JsonStateDumpPre067 = JsonStateDumpPre067;
18855
18757
  type index$1_JsonStatisticsData = JsonStatisticsData;
18856
18758
  declare const index$1_JsonStatisticsData: typeof JsonStatisticsData;
18857
18759
  type index$1_JsonStorageItem = JsonStorageItem;
@@ -18864,7 +18766,6 @@ declare const index$1_TicketsOrKeys: typeof TicketsOrKeys;
18864
18766
  declare const index$1_availabilityAssignmentFromJson: typeof availabilityAssignmentFromJson;
18865
18767
  declare const index$1_disputesRecordsFromJson: typeof disputesRecordsFromJson;
18866
18768
  declare const index$1_fullStateDumpFromJson: typeof fullStateDumpFromJson;
18867
- declare const index$1_fullStateDumpFromJsonPre067: typeof fullStateDumpFromJsonPre067;
18868
18769
  declare const index$1_lookupMetaFromJson: typeof lookupMetaFromJson;
18869
18770
  declare const index$1_notYetAccumulatedFromJson: typeof notYetAccumulatedFromJson;
18870
18771
  declare const index$1_recentBlockStateFromJson: typeof recentBlockStateFromJson;
@@ -18874,8 +18775,8 @@ declare const index$1_serviceStatisticsEntryFromJson: typeof serviceStatisticsEn
18874
18775
  declare const index$1_ticketFromJson: typeof ticketFromJson;
18875
18776
  declare const index$1_validatorDataFromJson: typeof validatorDataFromJson;
18876
18777
  declare namespace index$1 {
18877
- export { index$1_JsonCoreStatistics as JsonCoreStatistics, index$1_JsonDisputesRecords as JsonDisputesRecords, index$1_JsonPreimageItem as JsonPreimageItem, index$1_JsonService as JsonService, index$1_JsonServiceInfo as JsonServiceInfo, index$1_JsonServiceInfoPre067 as JsonServiceInfoPre067, index$1_JsonServiceStatistics as JsonServiceStatistics, index$1_JsonStatisticsData as JsonStatisticsData, index$1_JsonStorageItem as JsonStorageItem, index$1_JsonValidatorStatistics as JsonValidatorStatistics, index$1_TicketsOrKeys as TicketsOrKeys, index$1_availabilityAssignmentFromJson as availabilityAssignmentFromJson, index$1_disputesRecordsFromJson as disputesRecordsFromJson, index$1_fullStateDumpFromJson as fullStateDumpFromJson, index$1_fullStateDumpFromJsonPre067 as fullStateDumpFromJsonPre067, index$1_lookupMetaFromJson as lookupMetaFromJson, index$1_notYetAccumulatedFromJson as notYetAccumulatedFromJson, index$1_recentBlockStateFromJson as recentBlockStateFromJson, index$1_recentBlocksHistoryFromJson as recentBlocksHistoryFromJson, index$1_reportedWorkPackageFromJson as reportedWorkPackageFromJson, index$1_serviceStatisticsEntryFromJson as serviceStatisticsEntryFromJson, index$1_ticketFromJson as ticketFromJson, index$1_validatorDataFromJson as validatorDataFromJson };
18878
- export type { index$1_JsonAvailabilityAssignment as JsonAvailabilityAssignment, index$1_JsonLookupMeta as JsonLookupMeta, index$1_JsonRecentBlockState as JsonRecentBlockState, index$1_JsonRecentBlocks as JsonRecentBlocks, index$1_JsonReportedWorkPackageInfo as JsonReportedWorkPackageInfo, index$1_JsonStateDump as JsonStateDump, index$1_JsonStateDumpPre067 as JsonStateDumpPre067, index$1_ServiceStatisticsEntry as ServiceStatisticsEntry };
18778
+ export { index$1_JsonCoreStatistics as JsonCoreStatistics, index$1_JsonDisputesRecords as JsonDisputesRecords, index$1_JsonPreimageItem as JsonPreimageItem, index$1_JsonService as JsonService, index$1_JsonServiceInfo as JsonServiceInfo, index$1_JsonServiceStatistics as JsonServiceStatistics, index$1_JsonStatisticsData as JsonStatisticsData, index$1_JsonStorageItem as JsonStorageItem, index$1_JsonValidatorStatistics as JsonValidatorStatistics, index$1_TicketsOrKeys as TicketsOrKeys, index$1_availabilityAssignmentFromJson as availabilityAssignmentFromJson, index$1_disputesRecordsFromJson as disputesRecordsFromJson, index$1_fullStateDumpFromJson as fullStateDumpFromJson, index$1_lookupMetaFromJson as lookupMetaFromJson, index$1_notYetAccumulatedFromJson as notYetAccumulatedFromJson, index$1_recentBlockStateFromJson as recentBlockStateFromJson, index$1_recentBlocksHistoryFromJson as recentBlocksHistoryFromJson, index$1_reportedWorkPackageFromJson as reportedWorkPackageFromJson, index$1_serviceStatisticsEntryFromJson as serviceStatisticsEntryFromJson, index$1_ticketFromJson as ticketFromJson, index$1_validatorDataFromJson as validatorDataFromJson };
18779
+ export type { index$1_JsonAvailabilityAssignment as JsonAvailabilityAssignment, index$1_JsonLookupMeta as JsonLookupMeta, index$1_JsonRecentBlockState as JsonRecentBlockState, index$1_JsonRecentBlocks as JsonRecentBlocks, index$1_JsonReportedWorkPackageInfo as JsonReportedWorkPackageInfo, index$1_JsonStateDump as JsonStateDump, index$1_ServiceStatisticsEntry as ServiceStatisticsEntry };
18879
18780
  }
18880
18781
 
18881
18782
  /** Helper function to create most used hashes in the block */