-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
refactor: Baseapp audit changes #14379
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1e6e8fd
merge utils_test.go and util_test.go
facundomedica 6999e96
fix getState comment
facundomedica ce138d6
remove parallel block execution comment. in the spec it says it will …
facundomedica fd0b844
factorize setState functions (from Amaury's notes)
facundomedica 306c596
Revert "merge utils_test.go and util_test.go"
facundomedica afc2c51
Revert "Revert "merge utils_test.go and util_test.go""
facundomedica ed5eb8a
Revert "factorize setState functions (from Amaury's notes)"
facundomedica 56e4e6a
Revert "Revert "factorize setState functions (from Amaury's notes)""
facundomedica c227080
found issue in setState
facundomedica 1ac40fe
Merge branch 'main' into facu/baseapp-audit
alexanderbez 962a584
Merge branch 'main' into facu/baseapp-audit
alexanderbez 2ce1297
Merge branch 'main' into facu/baseapp-audit
facundomedica 8cc6bce
Merge branch 'main' into facu/baseapp-audit
facundomedica 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -350,11 +350,11 @@ func (app *BaseApp) Init() error { | |
emptyHeader := tmproto.Header{} | ||
|
||
// needed for the export command which inits from store but never calls initchain | ||
app.setCheckState(emptyHeader) | ||
app.setState(runTxModeCheck, emptyHeader) | ||
|
||
// needed for ABCI Replay Blocks mode which calls Prepare/Process proposal (InitChain is not called) | ||
app.setPrepareProposalState(emptyHeader) | ||
app.setProcessProposalState(emptyHeader) | ||
app.setState(runTxPrepareProposal, emptyHeader) | ||
app.setState(runTxProcessProposal, emptyHeader) | ||
app.Seal() | ||
|
||
if app.cms == nil { | ||
|
@@ -402,49 +402,32 @@ func (app *BaseApp) Seal() { app.sealed = true } | |
// IsSealed returns true if the BaseApp is sealed and false otherwise. | ||
func (app *BaseApp) IsSealed() bool { return app.sealed } | ||
|
||
// setCheckState sets the BaseApp's checkState with a branched multi-store | ||
// (i.e. a CacheMultiStore) and a new Context with the same multi-store branch, | ||
// provided header, and minimum gas prices set. It is set on InitChain and reset | ||
// on Commit. | ||
func (app *BaseApp) setCheckState(header tmproto.Header) { | ||
// setState sets the BaseApp's state for the corresponding mode with a branched | ||
// multi-store (i.e. a CacheMultiStore) and a new Context with the same | ||
// multi-store branch, and provided header. | ||
func (app *BaseApp) setState(mode runTxMode, header tmproto.Header) { | ||
ms := app.cms.CacheMultiStore() | ||
app.checkState = &state{ | ||
ms: ms, | ||
ctx: sdk.NewContext(ms, header, true, app.logger).WithMinGasPrices(app.minGasPrices), | ||
} | ||
} | ||
|
||
// setDeliverState sets the BaseApp's deliverState with a branched multi-store | ||
// (i.e. a CacheMultiStore) and a new Context with the same multi-store branch, | ||
// and provided header. It is set on InitChain and BeginBlock and set to nil on | ||
// Commit. | ||
func (app *BaseApp) setDeliverState(header tmproto.Header) { | ||
ms := app.cms.CacheMultiStore() | ||
app.deliverState = &state{ | ||
ms: ms, | ||
ctx: sdk.NewContext(ms, header, false, app.logger), | ||
} | ||
} | ||
|
||
// setPrepareProposalState sets the BaseApp's prepareProposalState with a | ||
// branched multi-store (i.e. a CacheMultiStore) and a new Context with the | ||
// same multi-store branch, and provided header. It is set on InitChain and Commit. | ||
func (app *BaseApp) setPrepareProposalState(header tmproto.Header) { | ||
ms := app.cms.CacheMultiStore() | ||
app.prepareProposalState = &state{ | ||
baseState := &state{ | ||
ms: ms, | ||
ctx: sdk.NewContext(ms, header, false, app.logger), | ||
} | ||
} | ||
|
||
// setProcessProposalState sets the BaseApp's processProposalState with a | ||
// branched multi-store (i.e. a CacheMultiStore) and a new Context with the | ||
// same multi-store branch, and provided header. It is set on InitChain and Commit. | ||
func (app *BaseApp) setProcessProposalState(header tmproto.Header) { | ||
ms := app.cms.CacheMultiStore() | ||
app.processProposalState = &state{ | ||
ms: ms, | ||
ctx: sdk.NewContext(ms, header, false, app.logger), | ||
switch mode { | ||
case runTxModeCheck: | ||
// Minimum gas prices are also set. It is set on InitChain and reset on Commit. | ||
baseState.ctx = baseState.ctx.WithIsCheckTx(true).WithMinGasPrices(app.minGasPrices) | ||
app.checkState = baseState | ||
case runTxModeDeliver: | ||
// It is set on InitChain and BeginBlock and set to nil on Commit. | ||
app.deliverState = baseState | ||
case runTxPrepareProposal: | ||
// It is set on InitChain and Commit. | ||
app.prepareProposalState = baseState | ||
case runTxProcessProposal: | ||
// It is set on InitChain and Commit. | ||
app.processProposalState = baseState | ||
default: | ||
panic(fmt.Sprintf("invalid runTxMode for setState: %d", mode)) | ||
} | ||
} | ||
|
||
|
@@ -552,7 +535,8 @@ func validateBasicTxMsgs(msgs []sdk.Msg) error { | |
} | ||
|
||
// Returns the application's deliverState if app is in runTxModeDeliver, | ||
// otherwise it returns the application's checkstate. | ||
// prepareProposalState if app is in runTxPrepareProposal, processProposalState | ||
// if app is in runTxProcessProposal, and checkState otherwise. | ||
func (app *BaseApp) getState(mode runTxMode) *state { | ||
switch mode { | ||
case runTxModeDeliver: | ||
Comment on lines
535
to
542
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change potentially affects state. Call sequence:
|
||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods