feat: return actual gas charged to the transaction caller for zkVM transactions #592
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
When vm is on zkVM mode, Calls/Creates on EVM are intercepted and run as transactions on the zkVM made by the caller of the test contract. There are currently two problems related to gas visibility for them:
gas_used
value being returned is the computational gas spent by a bootloader program run onOneTx
mode with that transaction on its heap. This includes the gas for general setup and transaction validation + execution. This value does not make sense in neither the case where we would want to interpret the intercepted call as aCALL
opcode, because it would include setup + validation costs, nor for when we want to interpret it as an actual transaction (like done on evm tests when run onisolate
mode), because it includes non transaction related gas and does not account for neither pubdata nor intrinsic costs.InterpreterResult
represents 0 gas spent. This value is then used in traces which result in them showing 0 gas cost and gas report stats not showing any meaningful value.Solution
gas_used
.InterpreterResult
.