Quadratic memory cost
This commit is contained in:
parent
fa484fa892
commit
6f66552f00
|
@ -210,7 +210,7 @@ public class VM {
|
||||||
long memoryUsage = (newMemSize.longValue() + 31) / 32 * 32;
|
long memoryUsage = (newMemSize.longValue() + 31) / 32 * 32;
|
||||||
if (memoryUsage > oldMemSize) {
|
if (memoryUsage > oldMemSize) {
|
||||||
memWords = (memoryUsage - oldMemSize) / 32;
|
memWords = (memoryUsage - oldMemSize) / 32;
|
||||||
long memGas = GasCost.MEMORY * memWords;
|
long memGas = GasCost.MEMORY * (memWords + memWords * memWords / 1024);
|
||||||
program.spendGas(memGas, op.name() + " (memory usage)");
|
program.spendGas(memGas, op.name() + " (memory usage)");
|
||||||
gasCost += memGas;
|
gasCost += memGas;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue