@typeberry/lib 0.2.0-f9e8db5 → 0.2.0
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.cjs +18 -0
- package/index.d.ts +23 -0
- package/index.js +18 -0
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -16302,6 +16302,24 @@ class Interpreter {
|
|
|
16302
16302
|
getMemoryPage(pageNumber) {
|
|
16303
16303
|
return this.memory.getPageDump(tryAsPageNumber(pageNumber));
|
|
16304
16304
|
}
|
|
16305
|
+
calculateBlockGasCost() {
|
|
16306
|
+
const codeLength = this.code.length;
|
|
16307
|
+
const blocks = new Map();
|
|
16308
|
+
let currentBlock = "0";
|
|
16309
|
+
let gasCost = 0;
|
|
16310
|
+
const getNextIstructionIndex = (index) => index + 1 + this.mask.getNoOfBytesToNextInstruction(index + 1);
|
|
16311
|
+
for (let index = 0; index < codeLength; index = getNextIstructionIndex(index)) {
|
|
16312
|
+
const instruction = this.code[index];
|
|
16313
|
+
if (this.basicBlocks.isBeginningOfBasicBlock(index)) {
|
|
16314
|
+
blocks.set(currentBlock, gasCost);
|
|
16315
|
+
currentBlock = index.toString();
|
|
16316
|
+
gasCost = 0;
|
|
16317
|
+
}
|
|
16318
|
+
gasCost += instructionGasMap[instruction];
|
|
16319
|
+
}
|
|
16320
|
+
blocks.set(currentBlock, gasCost);
|
|
16321
|
+
return blocks;
|
|
16322
|
+
}
|
|
16305
16323
|
}
|
|
16306
16324
|
|
|
16307
16325
|
var index$7 = /*#__PURE__*/Object.freeze({
|
package/index.d.ts
CHANGED
|
@@ -17542,6 +17542,29 @@ declare class Interpreter {
|
|
|
17542
17542
|
getMemoryPage(pageNumber: number): null | Uint8Array {
|
|
17543
17543
|
return this.memory.getPageDump(tryAsPageNumber(pageNumber));
|
|
17544
17544
|
}
|
|
17545
|
+
|
|
17546
|
+
calculateBlockGasCost(): Map<string, number> {
|
|
17547
|
+
const codeLength = this.code.length;
|
|
17548
|
+
const blocks: Map<string, number> = new Map();
|
|
17549
|
+
let currentBlock = "0";
|
|
17550
|
+
let gasCost = 0;
|
|
17551
|
+
const getNextIstructionIndex = (index: number) => index + 1 + this.mask.getNoOfBytesToNextInstruction(index + 1);
|
|
17552
|
+
|
|
17553
|
+
for (let index = 0; index < codeLength; index = getNextIstructionIndex(index)) {
|
|
17554
|
+
const instruction = this.code[index];
|
|
17555
|
+
if (this.basicBlocks.isBeginningOfBasicBlock(index)) {
|
|
17556
|
+
blocks.set(currentBlock, gasCost);
|
|
17557
|
+
currentBlock = index.toString();
|
|
17558
|
+
gasCost = 0;
|
|
17559
|
+
}
|
|
17560
|
+
|
|
17561
|
+
gasCost += instructionGasMap[instruction];
|
|
17562
|
+
}
|
|
17563
|
+
|
|
17564
|
+
blocks.set(currentBlock, gasCost);
|
|
17565
|
+
|
|
17566
|
+
return blocks;
|
|
17567
|
+
}
|
|
17545
17568
|
}
|
|
17546
17569
|
|
|
17547
17570
|
type index$8_BigGas = BigGas;
|
package/index.js
CHANGED
|
@@ -16299,6 +16299,24 @@ class Interpreter {
|
|
|
16299
16299
|
getMemoryPage(pageNumber) {
|
|
16300
16300
|
return this.memory.getPageDump(tryAsPageNumber(pageNumber));
|
|
16301
16301
|
}
|
|
16302
|
+
calculateBlockGasCost() {
|
|
16303
|
+
const codeLength = this.code.length;
|
|
16304
|
+
const blocks = new Map();
|
|
16305
|
+
let currentBlock = "0";
|
|
16306
|
+
let gasCost = 0;
|
|
16307
|
+
const getNextIstructionIndex = (index) => index + 1 + this.mask.getNoOfBytesToNextInstruction(index + 1);
|
|
16308
|
+
for (let index = 0; index < codeLength; index = getNextIstructionIndex(index)) {
|
|
16309
|
+
const instruction = this.code[index];
|
|
16310
|
+
if (this.basicBlocks.isBeginningOfBasicBlock(index)) {
|
|
16311
|
+
blocks.set(currentBlock, gasCost);
|
|
16312
|
+
currentBlock = index.toString();
|
|
16313
|
+
gasCost = 0;
|
|
16314
|
+
}
|
|
16315
|
+
gasCost += instructionGasMap[instruction];
|
|
16316
|
+
}
|
|
16317
|
+
blocks.set(currentBlock, gasCost);
|
|
16318
|
+
return blocks;
|
|
16319
|
+
}
|
|
16302
16320
|
}
|
|
16303
16321
|
|
|
16304
16322
|
var index$7 = /*#__PURE__*/Object.freeze({
|