Closed ValarDragon closed 2 years ago
Hi @ValarDragon is this being worked on right now? Can i give it a shot, it seems interesting?
I don't think its being worked on (cc @xBalbinus to double check)
Would be really cool to get this in! Check out this blog post for some more details on extension interfaces: https://medium.com/swlh/what-is-the-extension-interface-pattern-in-golang-ce852dcecaec
Heyo @stackman27 !! Thanks for the help / offer! I was wrapping up some last things with some doc edits and was going to get to this real soon but if you have more availability, definitely feel free! Don't want to block you.
btw made a related PR in osmosis that shows how to do the typecast if it helps: https://github.com/osmosis-labs/osmosis/pull/2081
@ValarDragon Gotchu i will look into it & try it out
@xBalbinus for sure! i can give it a shot, i'm fairly free rn. Will reach out to you if i get stuck
@ValarDragon
type BeginEndBlockAppModule interface {
AppModule
BeginBlock(sdk.Context, abci.RequestBeginBlock)
EndBlock(sdk.Context, abci.RequestEndBlock) []abci.ValidatorUpdate
}
Is the idea to created a shared extension interfaces across all the modules or every module is going to have their own extension interface? Should i be creating a manger.go file?
There will only be a single interface, it's defined the same place where AppModule
is defined. There is no need to create any new files -- just add the interface to where AppModule
is defined (I believe that's module.go
).
Also since most modules right now have a no-op for AppModule.BeginBlock and AppModule.EndBlock why can't we define our extension interface like this;
Not sure I follow? You want two interfaces -- BeginBlockAppModule
and EndBlockAppModule
.
That should be it :)
Aah i see, this makes sense i was checking the individual module.go files for each modules and got confused. Thank you very much!
Summary
Most modules right now have a no-op for AppModule.BeginBlock and AppModule.EndBlock. We should move these methods off the AppModule interface so we have less deadcode, and instead move them to extension interfaces. This should not be a noticeable client breaking change, as users of the SDK don't really consume the AppModule interface, and thats moreso something for the ModuleManager.
This would mean removing:
from the AppModule interface, and making two new extension interfaces:
Then we retain having ModuleManager take in
AppModule
s, so there is no client breaking changes. The module manager should type cast internally to get the BeginBlock and EndBlock app module lists. (We may waste some memory in the struct, but this is negligible)As a secondary feature, (likely for a second PR), its total ordering constraint, can be relaxed to only requiring a specified order for modules that have the relevant method.
Problem Definition
Delete more methods from every module.go, improving the signal to noise ratio of cosmos code, and the accuracy of interfaces we work with.
(From discussion with @aaronc @kocubinski @alexanderbez )
For Admin Use