@typeberry/lib 0.0.1-96e327b → 0.0.1-a2f0b71

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 +458 -577
  3. package/index.js +1494 -813
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -60,7 +60,7 @@ declare namespace index$s {
60
60
 
61
61
  declare enum GpVersion {
62
62
  V0_6_7 = "0.6.7",
63
- V0_7_0 = "0.7.0-preview",
63
+ V0_7_0 = "0.7.0",
64
64
  V0_7_1 = "0.7.1-preview",
65
65
  }
66
66
 
@@ -74,7 +74,7 @@ declare const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
74
74
  declare const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
75
75
 
76
76
  declare const env = typeof process === "undefined" ? {} : process.env;
77
- declare const DEFAULT_VERSION = GpVersion.V0_6_7;
77
+ declare const DEFAULT_VERSION = GpVersion.V0_7_0;
78
78
  declare let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
79
79
  declare let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
80
80
 
@@ -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
  });
@@ -8501,8 +8552,8 @@ declare class RecentBlocksHistory extends WithDebug {
8501
8552
  const recentBlocks = RecentBlocks.Codec.decode(decoder);
8502
8553
  return RecentBlocksHistory.create(recentBlocks);
8503
8554
  },
8504
- (_sizer) => {
8505
- return RecentBlocks.Codec.sizeHint;
8555
+ (skip) => {
8556
+ return RecentBlocks.Codec.skip(skip);
8506
8557
  },
8507
8558
  );
8508
8559
 
@@ -8743,31 +8794,18 @@ declare const ignoreValueWithDefault = <T>(defaultValue: T) =>
8743
8794
  * https://graypaper.fluffylabs.dev/#/7e6ff6a/108301108301?v=0.6.7
8744
8795
  */
8745
8796
  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
- });
8797
+ static Codec = codec.Class(ServiceAccountInfo, {
8798
+ codeHash: codec.bytes(HASH_SIZE).asOpaque<CodeHash>(),
8799
+ balance: codec.u64,
8800
+ accumulateMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
8801
+ onTransferMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
8802
+ storageUtilisationBytes: codec.u64,
8803
+ gratisStorage: codec.u64,
8804
+ storageUtilisationCount: codec.u32,
8805
+ created: codec.u32.convert((x) => x, tryAsTimeSlot),
8806
+ lastAccumulation: codec.u32.convert((x) => x, tryAsTimeSlot),
8807
+ parentService: codec.u32.convert((x) => x, tryAsServiceId),
8808
+ });
8771
8809
 
8772
8810
  static create(a: CodecRecord<ServiceAccountInfo>) {
8773
8811
  return new ServiceAccountInfo(
@@ -8789,11 +8827,6 @@ declare class ServiceAccountInfo extends WithDebug {
8789
8827
  * https://graypaper.fluffylabs.dev/#/7e6ff6a/119e01119e01?v=0.6.7
8790
8828
  */
8791
8829
  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
8830
  const storageCost =
8798
8831
  BASE_SERVICE_BALANCE + ELECTIVE_ITEM_BALANCE * BigInt(items) + ELECTIVE_BYTE_BALANCE * bytes - gratisStorage;
8799
8832
 
@@ -10361,7 +10394,7 @@ type StateCodec<T> = {
10361
10394
 
10362
10395
  /** Serialization for particular state entries. */
10363
10396
  declare namespace serialize {
10364
- /** C(1): https://graypaper.fluffylabs.dev/#/85129da/38a20138a201?v=0.6.3 */
10397
+ /** C(1): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b15013b1501?v=0.6.7 */
10365
10398
  export const authPools: StateCodec<State["authPools"]> = {
10366
10399
  key: stateKeys.index(StateKeyIdx.Alpha),
10367
10400
  Codec: codecPerCore(
@@ -10374,7 +10407,7 @@ declare namespace serialize {
10374
10407
  extract: (s) => s.authPools,
10375
10408
  };
10376
10409
 
10377
- /** C(2): https://graypaper.fluffylabs.dev/#/85129da/38be0138be01?v=0.6.3 */
10410
+ /** C(2): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b31013b3101?v=0.6.7 */
10378
10411
  export const authQueues: StateCodec<State["authQueues"]> = {
10379
10412
  key: stateKeys.index(StateKeyIdx.Phi),
10380
10413
  Codec: codecPerCore(
@@ -10385,7 +10418,6 @@ declare namespace serialize {
10385
10418
 
10386
10419
  /**
10387
10420
  * C(3): Recent blocks with compatibility
10388
- * https://graypaper.fluffylabs.dev/#/85129da/38cb0138cb01?v=0.6.3
10389
10421
  * https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e013b3e01?v=0.6.7
10390
10422
  */
10391
10423
  export const recentBlocks: StateCodec<State["recentBlocks"]> = {
@@ -10394,7 +10426,7 @@ declare namespace serialize {
10394
10426
  extract: (s) => s.recentBlocks,
10395
10427
  };
10396
10428
 
10397
- /** C(4): https://graypaper.fluffylabs.dev/#/85129da/38e60138e601?v=0.6.3 */
10429
+ /** C(4): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b63013b6301?v=0.6.7 */
10398
10430
  export const safrole: StateCodec<SafroleData> = {
10399
10431
  key: stateKeys.index(StateKeyIdx.Gamma),
10400
10432
  Codec: SafroleData.Codec,
@@ -10407,63 +10439,63 @@ declare namespace serialize {
10407
10439
  }),
10408
10440
  };
10409
10441
 
10410
- /** C(5): https://graypaper.fluffylabs.dev/#/85129da/383d02383d02?v=0.6.3 */
10442
+ /** C(5): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bba013bba01?v=0.6.7 */
10411
10443
  export const disputesRecords: StateCodec<State["disputesRecords"]> = {
10412
10444
  key: stateKeys.index(StateKeyIdx.Psi),
10413
10445
  Codec: DisputesRecords.Codec,
10414
10446
  extract: (s) => s.disputesRecords,
10415
10447
  };
10416
10448
 
10417
- /** C(6): https://graypaper.fluffylabs.dev/#/85129da/387602387602?v=0.6.3 */
10449
+ /** C(6): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bf3013bf301?v=0.6.7 */
10418
10450
  export const entropy: StateCodec<State["entropy"]> = {
10419
10451
  key: stateKeys.index(StateKeyIdx.Eta),
10420
10452
  Codec: codecFixedSizeArray(codec.bytes(HASH_SIZE).asOpaque<EntropyHash>(), ENTROPY_ENTRIES),
10421
10453
  extract: (s) => s.entropy,
10422
10454
  };
10423
10455
 
10424
- /** C(7): https://graypaper.fluffylabs.dev/#/85129da/388302388302?v=0.6.3 */
10456
+ /** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
10425
10457
  export const designatedValidators: StateCodec<State["designatedValidatorData"]> = {
10426
10458
  key: stateKeys.index(StateKeyIdx.Iota),
10427
10459
  Codec: codecPerValidator(ValidatorData.Codec),
10428
10460
  extract: (s) => s.designatedValidatorData,
10429
10461
  };
10430
10462
 
10431
- /** C(8): https://graypaper.fluffylabs.dev/#/85129da/389002389002?v=0.6.3 */
10463
+ /** C(8): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b0d023b0d02?v=0.6.7 */
10432
10464
  export const currentValidators: StateCodec<State["currentValidatorData"]> = {
10433
10465
  key: stateKeys.index(StateKeyIdx.Kappa),
10434
10466
  Codec: codecPerValidator(ValidatorData.Codec),
10435
10467
  extract: (s) => s.currentValidatorData,
10436
10468
  };
10437
10469
 
10438
- /** C(9): https://graypaper.fluffylabs.dev/#/85129da/389d02389d02?v=0.6.3 */
10470
+ /** C(9): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b1a023b1a02?v=0.6.7 */
10439
10471
  export const previousValidators: StateCodec<State["previousValidatorData"]> = {
10440
10472
  key: stateKeys.index(StateKeyIdx.Lambda),
10441
10473
  Codec: codecPerValidator(ValidatorData.Codec),
10442
10474
  extract: (s) => s.previousValidatorData,
10443
10475
  };
10444
10476
 
10445
- /** C(10): https://graypaper.fluffylabs.dev/#/85129da/38aa0238aa02?v=0.6.3 */
10477
+ /** C(10): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b27023b2702?v=0.6.7 */
10446
10478
  export const availabilityAssignment: StateCodec<State["availabilityAssignment"]> = {
10447
10479
  key: stateKeys.index(StateKeyIdx.Rho),
10448
10480
  Codec: codecPerCore(codec.optional(AvailabilityAssignment.Codec)),
10449
10481
  extract: (s) => s.availabilityAssignment,
10450
10482
  };
10451
10483
 
10452
- /** C(11): https://graypaper.fluffylabs.dev/#/85129da/38c10238c102?v=0.6.3 */
10484
+ /** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
10453
10485
  export const timeslot: StateCodec<State["timeslot"]> = {
10454
10486
  key: stateKeys.index(StateKeyIdx.Tau),
10455
10487
  Codec: codec.u32.asOpaque<TimeSlot>(),
10456
10488
  extract: (s) => s.timeslot,
10457
10489
  };
10458
10490
 
10459
- /** C(12): https://graypaper.fluffylabs.dev/#/85129da/38cf0238cf02?v=0.6.3 */
10491
+ /** C(12): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b4c023b4c02?v=0.6.7 */
10460
10492
  export const privilegedServices: StateCodec<State["privilegedServices"]> = {
10461
10493
  key: stateKeys.index(StateKeyIdx.Chi),
10462
10494
  Codec: PrivilegedServices.Codec,
10463
10495
  extract: (s) => s.privilegedServices,
10464
10496
  };
10465
10497
 
10466
- /** C(13): https://graypaper.fluffylabs.dev/#/85129da/38e10238e102?v=0.6.3 */
10498
+ /** C(13): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b5e023b5e02?v=0.6.7 */
10467
10499
  export const statistics: StateCodec<State["statistics"]> = {
10468
10500
  key: stateKeys.index(StateKeyIdx.Pi),
10469
10501
  Codec: StatisticsData.Codec,
@@ -10477,7 +10509,7 @@ declare namespace serialize {
10477
10509
  extract: (s) => s.accumulationQueue,
10478
10510
  };
10479
10511
 
10480
- /** C(15): https://graypaper.fluffylabs.dev/#/85129da/381903381903?v=0.6.3 */
10512
+ /** C(15): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b96023b9602?v=0.6.7 */
10481
10513
  export const recentlyAccumulated: StateCodec<State["recentlyAccumulated"]> = {
10482
10514
  key: stateKeys.index(StateKeyIdx.Xi),
10483
10515
  Codec: codecPerEpochBlock(
@@ -10573,27 +10605,17 @@ declare function* serializeRemovedServices(servicesRemoved: ServiceId[] | undefi
10573
10605
  }
10574
10606
  }
10575
10607
 
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
10608
  declare function* serializeStorage(storage: UpdateStorage[] | undefined): Generator<StateEntryUpdate> {
10585
10609
  for (const { action, serviceId } of storage ?? []) {
10586
10610
  switch (action.kind) {
10587
10611
  case UpdateStorageKind.Set: {
10588
- const key = Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)
10589
- ? action.storage.key
10590
- : getLegacyKey(serviceId, action.storage.key);
10612
+ const key = action.storage.key;
10591
10613
  const codec = serialize.serviceStorage(serviceId, key);
10592
10614
  yield [StateEntryUpdateAction.Insert, codec.key, action.storage.value];
10593
10615
  break;
10594
10616
  }
10595
10617
  case UpdateStorageKind.Remove: {
10596
- const key = Compatibility.isGreaterOrEqual(GpVersion.V0_6_7) ? action.key : getLegacyKey(serviceId, action.key);
10618
+ const key = action.key;
10597
10619
  const codec = serialize.serviceStorage(serviceId, key);
10598
10620
  yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
10599
10621
  break;
@@ -10733,7 +10755,7 @@ declare function* serializeBasicKeys(spec: ChainSpec, update: Partial<State>) {
10733
10755
  yield doSerialize(update.recentlyAccumulated, serialize.recentlyAccumulated); // C(15)
10734
10756
  }
10735
10757
 
10736
- if (update.accumulationOutputLog !== undefined && Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)) {
10758
+ if (update.accumulationOutputLog !== undefined) {
10737
10759
  yield doSerialize(update.accumulationOutputLog, serialize.accumulationOutputLog); // C(16)
10738
10760
  }
10739
10761
  }
@@ -11528,9 +11550,7 @@ declare function convertInMemoryStateToDictionary(
11528
11550
  doSerialize(serialize.statistics); // C(13)
11529
11551
  doSerialize(serialize.accumulationQueue); // C(14)
11530
11552
  doSerialize(serialize.recentlyAccumulated); // C(15)
11531
- if (Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)) {
11532
- doSerialize(serialize.accumulationOutputLog); // C(16)
11533
- }
11553
+ doSerialize(serialize.accumulationOutputLog); // C(16)
11534
11554
 
11535
11555
  // services
11536
11556
  for (const [serviceId, service] of state.services.entries()) {
@@ -11721,10 +11741,7 @@ declare class SerializedState<T extends SerializedStateBackend = SerializedState
11721
11741
  }
11722
11742
 
11723
11743
  get accumulationOutputLog(): State["accumulationOutputLog"] {
11724
- if (Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)) {
11725
- return this.retrieve(serialize.accumulationOutputLog, "accumulationOutputLog");
11726
- }
11727
- return [];
11744
+ return this.retrieve(serialize.accumulationOutputLog, "accumulationOutputLog");
11728
11745
  }
11729
11746
  }
11730
11747
 
@@ -11871,7 +11888,6 @@ declare const index$c_U32_BYTES: typeof U32_BYTES;
11871
11888
  declare const index$c_binaryMerkleization: typeof binaryMerkleization;
11872
11889
  declare const index$c_convertInMemoryStateToDictionary: typeof convertInMemoryStateToDictionary;
11873
11890
  declare const index$c_dumpCodec: typeof dumpCodec;
11874
- declare const index$c_getLegacyKey: typeof getLegacyKey;
11875
11891
  declare const index$c_getSafroleData: typeof getSafroleData;
11876
11892
  declare const index$c_legacyServiceNested: typeof legacyServiceNested;
11877
11893
  declare const index$c_loadState: typeof loadState;
@@ -11885,7 +11901,7 @@ declare const index$c_serializeStorage: typeof serializeStorage;
11885
11901
  declare const index$c_stateEntriesSequenceCodec: typeof stateEntriesSequenceCodec;
11886
11902
  import index$c_stateKeys = stateKeys;
11887
11903
  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 };
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 };
11889
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 };
11890
11906
  }
11891
11907
 
@@ -12245,8 +12261,8 @@ declare function encodePoints(input: Bytes<PIECE_SIZE>): FixedSizeArray<Bytes<PO
12245
12261
  }
12246
12262
 
12247
12263
  // encode and add redundancy shards
12248
- const points = new ShardsCollection(POINT_ALIGNMENT, data);
12249
- 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);
12250
12266
  const encodedData = encodedResult.take_data();
12251
12267
 
12252
12268
  for (let i = 0; i < N_CHUNKS_REDUNDANCY; i++) {
@@ -12288,9 +12304,9 @@ declare function decodePiece(
12288
12304
  result.raw.set(points.raw, pointStartInResult);
12289
12305
  }
12290
12306
  }
12291
- const points = new ShardsCollection(POINT_ALIGNMENT, data, indices);
12307
+ const points = new reedSolomon.ShardsCollection(POINT_ALIGNMENT, data, indices);
12292
12308
 
12293
- const decodingResult = decode(N_CHUNKS_REQUIRED, N_CHUNKS_REDUNDANCY, POINT_ALIGNMENT, points);
12309
+ const decodingResult = reedSolomon.decode(N_CHUNKS_REQUIRED, N_CHUNKS_REDUNDANCY, points);
12294
12310
  const resultIndices = decodingResult.take_indices(); // it has to be called before take_data
12295
12311
  const resultData = decodingResult.take_data(); // it destroys the result object in rust
12296
12312
 
@@ -12527,6 +12543,10 @@ declare function chunksToShards(
12527
12543
  return tryAsPerValidator(result, spec);
12528
12544
  }
12529
12545
 
12546
+ declare const initEc = async () => {
12547
+ await init.reedSolomon();
12548
+ };
12549
+
12530
12550
  declare const index$a_HALF_POINT_SIZE: typeof HALF_POINT_SIZE;
12531
12551
  declare const index$a_N_CHUNKS_REDUNDANCY: typeof N_CHUNKS_REDUNDANCY;
12532
12552
  type index$a_N_CHUNKS_REQUIRED = N_CHUNKS_REQUIRED;
@@ -12540,6 +12560,7 @@ declare const index$a_decodeData: typeof decodeData;
12540
12560
  declare const index$a_decodeDataAndTrim: typeof decodeDataAndTrim;
12541
12561
  declare const index$a_decodePiece: typeof decodePiece;
12542
12562
  declare const index$a_encodePoints: typeof encodePoints;
12563
+ declare const index$a_initEc: typeof initEc;
12543
12564
  declare const index$a_join: typeof join;
12544
12565
  declare const index$a_lace: typeof lace;
12545
12566
  declare const index$a_padAndEncodeData: typeof padAndEncodeData;
@@ -12548,7 +12569,7 @@ declare const index$a_split: typeof split;
12548
12569
  declare const index$a_transpose: typeof transpose;
12549
12570
  declare const index$a_unzip: typeof unzip;
12550
12571
  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 };
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 };
12552
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 };
12553
12574
  }
12554
12575
 
@@ -12580,64 +12601,231 @@ declare const HostCallResult = {
12580
12601
  OK: tryAsU64(0n),
12581
12602
  } as const;
12582
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
+
12583
12619
  /**
12584
- * Mask class is an implementation of skip function defined in GP.
12620
+ * A function to parse logger definition (including modules) given as a string.
12585
12621
  *
12586
- * 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.
12587
12626
  */
12588
- 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 {
12589
12667
  /**
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.
12668
+ * Create a new logger instance given filename and an optional module name.
12592
12669
  *
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`.
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.
12599
12675
  */
12600
- private lookupTableForward: Uint8Array;
12601
-
12602
- constructor(mask: BitVec) {
12603
- 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);
12604
12679
  }
12605
12680
 
12606
- isInstruction(index: number) {
12607
- 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);
12608
12685
  }
12609
12686
 
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);
12613
- }
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);
12614
12702
 
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;
12627
- }
12703
+ const transport = ConsoleTransport.create(minimalLevel, options);
12628
12704
 
