@typeberry/jam 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/bootstrap-importer.mjs +18 -0
- package/bootstrap-importer.mjs.map +1 -1
- package/index.js +18 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -46062,6 +46062,24 @@ class Interpreter {
|
|
|
46062
46062
|
getMemoryPage(pageNumber) {
|
|
46063
46063
|
return this.memory.getPageDump(tryAsPageNumber(pageNumber));
|
|
46064
46064
|
}
|
|
46065
|
+
calculateBlockGasCost() {
|
|
46066
|
+
const codeLength = this.code.length;
|
|
46067
|
+
const blocks = new Map();
|
|
46068
|
+
let currentBlock = "0";
|
|
46069
|
+
let gasCost = 0;
|
|
46070
|
+
const getNextIstructionIndex = (index) => index + 1 + this.mask.getNoOfBytesToNextInstruction(index + 1);
|
|
46071
|
+
for (let index = 0; index < codeLength; index = getNextIstructionIndex(index)) {
|
|
46072
|
+
const instruction = this.code[index];
|
|
46073
|
+
if (this.basicBlocks.isBeginningOfBasicBlock(index)) {
|
|
46074
|
+
blocks.set(currentBlock, gasCost);
|
|
46075
|
+
currentBlock = index.toString();
|
|
46076
|
+
gasCost = 0;
|
|
46077
|
+
}
|
|
46078
|
+
gasCost += instructionGasMap[instruction];
|
|
46079
|
+
}
|
|
46080
|
+
blocks.set(currentBlock, gasCost);
|
|
46081
|
+
return blocks;
|
|
46082
|
+
}
|
|
46065
46083
|
}
|
|
46066
46084
|
|
|
46067
46085
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/index.ts
|