fix: revert tx when block gas limit exceeded (backport: #10770)#10814
Conversation
|
oh nice, thanks a lot. I'm putting in draft for now, let's merge #10770 first. |
41009cb to
e73a18e
Compare
|
I guess we better write a unit test for this too, but I find it not easy to do that? which test suite is the best place to write a test case for this? |
d6862eb to
fc6b209
Compare
There was a problem hiding this comment.
no need to check overflow since it's already handled in ConsumeGas.
There was a problem hiding this comment.
this seems correct to me, @yihuang did you think of how we can write a test for this?
Edit: maybe in TestMaxBlockGasLimits in baseapp_test?
There was a problem hiding this comment.
Can we remove this defer func?
AFAIK, there's no gas consumption after runMsgs. So if we put consumeBlockGas in runTx, before store write, then it should be okay?
There was a problem hiding this comment.
We need defer function to consume block gas when panic happens I think.
There was a problem hiding this comment.
Okay, let's maybe keep it for now
I tried before, find it very tedious to set up the environment, let me try it again. |
We can't do that in |
- used a different solution. changelog
4f9cf40 to
3d67fa8
Compare
tests added. |
amaury1093
left a comment
There was a problem hiding this comment.
thanks a lot
Let's get this released today 😎
robert-zaremba
left a comment
There was a problem hiding this comment.
utACK, left few tiny comments.
| result, err = app.runMsgs(runMsgCtx, msgs, mode) | ||
| if err == nil && mode == runTxModeDeliver { | ||
| // When block gas exceeds, it'll panic and won't commit the cached store. | ||
| consumeBlockGas() |
There was a problem hiding this comment.
do we need to call it here? It's already called in defer (line 614)
There was a problem hiding this comment.
do we need to call it here? It's already called in
defer(line 614)
That's the main purpose of this PR, call it here so if block gas limit exceeded, it'll panic and won't execute the msCache.Write(), so the tx msg side effects are not persisted.
There was a problem hiding this comment.
makes sense. Thanks!
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
|
Merging! |
…cosmos#10814) * revert tx when block gas limit exceeded (backport: cosmos#10770) - used a different solution. changelog * add unit test * Update baseapp/baseapp.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * simplfy the defer function Co-authored-by: Robert Zaremba <robert@zaremba.ch>
…cosmos#10814) * revert tx when block gas limit exceeded (backport: cosmos#10770) - used a different solution. changelog * add unit test * Update baseapp/baseapp.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * simplfy the defer function Co-authored-by: Robert Zaremba <robert@zaremba.ch>
…cosmos#10814) * revert tx when block gas limit exceeded (backport: cosmos#10770) - used a different solution. changelog * add unit test * Update baseapp/baseapp.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * simplfy the defer function Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Description
backport from #10770, but used a different solution from the master one, because of difference in code structure.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!to the type prefix if API or client breaking changeCHANGELOG.mdReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!in the type prefix if API or client breaking change