Skip to content

fix(baseapp): don't report block-level gas for failed tx decodes#3202

Closed
wen-coding wants to merge 1 commit intomainfrom
wen/fix_gasused_nil_tx
Closed

fix(baseapp): don't report block-level gas for failed tx decodes#3202
wen-coding wants to merge 1 commit intomainfrom
wen/fix_gasused_nil_tx

Conversation

@wen-coding
Copy link
Copy Markdown
Contributor

Summary

  • When a transaction fails to decode (nil tx), runTx's deferred epilogue was reading GasUsed from the block-level gas meter instead of a per-tx meter, since the ante handler never ran to install one.
  • Added a guard: if the gas meter hasn't changed from the block-level meter, skip reporting gas for that transaction.
  • Added TestRunTxDecodeError to verify decode failures always report zero gas regardless of block-level meter state.

Test plan

  • TestRunTxDecodeError — verifies zero GasUsed for nil tx even when block meter has accumulated gas
  • Existing TestTxGasLimits and TestRunInvalidTransaction still pass

🤖 Generated with Claude Code

When ante handling never runs (e.g. decode failure), the deferred
epilogue in runTx was reading the block-level gas meter instead of
a per-tx meter. Guard against this by checking whether a tx-scoped
meter was installed before reporting GasUsed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedApr 6, 2026, 9:44 PM

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.65%. Comparing base (292f78c) to head (30604f4).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3202   +/-   ##
=======================================
  Coverage   58.65%   58.65%           
=======================================
  Files        2055     2055           
  Lines      168498   168501    +3     
=======================================
+ Hits        98835    98841    +6     
+ Misses      60878    60876    -2     
+ Partials     8785     8784    -1     
Flag Coverage Δ
sei-chain-pr 63.54% <100.00%> (?)
sei-db 70.62% <ø> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-cosmos/baseapp/baseapp.go 76.42% <100.00%> (+0.55%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wen-coding wen-coding closed this Apr 7, 2026
@wen-coding wen-coding deleted the wen/fix_gasused_nil_tx branch April 7, 2026 00:02
github-merge-queue bot pushed a commit that referenced this pull request Apr 9, 2026
)

## Summary
- When a transaction fails to decode (nil tx), the deferred epilogue was
reading `GasUsed` from the block-level gas meter instead of a per-tx
meter, since the ante handler never ran to install one.
- Added a guard in all three tx execution paths: if the gas meter hasn't
changed from the block-level meter, skip reporting gas for that
transaction.
  - `app/legacyabci/deliver_tx.go` (production DeliverTx)
  - `app/legacyabci/check_tx.go` (production CheckTx)
  - `sei-cosmos/baseapp/baseapp.go` (simulation/CheckTx via runTx)

Supersedes #3202.

## Test plan
- [x] `TestDecodeFailureTxReportsZeroGas` (app) — successful bank send
reports nonzero gas, decode failure reports zero, insufficient-funds tx
(ante handler ran) reports nonzero gas
- [x] `TestRunTxDecodeError` (baseapp) — nil tx with prior block-level
gas reports zero GasUsed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant