Skip to content

Fix per-tx gasUsed to report actual gas consumed, not gas limit#158

Merged
niran merged 2 commits intomasterfrom
fix-per-tx-gas-used
Mar 30, 2026
Merged

Fix per-tx gasUsed to report actual gas consumed, not gas limit#158
niran merged 2 commits intomasterfrom
fix-per-tx-gas-used

Conversation

@niran
Copy link
Copy Markdown
Contributor

@niran niran commented Mar 28, 2026

Summary

  • Per-tx gasUsed was incorrectly storing the gas limit from the transaction envelope (tx.gas) instead of actual gas consumed from MeterBundleResult.gasUsed
  • Now includes both gasLimit and gasUsed per transaction in the API response
  • gasUsed is null for transactions without meter data (e.g. L1 attributes deposit tx)
  • UI shows "gasUsed / gasLimit gas" when meter data exists, or "gasLimit gas limit" when it doesn't
  • Cache deserialization is backwards-compatible with existing cached blocks

niran added 2 commits March 27, 2026 23:27
The block API was storing tx.gas (the gas limit from the transaction
envelope) as gasUsed for each transaction. The correct value was already
available in MeterBundleResult.gasUsed from the bundle history in S3.

Now includes both fields per transaction:
- gasLimit: from the transaction envelope (always available)
- gasUsed: actual gas consumed from meter data (null when unavailable)

The UI shows "gasUsed / gasLimit gas" when meter data exists, or
"gasLimit gas limit" for transactions without it (e.g. L1 deposit tx).

Cache deserialization is backwards-compatible with existing cached blocks
that only have the old gasUsed field (interpreted as gasLimit).
@niran niran requested a review from wlawt March 30, 2026 16:41
@niran niran merged commit 28d1af6 into master Mar 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants