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): handle cases for PostHandler in runTx #14593

Closed
wants to merge 20 commits into from

Conversation

Vvaradinov
Copy link
Contributor

@Vvaradinov Vvaradinov commented Jan 12, 2023

Description

This is a follow up PR to #13940. It includes the 3 cases for PostHandler logic in runTx.

Closes: #14592 #13942


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)

@Vvaradinov Vvaradinov requested a review from a team as a code owner January 12, 2023 13:23
@github-prbot github-prbot requested review from a team, JeancarloBarrios and likhita-809 and removed request for a team January 12, 2023 13:23
baseapp/utils_test.go Outdated Show resolved Hide resolved
baseapp/baseapp_test.go Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
Vvaradinov and others added 2 commits January 13, 2023 16:08
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
@fedekunze fedekunze marked this pull request as draft January 13, 2023 14:33
baseapp/baseapp.go Fixed Show fixed Hide fixed
@Vvaradinov Vvaradinov marked this pull request as ready for review February 6, 2023 16:21
@github-prbot github-prbot requested a review from a team February 6, 2023 16:21
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Fixed Show fixed Hide fixed
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
if app.postHandler != nil {
// Run optional postHandlers with a context branched off the ante handler ctx
postCtx, postCache := app.cacheTxContext(ctx, txBytes)

Check warning

Code scanning / CodeQL

Useless assignment to local variable

This definition of postCtx is never used.
@Vvaradinov Vvaradinov requested review from alexanderbez and removed request for JeancarloBarrios and likhita-809 February 22, 2023 16:22
baseapp/baseapp.go Outdated Show resolved Hide resolved

newCtx, err := app.postHandler(postCtx, tx, mode == runTxModeSimulate, err == nil)
if err != nil {
return gInfo, nil, anteEvents, priority, err
// return result in case the pointer has been modified by the post decorators
Copy link
Contributor

Choose a reason for hiding this comment

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

what pointer? There's no pointer being passed into postHandler.

Comment on lines +773 to +784
if len(anteEvents) > 0 && (mode == runTxModeDeliver || mode == runTxModeSimulate) {
// append the events in the order of occurrence
postEvents = newCtx.EventManager().ABCIEvents()
events = make([]abci.Event, len(anteEvents)+len(postEvents))
copy(events[:len(anteEvents)], anteEvents)
copy(events[len(anteEvents):], postEvents)
result.Events = append(result.Events, events...)
} else {
events = make([]abci.Event, len(postEvents))
copy(events, postEvents)
result.Events = append(result.Events, postEvents...)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really messy IMO. runTx is arguably the most important method of BaseApp and the state machine in general and it's already not written in the most friendly and intuitive way. These changes exacerbate that IMO.

Also the change from anteEvents to events is invalid. It should remain anteEvents because that's what we're returning.

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Apr 1, 2023

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Apr 1, 2023
@tac0turtle tac0turtle removed the stale label Apr 3, 2023
@tac0turtle
Copy link
Member

what is the status here? @JeancarloBarrios @alexanderbez

@alexanderbez
Copy link
Contributor

I'm not thrilled with the changes, specifically all the event logic. So we're gonna sync tomorrow.

@Vvaradinov Vvaradinov closed this Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor runTx to include PostHandler cases
6 participants