@typeberry/lib 0.0.1-b834975 → 0.0.1-be13f8e

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 +402 -546
  3. package/index.js +1462 -799
  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
 
@@ -7820,7 +7853,7 @@ declare const DEV_CONFIG = "dev";
7820
7853
  declare const DEFAULT_CONFIG = "default";
7821
7854
 
7822
7855
  declare const NODE_DEFAULTS = {
7823
- name: os.hostname(),
7856
+ name: isBrowser() ? "browser" : os.hostname(),
7824
7857
  config: DEFAULT_CONFIG,
7825
7858
  };
7826
7859
 
@@ -7875,11 +7908,11 @@ declare class NodeConfiguration {
7875
7908
 
7876
7909
  declare function loadConfig(configPath: string): NodeConfiguration {
7877
7910
  if (configPath === DEFAULT_CONFIG) {
7878
- return parseFromJson(defaultConfigJson, NodeConfiguration.fromJson);
7911
+ return parseFromJson(configs.default, NodeConfiguration.fromJson);
7879
7912
  }
7880
7913
 
7881
7914
  if (configPath === DEV_CONFIG) {
7882
- return parseFromJson(devConfigJson, NodeConfiguration.fromJson);
7915
+ return parseFromJson(configs.dev, NodeConfiguration.fromJson);
7883
7916
  }
7884
7917
 
7885
7918
  try {
@@ -8220,20 +8253,7 @@ declare class AutoAccumulate {
8220
8253
  declare class PrivilegedServices {
8221
8254
  static Codec = codec.Class(PrivilegedServices, {
8222
8255
  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
- ),
8256
+ authManager: codecPerCore(codec.u32.asOpaque<ServiceId>()),
8237
8257
  validatorsManager: codec.u32.asOpaque<ServiceId>(),
8238
8258
  autoAccumulateServices: readonlyArray(codec.sequenceVarLen(AutoAccumulate.Codec)),
8239
8259
  });
@@ -8743,31 +8763,18 @@ declare const ignoreValueWithDefault = <T>(defaultValue: T) =>
8743
8763
  * https://graypaper.fluffylabs.dev/#/7e6ff6a/108301108301?v=0.6.7
8744
8764
  */
8745
8765
  declare class ServiceAccountInfo extends WithDebug {
8746
- static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)
8747
- ? codec.Class(ServiceAccountInfo, {
8748
- codeHash: codec.bytes(HASH_SIZE).asOpaque<CodeHash>(),
8749
- balance: codec.u64,
8750
- accumulateMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
8751
- onTransferMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
8752
- storageUtilisationBytes: codec.u64,
8753
- gratisStorage: codec.u64,
8754
- storageUtilisationCount: codec.u32,
8755
- created: codec.u32.convert((x) => x, tryAsTimeSlot),
8756
- lastAccumulation: codec.u32.convert((x) => x, tryAsTimeSlot),
8757
- parentService: codec.u32.convert((x) => x, tryAsServiceId),
8758
- })
8759
- : codec.Class(ServiceAccountInfo, {
8760
- codeHash: codec.bytes(HASH_SIZE).asOpaque<CodeHash>(),
8761
- balance: codec.u64,
8762
- accumulateMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
8763
- onTransferMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
8764
- storageUtilisationBytes: codec.u64,
8765
- storageUtilisationCount: codec.u32,
8766
- gratisStorage: ignoreValueWithDefault(tryAsU64(0)),
8767
- created: ignoreValueWithDefault(tryAsTimeSlot(0)),
8768
- lastAccumulation: ignoreValueWithDefault(tryAsTimeSlot(0)),
8769
- parentService: ignoreValueWithDefault(tryAsServiceId(0)),
8770
- });
8766
+ static Codec = codec.Class(ServiceAccountInfo, {
8767
+ codeHash: codec.bytes(HASH_SIZE).asOpaque<CodeHash>(),
8768
+ balance: codec.u64,
8769
+ accumulateMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
8770
+ onTransferMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
8771
+ storageUtilisationBytes: codec.u64,
8772
+ gratisStorage: codec.u64,
8773
+ storageUtilisationCount: codec.u32,
8774
+ created: codec.u32.convert((x) => x, tryAsTimeSlot),
8775
+ lastAccumulation: codec.u32.convert((x) => x, tryAsTimeSlot),
8776
+ parentService: codec.u32.convert((x) => x, tryAsServiceId),
8777
+ });
8771
8778
 
8772
8779
  static create(a: CodecRecord<ServiceAccountInfo>) {
8773
8780
  return new ServiceAccountInfo(
@@ -8789,11 +8796,6 @@ declare class ServiceAccountInfo extends WithDebug {
8789
8796
  * https://graypaper.fluffylabs.dev/#/7e6ff6a/119e01119e01?v=0.6.7
8790
8797
  */
8791
8798
  static calculateThresholdBalance(items: U32, bytes: U64, gratisStorage: U64): U64 {
8792
- check(
8793
- gratisStorage === tryAsU64(0) || Compatibility.isGreaterOrEqual(GpVersion.V0_6_7),
8794
- "Gratis storage cannot be non-zero before 0.6.7",
8795
- );
8796
-
8797
8799
  const storageCost =
8798
8800
  BASE_SERVICE_BALANCE + ELECTIVE_ITEM_BALANCE * BigInt(items) + ELECTIVE_BYTE_BALANCE * bytes - gratisStorage;
8799
8801
 
@@ -10361,7 +10363,7 @@ type StateCodec<T> = {
10361
10363
 
10362
10364
  /** Serialization for particular state entries. */
10363
10365
  declare namespace serialize {
10364
- /** C(1): https://graypaper.fluffylabs.dev/#/85129da/38a20138a201?v=0.6.3 */
10366
+ /** C(1): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b15013b1501?v=0.6.7 */
10365
10367
  export const authPools: StateCodec<State["authPools"]> = {
10366
10368
  key: stateKeys.index(StateKeyIdx.Alpha),
10367
10369
  Codec: codecPerCore(
@@ -10374,7 +10376,7 @@ declare namespace serialize {
10374
10376
  extract: (s) => s.authPools,
10375
10377
  };
10376
10378
 
10377
- /** C(2): https://graypaper.fluffylabs.dev/#/85129da/38be0138be01?v=0.6.3 */
10379
+ /** C(2): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b31013b3101?v=0.6.7 */
10378
10380
  export const authQueues: StateCodec<State["authQueues"]> = {
10379
10381
  key: stateKeys.index(StateKeyIdx.Phi),
10380
10382
  Codec: codecPerCore(
@@ -10385,7 +10387,6 @@ declare namespace serialize {
10385
10387
 
10386
10388
  /**
10387
10389
  * C(3): Recent blocks with compatibility
10388
- * https://graypaper.fluffylabs.dev/#/85129da/38cb0138cb01?v=0.6.3
10389
10390
  * https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e013b3e01?v=0.6.7
10390
10391
  */
10391
10392
  export const recentBlocks: StateCodec<State["recentBlocks"]> = {
@@ -10394,7 +10395,7 @@ declare namespace serialize {
10394
10395
  extract: (s) => s.recentBlocks,
10395
10396
  };
10396
10397
 
10397
- /** C(4): https://graypaper.fluffylabs.dev/#/85129da/38e60138e601?v=0.6.3 */
10398
+ /** C(4): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b63013b6301?v=0.6.7 */
10398
10399
  export const safrole: StateCodec<SafroleData> = {
10399
10400
  key: stateKeys.index(StateKeyIdx.Gamma),
10400
10401
  Codec: SafroleData.Codec,
@@ -10407,63 +10408,63 @@ declare namespace serialize {
10407
10408
  }),
10408
10409
  };
10409
10410
 
10410
- /** C(5): https://graypaper.fluffylabs.dev/#/85129da/383d02383d02?v=0.6.3 */
10411
+ /** C(5): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bba013bba01?v=0.6.7 */
10411
10412
  export const disputesRecords: StateCodec<State["disputesRecords"]> = {
10412
10413
  key: stateKeys.index(StateKeyIdx.Psi),
10413
10414
  Codec: DisputesRecords.Codec,
10414
10415
  extract: (s) => s.disputesRecords,
10415
10416
  };
10416
10417
 
10417
- /** C(6): https://graypaper.fluffylabs.dev/#/85129da/387602387602?v=0.6.3 */
10418
+ /** C(6): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bf3013bf301?v=0.6.7 */
10418
10419
  export const entropy: StateCodec<State["entropy"]> = {
10419
10420
  key: stateKeys.index(StateKeyIdx.Eta),
10420
10421
  Codec: codecFixedSizeArray(codec.bytes(HASH_SIZE).asOpaque<EntropyHash>(), ENTROPY_ENTRIES),
10421
10422
  extract: (s) => s.entropy,
10422
10423
  };
10423
10424
 
10424
- /** C(7): https://graypaper.fluffylabs.dev/#/85129da/388302388302?v=0.6.3 */
10425
+ /** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
10425
10426
  export const designatedValidators: StateCodec<State["designatedValidatorData"]> = {
10426
10427
  key: stateKeys.index(StateKeyIdx.Iota),
10427
10428
  Codec: codecPerValidator(ValidatorData.Codec),
10428
10429
  extract: (s) => s.designatedValidatorData,
10429
10430
  };
10430
10431
 
10431
- /** C(8): https://graypaper.fluffylabs.dev/#/85129da/389002389002?v=0.6.3 */
10432
+ /** C(8): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b0d023b0d02?v=0.6.7 */
10432
10433
  export const currentValidators: StateCodec<State["currentValidatorData"]> = {
10433
10434
  key: stateKeys.index(StateKeyIdx.Kappa),
10434
10435
  Codec: codecPerValidator(ValidatorData.Codec),
10435
10436
  extract: (s) => s.currentValidatorData,
10436
10437
  };
10437
10438
 
10438
- /** C(9): https://graypaper.fluffylabs.dev/#/85129da/389d02389d02?v=0.6.3 */
10439
+ /** C(9): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b1a023b1a02?v=0.6.7 */
10439
10440
  export const previousValidators: StateCodec<State["previousValidatorData"]> = {
10440
10441
  key: stateKeys.index(StateKeyIdx.Lambda),
10441
10442
  Codec: codecPerValidator(ValidatorData.Codec),
10442
10443
  extract: (s) => s.previousValidatorData,
10443
10444
  };
10444
10445
 
10445
- /** C(10): https://graypaper.fluffylabs.dev/#/85129da/38aa0238aa02?v=0.6.3 */
10446
+ /** C(10): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b27023b2702?v=0.6.7 */
10446
10447
  export const availabilityAssignment: StateCodec<State["availabilityAssignment"]> = {
10447
10448
  key: stateKeys.index(StateKeyIdx.Rho),
10448
10449
  Codec: codecPerCore(codec.optional(AvailabilityAssignment.Codec)),
10449
10450
  extract: (s) => s.availabilityAssignment,
10450
10451
  };
10451
10452
 
10452
- /** C(11): https://graypaper.fluffylabs.dev/#/85129da/38c10238c102?v=0.6.3 */
10453
+ /** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
10453
10454
  export const timeslot: StateCodec<State["timeslot"]> = {
10454
10455
  key: stateKeys.index(StateKeyIdx.Tau),
10455
10456
  Codec: codec.u32.asOpaque<TimeSlot>(),
10456
10457
  extract: (s) => s.timeslot,
10457
10458
  };
10458
10459
 
10459
- /** C(12): https://graypaper.fluffylabs.dev/#/85129da/38cf0238cf02?v=0.6.3 */
10460
+ /** C(12): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b4c023b4c02?v=0.6.7 */
10460
10461
  export const privilegedServices: StateCodec<State["privilegedServices"]> = {
10461
10462
  key: stateKeys.index(StateKeyIdx.Chi),
10462
10463
  Codec: PrivilegedServices.Codec,
10463
10464
  extract: (s) => s.privilegedServices,
10464
10465
  };
10465
10466
 
10466
- /** C(13): https://graypaper.fluffylabs.dev/#/85129da/38e10238e102?v=0.6.3 */
10467
+ /** C(13): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b5e023b5e02?v=0.6.7 */
10467
10468
  export const statistics: StateCodec<State["statistics"]> = {
10468
10469
  key: stateKeys.index(StateKeyIdx.Pi),
10469
10470
  Codec: StatisticsData.Codec,
@@ -10477,7 +10478,7 @@ declare namespace serialize {
10477
10478
  extract: (s) => s.accumulationQueue,
10478
10479
  };
10479
10480
 
10480
- /** C(15): https://graypaper.fluffylabs.dev/#/85129da/381903381903?v=0.6.3 */
10481
+ /** C(15): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b96023b9602?v=0.6.7 */
10481
10482
  export const recentlyAccumulated: StateCodec<State["recentlyAccumulated"]> = {
10482
10483
  key: stateKeys.index(StateKeyIdx.Xi),
10483
10484
  Codec: codecPerEpochBlock(
@@ -10573,27 +10574,17 @@ declare function* serializeRemovedServices(servicesRemoved: ServiceId[] | undefi
10573
10574
  }
10574
10575
  }
10575
10576
 
10576
- declare function getLegacyKey(serviceId: ServiceId, rawKey: StorageKey): StorageKey {
10577
- const SERVICE_ID_BYTES = 4;
10578
- const serviceIdAndKey = new Uint8Array(SERVICE_ID_BYTES + rawKey.length);
10579
- serviceIdAndKey.set(u32AsLeBytes(serviceId));
10580
- serviceIdAndKey.set(rawKey.raw, SERVICE_ID_BYTES);
10581
- return asOpaqueType(BytesBlob.blobFrom(blake2b.hashBytes(serviceIdAndKey).raw));
10582
- }
10583
-
10584
10577
  declare function* serializeStorage(storage: UpdateStorage[] | undefined): Generator<StateEntryUpdate> {
10585
10578
  for (const { action, serviceId } of storage ?? []) {
10586
10579
  switch (action.kind) {
10587
10580
  case UpdateStorageKind.Set: {
10588
- const key = Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)
10589
- ? action.storage.key
10590
- : getLegacyKey(serviceId, action.storage.key);
10581
+ const key = action.storage.key;
10591
10582
  const codec = serialize.serviceStorage(serviceId, key);
10592
10583
  yield [StateEntryUpdateAction.Insert, codec.key, action.storage.value];
10593
10584
  break;
10594
10585
  }
10595
10586
  case UpdateStorageKind.Remove: {
10596
- const key = Compatibility.isGreaterOrEqual(GpVersion.V0_6_7) ? action.key : getLegacyKey(serviceId, action.key);
10587
+ const key = action.key;
10597
10588
  const codec = serialize.serviceStorage(serviceId, key);
10598
10589
  yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
10599
10590
  break;
@@ -10733,7 +10724,7 @@ declare function* serializeBasicKeys(spec: ChainSpec, update: Partial<State>) {
10733
10724
  yield doSerialize(update.recentlyAccumulated, serialize.recentlyAccumulated); // C(15)
10734
10725
  }
10735
10726
 
10736
- if (update.accumulationOutputLog !== undefined && Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)) {
10727
+ if (update.accumulationOutputLog !== undefined) {
10737
10728
  yield doSerialize(update.accumulationOutputLog, serialize.accumulationOutputLog); // C(16)
10738
10729
  }
10739
10730
  }
@@ -11528,9 +11519,7 @@ declare function convertInMemoryStateToDictionary(
11528
11519
  doSerialize(serialize.statistics); // C(13)
11529
11520
  doSerialize(serialize.accumulationQueue); // C(14)
11530
11521
  doSerialize(serialize.recentlyAccumulated); // C(15)
11531
- if (Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)) {
11532
- doSerialize(serialize.accumulationOutputLog); // C(16)
11533
- }
11522
+ doSerialize(serialize.accumulationOutputLog); // C(16)
11534
11523
 
11535
11524
  // services
11536
11525
  for (const [serviceId, service] of state.services.entries()) {
@@ -11721,10 +11710,7 @@ declare class SerializedState<T extends SerializedStateBackend = SerializedState
11721
11710
  }
11722
11711
 
11723
11712
  get accumulationOutputLog(): State["accumulationOutputLog"] {
11724
- if (Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)) {
11725
- return this.retrieve(serialize.accumulationOutputLog, "accumulationOutputLog");
11726
- }
11727
- return [];
11713
+ return this.retrieve(serialize.accumulationOutputLog, "accumulationOutputLog");
11728
11714
  }
11729
11715
  }
11730
11716
 
@@ -11871,7 +11857,6 @@ declare const index$c_U32_BYTES: typeof U32_BYTES;
11871
11857
  declare const index$c_binaryMerkleization: typeof binaryMerkleization;
11872
11858
  declare const index$c_convertInMemoryStateToDictionary: typeof convertInMemoryStateToDictionary;
11873
11859
  declare const index$c_dumpCodec: typeof dumpCodec;
11874
- declare const index$c_getLegacyKey: typeof getLegacyKey;
11875
11860
  declare const index$c_getSafroleData: typeof getSafroleData;
11876
11861
  declare const index$c_legacyServiceNested: typeof legacyServiceNested;
11877
11862
  declare const index$c_loadState: typeof loadState;
@@ -11885,7 +11870,7 @@ declare const index$c_serializeStorage: typeof serializeStorage;
11885
11870
  declare const index$c_stateEntriesSequenceCodec: typeof stateEntriesSequenceCodec;
11886
11871
  import index$c_stateKeys = stateKeys;
11887
11872
  declare namespace index$c {
11888
- 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 };
11873
+ 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 };
11889
11874
  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 };
11890
11875
  }
11891
11876
 
@@ -12245,8 +12230,8 @@ declare function encodePoints(input: Bytes<PIECE_SIZE>): FixedSizeArray<Bytes<PO
12245
12230
  }
12246
12231
 
12247
12232
  // encode and add redundancy shards
12248
- const points = new ShardsCollection(POINT_ALIGNMENT, data);
12249
- const encodedResult = encode(N_CHUNKS_REDUNDANCY, POINT_ALIGNMENT, points);
12233
+ const points = new reedSolomon.ShardsCollection(POINT_ALIGNMENT, data);
12234
+ const encodedResult = reedSolomon.encode(N_CHUNKS_REDUNDANCY, points);
12250
12235
  const encodedData = encodedResult.take_data();
12251
12236
 
12252
12237
  for (let i = 0; i < N_CHUNKS_REDUNDANCY; i++) {
@@ -12288,9 +12273,9 @@ declare function decodePiece(
12288
12273
  result.raw.set(points.raw, pointStartInResult);
12289
12274
  }
12290
12275
  }
12291
- const points = new ShardsCollection(POINT_ALIGNMENT, data, indices);
12276
+ const points = new reedSolomon.ShardsCollection(POINT_ALIGNMENT, data, indices);
12292
12277
 
12293
- const decodingResult = decode(N_CHUNKS_REQUIRED, N_CHUNKS_REDUNDANCY, POINT_ALIGNMENT, points);
12278
+ const decodingResult = reedSolomon.decode(N_CHUNKS_REQUIRED, N_CHUNKS_REDUNDANCY, points);
12294
12279
  const resultIndices = decodingResult.take_indices(); // it has to be called before take_data
12295
12280
  const resultData = decodingResult.take_data(); // it destroys the result object in rust
12296
12281
 
@@ -12527,6 +12512,10 @@ declare function chunksToShards(
12527
12512
  return tryAsPerValidator(result, spec);
12528
12513
  }
12529
12514
 
12515
+ declare const initEc = async () => {
12516
+ await init.reedSolomon();
12517
+ };
12518
+
12530
12519
  declare const index$a_HALF_POINT_SIZE: typeof HALF_POINT_SIZE;
12531
12520
  declare const index$a_N_CHUNKS_REDUNDANCY: typeof N_CHUNKS_REDUNDANCY;
12532
12521
  type index$a_N_CHUNKS_REQUIRED = N_CHUNKS_REQUIRED;
@@ -12540,6 +12529,7 @@ declare const index$a_decodeData: typeof decodeData;
12540
12529
  declare const index$a_decodeDataAndTrim: typeof decodeDataAndTrim;
12541
12530
  declare const index$a_decodePiece: typeof decodePiece;
12542
12531
  declare const index$a_encodePoints: typeof encodePoints;
12532
+ declare const index$a_initEc: typeof initEc;
12543
12533
  declare const index$a_join: typeof join;
12544
12534
  declare const index$a_lace: typeof lace;
12545
12535
  declare const index$a_padAndEncodeData: typeof padAndEncodeData;
@@ -12548,7 +12538,7 @@ declare const index$a_split: typeof split;
12548
12538
  declare const index$a_transpose: typeof transpose;
12549
12539
  declare const index$a_unzip: typeof unzip;
12550
12540
  declare namespace index$a {
12551
- 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 };
12541
+ 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 };
12552
12542
  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 };
12553
12543
  }
12554
12544
 
@@ -12580,56 +12570,223 @@ declare const HostCallResult = {
12580
12570
  OK: tryAsU64(0n),
12581
12571
  } as const;
12582
12572
 
12573
+ declare enum Level {
12574
+ INSANE = 1,
12575
+ TRACE = 2,
12576
+ LOG = 3,
12577
+ INFO = 4,
12578
+ WARN = 5,
12579
+ ERROR = 6,
12580
+ }
12581
+
12582
+ type Options = {
12583
+ defaultLevel: Level;
12584
+ workingDir: string;
12585
+ modules: Map<string, Level>;
12586
+ };
12587
+
12583
12588
  /**
12584
- * Mask class is an implementation of skip function defined in GP.
12589
+ * A function to parse logger definition (including modules) given as a string.
12585
12590
  *
12586
- * https://graypaper.fluffylabs.dev/#/5f542d7/237201239801
12591
+ * Examples
12592
+ * - `info` - setup default logging level to `info`.
12593
+ * - `trace` - default logging level set to `trace`.
12594
+ * - `debug;consensus=trace` - default level is set to `debug/log`, but consensus is in trace mode.
12587
12595
  */
12588
- declare class Mask {
12596
+ declare function parseLoggerOptions(input: string, defaultLevel: Level, workingDir?: string): Options {
12597
+ const modules = new Map<string, Level>();
12598
+ const parts = input.toLowerCase().split(",");
12599
+ let defLevel = defaultLevel;
12600
+
12601
+ for (const p of parts) {
12602
+ const clean = p.trim();
12603
+ // skip empty objects (forgotten `,` removed)
12604
+ if (clean.length === 0) {
12605
+ continue;
12606
+ }
12607
+ // we just have the default level
12608
+ if (clean.includes("=")) {
12609
+ const [mod, lvl] = clean.split("=");
12610
+ modules.set(mod.trim(), parseLevel(lvl.trim()));
12611
+ } else {
12612
+ defLevel = parseLevel(clean);
12613
+ }
12614
+ }
12615
+
12616
+ // TODO [ToDr] Fix dirname for workers.
12617
+ const myDir = (import.meta.dirname ?? "").split("/");
12618
+ myDir.pop();
12619
+ myDir.pop();
12620
+ return {
12621
+ defaultLevel: defLevel,
12622
+ modules,
12623
+ workingDir: workingDir ?? myDir.join("/"),
12624
+ };
12625
+ }
12626
+
12627
+ declare const GLOBAL_CONFIG = {
12628
+ options: DEFAULT_OPTIONS,
12629
+ transport: ConsoleTransport.create(DEFAULT_OPTIONS.defaultLevel, DEFAULT_OPTIONS),
12630
+ };
12631
+
12632
+ /**
12633
+ * A logger instance.
12634
+ */
12635
+ declare class Logger {
12589
12636
  /**
12590
- * The lookup table will have `0` at the index which corresponds to an instruction on the same index in the bytecode.
12591
- * In case the value is non-zero it signifies the offset to the index with next instruction.
12637
+ * Create a new logger instance given filename and an optional module name.
12592
12638
  *
12593
- * Example:
12594
- * ```
12595
- * 0..1..2..3..4..5..6..7..8..9 # Indices
12596
- * 0..2..1..0..1..0..3..2..1..0 # lookupTable forward values
12597
- * ```
12598
- * There are instructions at indices `0, 3, 5, 9`.
12639
+ * If the module name is not given, `fileName` becomes the module name.
12640
+ * The module name can be composed from multiple parts separated with `/`.
12641
+ *
12642
+ * The logger will use a global configuration which can be changed using
12643
+ * [`configureLogger`] function.
12599
12644
  */
12600
- private lookupTableForward: Uint8Array;
12645
+ static new(fileName?: string, moduleName?: string) {
12646
+ const fName = fileName ?? "unknown";
12647
+ return new Logger(moduleName ?? fName, fName, GLOBAL_CONFIG);
12648
+ }
12601
12649
 
12602
- constructor(mask: BitVec) {
12603
- this.lookupTableForward = this.buildLookupTableForward(mask);
12650
+ /**
12651
+ * Return currently configured level for given module. */
12652
+ static getLevel(moduleName: string): Level {
12653
+ return findLevel(GLOBAL_CONFIG.options, moduleName);
12604
12654
  }
12605
12655
 
12606
- isInstruction(index: number) {
12607
- return this.lookupTableForward[index] === 0;
12656
+ /**
12657
+ * Global configuration of all loggers.
12658
+ *
12659
+ * One can specify a default logging level (only logs with level >= default will be printed).
12660
+ * It's also possible to configure per-module logging level that takes precedence
12661
+ * over the default one.
12662
+ *
12663
+ * Changing the options affects all previously created loggers.
12664
+ */
12665
+ static configureAllFromOptions(options: Options) {
12666
+ // find minimal level to optimise logging in case
12667
+ // we don't care about low-level logs.
12668
+ const minimalLevel = Array.from(options.modules.values()).reduce((level, modLevel) => {
12669
+ return level < modLevel ? level : modLevel;
12670
+ }, options.defaultLevel);
12671
+
12672
+ const transport = ConsoleTransport.create(minimalLevel, options);
12673
+
12674
+ // set the global config
12675
+ GLOBAL_CONFIG.options = options;
12676
+ GLOBAL_CONFIG.transport = transport;
12608
12677
  }
12609
12678
 
12610
- getNoOfBytesToNextInstruction(index: number) {
12611
- check(index >= 0, `index (${index}) cannot be a negative number`);
12612
- return Math.min(this.lookupTableForward[index] ?? 0, MAX_INSTRUCTION_DISTANCE);
12679
+ /**
12680
+ * Global configuration of all loggers.
12681
+ *
12682
+ * Parse configuration options from an input string typically obtained
12683
+ * from environment variable `JAM_LOG`.
12684
+ */
12685
+ static configureAll(input: string, defaultLevel: Level, workingDir?: string) {
12686
+ const options = parseLoggerOptions(input, defaultLevel, workingDir);
12687
+ Logger.configureAllFromOptions(options);
12613
12688
  }
12614
12689
 
12615
- private buildLookupTableForward(mask: BitVec) {
12616
- const table = new Uint8Array(mask.bitLength);
12617
- let lastInstructionOffset = 0;
12618
- for (let i = mask.bitLength - 1; i >= 0; i--) {
12619
- if (mask.isSet(i)) {
12620
- lastInstructionOffset = 0;
12621
- } else {
12622
- lastInstructionOffset++;
12623
- }
12624
- table[i] = lastInstructionOffset;
12625
- }
12626
- return table;
12690
+ constructor(
12691
+ private readonly moduleName: string,
12692
+ private readonly fileName: string,
12693
+ private readonly config: typeof GLOBAL_CONFIG,
12694
+ ) {}
12695
+
12696
+ /** Log a message with `INSANE` level. */
12697
+ insane(val: string) {
12698
+ this.config.transport.insane(this.moduleName, val);
12627
12699
  }
12628
12700
 
12629
- static empty() {
12630
- return new Mask(BitVec.empty(0));
12701
+ /** Log a message with `TRACE` level. */
12702
+ trace(val: string) {
12703
+ this.config.transport.trace(this.moduleName, val);
12631
12704
  }
12632
- }
12705
+
12706
+ /** Log a message with `DEBUG`/`LOG` level. */
12707
+ log(val: string) {
12708
+ this.config.transport.log(this.moduleName, val);
12709
+ }
12710
+
12711
+ /** Log a message with `INFO` level. */
12712
+ info(val: string) {
12713
+ this.config.transport.info(this.moduleName, val);
12714
+ }
12715
+
12716
+ /** Log a message with `WARN` level. */
12717
+ warn(val: string) {
12718
+ this.config.transport.warn(this.moduleName, val);
12719
+ }
12720
+
12721
+ /** Log a message with `ERROR` level. */
12722
+ error(val: string) {
12723
+ this.config.transport.error(this.moduleName, val);
12724
+ }
12725
+ }
12726
+
12727
+ type index$9_Level = Level;
12728
+ declare const index$9_Level: typeof Level;
12729
+ type index$9_Logger = Logger;
12730
+ declare const index$9_Logger: typeof Logger;
12731
+ declare const index$9_parseLoggerOptions: typeof parseLoggerOptions;
12732
+ declare namespace index$9 {
12733
+ export {
12734
+ index$9_Level as Level,
12735
+ index$9_Logger as Logger,
12736
+ index$9_parseLoggerOptions as parseLoggerOptions,
12737
+ };
12738
+ }
12739
+
12740
+ /**
12741
+ * Mask class is an implementation of skip function defined in GP.
12742
+ *
12743
+ * https://graypaper.fluffylabs.dev/#/5f542d7/237201239801
12744
+ */
12745
+ declare class Mask {
12746
+ /**
12747
+ * The lookup table will have `0` at the index which corresponds to an instruction on the same index in the bytecode.
12748
+ * In case the value is non-zero it signifies the offset to the index with next instruction.
12749
+ *
12750
+ * Example:
12751
+ * ```
12752
+ * 0..1..2..3..4..5..6..7..8..9 # Indices
12753
+ * 0..2..1..0..1..0..3..2..1..0 # lookupTable forward values
12754
+ * ```
12755
+ * There are instructions at indices `0, 3, 5, 9`.
12756
+ */
12757
+ private lookupTableForward: Uint8Array;
12758
+
12759
+ constructor(mask: BitVec) {
12760
+ this.lookupTableForward = this.buildLookupTableForward(mask);
12761
+ }
12762
+
12763
+ isInstruction(index: number) {
12764
+ return this.lookupTableForward[index] === 0;
12765
+ }
12766
+
12767
+ getNoOfBytesToNextInstruction(index: number) {
12768
+ check(index >= 0, `index (${index}) cannot be a negative number`);
12769
+ return Math.min(this.lookupTableForward[index] ?? 0, MAX_INSTRUCTION_DISTANCE);
12770
+ }
12771
+
12772
+ private buildLookupTableForward(mask: BitVec) {
12773
+ const table = new Uint8Array(mask.bitLength);
12774
+ let lastInstructionOffset = 0;
12775
+ for (let i = mask.bitLength - 1; i >= 0; i--) {
12776
+ if (mask.isSet(i)) {
12777
+ lastInstructionOffset = 0;
12778
+ } else {
12779
+ lastInstructionOffset++;
12780
+ }
12781
+ table[i] = lastInstructionOffset;
12782
+ }
12783
+ return table;
12784
+ }
12785
+
12786
+ static empty() {
12787
+ return new Mask(BitVec.empty(0));
12788
+ }
12789
+ }
12633
12790
 
12634
12791
  declare enum ArgumentType {
12635
12792
  NO_ARGUMENTS = 0,
@@ -13839,13 +13996,14 @@ declare abstract class MemoryPage {
13839
13996
  * And then a new version of TypeScript is released.
13840
13997
  */
13841
13998
  declare global {
13842
- interface ArrayBufferConstructor {
13843
- new (length: number, options?: { maxByteLength: number }): ArrayBuffer;
13844
- }
13845
-
13846
- interface ArrayBuffer {
13847
- resize(length: number): void;
13848
- }
13999
+ interface ArrayBufferConstructor {
14000
+ new (length: number, options?: {
14001
+ maxByteLength: number;
14002
+ }): ArrayBuffer;
14003
+ }
14004
+ interface ArrayBuffer {
14005
+ resize(length: number): void;
14006
+ }
13849
14007
  }
13850
14008
 
13851
14009
  type InitialMemoryState = {
@@ -13858,6 +14016,7 @@ declare enum AccessType {
13858
14016
  READ = 0,
13859
14017
  WRITE = 1,
13860
14018
  }
14019
+
13861
14020
  declare class Memory {
13862
14021
  static fromInitialMemory(initialMemoryState: InitialMemoryState) {
13863
14022
  return new Memory(
@@ -13894,6 +14053,7 @@ declare class Memory {
13894
14053
  return Result.ok(OK);
13895
14054
  }
13896
14055
 
14056
+ logger.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
13897
14057
  const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
13898
14058
 
13899
14059
  if (pagesResult.isError) {
@@ -13982,6 +14142,7 @@ declare class Memory {
13982
14142
  bytesLeft -= bytesToRead;
13983
14143
  }
13984
14144
 
14145
+ logger.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
13985
14146
  return Result.ok(OK);
13986
14147
  }
13987
14148
 
@@ -14981,6 +15142,10 @@ declare class JumpTable {
14981
15142
  return new JumpTable(0, new Uint8Array());
14982
15143
  }
14983
15144
 
15145
+ getSize() {
15146
+ return this.indices.length;
15147
+ }
15148
+
14984
15149
  copyFrom(jt: JumpTable) {
14985
15150
  this.indices = jt.indices;
14986
15151
  }
@@ -15882,167 +16047,6 @@ declare class OneRegOneExtImmDispatcher {
15882
16047
  }
15883
16048
  }
15884
16049
 
15885
- declare enum Level {
15886
- TRACE = 1,
15887
- LOG = 2,
15888
- INFO = 3,
15889
- WARN = 4,
15890
- ERROR = 5,
15891
- }
15892
-
15893
- type Options = {
15894
- defaultLevel: Level;
15895
- workingDir: string;
15896
- modules: Map<string, Level>;
15897
- };
15898
-
15899
- /**
15900
- * A function to parse logger definition (including modules) given as a string.
15901
- *
15902
- * Examples
15903
- * - `info` - setup default logging level to `info`.
15904
- * - `trace` - default logging level set to `trace`.
15905
- * - `debug;consensus=trace` - default level is set to `debug/log`, but consensus is in trace mode.
15906
- */
15907
- declare function parseLoggerOptions(input: string, defaultLevel: Level, workingDir?: string): Options {
15908
- const modules = new Map<string, Level>();
15909
- const parts = input.toLowerCase().split(",");
15910
- let defLevel = defaultLevel;
15911
-
15912
- for (const p of parts) {
15913
- const clean = p.trim();
15914
- // skip empty objects (forgotten `,` removed)
15915
- if (clean.length === 0) {
15916
- continue;
15917
- }
15918
- // we just have the default level
15919
- if (clean.includes("=")) {
15920
- const [mod, lvl] = clean.split("=");
15921
- modules.set(mod.trim(), parseLevel(lvl.trim()));
15922
- } else {
15923
- defLevel = parseLevel(clean);
15924
- }
15925
- }
15926
-
15927
- // TODO [ToDr] Fix dirname for workers.
15928
- const myDir = (import.meta.dirname ?? "").split("/");
15929
- myDir.pop();
15930
- myDir.pop();
15931
- return {
15932
- defaultLevel: defLevel,
15933
- modules,
15934
- workingDir: workingDir ?? myDir.join("/"),
15935
- };
15936
- }
15937
-
15938
- declare const GLOBAL_CONFIG = {
15939
- options: DEFAULT_OPTIONS,
15940
- transport: ConsoleTransport.create(DEFAULT_OPTIONS.defaultLevel, DEFAULT_OPTIONS),
15941
- };
15942
-
15943
- /**
15944
- * A logger instance.
15945
- */
15946
- declare class Logger {
15947
- /**
15948
- * Create a new logger instance given filename and an optional module name.
15949
- *
15950
- * If the module name is not given, `fileName` becomes the module name.
15951
- * The module name can be composed from multiple parts separated with `/`.
15952
- *
15953
- * The logger will use a global configuration which can be changed using
15954
- * [`configureLogger`] function.
15955
- */
15956
- static new(fileName?: string, moduleName?: string) {
15957
- const fName = fileName ?? "unknown";
15958
- return new Logger(moduleName ?? fName, fName, GLOBAL_CONFIG);
15959
- }
15960
-
15961
- /**
15962
- * Return currently configured level for given module. */
15963
- static getLevel(moduleName: string): Level {
15964
- return findLevel(GLOBAL_CONFIG.options, moduleName);
15965
- }
15966
-
15967
- /**
15968
- * Global configuration of all loggers.
15969
- *
15970
- * One can specify a default logging level (only logs with level >= default will be printed).
15971
- * It's also possible to configure per-module logging level that takes precedence
15972
- * over the default one.
15973
- *
15974
- * Changing the options affects all previously created loggers.
15975
- */
15976
- static configureAllFromOptions(options: Options) {
15977
- // find minimal level to optimise logging in case
15978
- // we don't care about low-level logs.
15979
- const minimalLevel = Array.from(options.modules.values()).reduce((level, modLevel) => {
15980
- return level < modLevel ? level : modLevel;
15981
- }, options.defaultLevel);
15982
-
15983
- const transport = ConsoleTransport.create(minimalLevel, options);
15984
-
15985
- // set the global config
15986
- GLOBAL_CONFIG.options = options;
15987
- GLOBAL_CONFIG.transport = transport;
15988
- }
15989
-
15990
- /**
15991
- * Global configuration of all loggers.
15992
- *
15993
- * Parse configuration options from an input string typically obtained
15994
- * from environment variable `JAM_LOG`.
15995
- */
15996
- static configureAll(input: string, defaultLevel: Level, workingDir?: string) {
15997
- const options = parseLoggerOptions(input, defaultLevel, workingDir);
15998
- Logger.configureAllFromOptions(options);
15999
- }
16000
-
16001
- constructor(
16002
- private readonly moduleName: string,
16003
- private readonly fileName: string,
16004
- private readonly config: typeof GLOBAL_CONFIG,
16005
- ) {}
16006
-
16007
- /** Log a message with `TRACE` level. */
16008
- trace(val: string) {
16009
- this.config.transport.trace(this.moduleName, this.fileName, val);
16010
- }
16011
-
16012
- /** Log a message with `DEBUG`/`LOG` level. */
16013
- log(val: string) {
16014
- this.config.transport.log(this.moduleName, this.fileName, val);
16015
- }
16016
-
16017
- /** Log a message with `INFO` level. */
16018
- info(val: string) {
16019
- this.config.transport.info(this.moduleName, this.fileName, val);
16020
- }
16021
-
16022
- /** Log a message with `WARN` level. */
16023
- warn(val: string) {
16024
- this.config.transport.warn(this.moduleName, this.fileName, val);
16025
- }
16026
-
16027
- /** Log a message with `ERROR` level. */
16028
- error(val: string) {
16029
- this.config.transport.error(this.moduleName, this.fileName, val);
16030
- }
16031
- }
16032
-
16033
- type index$9_Level = Level;
16034
- declare const index$9_Level: typeof Level;
16035
- type index$9_Logger = Logger;
16036
- declare const index$9_Logger: typeof Logger;
16037
- declare const index$9_parseLoggerOptions: typeof parseLoggerOptions;
16038
- declare namespace index$9 {
16039
- export {
16040
- index$9_Level as Level,
16041
- index$9_Logger as Logger,
16042
- index$9_parseLoggerOptions as parseLoggerOptions,
16043
- };
16044
- }
16045
-
16046
16050
  declare enum ProgramDecoderError {
16047
16051
  InvalidProgramError = 0,
16048
16052
  }
@@ -16125,6 +16129,8 @@ type InterpreterOptions = {
16125
16129
  useSbrkGas?: boolean;
16126
16130
  };
16127
16131
 
16132
+ declare const logger = Logger.new(import.meta.filename, "pvm");
16133
+
16128
16134
  declare class Interpreter {
16129
16135
  private readonly useSbrkGas: boolean;
16130
16136
  private registers = new Registers();
@@ -16260,6 +16266,8 @@ declare class Interpreter {
16260
16266
  const argsResult = this.argsDecodingResults[argsType];
16261
16267
  this.argsDecoder.fillArgs(this.pc, argsResult);
16262
16268
 
16269
+ logger.insane(`[PC: ${this.pc}] ${Instruction[currentInstruction]}`);
16270
+
16263
16271
  if (!isValidInstruction) {
16264
16272
  this.instructionResult.status = Result.PANIC;
16265
16273
  } else {
@@ -16335,6 +16343,7 @@ declare class Interpreter {
16335
16343
  this.status = Status.HOST;
16336
16344
  break;
16337
16345
  }
16346
+ logger.insane(`[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}`);
16338
16347
  return this.status;
16339
16348
  }
16340
16349
 
@@ -16406,13 +16415,14 @@ declare const index$8_Registers: typeof Registers;
16406
16415
  type index$8_SbrkIndex = SbrkIndex;
16407
16416
  type index$8_SmallGas = SmallGas;
16408
16417
  declare const index$8_gasCounter: typeof gasCounter;
16418
+ declare const index$8_logger: typeof logger;
16409
16419
  declare const index$8_tryAsBigGas: typeof tryAsBigGas;
16410
16420
  declare const index$8_tryAsGas: typeof tryAsGas;
16411
16421
  declare const index$8_tryAsMemoryIndex: typeof tryAsMemoryIndex;
16412
16422
  declare const index$8_tryAsSbrkIndex: typeof tryAsSbrkIndex;
16413
16423
  declare const index$8_tryAsSmallGas: typeof tryAsSmallGas;
16414
16424
  declare namespace index$8 {
16415
- 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 };
16425
+ 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 };
16416
16426
  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 };
16417
16427
  }
16418
16428
 
@@ -16550,7 +16560,7 @@ declare class HostCallsManager {
16550
16560
  return `r${idx}=${value} (0x${value.toString(16)})`;
16551
16561
  })
16552
16562
  .join(", ");
16553
- logger.trace(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
16563
+ logger.insane(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
16554
16564
  }
16555
16565
  }
16556
16566
 
@@ -16671,14 +16681,15 @@ declare class HostCalls {
16671
16681
  const gasCost = typeof hostCall.gasCost === "number" ? hostCall.gasCost : hostCall.gasCost(regs);
16672
16682
  const underflow = gas.sub(gasCost);
16673
16683
 
16684
+ const pcLog = `[PC: ${pvmInstance.getPC()}]`;
16674
16685
  if (underflow) {
16675
- this.hostCalls.traceHostCall("OOG", index, hostCall, regs, gas.get());
16686
+ this.hostCalls.traceHostCall(`${pcLog} OOG`, index, hostCall, regs, gas.get());
16676
16687
  return ReturnValue.fromStatus(pvmInstance.getGasConsumed(), Status.OOG);
16677
16688
  }
16678
- this.hostCalls.traceHostCall("Invoking", index, hostCall, regs, gasBefore);
16689
+ this.hostCalls.traceHostCall(`${pcLog} Invoking`, index, hostCall, regs, gasBefore);
16679
16690
  const result = await hostCall.execute(gas, regs, memory);
16680
16691
  this.hostCalls.traceHostCall(
16681
- result === undefined ? "Result" : `Status(${PvmExecution[result]})`,
16692
+ result === undefined ? `${pcLog} Result` : `${pcLog} Status(${PvmExecution[result]})`,
16682
16693
  index,
16683
16694
  hostCall,
16684
16695
  regs,
@@ -16690,8 +16701,18 @@ declare class HostCalls {
16690
16701
  return this.getReturnValue(status, pvmInstance);
16691
16702
  }
16692
16703
 
16693
- pvmInstance.runProgram();
16694
- status = pvmInstance.getStatus();
16704
+ if (result === PvmExecution.Panic) {
16705
+ status = Status.PANIC;
16706
+ return this.getReturnValue(status, pvmInstance);
16707
+ }
16708
+
16709
+ if (result === undefined) {
16710
+ pvmInstance.runProgram();
16711
+ status = pvmInstance.getStatus();
16712
+ continue;
16713
+ }
16714
+
16715
+ assertNever(result);
16695
16716
  }
16696
16717
  }
16697
16718
 
@@ -18030,6 +18051,7 @@ declare const index$3_getServiceId: typeof getServiceId;
18030
18051
  declare const index$3_getServiceIdOrCurrent: typeof getServiceIdOrCurrent;
18031
18052
  declare const index$3_inspect: typeof inspect;
18032
18053
  declare const index$3_instructionArgumentTypeMap: typeof instructionArgumentTypeMap;
18054
+ declare const index$3_isBrowser: typeof isBrowser;
18033
18055
  declare const index$3_isTaggedError: typeof isTaggedError;
18034
18056
  declare const index$3_maybeTaggedErrorToString: typeof maybeTaggedErrorToString;
18035
18057
  declare const index$3_measure: typeof measure;
@@ -18042,7 +18064,7 @@ declare const index$3_tryAsMachineId: typeof tryAsMachineId;
18042
18064
  declare const index$3_tryAsProgramCounter: typeof tryAsProgramCounter;
18043
18065
  declare const index$3_writeServiceIdAsLeBytes: typeof writeServiceIdAsLeBytes;
18044
18066
  declare namespace index$3 {
18045
- 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 };
18067
+ 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 };
18046
18068
  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 };
18047
18069
  }
18048
18070
 
@@ -18080,41 +18102,7 @@ declare namespace index$2 {
18080
18102
  };
18081
18103
  }
18082
18104
 
18083
- declare class JsonServiceInfoPre067 {
18084
- static fromJson = json.object<JsonServiceInfoPre067, ServiceAccountInfo>(
18085
- {
18086
- code_hash: fromJson.bytes32(),
18087
- balance: json.fromNumber((x) => tryAsU64(x)),
18088
- min_item_gas: json.fromNumber((x) => tryAsServiceGas(x)),
18089
- min_memo_gas: json.fromNumber((x) => tryAsServiceGas(x)),
18090
- bytes: json.fromNumber((x) => tryAsU64(x)),
18091
- items: "number",
18092
- },
18093
- ({ code_hash, balance, min_item_gas, min_memo_gas, bytes, items }) => {
18094
- return ServiceAccountInfo.create({
18095
- codeHash: code_hash,
18096
- balance,
18097
- accumulateMinGas: min_item_gas,
18098
- onTransferMinGas: min_memo_gas,
18099
- storageUtilisationBytes: bytes,
18100
- storageUtilisationCount: items,
18101
- gratisStorage: tryAsU64(0),
18102
- created: tryAsTimeSlot(0),
18103
- lastAccumulation: tryAsTimeSlot(0),
18104
- parentService: tryAsServiceId(0),
18105
- });
18106
- },
18107
- );
18108
-
18109
- code_hash!: CodeHash;
18110
- balance!: U64;
18111
- min_item_gas!: ServiceGas;
18112
- min_memo_gas!: ServiceGas;
18113
- bytes!: U64;
18114
- items!: U32;
18115
- }
18116
-
18117
- declare class JsonServiceInfo extends JsonServiceInfoPre067 {
18105
+ declare class JsonServiceInfo {
18118
18106
  static fromJson = json.object<JsonServiceInfo, ServiceAccountInfo>(
18119
18107
  {
18120
18108
  code_hash: fromJson.bytes32(),
@@ -18155,6 +18143,12 @@ declare class JsonServiceInfo extends JsonServiceInfoPre067 {
18155
18143
  },
18156
18144
  );
18157
18145
 
18146
+ code_hash!: CodeHash;
18147
+ balance!: U64;
18148
+ min_item_gas!: ServiceGas;
18149
+ min_memo_gas!: ServiceGas;
18150
+ bytes!: U64;
18151
+ items!: U32;
18158
18152
  creation_slot!: TimeSlot;
18159
18153
  deposit_offset!: U64;
18160
18154
  last_accumulation_slot!: TimeSlot;
@@ -18208,9 +18202,7 @@ declare class JsonService {
18208
18202
  {
18209
18203
  id: "number",
18210
18204
  data: {
18211
- service: Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)
18212
- ? JsonServiceInfo.fromJson
18213
- : JsonServiceInfoPre067.fromJson,
18205
+ service: JsonServiceInfo.fromJson,
18214
18206
  preimages: json.optional(json.array(JsonPreimageItem.fromJson)),
18215
18207
  storage: json.optional(json.array(JsonStorageItem.fromJson)),
18216
18208
  lookup_meta: json.optional(json.array(lookupMetaFromJson)),
@@ -18713,138 +18705,6 @@ declare const fullStateDumpFromJson = (spec: ChainSpec) =>
18713
18705
  },
18714
18706
  );
18715
18707
 
18716
- type JsonStateDumpPre067 = {
18717
- alpha: AuthorizerHash[][];
18718
- varphi: AuthorizerHash[][];
18719
- beta: State["recentBlocks"] | null;
18720
- gamma: {
18721
- gamma_k: State["nextValidatorData"];
18722
- gamma_z: State["epochRoot"];
18723
- gamma_s: TicketsOrKeys;
18724
- gamma_a: State["ticketsAccumulator"];
18725
- };
18726
- psi: State["disputesRecords"];
18727
- eta: State["entropy"];
18728
- iota: State["designatedValidatorData"];
18729
- kappa: State["currentValidatorData"];
18730
- lambda: State["previousValidatorData"];
18731
- rho: State["availabilityAssignment"];
18732
- tau: State["timeslot"];
18733
- chi: {
18734
- chi_m: PrivilegedServices["manager"];
18735
- chi_a: ServiceId; // NOTE: [MaSo] pre067
18736
- chi_v: PrivilegedServices["validatorsManager"];
18737
- chi_g: PrivilegedServices["autoAccumulateServices"] | null;
18738
- };
18739
- pi: JsonStatisticsData;
18740
- theta: State["accumulationQueue"];
18741
- xi: PerEpochBlock<WorkPackageHash[]>;
18742
- accounts: InMemoryService[];
18743
- };
18744
-
18745
- declare const fullStateDumpFromJsonPre067 = (spec: ChainSpec) =>
18746
- json.object<JsonStateDumpPre067, InMemoryState>(
18747
- {
18748
- alpha: json.array(json.array(fromJson.bytes32<AuthorizerHash>())),
18749
- varphi: json.array(json.array(fromJson.bytes32<AuthorizerHash>())),
18750
- beta: json.nullable(recentBlocksHistoryFromJson),
18751
- gamma: {
18752
- gamma_k: json.array(validatorDataFromJson),
18753
- gamma_a: json.array(ticketFromJson),
18754
- gamma_s: TicketsOrKeys.fromJson,
18755
- gamma_z: json.fromString((v) => Bytes.parseBytes(v, BANDERSNATCH_RING_ROOT_BYTES).asOpaque()),
18756
- },
18757
- psi: disputesRecordsFromJson,
18758
- eta: json.array(fromJson.bytes32<EntropyHash>()),
18759
- iota: json.array(validatorDataFromJson),
18760
- kappa: json.array(validatorDataFromJson),
18761
- lambda: json.array(validatorDataFromJson),
18762
- rho: json.array(json.nullable(availabilityAssignmentFromJson)),
18763
- tau: "number",
18764
- chi: {
18765
- chi_m: "number",
18766
- chi_a: "number",
18767
- chi_v: "number",
18768
- chi_g: json.nullable(
18769
- json.array({
18770
- service: "number",
18771
- gasLimit: json.fromNumber((v) => tryAsServiceGas(v)),
18772
- }),
18773
- ),
18774
- },
18775
- pi: JsonStatisticsData.fromJson,
18776
- theta: json.array(json.array(notYetAccumulatedFromJson)),
18777
- xi: json.array(json.array(fromJson.bytes32())),
18778
- accounts: json.array(JsonService.fromJson),
18779
- },
18780
- ({
18781
- alpha,
18782
- varphi,
18783
- beta,
18784
- gamma,
18785
- psi,
18786
- eta,
18787
- iota,
18788
- kappa,
18789
- lambda,
18790
- rho,
18791
- tau,
18792
- chi,
18793
- pi,
18794
- theta,
18795
- xi,
18796
- accounts,
18797
- }): InMemoryState => {
18798
- return InMemoryState.create({
18799
- authPools: tryAsPerCore(
18800
- alpha.map((perCore) => {
18801
- if (perCore.length > MAX_AUTH_POOL_SIZE) {
18802
- throw new Error(`AuthPools: expected less than ${MAX_AUTH_POOL_SIZE}, got ${perCore.length}`);
18803
- }
18804
- return asKnownSize(perCore);
18805
- }),
18806
- spec,
18807
- ),
18808
- authQueues: tryAsPerCore(
18809
- varphi.map((perCore) => {
18810
- if (perCore.length !== AUTHORIZATION_QUEUE_SIZE) {
18811
- throw new Error(`AuthQueues: expected ${AUTHORIZATION_QUEUE_SIZE}, got: ${perCore.length}`);
18812
- }
18813
- return asKnownSize(perCore);
18814
- }),
18815
- spec,
18816
- ),
18817
- recentBlocks: beta ?? RecentBlocksHistory.empty(),
18818
- nextValidatorData: gamma.gamma_k,
18819
- epochRoot: gamma.gamma_z,
18820
- sealingKeySeries: TicketsOrKeys.toSafroleSealingKeys(gamma.gamma_s, spec),
18821
- ticketsAccumulator: gamma.gamma_a,
18822
- disputesRecords: psi,
18823
- entropy: eta,
18824
- designatedValidatorData: iota,
18825
- currentValidatorData: kappa,
18826
- previousValidatorData: lambda,
18827
- availabilityAssignment: rho,
18828
- timeslot: tau,
18829
- privilegedServices: PrivilegedServices.create({
18830
- manager: chi.chi_m,
18831
- authManager: tryAsPerCore(new Array(spec.coresCount).fill(chi.chi_a), spec),
18832
- validatorsManager: chi.chi_v,
18833
- autoAccumulateServices: chi.chi_g ?? [],
18834
- }),
18835
- statistics: JsonStatisticsData.toStatisticsData(spec, pi),
18836
- accumulationQueue: theta,
18837
- recentlyAccumulated: tryAsPerEpochBlock(
18838
- xi.map((x) => HashSet.from(x)),
18839
- spec,
18840
- ),
18841
- services: new Map(accounts.map((x) => [x.serviceId, x])),
18842
- // NOTE Field not present in pre067, added here for compatibility reasons
18843
- accumulationOutputLog: [],
18844
- });
18845
- },
18846
- );
18847
-
18848
18708
  type index$1_JsonAvailabilityAssignment = JsonAvailabilityAssignment;
18849
18709
  type index$1_JsonCoreStatistics = JsonCoreStatistics;
18850
18710
  declare const index$1_JsonCoreStatistics: typeof JsonCoreStatistics;
@@ -18860,12 +18720,9 @@ type index$1_JsonService = JsonService;
18860
18720
  declare const index$1_JsonService: typeof JsonService;
18861
18721
  type index$1_JsonServiceInfo = JsonServiceInfo;
18862
18722
  declare const index$1_JsonServiceInfo: typeof JsonServiceInfo;
18863
- type index$1_JsonServiceInfoPre067 = JsonServiceInfoPre067;
18864
- declare const index$1_JsonServiceInfoPre067: typeof JsonServiceInfoPre067;
18865
18723
  type index$1_JsonServiceStatistics = JsonServiceStatistics;
18866
18724
  declare const index$1_JsonServiceStatistics: typeof JsonServiceStatistics;
18867
18725
  type index$1_JsonStateDump = JsonStateDump;
18868
- type index$1_JsonStateDumpPre067 = JsonStateDumpPre067;
18869
18726
  type index$1_JsonStatisticsData = JsonStatisticsData;
18870
18727
  declare const index$1_JsonStatisticsData: typeof JsonStatisticsData;
18871
18728
  type index$1_JsonStorageItem = JsonStorageItem;
@@ -18878,7 +18735,6 @@ declare const index$1_TicketsOrKeys: typeof TicketsOrKeys;
18878
18735
  declare const index$1_availabilityAssignmentFromJson: typeof availabilityAssignmentFromJson;
18879
18736
  declare const index$1_disputesRecordsFromJson: typeof disputesRecordsFromJson;
18880
18737
  declare const index$1_fullStateDumpFromJson: typeof fullStateDumpFromJson;
18881
- declare const index$1_fullStateDumpFromJsonPre067: typeof fullStateDumpFromJsonPre067;
18882
18738
  declare const index$1_lookupMetaFromJson: typeof lookupMetaFromJson;
18883
18739
  declare const index$1_notYetAccumulatedFromJson: typeof notYetAccumulatedFromJson;
18884
18740
  declare const index$1_recentBlockStateFromJson: typeof recentBlockStateFromJson;
@@ -18888,8 +18744,8 @@ declare const index$1_serviceStatisticsEntryFromJson: typeof serviceStatisticsEn
18888
18744
  declare const index$1_ticketFromJson: typeof ticketFromJson;
18889
18745
  declare const index$1_validatorDataFromJson: typeof validatorDataFromJson;
18890
18746
  declare namespace index$1 {
18891
- 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 };
18892
- 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 };
18747
+ 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 };
18748
+ 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 };
18893
18749
  }
18894
18750
 
18895
18751
  /** Helper function to create most used hashes in the block */