Allow modules to define module-specific antehandling functions (for now call these ModuleAnteHandler). Any module that has ModuleAnteHandler defined can get registered with ModuleManager. These ModuleAnteHandlers can then get run in runTx. If any ModuleAnteHandler fails, then runTx will return the result.
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.
Add AnteHandler function to AppModule interface. Add OrderAnteHandler functions to Manager interface.
Remove notion of single overseeing AnteHandler function. Instead just run all AnteHandler functions defined by ModuleManager in runTx in baseapp.go
RFC @joon, @alexanderbez
Looks great @AdityaSripal, thanks! I like the idea of adding an AnteHandler method to the AppModule interface. However, I don't see a reason to modify BaseApp at all. Instead, one option we can do is have SetOrderAnteHandler set the order. Then, implement AnteHandler on the Module type. This will return an AnteHandler closure by looping over all the registered module ante-handler and calling them. What are your thoughts?
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
Most helpful comment
Decided to go with SimpleDecorators approach in #4942
Will start implementing