Skip to content

Commit

Permalink
Updating gas calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
nagarev committed Dec 13, 2024
1 parent ec1e055 commit 5091668
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion rskj-core/src/main/java/org/ethereum/vm/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -769,10 +769,19 @@ private long computeDataCopyGas() {

private long computeMemoryCopyGas() {
DataWord length = stack.get(stack.size() - 3);
DataWord offset = stack.peek();
DataWord src = stack.get(stack.size() - 2);
DataWord dst = stack.peek();

long copySize = Program.limitToMaxLong(length);
checkSizeArgument(copySize);

DataWord offset = dst;
if (src.value().compareTo(dst.value()) > 0) {
offset = src;
}

long newMemSize = memNeeded(offset, copySize);

// Note: 3 additional units are added outside because of the "Very Low Tier" configuration
return calcMemGas(oldMemSize, newMemSize, copySize);
}
Expand Down

0 comments on commit 5091668

Please sign in to comment.