design icon indicating copy to clipboard operation
design copied to clipboard

EEI: add metering of memory

Open axic opened this issue 7 years ago • 2 comments

axic avatar Jan 21 '18 18:01 axic

A relevant old issue: https://github.com/ewasm/wasm-metering-old/issues/1

axic avatar Jan 24 '18 01:01 axic

I think that useGas for memory should be injected in two places: i) at the beginning of the main function to charge for pre-allocated memory in the memory section, and ii) before each memory.grow Wasm opcode. The cost for each memory page should reflect zeroing-out a 64kB page. memory.grow should be more expensive since it is done at run-time.

To prevent resource exhaustion, we can have either i) a sentinel validation rule that the memory section must have a max e.g. 1024 memory pages, or ii) an algebraically or exponentially growing memory gas cost. The second option makes gas cost known only at run-time, which is undesirable.

Any other options or ideas?

poemm avatar Jul 31 '18 00:07 poemm