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

feat: access to msg events result on postHandler #18377

Closed
wants to merge 2 commits into from

Conversation

emidev98
Copy link
Contributor

@emidev98 emidev98 commented Nov 6, 2023

When using PostHandler developers may expect to have access to the events from each message execution, that way developers would be able to do operations based on the results of a specific transaction e.g.: feeshare module from Juno could split the fees equally between all smart contracts involved in that tx by iterating the events, getting the type "execute" and splitting the fee between all the _contract_addresses. Pleas let me know your thoughts and if it is a good solution for a future release.

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
  • run make lint and make test
  • 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)

Summary by CodeRabbit

  • New Features
    • Enhanced transaction processing by allowing access to transaction events during post-processing.
  • Tests
    • Updated tests to accommodate the new feature of accessing transaction events in post-processing.

@emidev98 emidev98 requested a review from a team as a code owner November 6, 2023 16:22
Copy link
Contributor

coderabbitai bot commented Nov 6, 2023

Walkthrough

The changes across multiple files primarily revolve around the addition of a new parameter txEvents []abci.Event to the PostHandle function in the BaseApp, MockPostDecorator, and PostDecorator structures. This allows transaction events to be passed to the post-processing logic, enhancing the functionality and flexibility of the system.

Changes

File Path Change Summary
baseapp/baseapp.go Modified runTx function to pass result.Events to postHandler function.
testutil/mock/types_handler.go Added import statement, updated PostHandle function in MockPostDecorator and MockPostDecoratorMockRecorder to include txEvents parameter.
types/handler.go Updated PostHandler function and PostDecorator interface's PostHandle method to include txEvents parameter.
types/handler_test.go Rearranged import order, updated PostHandle and ChainPostDecorators function calls to include txEvents parameter.

Poem

🍂 As autumn leaves gently fall,
Code changes we do install.
With txEvents in our hand,
Post-processing is so grand! 🎉

On this day, a change so bright,
Enhancing our code's might.
In the spirit of Guy Fawkes Night,
Our code now sparkles in the light! 💫

So here's to the coders, working late,
Making software truly great.
With each line, and each update,
We shape a more efficient fate. 🐇


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@github-prbot github-prbot requested review from a team, facundomedica and julienrbrt and removed request for a team November 6, 2023 16:22
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between fb9dadc and b833516.
Files selected for processing (4)
  • baseapp/baseapp.go (1 hunks)
  • testutil/mock/types_handler.go (2 hunks)
  • types/handler.go (3 hunks)
  • types/handler_test.go (2 hunks)
Additional comments: 7
types/handler.go (2)
  • 1-14: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [1-21]

The changes to the PostHandler and PostDecorator function signatures look good. They now accept an additional parameter txEvents []abci.Event which allows passing transaction events to the post-processing logic. Ensure that all calls to these functions throughout the codebase have been updated to match the new signatures.

  • 69-81: The ChainPostDecorators function has been updated to accommodate the new txEvents parameter in the PostHandler function calls. This looks good.
testutil/mock/types_handler.go (3)
  • 10-16: The new import statement is correctly added to import the abci package. This is necessary for the new txEvents []abci.Event parameter in the PostHandle function.

  • 80-84: The PostHandle function in the MockPostDecorator struct now correctly takes an additional parameter txEvents []abci.Event before the simulate parameter. The function also now returns (types.Context, error) instead of just types.Context, which is a good practice for error handling.

  • 88-90: The PostHandle method in the MockPostDecoratorMockRecorder struct has been updated to include the txEvents parameter. This is necessary to match the updated function signature of PostHandle.

baseapp/baseapp.go (1)
  • 942-945: The postHandler function now takes an additional argument result.Events. Ensure that all implementations of postHandler have been updated to match this new signature. Also, verify that the error handling logic is still correct given the new argument.
types/handler_test.go (1)
  • 3-10: The import order is fine and follows the Go convention of grouping standard library imports and third-party imports separately.

types/handler_test.go Show resolved Hide resolved
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.

Hey events shouldn't be depended on like this since they are not part of consensus. If a module or contract changes their events it could cause issues for your code. At this time we may not be able to accept this pr

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b833516 and 42a6b7c.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional comments: 1
CHANGELOG.md (1)
  • 40-46: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [43-47]

The changes in the changelog are clear and concise, providing a good summary of the new features introduced in the pull request. The links to the pull requests provide a way for developers to get more detailed information about each change.

@emidev98
Copy link
Contributor Author

emidev98 commented Nov 6, 2023

Hey @tac0turtle I see your point, what if we add some warnings that this can be a double edge sword? Without allowing events to be in the PostHandler seems like its functionalities and scope is very limited. What do you think?

@emidev98
Copy link
Contributor Author

emidev98 commented Nov 7, 2023

Sleeping over it makes sense the way mention it. Thanks for the fast review and explanation! I'll proceed to close this PR

@emidev98 emidev98 closed this Nov 7, 2023
@emidev98 emidev98 deleted the feat/post/handler/events branch November 7, 2023 06:15
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.

2 participants