12629
- static empty() {
12630
- return new Mask(BitVec.empty(0));
12705
+ // set the global config
12706
+ GLOBAL_CONFIG.options = options;
12707
+ GLOBAL_CONFIG.transport = transport;
12631
12708
  }
12632
- }
12633
12709
 
12634
- declare enum ArgumentType {
12635
- NO_ARGUMENTS = 0,
12636
- ONE_IMMEDIATE = 1,
12637
- TWO_IMMEDIATES = 2,
12638
- ONE_OFFSET = 3,
12639
- ONE_REGISTER_ONE_IMMEDIATE = 4,
12640
- ONE_REGISTER_TWO_IMMEDIATES = 5,
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);
12719
+ }
12720
+
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,
12826
+ ONE_OFFSET = 3,
12827
+ ONE_REGISTER_ONE_IMMEDIATE = 4,
12828
+ ONE_REGISTER_TWO_IMMEDIATES = 5,
12641
12829
  ONE_REGISTER_ONE_IMMEDIATE_ONE_OFFSET = 6,
12642
12830
  TWO_REGISTERS = 7,
12643
12831
  TWO_REGISTERS_ONE_IMMEDIATE = 8,
@@ -13839,13 +14027,14 @@ declare abstract class MemoryPage {
13839
14027
  * And then a new version of TypeScript is released.
13840
14028
  */
13841
14029
  declare global {
13842
- interface ArrayBufferConstructor {
13843
- new (length: number, options?: { maxByteLength: number }): ArrayBuffer;
13844
- }
13845
-
13846
- interface ArrayBuffer {
13847
- resize(length: number): void;
13848
- }
14030
+ interface ArrayBufferConstructor {
14031
+ new (length: number, options?: {
14032
+ maxByteLength: number;
14033
+ }): ArrayBuffer;
14034
+ }
14035
+ interface ArrayBuffer {
14036
+ resize(length: number): void;
14037
+ }
13849
14038
  }
13850
14039
 
13851
14040
  type InitialMemoryState = {
@@ -13858,6 +14047,7 @@ declare enum AccessType {
13858
14047
  READ = 0,
13859
14048
  WRITE = 1,
13860
14049
  }
14050
+
13861
14051
  declare class Memory {
13862
14052
  static fromInitialMemory(initialMemoryState: InitialMemoryState) {
13863
14053
  return new Memory(
@@ -13894,6 +14084,7 @@ declare class Memory {
13894
14084
  return Result.ok(OK);
13895
14085
  }
13896
14086
 
14087
+ logger.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
13897
14088
  const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
13898
14089
 
13899
14090
  if (pagesResult.isError) {
@@ -13982,6 +14173,7 @@ declare class Memory {
13982
14173
  bytesLeft -= bytesToRead;
13983
14174
  }
13984
14175
 
14176
+ logger.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
13985
14177
  return Result.ok(OK);
13986
14178
  }
13987
14179
 
@@ -14981,6 +15173,10 @@ declare class JumpTable {
14981
15173
  return new JumpTable(0, new Uint8Array());
14982
15174
  }
14983
15175
 
15176
+ getSize() {
15177
+ return this.indices.length;
15178
+ }
15179
+
14984
15180
  copyFrom(jt: JumpTable) {
14985
15181
  this.indices = jt.indices;
14986
15182
  }
@@ -15882,167 +16078,6 @@ declare class OneRegOneExtImmDispatcher {
15882
16078
  }
15883
16079
  }
15884
16080
 
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
16081
  declare enum ProgramDecoderError {
16047
16082
  InvalidProgramError = 0,
16048
16083
  }
@@ -16125,6 +16160,8 @@ type InterpreterOptions = {
16125
16160
  useSbrkGas?: boolean;
16126
16161
  };
16127
16162
 
16163
+ declare const logger = Logger.new(import.meta.filename, "pvm");
16164
+
16128
16165
  declare class Interpreter {
16129
16166
  private readonly useSbrkGas: boolean;
16130
16167
  private registers = new Registers();
@@ -16260,6 +16297,8 @@ declare class Interpreter {
16260
16297
  const argsResult = this.argsDecodingResults[argsType];
16261
16298
  this.argsDecoder.fillArgs(this.pc, argsResult);
16262
16299
 
16300
+ logger.insane(`[PC: ${this.pc}] ${Instruction[currentInstruction]}`);
16301
+
16263
16302
  if (!isValidInstruction) {
16264
16303
  this.instructionResult.status = Result.PANIC;
16265
16304
  } else {
@@ -16320,12 +16359,6 @@ declare class Interpreter {
16320
16359
  }
16321
16360
 
16322
16361
  if (this.instructionResult.status !== null) {
16323
- // All abnormal terminations should be interpreted as TRAP and we should subtract the gas. In case of FAULT we have to do it manually at the very end.
16324
- if (this.instructionResult.status === Result.FAULT || this.instructionResult.status === Result.FAULT_ACCESS) {
16325
- // TODO [ToDr] underflow?
16326
- this.gas.sub(instructionGasMap[Instruction.TRAP]);
16327
- }
16328
-
16329
16362
  switch (this.instructionResult.status) {
16330
16363
  case Result.FAULT:
16331
16364
  this.status = Status.FAULT;
@@ -16341,6 +16374,7 @@ declare class Interpreter {
16341
16374
  this.status = Status.HOST;
16342
16375
  break;
16343
16376
  }
16377
+ logger.insane(`[PC: ${this.pc}] Status: ${Result[this.instructionResult.status]}`);
16344
16378
  return this.status;
16345
16379
  }
16346
16380
 
@@ -16412,13 +16446,14 @@ declare const index$8_Registers: typeof Registers;
16412
16446
  type index$8_SbrkIndex = SbrkIndex;
16413
16447
  type index$8_SmallGas = SmallGas;
16414
16448
  declare const index$8_gasCounter: typeof gasCounter;
16449
+ declare const index$8_logger: typeof logger;
16415
16450
  declare const index$8_tryAsBigGas: typeof tryAsBigGas;
16416
16451
  declare const index$8_tryAsGas: typeof tryAsGas;
16417
16452
  declare const index$8_tryAsMemoryIndex: typeof tryAsMemoryIndex;
16418
16453
  declare const index$8_tryAsSbrkIndex: typeof tryAsSbrkIndex;
16419
16454
  declare const index$8_tryAsSmallGas: typeof tryAsSmallGas;
16420
16455
  declare namespace index$8 {
16421
- 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 };
16422
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 };
16423
16458
  }
16424
16459
 
@@ -16556,7 +16591,7 @@ declare class HostCallsManager {
16556
16591
  return `r${idx}=${value} (0x${value.toString(16)})`;
16557
16592
  })
16558
16593
  .join(", ");
16559
- logger.trace(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
16594
+ logger.insane(`[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`);
16560
16595
  }
16561
16596
  }
16562
16597
 
@@ -16677,14 +16712,15 @@ declare class HostCalls {
16677
16712
  const gasCost = typeof hostCall.gasCost === "number" ? hostCall.gasCost : hostCall.gasCost(regs);
16678
16713
  const underflow = gas.sub(gasCost);
16679
16714
 
16715
+ const pcLog = `[PC: ${pvmInstance.getPC()}]`;
16680
16716
  if (underflow) {
16681
- this.hostCalls.traceHostCall("OOG", index, hostCall, regs, gas.get());
16717
+ this.hostCalls.traceHostCall(`${pcLog} OOG`, index, hostCall, regs, gas.get());
16682
16718
  return ReturnValue.fromStatus(pvmInstance.getGasConsumed(), Status.OOG);
16683
16719
  }
16684
- this.hostCalls.traceHostCall("Invoking", index, hostCall, regs, gasBefore);
16720
+ this.hostCalls.traceHostCall(`${pcLog} Invoking`, index, hostCall, regs, gasBefore);
16685
16721
  const result = await hostCall.execute(gas, regs, memory);
16686
16722
  this.hostCalls.traceHostCall(
16687
- result === undefined ? "Result" : `Status(${result})`,
16723
+ result === undefined ? `${pcLog} Result` : `${pcLog} Status(${PvmExecution[result]})`,
16688
16724
  index,
16689
16725
  hostCall,
16690
16726
  regs,
@@ -16696,8 +16732,18 @@ declare class HostCalls {
16696
16732
  return this.getReturnValue(status, pvmInstance);
16697
16733
  }
16698
16734
 
16699
- pvmInstance.runProgram();
16700
- 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);
16701
16747
  }
16702
16748
  }
16703
16749
 
@@ -18036,6 +18082,7 @@ declare const index$3_getServiceId: typeof getServiceId;
18036
18082
  declare const index$3_getServiceIdOrCurrent: typeof getServiceIdOrCurrent;
18037
18083
  declare const index$3_inspect: typeof inspect;
18038
18084
  declare const index$3_instructionArgumentTypeMap: typeof instructionArgumentTypeMap;
18085
+ declare const index$3_isBrowser: typeof isBrowser;
18039
18086
  declare const index$3_isTaggedError: typeof isTaggedError;
18040
18087
  declare const index$3_maybeTaggedErrorToString: typeof maybeTaggedErrorToString;
18041
18088
  declare const index$3_measure: typeof measure;
@@ -18048,7 +18095,7 @@ declare const index$3_tryAsMachineId: typeof tryAsMachineId;
18048
18095
  declare const index$3_tryAsProgramCounter: typeof tryAsProgramCounter;
18049
18096
  declare const index$3_writeServiceIdAsLeBytes: typeof writeServiceIdAsLeBytes;
18050
18097
  declare namespace index$3 {
18051
- 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 };
18052
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 };
18053
18100
  }
18054
18101
 
@@ -18086,41 +18133,7 @@ declare namespace index$2 {
18086
18133
  };
18087
18134
  }
18088
18135
 
18089
- declare class JsonServiceInfoPre067 {
18090
- static fromJson = json.object<JsonServiceInfoPre067, ServiceAccountInfo>(
18091
- {
18092
- code_hash: fromJson.bytes32(),
18093
- balance: json.fromNumber((x) => tryAsU64(x)),
18094
- min_item_gas: json.fromNumber((x) => tryAsServiceGas(x)),
18095
- min_memo_gas: json.fromNumber((x) => tryAsServiceGas(x)),
18096
- bytes: json.fromNumber((x) => tryAsU64(x)),
18097
- items: "number",
18098
- },
18099
- ({ code_hash, balance, min_item_gas, min_memo_gas, bytes, items }) => {
18100
- return ServiceAccountInfo.create({
18101
- codeHash: code_hash,
18102
- balance,
18103
- accumulateMinGas: min_item_gas,
18104
- onTransferMinGas: min_memo_gas,
18105
- storageUtilisationBytes: bytes,
18106
- storageUtilisationCount: items,
18107
- gratisStorage: tryAsU64(0),
18108
- created: tryAsTimeSlot(0),
18109
- lastAccumulation: tryAsTimeSlot(0),
18110
- parentService: tryAsServiceId(0),
18111
- });
18112
- },
18113
- );
18114
-
18115
- code_hash!: CodeHash;
18116
- balance!: U64;
18117
- min_item_gas!: ServiceGas;
18118
- min_memo_gas!: ServiceGas;
18119
- bytes!: U64;
18120
- items!: U32;
18121
- }
18122
-
18123
- declare class JsonServiceInfo extends JsonServiceInfoPre067 {
18136
+ declare class JsonServiceInfo {
18124
18137
  static fromJson = json.object<JsonServiceInfo, ServiceAccountInfo>(
18125
18138
  {
18126
18139
  code_hash: fromJson.bytes32(),
@@ -18161,6 +18174,12 @@ declare class JsonServiceInfo extends JsonServiceInfoPre067 {
18161
18174
  },
18162
18175
  );
18163
18176
 
18177
+ code_hash!: CodeHash;
18178
+ balance!: U64;
18179
+ min_item_gas!: ServiceGas;
18180
+ min_memo_gas!: ServiceGas;
18181
+ bytes!: U64;
18182
+ items!: U32;
18164
18183
  creation_slot!: TimeSlot;
18165
18184
  deposit_offset!: U64;
18166
18185
  last_accumulation_slot!: TimeSlot;
@@ -18214,9 +18233,7 @@ declare class JsonService {
18214
18233
  {
18215
18234
  id: "number",
18216
18235
  data: {
18217
- service: Compatibility.isGreaterOrEqual(GpVersion.V0_6_7)
18218
- ? JsonServiceInfo.fromJson
18219
- : JsonServiceInfoPre067.fromJson,
18236
+ service: JsonServiceInfo.fromJson,
18220
18237
  preimages: json.optional(json.array(JsonPreimageItem.fromJson)),
18221
18238
  storage: json.optional(json.array(JsonStorageItem.fromJson)),
18222
18239
  lookup_meta: json.optional(json.array(lookupMetaFromJson)),
@@ -18719,138 +18736,6 @@ declare const fullStateDumpFromJson = (spec: ChainSpec) =>
18719
18736
  },
18720
18737
  );
18721
18738
 
18722
- type JsonStateDumpPre067 = {
18723
- alpha: AuthorizerHash[][];
18724
- varphi: AuthorizerHash[][];
18725
- beta: State["recentBlocks"] | null;
18726
- gamma: {
18727
- gamma_k: State["nextValidatorData"];
18728
- gamma_z: State["epochRoot"];
18729
- gamma_s: TicketsOrKeys;
18730
- gamma_a: State["ticketsAccumulator"];
18731
- };
18732
- psi: State["disputesRecords"];
18733
- eta: State["entropy"];
18734
- iota: State["designatedValidatorData"];
18735
- kappa: State["currentValidatorData"];
18736
- lambda: State["previousValidatorData"];
18737
- rho: State["availabilityAssignment"];
18738
- tau: State["timeslot"];
18739
- chi: {
18740
- chi_m: PrivilegedServices["manager"];
18741
- chi_a: ServiceId; // NOTE: [MaSo] pre067
18742
- chi_v: PrivilegedServices["validatorsManager"];
18743
- chi_g: PrivilegedServices["autoAccumulateServices"] | null;
18744
- };
18745
- pi: JsonStatisticsData;
18746
- theta: State["accumulationQueue"];
18747
- xi: PerEpochBlock<WorkPackageHash[]>;
18748
- accounts: InMemoryService[];
18749
- };
18750
-
18751
- declare const fullStateDumpFromJsonPre067 = (spec: ChainSpec) =>
18752
- json.object<JsonStateDumpPre067, InMemoryState>(
18753
- {
18754
- alpha: json.array(json.array(fromJson.bytes32<AuthorizerHash>())),
18755
- varphi: json.array(json.array(fromJson.bytes32<AuthorizerHash>())),
18756
- beta: json.nullable(recentBlocksHistoryFromJson),
18757
- gamma: {
18758
- gamma_k: json.array(validatorDataFromJson),
18759
- gamma_a: json.array(ticketFromJson),
18760
- gamma_s: TicketsOrKeys.fromJson,
18761
- gamma_z: json.fromString((v) => Bytes.parseBytes(v, BANDERSNATCH_RING_ROOT_BYTES).asOpaque()),
18762
- },
18763
- psi: disputesRecordsFromJson,
18764
- eta: json.array(fromJson.bytes32<EntropyHash>()),
18765
- iota: json.array(validatorDataFromJson),
18766
- kappa: json.array(validatorDataFromJson),
18767
- lambda: json.array(validatorDataFromJson),
18768
- rho: json.array(json.nullable(availabilityAssignmentFromJson)),
18769
- tau: "number",
18770
- chi: {
18771
- chi_m: "number",
18772
- chi_a: "number",
18773
- chi_v: "number",
18774
- chi_g: json.nullable(
18775
- json.array({
18776
- service: "number",
18777
- gasLimit: json.fromNumber((v) => tryAsServiceGas(v)),
18778
- }),
18779
- ),
18780
- },
18781
- pi: JsonStatisticsData.fromJson,
18782
- theta: json.array(json.array(notYetAccumulatedFromJson)),
18783
- xi: json.array(json.array(fromJson.bytes32())),
18784
- accounts: json.array(JsonService.fromJson),
18785
- },
18786
- ({
18787
- alpha,
18788
- varphi,
18789
- beta,
18790
- gamma,
18791
- psi,
18792
- eta,
18793
- iota,
18794
- kappa,
18795
- lambda,
18796
- rho,
18797
- tau,
18798
- chi,
18799
- pi,
18800
- theta,
18801
- xi,
18802
- accounts,
18803
- }): InMemoryState => {
18804
- return InMemoryState.create({
18805
- authPools: tryAsPerCore(
18806
- alpha.map((perCore) => {
18807
- if (perCore.length > MAX_AUTH_POOL_SIZE) {
18808
- throw new Error(`AuthPools: expected less than ${MAX_AUTH_POOL_SIZE}, got ${perCore.length}`);
18809
- }
18810
- return asKnownSize(perCore);
18811
- }),
18812
- spec,
18813
- ),
18814
- authQueues: tryAsPerCore(
18815
- varphi.map((perCore) => {
18816
- if (perCore.length !== AUTHORIZATION_QUEUE_SIZE) {
18817
- throw new Error(`AuthQueues: expected ${AUTHORIZATION_QUEUE_SIZE}, got: ${perCore.length}`);
18818
- }
18819
- return asKnownSize(perCore);
18820
- }),
18821
- spec,
18822
- ),
18823
- recentBlocks: beta ?? RecentBlocksHistory.empty(),
18824
- nextValidatorData: gamma.gamma_k,
18825
- epochRoot: gamma.gamma_z,
18826
- sealingKeySeries: TicketsOrKeys.toSafroleSealingKeys(gamma.gamma_s, spec),
18827
- ticketsAccumulator: gamma.gamma_a,
18828
- disputesRecords: psi,
18829
- entropy: eta,
18830
- designatedValidatorData: iota,
18831
- currentValidatorData: kappa,
18832
- previousValidatorData: lambda,
18833
- availabilityAssignment: rho,
18834
- timeslot: tau,
18835
- privilegedServices: PrivilegedServices.create({
18836
- manager: chi.chi_m,
18837
- authManager: tryAsPerCore(new Array(spec.coresCount).fill(chi.chi_a), spec),
18838
- validatorsManager: chi.chi_v,
18839
- autoAccumulateServices: chi.chi_g ?? [],
18840
- }),
18841
- statistics: JsonStatisticsData.toStatisticsData(spec, pi),
18842
- accumulationQueue: theta,
18843
- recentlyAccumulated: tryAsPerEpochBlock(
18844
- xi.map((x) => HashSet.from(x)),
18845
- spec,
18846
- ),
18847
- services: new Map(accounts.map((x) => [x.serviceId, x])),
18848
- // NOTE Field not present in pre067, added here for compatibility reasons
18849
- accumulationOutputLog: [],
18850
- });
18851
- },
18852
- );
18853
-
18854
18739
  type index$1_JsonAvailabilityAssignment = JsonAvailabilityAssignment;
18855
18740
  type index$1_JsonCoreStatistics = JsonCoreStatistics;
18856
18741
  declare const index$1_JsonCoreStatistics: typeof JsonCoreStatistics;
@@ -18866,12 +18751,9 @@ type index$1_JsonService = JsonService;
18866
18751
  declare const index$1_JsonService: typeof JsonService;
18867
18752
  type index$1_JsonServiceInfo = JsonServiceInfo;
18868
18753
  declare const index$1_JsonServiceInfo: typeof JsonServiceInfo;
18869
- type index$1_JsonServiceInfoPre067 = JsonServiceInfoPre067;
18870
- declare const index$1_JsonServiceInfoPre067: typeof JsonServiceInfoPre067;
18871
18754
  type index$1_JsonServiceStatistics = JsonServiceStatistics;
18872
18755
  declare const index$1_JsonServiceStatistics: typeof JsonServiceStatistics;
18873
18756
  type index$1_JsonStateDump = JsonStateDump;
18874
- type index$1_JsonStateDumpPre067 = JsonStateDumpPre067;
18875
18757
  type index$1_JsonStatisticsData = JsonStatisticsData;
18876
18758
  declare const index$1_JsonStatisticsData: typeof JsonStatisticsData;
18877
18759
  type index$1_JsonStorageItem = JsonStorageItem;
@@ -18884,7 +18766,6 @@ declare const index$1_TicketsOrKeys: typeof TicketsOrKeys;
18884
18766
  declare const index$1_availabilityAssignmentFromJson: typeof availabilityAssignmentFromJson;
18885
18767
  declare const index$1_disputesRecordsFromJson: typeof disputesRecordsFromJson;
18886
18768
  declare const index$1_fullStateDumpFromJson: typeof fullStateDumpFromJson;
18887
- declare const index$1_fullStateDumpFromJsonPre067: typeof fullStateDumpFromJsonPre067;
18888
18769
  declare const index$1_lookupMetaFromJson: typeof lookupMetaFromJson;
18889
18770
  declare const index$1_notYetAccumulatedFromJson: typeof notYetAccumulatedFromJson;
18890
18771
  declare const index$1_recentBlockStateFromJson: typeof recentBlockStateFromJson;
@@ -18894,8 +18775,8 @@ declare const index$1_serviceStatisticsEntryFromJson: typeof serviceStatisticsEn
18894
18775
  declare const index$1_ticketFromJson: typeof ticketFromJson;
18895
18776
  declare const index$1_validatorDataFromJson: typeof validatorDataFromJson;
18896
18777
  declare namespace index$1 {
18897
- 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 };
18898
- 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 };
18899
18780
  }
18900
18781
 
18901
18782
  /** Helper function to create most used hashes in the block */