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: Add msg service router interface #2

Merged
merged 14 commits into from
Dec 23, 2021

Conversation

channa-figure
Copy link

@channa-figure channa-figure commented Nov 5, 2021

Add an interface to the msg router service for customization of msg handling. The current format for the msg_router_service is a struct. This design does not allow for adding custom behavior to the MsgServiceRouter. Therefore, we added an interface to the MsgServiceRouter called IMsgServiceRouter this allows for applications to add a custom router in the app.go file of their application. The default can also still be used that is defined in the baseapp.

Provenance needed to modify the behavior of the router to add additional fees to specific msg types. i.e.) The MsgSend can have an additional 500nhash charge when executed. Therefore, fees would be addition charges + gas fees = total fees.

Description

Closes: #XXXX


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)

@arnabmitra arnabmitra marked this pull request as ready for review November 19, 2021 16:40
@arnabmitra arnabmitra changed the title Add msg service router interface feat: Add msg service router interface Dec 8, 2021
@arnabmitra arnabmitra changed the base branch from v0.44.3-pio to release-pio/v0.44.3.x December 15, 2021 22:23
Copy link
Member

@iramiller iramiller left a comment

Choose a reason for hiding this comment

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

See comment about the feemsghandler in here ... it also seems weird that we have to add a context into these methods ... I haven't compared to how the middleware refector does it yet–maybe they added a similar hoook?

@@ -133,6 +133,9 @@ type BaseApp struct { // nolint: maligned
// indexEvents defines the set of events in the form {eventType}.{attributeKey},
// which informs Tendermint what to index. If empty, all events will be indexed.
indexEvents map[string]struct{}

// msg fee handler
additionalMsgFeeHandler sdk.AdditionalMsgFeeHandler // ante handler for fee and auth
Copy link
Member

Choose a reason for hiding this comment

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

Since this is the core SDK and the msg fee module isn't part of the core cosmos sdk ... it feels like there shouldn't be anything named "msg fee handler" here...

@iramiller
Copy link
Member

iramiller commented Dec 17, 2021

I haven't compared to how the middleware refector does it yet–maybe they added a similar hoook?

They do in fact have context available in DeliverTx for middleware ... looks like that won't be an issue.

Copy link
Member

@iramiller iramiller left a comment

Choose a reason for hiding this comment

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

LGTM.

@channa-figure channa-figure merged commit eff7dd7 into release-pio/v0.44.3.x Dec 23, 2021
arnabmitra added a commit that referenced this pull request Feb 1, 2022
* Updated and fixed Rosetta

* add changelog

* added prs to changelog

* update release notes

* feat: Add msg service router interface (#2)

* convert message router to interface

* Add setter for msg service interface

* Adding a custom fee charging handler, so that if provenance want's they can charge fees for certain msg types.

* refactored variable name.

* Fixing comments on changed files.

* Return transaction context from runTx

* emitting events from AdditionalMsgFeeHandler, since authz and wasm calls need the event too.

* test: Fix comppile issues on existing tests

* handling error on failure to charge additional fee.

* fixing err while deliverTx.

* Update return values to have err at end

* Fix tests

* Refactor to remove pio specific stuff

Co-authored-by: arnabmitra <[email protected]>

* fixed @arnabmitra cr request

* go mod vendor

* cleanup

* fmt

* adding msg fee work to the changelog under unreleased section.

* fixed tests

* updated changelog to reflect provenance releases

* remove unused db copy cmd

* updated release notes

* updating comment.

* updating comment based on code review.

* adding anteevents which were missed in the merge.

* update release notes wording

* baseapp changes the way they propagate antehandler events, this commit takes care of the order of ante and base events, since ante events are charged before all events and fee events are charged at the end.

* Error from fee invoker is not getting propagated properly.

* merging.

* updating release notes.

* Add missing iavl config size value to config parser

Co-authored-by: fkneeland <[email protected]>
Co-authored-by: fkneeland-figure <[email protected]>
Co-authored-by: Carlton Hanna <[email protected]>
Co-authored-by: Carlton Hanna <[email protected]>
@SpicyLemon SpicyLemon deleted the add-msg-service-router-interface branch December 17, 2024 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants