dymensionxyz / ibc-go

Interblockchain Communication Protocol (IBC) implementation in Golang.
https://ibc.cosmos.network/
MIT License
5 stars 3 forks source link

Message interceptor #28

Closed liorzilp closed 1 year ago

liorzilp commented 1 year ago

Overview

Following https://github.com/dymensionxyz/ibc-go/issues/14 we could also add hooks for more IBC messages. Instead of hooks, we can export the message server that is registered for the IBC messages. Say am.msgSrvInterceptor is implementing the required interface, we can just change the registry:

// RegisterServices registers module services.
func (am AppModule) RegisterServices(cfg module.Configurator) {
    clienttypes.RegisterMsgServer(cfg.MsgServer(), am.msgSrvInterceptor)
    connectiontypes.RegisterMsgServer(cfg.MsgServer(), am.msgSrvInterceptor)
    channeltypes.RegisterMsgServer(cfg.MsgServer(), am.msgSrvInterceptor)

    ...
}

That way, we can define one interface that is implementing the required message handling and initialize the IBC module with it. The default would be to initialize with the IBC keeper, but other application logic could be applied as well. The common use should be wrapping the IBC keeper handling with the required logic.

The interception is needed for creating a framework to support more features of the IRC that middleware can't achieve.

Remove client hooks

The use of client hooks should be replaced with this interceptor.