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

Adding updates to composite router and scaffolding for LegacyIBCModule #7010

Merged
merged 14 commits into from
Aug 5, 2024

Conversation

chatton
Copy link
Contributor

@chatton chatton commented Aug 1, 2024

Description

This PR applies some PoC router changes to the feature branch.

The main idea being introduced is the concept of a ClassicIBCModule which will be the same as the IBCModule we have now, and then in a future PR we will strip down the IBCModule to no longer include the handshake fns.

In the channel handshake fns, we will route to the Classic modules, and in Send / Recv etc will will route to the slimmer IBCModule modules.

There is a bit of a hack introduced in the AddRoute function which gradually builds up the LegacyIBCModule based on consecutive calls to AddRoute. I think we should be able to remove this entirely with a single call to AddClassicRoute.

closes: #XXXX


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

@chatton chatton marked this pull request as ready for review August 1, 2024 12:59
Comment on lines 18 to 21
legacyRoutes map[string]ClassicIBCModule

// classicRoutes facilitates the consecutive calls to AddRoute for existing modules.
classicRoutes map[string][]ClassicIBCModule
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also aware having 2 things called legacy and classic of almost the same type is terrible naming, so we can change that :D

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can add a todo that one will be removed?

@chatton
Copy link
Contributor Author

chatton commented Aug 1, 2024

E2E tests failing due to issue that's being fixed in #7009

@chatton chatton added the priority PRs that need prompt reviews label Aug 1, 2024
modules/core/05-port/types/router_v2.go Show resolved Hide resolved
modules/core/05-port/types/ibc_legacy_module.go Outdated Show resolved Hide resolved
modules/core/05-port/types/router_v2.go Outdated Show resolved Hide resolved
Comment on lines +59 to +68
if _, ok := cbs.(ClassicIBCModule); ok {
rtr.classicRoutes[module] = append(rtr.classicRoutes[module], cbs)

// in order to facilitate having a single LegacyIBCModule, but also allowing for
// consecutive calls to AddRoute to support existing functionality, we can re-create
// the legacy module with the routes as they get added.
if classicRoutes, ok := rtr.classicRoutes[module]; ok && len(classicRoutes) > 1 {
rtr.legacyRoutes[module] = NewLegacyIBCModule(classicRoutes...)
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

this part I don't understand. Is it to avoid changing the current wiring in app.go?

Copy link
Contributor Author

@chatton chatton Aug 1, 2024

Choose a reason for hiding this comment

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

essentially yes. In the app.go we do things like

appStack := ...
ibcAppRouter.AddRoute(name, appStack)
appStack = wrap(appStack)
ibcAppRouter.AddRoute(name, appStack)

etc.

Previously, we just built up a slice of callbacks and appended, but the idea now is that we have one type (LegacyIBCModule) that contains this list.

So we can either

A: construct the full list of callbacks and pass to router.AddClassicRoute ( from app.go )
B: internally maintain this list and build up the LegacyIBCModule ( in router_v2.go )

This is solution B. We should be able to remove this when our app.gos use version A

Copy link
Contributor

@colin-axner colin-axner Aug 1, 2024

Choose a reason for hiding this comment

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

I think the app.go wiring on the router v2 added in the feature branch is actually incorrect. Apps shouldn't be doing the wrap() step anymore

I prefer option A

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I understand the issue now. If we want to test ics29 for example, currently it wraps other apps and doesn't have an api to return as a standalone app, so to use it for certain handshake functions, we still call the wrapping. I guess once everything is done, we can remove the additional add route calls

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can open an issue to track removal of this logic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we cannot do option A until we remove the middleware altogether, looking at some code on the feature branch now

	var transferStack porttypes.IBCModule
	transferStack = transfer.NewIBCModule(app.TransferKeeper)
	ibcAppRouter.AddRoute(ibctransfertypes.ModuleName, transferStack)
	transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)
	ibcAppRouter.AddRoute(ibctransfertypes.ModuleName, transferStack)

This does not seem correct, we are currently iterating over {transfer, feeWrappedTransfer } which will almost certainly not behave the same as a single fee Wrapped transfer with router v1

Copy link
Contributor

Choose a reason for hiding this comment

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

We discussed offline ^ . We will stick with current wiring and I'll open an issue to change to the final form

Comment on lines 18 to 21
legacyRoutes map[string]ClassicIBCModule

// classicRoutes facilitates the consecutive calls to AddRoute for existing modules.
classicRoutes map[string][]ClassicIBCModule
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can add a todo that one will be removed?

@chatton chatton mentioned this pull request Aug 1, 2024
10 tasks
Copy link

sonarcloud bot commented Aug 1, 2024

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Thanks @chatton! I re-reviewed the code and added some issue links so as not to lead to any confusion. I am going to merge and we can continue work in fresh prs

@colin-axner colin-axner merged commit 832a0fc into feat/port-router Aug 5, 2024
48 of 63 checks passed
@colin-axner colin-axner deleted the cian/add-composite-router branch August 5, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: port-router priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants