-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Module-Specific AnteHandlers #4572
Comments
RFC @Joon, @alexanderbez |
Looks great @AdityaSripal, thanks! I like the idea of adding an e.g. func (m *Manager) AnteHandler(ctx sdk.Context) sdk.AnteHandler {
return func(
ctx sdk.Context, tx sdk.Tx, simulate bool,
) (newCtx sdk.Context, res sdk.Result, abort bool) {
for _, moduleName := range m.OrderAnteHandler {
newCtx, res, err := m.Modules[moduleName].AnteHalder(ctx)
if err != nil {
return newCtx, res, true
}
ctx = newCtx
}
return ctx, res, false
}
} |
yup once i started implementing i realized its not necessary. the above is exactly how i have it |
Decided to go with SimpleDecorators approach in #4942 Will start implementing |
Summary
Allow modules to define module-specific antehandling functions (for now call these
ModuleAnteHandler
). Any module that hasModuleAnteHandler
defined can get registered with ModuleManager. These ModuleAnteHandlers can then get run inrunTx
. If any ModuleAnteHandler fails, thenrunTx
will return the result.Problem Definition
It would allow users to create modules that specify their own antehandler logic and register these functions with the module manager rather than having to recreate all ante-handler logic.
If Antehandler gets refactored to seperate fee and signature logic into separate functions, then this would allow other modules to get their own ante-logic executed in the same way.
Makes it more convenient for users to define custom ante-handling logic on a per-module basis. Rather than creating a new single AnteHandler for every application that may use modules that require custom ante-handling.
Disadvantages: It is possible that this can be abused by modules who will do all message-logic checking in the antehandler. However if developers explicitly want that functionality, it is now available.
Proposal
Add
AnteHandler
function toAppModule
interface. AddOrderAnteHandler
functions toManager
interface.Remove notion of single overseeing
AnteHandler
function. Instead just run allAnteHandler
functions defined byModuleManager
inrunTx
inbaseapp.go
For Admin Use
The text was updated successfully, but these errors were encountered: