Ganache produces shifted or even negative gas costs in debug_traceTransaction
See original GitHub issueExpected Behavior
I expect the trace to contain all the gas used by the transaction assigned to opcodes.
Current Behavior
In reality, when I sum all the costs found in a trace I get much less than the gas found on a transaction receipt.
(The image is actually from geth and is here just for visual purposes)
Possible Solution
Investigate and either fix or explain why is it like that.
Steps to Reproduce (for bugs)
- Create
truffleproject from ametacoinbox. - Run JS test that calls
sendCoin - Look at ganache logs to see the gas usage.
- Request the transaction trace and sum up gas costs of opcodes.
You don’t need that exact box. Just any smart contract transaction. This is probably the simplest one. You could probably also use remix.
Context
I’m building a profiler based on traces and I can only assign half of the gas to opcodes. I’d like to know where is the other half.
BTW, Geth has the same problem, so there is probably some fundamental misunderstanding on my side about how gas/traces work.
Your Environment
- Version used: Latest and latest beta.
- Environment name and version (e.g. PHP 5.4 on nginx 1.9.1):
- Server type and version:
- Operating System and version: Mac latest
- Link to your project: https://0x.org
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Why gas prices are so high
Gas prices have more than doubled in two years, adding enormous costs for drivers. Here's what caused prices to soar.
Read more >Why US gas prices are at a record and why they'll stay high ...
Numerous factors are combining to push gas prices up to a record. Gas hit $4.25 for a gallon of regular gas, according to...
Read more >Fuel prices are a problem for business and consumers
Consumers are grappling with record high gas prices, but the surge is also hurting businesses.
Read more >Why gas prices are so high, explained
Gasoline is the only product in modern-day America whose price is listed on giant signs almost everywhere you go. Most people, even if...
Read more >Gasoline costs more these days, but price spikes have a ...
A driver makes his selection from various fuels priced over $6 at a ... Also, gas prices are posted all over town on...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’d like to inform you that shifting
gasCosts works. I’ve just done it on my side and now I’m able to reconstruct the whole gas use by a transaction and profile it. I will not close the issue because it should be fixed on your side.I’ve digged deeped into ganache trace and it seems like it’s shifted.
When in reality if I check here or in yellowpaper here are the costs:
PUSH1-> 3MSTORE-> 3 * lengthCALLDATASIZE-> 2 *