Skip to content

Commit

Permalink
Adding gas cost calculation WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nagarev committed Sep 26, 2024
1 parent 43cabf2 commit 1331067
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions rskj-core/src/main/java/org/ethereum/vm/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -1437,30 +1437,17 @@ protected void doJUMPDEST()
}

protected void doMCOPY() {

/*
TODO -> Implement Gas Usage
Per yellow paper terminology, it should be considered part of the W_copy group of opcodes, and follow the gas calculation for W_copy in the yellow paper. While the calculation in the yellow paper should be considered the final word, for reference, as of time of this writing, that currently means its gas cost is:
words_copied = (length + 31) // 32
g_verylow = 3
g_copy = 3 * words_copied + memory_expansion_cost
gas_cost = g_verylow + g_copy
*/

/*
if (computeGas) {
long newMemSize = memNeeded(stack.peek(), 32);
gasCost = GasCost.add(gasCost, calcMemGas(oldMemSize, newMemSize, 0));
// See "Gas Cost" section on EIP 5656
// gas cost = 3 * (length + 31) + memory expansion cost + very low
long length = stack.get(stack.size() - 3).longValue();
long newMemSize = memNeeded(stack.peek(), length);
long cost = 3 * (length + 31) + calcMemGas(oldMemSize, newMemSize, 0) + 3; // TODO -> Check copy size

gasCost = GasCost.add(gasCost, cost);
spendOpCodeGas();
}

*/

// EXECUTION PHASE
DataWord dst = program.stackPop();
DataWord src = program.stackPop();
Expand Down

0 comments on commit 1331067

Please sign in to comment.