@typeberry/convert 0.4.0-2473e55 → 0.4.0-248b604
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/index.js +120 -40
- package/index.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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;
|
|
@@ -15798,45 +15802,6 @@ var status_Status;
|
|
|
15798
15802
|
|
|
15799
15803
|
|
|
15800
15804
|
|
|
15801
|
-
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/gas.ts
|
|
15802
|
-
|
|
15803
|
-
|
|
15804
|
-
/** Create a new gas counter instance depending on the gas value. */
|
|
15805
|
-
function gas_gasCounter(gas) {
|
|
15806
|
-
return new GasCounterU64(tryAsU64(gas));
|
|
15807
|
-
}
|
|
15808
|
-
class GasCounterU64 {
|
|
15809
|
-
gas;
|
|
15810
|
-
initialGas;
|
|
15811
|
-
constructor(gas) {
|
|
15812
|
-
this.gas = gas;
|
|
15813
|
-
this.initialGas = tryAsGas(gas);
|
|
15814
|
-
}
|
|
15815
|
-
set(g) {
|
|
15816
|
-
this.gas = tryAsU64(g);
|
|
15817
|
-
}
|
|
15818
|
-
get() {
|
|
15819
|
-
return tryAsGas(this.gas);
|
|
15820
|
-
}
|
|
15821
|
-
sub(g) {
|
|
15822
|
-
const result = this.gas - tryAsU64(g);
|
|
15823
|
-
if (result >= 0n) {
|
|
15824
|
-
this.gas = tryAsU64(result);
|
|
15825
|
-
return false;
|
|
15826
|
-
}
|
|
15827
|
-
this.gas = tryAsU64(0n);
|
|
15828
|
-
return true;
|
|
15829
|
-
}
|
|
15830
|
-
used() {
|
|
15831
|
-
const gasConsumed = tryAsU64(this.initialGas) - this.gas;
|
|
15832
|
-
// In we have less than zero left we assume that all gas has been consumed.
|
|
15833
|
-
if (gasConsumed < 0) {
|
|
15834
|
-
return this.initialGas;
|
|
15835
|
-
}
|
|
15836
|
-
return tryAsGas(gasConsumed);
|
|
15837
|
-
}
|
|
15838
|
-
}
|
|
15839
|
-
|
|
15840
15805
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/memory/memory-index.ts
|
|
15841
15806
|
|
|
15842
15807
|
|
|
@@ -17571,6 +17536,45 @@ class basic_blocks_BasicBlocks {
|
|
|
17571
17536
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/basic-blocks/index.ts
|
|
17572
17537
|
|
|
17573
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
|
+
|
|
17574
17578
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/instruction-gas-map.ts
|
|
17575
17579
|
|
|
17576
17580
|
|
|
@@ -19419,12 +19423,88 @@ class interpreter_Interpreter {
|
|
|
19419
19423
|
}
|
|
19420
19424
|
}
|
|
19421
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
|
+
|
|
19422
19501
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/index.ts
|
|
19423
19502
|
|
|
19424
19503
|
|
|
19425
19504
|
|
|
19426
19505
|
|
|
19427
19506
|
|
|
19507
|
+
|
|
19428
19508
|
;// CONCATENATED MODULE: ./bin/test-runner/w3f/pvm.ts
|
|
19429
19509
|
|
|
19430
19510
|
|