Skip to content

Commit

Permalink
Problem: invalid tx returns negative gas wanted
Browse files Browse the repository at this point in the history
Solution:
- add checks
  • Loading branch information
yihuang committed Apr 3, 2024
1 parent fecb1b0 commit 86e52f6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,14 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Request
blockGasWanted uint64
)
for _, res := range txResults {
blockGasUsed += uint64(res.GasUsed)
blockGasWanted += uint64(res.GasWanted)
// GasUsed should not be -1 but just in case
if res.GasUsed > 0 {
blockGasUsed += uint64(res.GasUsed)
}
// GasWanted could be -1 if the tx is invalid
if res.GasWanted > 0 {
blockGasWanted += uint64(res.GasWanted)
}
}
app.finalizeBlockState.SetContext(
app.finalizeBlockState.Context().
Expand Down

0 comments on commit 86e52f6

Please sign in to comment.