Conversation
| Subtracts an amount to the gas counter | ||
| Reduces the gas left counter by an amount. | ||
|
|
||
| It should also charge for memory cost by multiplying `memory_pages * memory_cost * amount`, where `memory_cost` is defined by the gas schedule. |
There was a problem hiding this comment.
Actually this could be implemented in the metering process by
(call $useGas
(i64.mul
(i64.const <instruction gas>)
(i64.mul (i64.const <memory cost per page>) (current_memory))))
Though the two muls could be precomputed into one. I'd say this wouldn't have any lower overhead then doing it in the interface, but does remove possibility to adjust memory cost after metering.
There was a problem hiding this comment.
- Shouldn't it just charge for "added" memory pages instead of charging for all of them each time?
- In the comment you have
<instruction gas> * <memory cost>. Shouldn't it be+?
There was a problem hiding this comment.
The idea here is to charge for memory pages for the given time those are alive. The time dimension is metered by instruction gas (eg how many cycles it takes). In every block the entire available memory is charged for the duration it is required.
This is an idea @wanderer and I discussed and removes the need for the quadratic memory cost rule.
There was a problem hiding this comment.
Yes, I noticed it will be some-way quadratic.
| Subtracts an amount to the gas counter | ||
| Reduces the gas left counter by an amount. | ||
|
|
||
| It should also charge for memory cost by multiplying `memory_pages * memory_cost * amount`, where `memory_cost` is defined by the gas schedule. |
There was a problem hiding this comment.
- Shouldn't it just charge for "added" memory pages instead of charging for all of them each time?
- In the comment you have
<instruction gas> * <memory cost>. Shouldn't it be+?
| ## useGas | ||
|
|
||
| Subtracts an amount to the gas counter | ||
| Reduces the gas left counter by an amount. |
There was a problem hiding this comment.
Is the "gas left counter" kept outside of the WASM?
There was a problem hiding this comment.
I see here one problem, the takeGas function does not provide any reference to the current VM execution context. How would a VM handle this in concurrent environment?
There was a problem hiding this comment.
There are no references in any of the methods. Each contract has its own instance, it is an implementation detail in VM how to add the context to the methods.
There was a problem hiding this comment.
There's an instance of the methods for each execution (follows the sample way binaryen gives). It can be optimised though, but shouldn't affect the interface.
|
A relevant old issue: ewasm/wasm-metering-old#1 |
|
I think that To prevent resource exhaustion, we can have either i) a sentinel validation rule that the Any other options or ideas? |
| **Parameters** | ||
|
|
||
| - `amount` **i64** the amount to subtract to the gas counter | ||
| - `amount` **i64** the amount to reduce the gas left counter with |
There was a problem hiding this comment.
s/with/by/
or
"the amount by which to reduce the remaining gas counter"
No description provided.