-
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
fix: use deliverState in prepare and processProposal at height 1 #14505
Merged
Merged
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
704d4d3
fix: use deliverState in prepare and processProposal at height 1
facundomedica c0d666c
cache deliverState
facundomedica 2d80482
add test + add panic if prepareProposal gets called with height=0
facundomedica 641b0a5
Merge branch 'main' into facu/fix-prep-prop-2
facundomedica 18e8daf
make the linter happy
facundomedica dafc7f6
Merge branch 'main' into facu/fix-prep-prop-2
facundomedica fac4b17
make the linter happy
facundomedica 5f24a29
Merge branch 'facu/fix-prep-prop-2' of https://github.com/cosmos/cosm…
facundomedica aec9010
add comment
facundomedica a220784
Revert "make the linter happy"
facundomedica d5d0bbc
fix a wrongly pushed test app
facundomedica f9167dc
make the linter happy
facundomedica 223c445
make the linter happy
facundomedica 4ce6f8c
make the linter happy
facundomedica b0e8f83
Merge branch 'main' into facu/fix-prep-prop-2
facundomedica 68dd679
Merge branch 'main' into facu/fix-prep-prop-2
alexanderbez 161f4b9
Merge branch 'main' into facu/fix-prep-prop-2
JeancarloBarrios 21a874e
Merge branch 'main' into facu/fix-prep-prop-2
tac0turtle 4a3beff
suggestion from @ttl33
facundomedica ac4c3f2
add cl
facundomedica ae72588
Merge branch 'main' into facu/fix-prep-prop-2
julienrbrt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Curious - why is the state with changes that InitChain made not available to the app?
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.
wdym "not available to the app"?
After
InitChain
, changes are not committed. They're technically staged/cached on the (cached) root multi-store. This isn't whatprepareProposal
state is based off of untilCommit
is called.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.
InitChain initializes and applies changes (params, genesis and such) to
deliverState
, which is not persisted until Commit(): see here.In
Commit()
deliverState
is set to nil while the other states are set to the latest header (that's why we were seeing the previous block height inPrepareProposal
before addingWithBlockHeight(req.Height)
in this PR).So
PrepareProposal
andProcessProposal
will always be seeing persisted state (from the previous produced block), except for the first block that we feed it with the genesis state. Also it's good to note that we shouldn't be making any persistable state changes during these stages.Also
BeginBlock
is the one in charge of setting deliverState; except when we are at the first block: in that case we just want to update the context retaining any state changes made inInitChain
. see hereThere 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 see, thanks for the explanation. That makes sense.
Random alternative thoughts:
InitChain
only? meaning that the at height 1, CosmosSDK just runsInitChain
and then callsCommit
. No special logic to override the ctx state to be thedeliverState
which has not been committed. My main reasoning around this is if there would be any weird behavior for thePrepareProposal
to be based off of state that has not been committed to state.InitChain
andCommit
only