-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[R4R] Cache-wrap context during ante handler exec #2781
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2781 +/- ##
===========================================
+ Coverage 56.74% 56.77% +0.02%
===========================================
Files 131 131
Lines 8564 8545 -19
===========================================
- Hits 4860 4851 -9
+ Misses 3371 3363 -8
+ Partials 333 331 -2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment. Can we add a section to the SDK docs covering baseapp
and the expected sequence of transactions through CheckTx
/ DeliverTx
, explaining when ante handler state will be persisted, and explaining that a proposer can bypass CheckTx
? All of these are non-obvious to developers (and quite possibly also to us).
(and then link to parts of that spec directly in this code)
@cwgoes I can absolutely do that, I think that is a fantastic idea! |
@cwgoes addressed your concerns about state transitions + added BaseApp docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, mostly looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions and minor comments
docs/sdk/core/baseapp.md
Outdated
### CheckTx | ||
|
||
During the execution of `CheckTx`, first the AnteHandler is executed. If the | ||
AnteHandler fails or panics then the transaction fails. After the successful |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When should it panic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During any state transition that doesn't gracefully return an sdk.Result
that's also not out of gas.
baseapp/baseapp.go
Outdated
|
||
anteCtx := ctx | ||
if mode == runTxModeDeliver { | ||
anteCtx, msCache = app.cacheTxContext(ctx, txBytes, mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to do this for all modes? Otherwise eg invalid txs will change the checktx state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the current behavior so I left as-is and I don't see any direct reason to change it, unless you do?
|
||
// execute a successful ante handler and message execution where state is | ||
// implicitly checked by previous tx executions | ||
tx = newTxCounter(1, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so I guess the first arg, 1, means that the ante handler for one of the two above succeeded? But it's not clear which one.
The second 0 means that none of the msgs succeeded, but that wasn't clear either...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added explicit store checks via getting the app's state. Lmk if this still isn't clear. This logic is baked into the testing ante handler and message handler, so I'm trying to work with what I already have without making further drastic changes.
docs/sdk/core/baseapp.md
Outdated
|
||
The transaction execution during `DeliverTx` operates in a similar fashion to | ||
`CheckTx`. However, state transitions caused by the AnteHandler are persisted | ||
unless the transaction fails. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state transitions that occur during the AnteHandler are persisted even when the following Handler processing logic fails.
It is possible that a malicious proposer may include a transaction in a block that fails CheckTx
. In this case (i.e. the AnteHandler processing itself fails during DeliverTx), all state transitions for the offending transaction are discarded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you're suggesting here @jaekwon. I'm simply stating ante handler state updates are discarded/reverted if the ante handler fails during deliverTx
.
If you want rewording, can you please suggest something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the comments and ping me back!
Lol, Ethan and I left more or less the same comments. |
@jaekwon your change is failing on
I think this was the reason why I only did context caching on |
Perhaps we need to change the testcase. |
runTx
. State will only be persisted if the ante handler does fail (abort signaled).getState
a method ofBaseApp
-- not sure why it wasn't before as we were passing the reference in directly as a parameter.I believe the existing base app unit tests cover the cases that need to be covered.
closes: #2772
Targeted PR against correct branch (see CONTRIBUTING.md)
Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
Wrote tests
Updated relevant documentation (
docs/
)Added entries in
PENDING.md
with issue #rereviewed
Files changed
in the github PR explorerFor Admin Use: