Skip to content
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 13 commits into from
Dec 22, 2022
Merged

refactor: Baseapp audit changes #14379

merged 13 commits into from
Dec 22, 2022

Conversation

facundomedica
Copy link
Member

@facundomedica facundomedica commented Dec 21, 2022

Description

Some refactor from Amaury's and my notes.

  • Fixed comments
  • Factorize all set state functions into a single one
  • merged utils_test.go and util_test.go

Some other stuff is left, will do on a separate PR as those still need review


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...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers 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...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@facundomedica facundomedica requested a review from a team as a code owner December 21, 2022 14:05
@github-prbot github-prbot requested review from a team, JeancarloBarrios and atheeshp and removed request for a team December 21, 2022 14:05
@facundomedica facundomedica marked this pull request as draft December 21, 2022 14:06
@facundomedica facundomedica marked this pull request as ready for review December 21, 2022 14:10
@facundomedica facundomedica marked this pull request as draft December 21, 2022 14:15
Comment on lines 552 to 559
}

// 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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change potentially affects state.

Call sequence:

github.com/cosmos/cosmos-sdk/baseapp.validateBasicTxMsgs (baseapp/baseapp.go:539)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).runTx (baseapp/baseapp.go:618)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).DeliverTx (baseapp/baseapp.go:326)

@@ -162,7 +162,7 @@
// already be initialized in InitChain. Otherwise app.deliverState will be
// nil, since it is reset on Commit.
if app.deliverState == nil {
app.setDeliverState(req.Header)
app.setState(runTxModeDeliver, req.Header)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
@facundomedica facundomedica changed the title refactor: Baseapp audit cleanups refactor: Baseapp audit changes Dec 21, 2022
@facundomedica facundomedica marked this pull request as ready for review December 21, 2022 15:17
@alexanderbez
Copy link
Contributor

LGTM! Thanks :)

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@sonarqubecloud
Copy link

[Cosmos SDK] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@alexanderbez alexanderbez added the backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release label Dec 22, 2022
@alexanderbez
Copy link
Contributor

FYI @facundomedica -- audit PRs need to be backported to v0.47 :)

@alexanderbez alexanderbez merged commit 6d33fa8 into main Dec 22, 2022
@alexanderbez alexanderbez deleted the facu/baseapp-audit branch December 22, 2022 14:43
mergify bot pushed a commit that referenced this pull request Dec 22, 2022
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
(cherry picked from commit 6d33fa8)
alexanderbez pushed a commit that referenced this pull request Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants