Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory.grow's price may not reasonable #22

Open
zzfire opened this issue Dec 17, 2018 · 1 comment
Open

memory.grow's price may not reasonable #22

zzfire opened this issue Dec 17, 2018 · 1 comment

Comments

@zzfire
Copy link

zzfire commented Dec 17, 2018

In webassembly spec, memory.grow has no immediate number parameter, only consume the i32 element in stack top as the page size to grow. Currently in wasm-metering, memory.grow is treated as a "branch" instruction, and charged only by its appeared times, not including its page-size params. I understand it's impossible to get the run-time stack info when statically analysing a wasm file. But is there a more reasonable way to keep the "memory.grow" monster into the cage ?

I have a proposal, if we set the max-size of the memory's page size as a must value and a concrete value(take 1000 for example) before the metering work, is it more reasonable when we only count the appeared times of "memory.grow" ? In detail, in the wasm file's memory section, if max is not set, we set it to 1000, if max is larger than 1000, then failed it as a unqualified contract, if it's smaller than 1000, then we do nothing.

@zzfire
Copy link
Author

zzfire commented Dec 17, 2018

Initial Cost
The Initial cost for instantation for the module is calculated from all the sections other than the code section (which is metered at runtime). This information is stored as a custom section that is inserted directly after the preamble. It uses the the name initCost and its payload contains the initial cost encoded as an unsigned leb128 interger.

besides, another question, above description in README seems not implemented in current project. Is there a customized clang&llvm tool chain to insert the initial cost value in the custom section, where can I find it? and in wasm-metering, we have to read the initial cost value from custom section, currently it's missing.

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant