@typeberry/convert 0.4.0-fcdfbb1 → 0.4.1-dae2283

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.
package/README.md CHANGED
@@ -8,6 +8,11 @@ Typeberry is a TypeScript implementation of [JAM protocol](https://graypaper.com
8
8
  PRs unless the contributor waives any claims to the prize and copy rights for
9
9
  the submitted code. By creating the PR you accept this requirement.**
10
10
 
11
+ ## Links
12
+
13
+ - [Documentation](https://fluffylabs.dev/typeberry)
14
+ - [Performance Charts](https://typeberry.fluffylabs.dev)
15
+
11
16
  ## Implementation status
12
17
 
13
18
  Gray Paper compliance can be controlled via `GP_VERSION` environment variable.
package/index.js CHANGED
@@ -4254,7 +4254,11 @@ var TestSuite;
4254
4254
  })(TestSuite || (TestSuite = {}));
4255
4255
  const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
4256
4256
  const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
4257
- const DEFAULT_VERSION = GpVersion.V0_7_2;
4257
+ /**
4258
+ * Current version is set to track the jam-conformance testing.
4259
+ * Since we are currently at 0.7.1 not 0.7.2, we set our default version accordingly.
4260
+ */
4261
+ const DEFAULT_VERSION = GpVersion.V0_7_1;
4258
4262
  const env = typeof process === "undefined" ? {} : process.env;
4259
4263
  let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
4260
4264
  let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
@@ -4313,8 +4317,8 @@ class Compatibility {
4313
4317
  /**
4314
4318
  * Allows selecting different values for different Gray Paper versions from one record.
4315
4319
  *
4316
- * @param fallback The default value to return if no value is found for the current.
4317
- * @param record A record mapping versions to values, checking if the version is greater or equal to the current version.
4320
+ * fallback The default value to return if no value is found for the current.
4321
+ * versions A record mapping versions to values, checking if the version is greater or equal to the current version.
4318
4322
  * @returns The value for the current version, or the default value.
4319
4323
  */
4320
4324
  static selectIfGreaterOrEqual({ fallback, versions, }) {
@@ -4477,7 +4481,7 @@ const workspacePathFix = dev_env.NODE_ENV === "development"
4477
4481
 
4478
4482
  ;// CONCATENATED MODULE: ./packages/core/utils/opaque.ts
4479
4483
  /**
4480
- * @fileoverview `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
4484
+ * `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
4481
4485
  * specified unique token Token. It means that base type cannot be assigned to unique type by accident.
4482
4486
  * Good examples of opaque types include:
4483
4487
  * - JWTs or other tokens - these are special kinds of string used for authorization purposes.
@@ -4840,7 +4844,7 @@ function isResult(x) {
4840
4844
  var minimist = __nccwpck_require__(595);
4841
4845
  var minimist_default = /*#__PURE__*/__nccwpck_require__.n(minimist);
4842
4846
  ;// CONCATENATED MODULE: ./bin/convert/package.json
4843
- const package_namespaceObject = {"rE":"0.4.0"};
4847
+ const package_namespaceObject = {"rE":"0.4.1"};
4844
4848
  ;// CONCATENATED MODULE: ./packages/core/bytes/bitvec.ts
4845
4849
 
4846
4850
  /**
@@ -12689,11 +12693,32 @@ const ENTROPY_ENTRIES = 4;
12689
12693
 
12690
12694
  var state_update_UpdatePreimageKind;
12691
12695
  (function (UpdatePreimageKind) {
12692
- /** Insert new preimage and optionally update it's lookup history. */
12696
+ /**
12697
+ * Insert new preimage and optionally update it's lookup history.
12698
+ *
12699
+ * Used in: `provide`
12700
+ *
12701
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/383904383904?v=0.7.2
12702
+ */
12693
12703
  UpdatePreimageKind[UpdatePreimageKind["Provide"] = 0] = "Provide";
12694
- /** Remove a preimage and it's lookup history. */
12704
+ /**
12705
+ * Remove a preimage and it's lookup history.
12706
+ *
12707
+ * Used in: `forget` and `eject`
12708
+ *
12709
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/38c701380202?v=0.7.2
12710
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/379102379302?v=0.7.2
12711
+ */
12695
12712
  UpdatePreimageKind[UpdatePreimageKind["Remove"] = 1] = "Remove";
12696
- /** update or add lookup history for preimage hash/len to given value. */
12713
+ /**
12714
+ * Update or add lookup history for preimage hash/len to given value.
12715
+ *
12716
+ * Used in: `solicit` and `forget`
12717
+ *
12718
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/382802382802?v=0.7.2
12719
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/384002384b02?v=0.7.2
12720
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/38c60038ea00?v=0.7.2
12721
+ */
12697
12722
  UpdatePreimageKind[UpdatePreimageKind["UpdateOrAdd"] = 2] = "UpdateOrAdd";
12698
12723
  })(state_update_UpdatePreimageKind || (state_update_UpdatePreimageKind = {}));
12699
12724
  /**
@@ -12701,7 +12726,7 @@ var state_update_UpdatePreimageKind;
12701
12726
  *
12702
12727
  * Can be one of the following cases:
12703
12728
  * 1. Provide a new preimage blob and set the lookup history to available at `slot`.
12704
- * 2. Remove (expunge) a preimage and it's lookup history.
12729
+ * 2. Remove (forget) a preimage and it's lookup history.
12705
12730
  * 3. Update `LookupHistory` with given value.
12706
12731
  */
12707
12732
  class UpdatePreimage {
@@ -14584,7 +14609,6 @@ class LeafNode {
14584
14609
  /**
14585
14610
  * Get the byte length of embedded value.
14586
14611
  *
14587
- * @remark
14588
14612
  * Note in case this node only contains hash this is going to be 0.
14589
14613
  */
14590
14614
  getValueLength() {
@@ -14595,7 +14619,6 @@ class LeafNode {
14595
14619
  /**
14596
14620
  * Returns the embedded value.
14597
14621
  *
14598
- * @remark
14599
14622
  * Note that this is going to be empty for a regular leaf node (i.e. containing a hash).
14600
14623
  */
14601
14624
  getValue() {
@@ -14605,7 +14628,6 @@ class LeafNode {
14605
14628
  /**
14606
14629
  * Returns contained value hash.
14607
14630
  *
14608
- * @remark
14609
14631
  * Note that for embedded value this is going to be full 0-padded 32 bytes.
14610
14632
  */
14611
14633
  getValueHash() {
@@ -15801,45 +15823,6 @@ var status_Status;
15801
15823
 
15802
15824
 
15803
15825
 
15804
- ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/gas.ts
15805
-
15806
-
15807
- /** Create a new gas counter instance depending on the gas value. */
15808
- function gas_gasCounter(gas) {
15809
- return new GasCounterU64(tryAsU64(gas));
15810
- }
15811
- class GasCounterU64 {
15812
- gas;
15813
- initialGas;
15814
- constructor(gas) {
15815
- this.gas = gas;
15816
- this.initialGas = tryAsGas(gas);
15817
- }
15818
- set(g) {
15819
- this.gas = tryAsU64(g);
15820
- }
15821
- get() {
15822
- return tryAsGas(this.gas);
15823
- }
15824
- sub(g) {
15825
- const result = this.gas - tryAsU64(g);
15826
- if (result >= 0n) {
15827
- this.gas = tryAsU64(result);
15828
- return false;
15829
- }
15830
- this.gas = tryAsU64(0n);
15831
- return true;
15832
- }
15833
- used() {
15834
- const gasConsumed = tryAsU64(this.initialGas) - this.gas;
15835
- // In we have less than zero left we assume that all gas has been consumed.
15836
- if (gasConsumed < 0) {
15837
- return this.initialGas;
15838
- }
15839
- return tryAsGas(gasConsumed);
15840
- }
15841
- }
15842
-
15843
15826
  ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/memory/memory-index.ts
15844
15827
 
15845
15828
 
@@ -17574,6 +17557,45 @@ class basic_blocks_BasicBlocks {
17574
17557
  ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/basic-blocks/index.ts
17575
17558
 
17576
17559
 
17560
+ ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/gas.ts
17561
+
17562
+
17563
+ /** Create a new gas counter instance depending on the gas value. */
17564
+ function gas_gasCounter(gas) {
17565
+ return new GasCounterU64(tryAsU64(gas));
17566
+ }
17567
+ class GasCounterU64 {
17568
+ gas;
17569
+ initialGas;
17570
+ constructor(gas) {
17571
+ this.gas = gas;
17572
+ this.initialGas = tryAsGas(gas);
17573
+ }
17574
+ set(g) {
17575
+ this.gas = tryAsU64(g);
17576
+ }
17577
+ get() {
17578
+ return tryAsGas(this.gas);
17579
+ }
17580
+ sub(g) {
17581
+ const result = this.gas - tryAsU64(g);
17582
+ if (result >= 0n) {
17583
+ this.gas = tryAsU64(result);
17584
+ return false;
17585
+ }
17586
+ this.gas = tryAsU64(0n);
17587
+ return true;
17588
+ }
17589
+ used() {
17590
+ const gasConsumed = tryAsU64(this.initialGas) - this.gas;
17591
+ // In we have less than zero left we assume that all gas has been consumed.
17592
+ if (gasConsumed < 0) {
17593
+ return this.initialGas;
17594
+ }
17595
+ return tryAsGas(gasConsumed);
17596
+ }
17597
+ }
17598
+
17577
17599
  ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/instruction-gas-map.ts
17578
17600
 
17579
17601
 
@@ -19422,12 +19444,88 @@ class interpreter_Interpreter {
19422
19444
  }
19423
19445
  }
19424
19446
 
19447
+ ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/debugger-adapter.ts
19448
+
19449
+
19450
+
19451
+
19452
+
19453
+
19454
+ class DebuggerAdapter {
19455
+ pvm;
19456
+ constructor(useSbrkGas = false) {
19457
+ this.pvm = new Interpreter({ useSbrkGas });
19458
+ }
19459
+ resetGeneric(rawProgram, flatRegisters, initialGas) {
19460
+ this.pvm.resetGeneric(rawProgram, 0, tryAsGas(initialGas), new Registers(flatRegisters));
19461
+ }
19462
+ reset(rawProgram, pc, gas, maybeRegisters, maybeMemory) {
19463
+ this.pvm.resetGeneric(rawProgram, pc, tryAsGas(gas), maybeRegisters, maybeMemory);
19464
+ }
19465
+ getPageDump(pageNumber) {
19466
+ const page = this.pvm.getMemoryPage(pageNumber);
19467
+ if (page === null) {
19468
+ // page wasn't allocated so we return an empty page
19469
+ return safeAllocUint8Array(PAGE_SIZE);
19470
+ }
19471
+ if (page.length === PAGE_SIZE) {
19472
+ // page was allocated and has a proper size so we can simply return it
19473
+ return page;
19474
+ }
19475
+ // page was allocated but it is shorter than PAGE_SIZE so we have to extend it
19476
+ const fullPage = safeAllocUint8Array(PAGE_SIZE);
19477
+ fullPage.set(page);
19478
+ return fullPage;
19479
+ }
19480
+ setMemory(address, value) {
19481
+ this.pvm.memory.storeFrom(tryAsMemoryIndex(address), value);
19482
+ }
19483
+ getExitArg() {
19484
+ return this.pvm.getExitParam() ?? 0;
19485
+ }
19486
+ getStatus() {
19487
+ return this.pvm.getStatus();
19488
+ }
19489
+ nextStep() {
19490
+ return this.pvm.nextStep() === Status.OK;
19491
+ }
19492
+ nSteps(steps) {
19493
+ check `${steps >>> 0 > 0} Expected a positive integer got ${steps}`;
19494
+ for (let i = 0; i < steps; i++) {
19495
+ const isOk = this.nextStep();
19496
+ if (!isOk) {
19497
+ return false;
19498
+ }
19499
+ }
19500
+ return true;
19501
+ }
19502
+ getRegisters() {
19503
+ return this.pvm.registers.getAllU64();
19504
+ }
19505
+ setRegisters(registers) {
19506
+ this.pvm.registers.copyFrom(new Registers(registers));
19507
+ }
19508
+ getProgramCounter() {
19509
+ return this.pvm.getPC();
19510
+ }
19511
+ setNextProgramCounter(nextPc) {
19512
+ this.pvm.setNextPC(nextPc);
19513
+ }
19514
+ getGasLeft() {
19515
+ return BigInt(this.pvm.gas.get());
19516
+ }
19517
+ setGasLeft(gas) {
19518
+ this.pvm.gas.set(tryAsGas(gas));
19519
+ }
19520
+ }
19521
+
19425
19522
  ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/index.ts
19426
19523
 
19427
19524
 
19428
19525
 
19429
19526
 
19430
19527
 
19528
+
19431
19529
  ;// CONCATENATED MODULE: ./bin/test-runner/w3f/pvm.ts
19432
19530
 
19433
19531