Unification of wasm fuel across runtimes
In the https://github.com/hyperledger-iroha/iroha/pull/5465 PR, wasm execution calls are made, requiring a more advanced way to control wasm fuel usage. Some of the obvious issues that this issue aims to cover:
- For the fees case, fuel is incorrectly tracked
- Infinite recursive wasm calls are possible
What is the desired outcome?
- The fuel can be added/removed in the executor, and consequent smartcontact runtimes will use/re-use those amounts without resetting them to the default ones.
The example of the flow:
The changes might include adding a fuel field in the State struct. At the beginning of the host function call, the state will receive fuel from the previous runtime and use that value when creating a new runtime. At the end of the execution, parent's runtime should receive new fuel from state and continue execution,
I agree with the idea of carrying over the remaining consumable computation capacity from instruction to instruction.
However, as mentioned in https://github.com/hyperledger-iroha/iroha/pull/5421#discussion_r2094721370, I think it's better to first define a term other than the Wasm-specific "fuel" and base the discussion around that.
Since #5357 no longer assumes an "executor", a dedicated component that inherits the fee-related functionality should be devised.