-
Notifications
You must be signed in to change notification settings - Fork 228
Evaporate & Check Gas APIs #1394
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
Conversation
…an throwing error
New gas_evaporate API function
# Conflicts: # cosmwasm/enclaves/shared/contract-engine/src/wasm3/mod.rs # cosmwasm/packages/sgx-vm/src/compatability.rs
Looks great! I don't fully understand why it is offset by 1 sometimes. I would have thought since it is always adding a multiple of 1000 to cosmwasm gas that it would eventually result in the same sdk gas when it is divided by 1000 later on, unless there are other things contributing to cosmwasm gas when the api call is made (eg memory reads?). Anyway, I guess it doesn't matter as long as when a contract dev wants to target exact gas for different functions that they all end up the same (and not some one off from the others). Do you think it would be useful to create a new SNIP with guidelines on how to use the evaporate API? It could also be incorporated into snip20-reference-impl. Maybe just add an optional |
|
Oh wait, could it just be something as simple as the line
|
|
Yeah it's possible - let me see if that makes a difference. Though I'd still expect the shift in gas to be consistent if that was the case. But for some reason executing with 100 gas to evaporate returns X and 400000 returns X+1. Maybe it's the difference in some internal allocation in the contract? @assafmo want to take a look at see if you have any other ideas? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The off by 1 issue is definitely something with additional WASM opcodes/memory allocations.
Added the check_gas API and a couple of tests. Found some interesting behaviour, but otherwise seems pretty solid.
Matching Cosmwasm PR: scrtlabs/cosmwasm#14
cc: @darwinzer0 @blake-regalia - what do you guys think?