Skip to content

sdk.Router should be stateful #5455

Closed

Description

Summary

The sdk.Router interface should be generalized to allow for more stateful router implementations.

Problem Definition

The basic default router included in baseapp is a stateless router i.e. the mapping from path strings to handlers is static and defined in the application codebase (in the app.go). However, the requirement to remain stateless is limiting in that it restricts the ability to do more complex modifications of routes.

Some examples of advanced router functionality that need statefulness:

  • Allowing governance or permissioned entities to enable or disable msg routes (requires to be able to read current state of param store)
  • Allowing governance to switch the handler that a specific route points to for upgrade purposes

Proposal

  • Update the sdk.Router interface's .Route() function to take in an sdk.Context as an argument
  • Keep the baseapp.Router implementation as the stateless design it is right now
  • Baseapp uses baseapp.Router by default unless intentionally passed a new router by an application's app.go
  • Add baseapp.WithRouter() function to allow an app.go to pass in its own router implementation.

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C:baseappS:proposedT: API BreakingBreaking changes that impact APIs and the SDK only (not state machine).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions