@typeberry/convert 0.4.0-5a35a0a → 0.4.0-a5d5d88

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.
@@ -10702,7 +10706,7 @@ function parseBootnode(v) {
10702
10706
  if (name === "" || ip === "" || port === "") {
10703
10707
  throw new Error(`Invalid bootnode format, expected: <name>@<ip>:<port>, got: "${v}"`);
10704
10708
  }
10705
- const portNumber = Number.parseInt(port);
10709
+ const portNumber = Number.parseInt(port, 10);
10706
10710
  if (!isU16(portNumber)) {
10707
10711
  throw new Error(`Invalid port number: "${port}"`);
10708
10712
  }
@@ -14584,7 +14588,6 @@ class LeafNode {
14584
14588
  /**
14585
14589
  * Get the byte length of embedded value.
14586
14590
  *
14587
- * @remark
14588
14591
  * Note in case this node only contains hash this is going to be 0.
14589
14592
  */
14590
14593
  getValueLength() {
@@ -14595,7 +14598,6 @@ class LeafNode {
14595
14598
  /**
14596
14599
  * Returns the embedded value.
14597
14600
  *
14598
- * @remark
14599
14601
  * Note that this is going to be empty for a regular leaf node (i.e. containing a hash).
14600
14602
  */
14601
14603
  getValue() {
@@ -14605,7 +14607,6 @@ class LeafNode {
14605
14607
  /**
14606
14608
  * Returns contained value hash.
14607
14609
  *
14608
- * @remark
14609
14610
  * Note that for embedded value this is going to be full 0-padded 32 bytes.
14610
14611
  */
14611
14612
  getValueHash() {
@@ -15801,45 +15802,6 @@ var status_Status;
15801
15802
 
15802
15803
 
15803
15804
 
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
15805
  ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/memory/memory-index.ts
15844
15806
 
15845
15807
 
@@ -17574,6 +17536,45 @@ class basic_blocks_BasicBlocks {
17574
17536
  ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/basic-blocks/index.ts
17575
17537
 
17576
17538
 
17539
+ ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/gas.ts
17540
+
17541
+
17542
+ /** Create a new gas counter instance depending on the gas value. */
17543
+ function gas_gasCounter(gas) {
17544
+ return new GasCounterU64(tryAsU64(gas));
17545
+ }
17546
+ class GasCounterU64 {
17547
+ gas;
17548
+ initialGas;
17549
+ constructor(gas) {
17550
+ this.gas = gas;
17551
+ this.initialGas = tryAsGas(gas);
17552
+ }
17553
+ set(g) {
17554
+ this.gas = tryAsU64(g);
17555
+ }
17556
+ get() {
17557
+ return tryAsGas(this.gas);
17558
+ }
17559
+ sub(g) {
17560
+ const result = this.gas - tryAsU64(g);
17561
+ if (result >= 0n) {
17562
+ this.gas = tryAsU64(result);
17563
+ return false;
17564
+ }
17565
+ this.gas = tryAsU64(0n);
17566
+ return true;
17567
+ }
17568
+ used() {
17569
+ const gasConsumed = tryAsU64(this.initialGas) - this.gas;
17570
+ // In we have less than zero left we assume that all gas has been consumed.
17571
+ if (gasConsumed < 0) {
17572
+ return this.initialGas;
17573
+ }
17574
+ return tryAsGas(gasConsumed);
17575
+ }
17576
+ }
17577
+
17577
17578
  ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/instruction-gas-map.ts
17578
17579
 
17579
17580
 
@@ -19422,12 +19423,88 @@ class interpreter_Interpreter {
19422
19423
  }
19423
19424
  }
19424
19425
 
19426
+ ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/debugger-adapter.ts
19427
+
19428
+
19429
+
19430
+
19431
+
19432
+
19433
+ class DebuggerAdapter {
19434
+ pvm;
19435
+ constructor(useSbrkGas = false) {
19436
+ this.pvm = new Interpreter({ useSbrkGas });
19437
+ }
19438
+ resetGeneric(rawProgram, flatRegisters, initialGas) {
19439
+ this.pvm.resetGeneric(rawProgram, 0, tryAsGas(initialGas), new Registers(flatRegisters));
19440
+ }
19441
+ reset(rawProgram, pc, gas, maybeRegisters, maybeMemory) {
19442
+ this.pvm.resetGeneric(rawProgram, pc, tryAsGas(gas), maybeRegisters, maybeMemory);
19443
+ }
19444
+ getPageDump(pageNumber) {
19445
+ const page = this.pvm.getMemoryPage(pageNumber);
19446
+ if (page === null) {
19447
+ // page wasn't allocated so we return an empty page
19448
+ return safeAllocUint8Array(PAGE_SIZE);
19449
+ }
19450
+ if (page.length === PAGE_SIZE) {
19451
+ // page was allocated and has a proper size so we can simply return it
19452
+ return page;
19453
+ }
19454
+ // page was allocated but it is shorter than PAGE_SIZE so we have to extend it
19455
+ const fullPage = safeAllocUint8Array(PAGE_SIZE);
19456
+ fullPage.set(page);
19457
+ return fullPage;
19458
+ }
19459
+ setMemory(address, value) {
19460
+ this.pvm.memory.storeFrom(tryAsMemoryIndex(address), value);
19461
+ }
19462
+ getExitArg() {
19463
+ return this.pvm.getExitParam() ?? 0;
19464
+ }
19465
+ getStatus() {
19466
+ return this.pvm.getStatus();
19467
+ }
19468
+ nextStep() {
19469
+ return this.pvm.nextStep() === Status.OK;
19470
+ }
19471
+ nSteps(steps) {
19472
+ check `${steps >>> 0 > 0} Expected a positive integer got ${steps}`;
19473
+ for (let i = 0; i < steps; i++) {
19474
+ const isOk = this.nextStep();
19475
+ if (!isOk) {
19476
+ return false;
19477
+ }
19478
+ }
19479
+ return true;
19480
+ }
19481
+ getRegisters() {
19482
+ return this.pvm.registers.getAllU64();
19483
+ }
19484
+ setRegisters(registers) {
19485
+ this.pvm.registers.copyFrom(new Registers(registers));
19486
+ }
19487
+ getProgramCounter() {
19488
+ return this.pvm.getPC();
19489
+ }
19490
+ setNextProgramCounter(nextPc) {
19491
+ this.pvm.setNextPC(nextPc);
19492
+ }
19493
+ getGasLeft() {
19494
+ return BigInt(this.pvm.gas.get());
19495
+ }
19496
+ setGasLeft(gas) {
19497
+ this.pvm.gas.set(tryAsGas(gas));
19498
+ }
19499
+ }
19500
+
19425
19501
  ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/index.ts
19426
19502
 
19427
19503
 
19428
19504
 
19429
19505
 
19430
19506
 
19507
+
19431
19508
  ;// CONCATENATED MODULE: ./bin/test-runner/w3f/pvm.ts
19432
19509
 
19433
19510