Submitted by 0x41
In call_contract.go, when a contract call fails, the code only consumes gas for the failed transaction but does not account for previously accumulated block gas usage. This creates a mismatch between the actual gas used in the block and what gets consumed in the gas meter.
The issue occurs in the error handling path of CallContractWithInput where after a failed call, only the gas of the failed transaction is consumed:
However, in the success path, the code correctly adds the gas used to the block total:
This inconsistency means that failed transactions do not properly contribute to the blocks gas tracking. This is especially bad when the failed transaction is the last one in a block, as it will decrease the gas counter heavily (only the last transaction vs. the sum of all).
The issue can be found in call_contract.go#L118:
Compared to the success path at call_contract.go#L133:
To fix this issue, the gas accounting should be consistent between success and failure paths. Add the block gas tracking before handling the failure case:
This ensures that all gas used, whether from successful or failed transactions, is properly accounted for in the block total.
berndartmueller (judge) commented:
k-yang (Nibiru) confirmed and commented:
Lambda (warden) commented:
berndartmueller (judge) commented:
Lambda (warden) commented:
berndartmueller (judge) commented:
Lambda (warden) commented:
berndartmueller (judge) commented:
k-yang (Nibiru) commented:
Nibiru mitigated:
Status: Mitigation confirmed. 
