-
Notifications
You must be signed in to change notification settings - Fork 210
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
chore: pass ClientHandleArc to handle_cli_command #5108
Conversation
The problem is not passing the client as much as just making modules depend on each other, especialy the compile side aspect of it. If we start doing things this way then we will quickly find ourselves hitting circular dependencies between modules. Modules already get access to the client via https://docs.fedimint.org/fedimint_client/module/struct.ClientContext.html passed to the during construction https://docs.fedimint.org/fedimint_client/module/init/trait.ClientModuleInit.html#tymethod.init . On the
The Bitcoin network should probably be a global property of the Federation. I don't think we are ever going to support Federation where each module is on a different network, so we can reasonably say that the network comes with the Federation. So in that case the roast server side module maybe should get passed the network, just like the wallet server module, possibly via https://docs.fedimint.org/fedimint_core/module/struct.ServerModuleInitArgs.html or from the server side config. |
Perhaps the CLI should always be in a separate crate outside of the module's client crate? The CLI is essentially an integrated wallet/app, it seems natural to me that it should have access to multiple modules. Agreed the bitcoin network should be a global property. I just made this PR since this was the solution that unblocked me, but if we want to go with the cleaner route of adding it to |
That might be a good idea, and it would solve the cyclic deps at compilation time at least. But how are we going to impl But despite all of that, I still think that in principle if a module needs other modules, than it's not really its own command. IMO we should define interoperability points like this at So e.g.:
would allow any module get ahold of a primary module and mine itself some change etc.
would allow modules get "wallet modules Bitcoin network", if it wasn't that it probably should just be global property. Generally any interaction that we deemed worthwile and general enough can be done this way, and avoids modules hardwiring dependencies between each other.
Let's see what @elsirion thinks. |
tl;dr: let's make the network global and I don't see a use case for cross-module dependencies then.
Originally I wanted to avoid this since it would be awkward in use cases where BTC isn't needed, e.g. issuing toilet access tokens (the raison d'être for SCRIT, a real shitcoin and hugely influential on early Fedimint development). But realistically we will always have Bitcoin as an asset and might just add additional asset support eventually, so this makes sense.
I disagree with that. In general modules are self-contained. They may need money or want to store it, and use the (opaque to them) primary module abstraction for that, but assuming any module is available and thus coupling them is very bad long-term since it makes replacing old versions with new ones much harder and also requires way more context to maintain a module. I recently chatted with @joschisan about the importance of keeping modules strictly separated to make reasoning about them independently possible and keeping complexity manageable. |
Made an issue: #5121 |
In defense of it ... . The CLI interactions that do use multiple modules are not entangling the logic of modules themselves with each other. We do that a lot if Anyway I think the way to go, at least for now is in preference order:
|
When developing ROASTR I found myself needing to execute commands against other modules (for example: to get the Bitcoin network of the wallet module). There might be a more elegant way to do this, but one easy way to accomplish this is to pass
ClientHandlArc
intohandle_cli_command
so that the cli inside other modules can execute functions from other modules.