quadratic memory charge

This commit is contained in:
NikVolf 2018-02-06 00:44:51 +03:00
parent 81e53080d3
commit 72d71ec1c7

View File

@ -48,6 +48,10 @@ fn add_grow_counter(module: elements::Module, rules: &rules::Set, gas_func: u32)
GetLocal(0),
I32Const(rules.grow_cost() as i32),
I32Mul,
CurrentMemory(0),
I32Const(1),
I32Add,
I32Mul,
// todo: there should be strong guarantee that it does not return anything on stack?
Call(gas_func),
GrowMemory(0),
@ -244,6 +248,10 @@ mod tests {
GetLocal(0),
I32Const(10000),
I32Mul,
CurrentMemory(0),
I32Const(1),
I32Add,
I32Mul,
Call(0),
GrowMemory(0),
GetLocal(0),