design
design copied to clipboard
EEI: add metering of memory
A relevant old issue: https://github.com/ewasm/wasm-metering-old/issues/1
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?