hyperledger / iroha

Iroha - A simple, enterprise-grade decentralized ledger
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
433 stars 276 forks source link

Umbrella `iroha` CLI #4969

Open nxsaken opened 1 month ago

nxsaken commented 1 month ago

Would it be better for UX to have a single iroha binary that contains all needed functionality, each gated behind features? Right now we have iroha and irohad as the main binaries, but also iroha_swarm, kagami, kura_inspector, iroha_wasm_builder, iroha_wasm_test_runner, parity_scale_cli. As a user, this feels clunky, I'd rather have everything accessible through the iroha binary.

# spawns irohad (features = ["peer"])
iroha serve ...

# kagami (features = ["kagami"])
iroha keygen ...
iroha schema
iroha genesis generate ...
iroha genesis sign ...

# client commands (features = ["client"])
iroha register domain ...
iroha register account ...
iroha transfer domain ...

# kura inspector (features = ["inspector"])
iroha inspect ...

# wasm stuff (features = ["wasm"])
iroha wasm check ...
iroha wasm build ...
iroha wasm test ...

# swarm (features = ["swarm"])
iroha swarm ...

# parity scale codec (features = ["codec"])
iroha codec types
iroha codec json-to-scale ...
iroha codec scale-to-json ...
iroha codec scale-to-rust ...
mversic commented 1 month ago

I don't think iroha should be mixed with irohad. It's very common to keep this separate if nothing then because irohad would bloat iroha client which should be lightweight

nxsaken commented 1 month ago

We could keep them separate and spawn irohad from the CLI.

mversic commented 1 month ago

as for the others that you've listed I'm not sure. They are helper tools. Most of them are not for end users but for devs. Many of them shouldn't even be published as crates. We need to consider each separately:

  1. iroha_wasm_test_runner/iroha_swarm/kura_inspector should most certainly not be part of iroha cli or published. These are tools exclusively for internal development of iroha
  2. parity_scale_cli (if we rename it) can be considered only because it helps one to translate between scale and json encodings of iroha data model structs. Could help 3rd parties to integrate with iroha. This is for developers but not internal
  3. kagami and iroha_wasm_builder are helper tools for users of iroha and as such we can consider to integrate with iroha cli
mversic commented 1 month ago

We could keep them separate and spawn irohad from the CLI.

you mean to keep it as it is right now?

nxsaken commented 1 month ago

I think it’s simpler to treat all tools as first-class citizens rather than special-casing them. Since everything can be feature-gated anyway, why not provide this flexibility to users (who are likely to double as developers)? This approach makes it easier to use, avoids polluting the system with multiple binaries that need to be tracked, and ensures consistency across Iroha development-wise by maintaining a single CLI.

There are strong precedents for this, such as Git and Cargo, which orchestrate multiple binaries under the same umbrella CLI.

you mean to keep it as it is right now?

Right now, users have to install irohad separately and launch it directly. We can have irohad as a separate binary, while also allowing iroha to launch it if it’s installed/feature-gate-enabled. It’s worth researching how e.g. cargo subcommands handle this, but I believe this approach would provide a more streamlined user experience.

mversic commented 1 month ago

we are in a disagreement. I'm very much against unifying iroha and irohad. I'm also against integrating dev tools into iroha cli and polluting feature space. On others I'm willing to explore compromise

This approach makes it easier to use, avoids polluting the system with multiple binaries that need to be tracked, and ensures consistency across Iroha development-wise by maintaining a single CLI.

I can't say I understand this argument, but you can make all dev tools into a single binary

There are strong precedents for this, such as Git and Cargo, which orchestrate multiple binaries under the same umbrella CLI.

there are strong precedents for the other case like mysql vs mysqld or psql vs postgres

mversic commented 1 month ago

also having features is nice for libraries, but not so nice for making binaries. Laymen end users don't appreciate having to recompile code, they just want to download binaries and run with it

0x009922 commented 1 month ago

I very much like the idea of unification! Maybe just slightly differently.

My idea is to make iroha the main server, and kagami - its universal client-side tool. You know, kagami means a mirror, and it makes sense to be a tool that encompasses a wide range of interactions with Iroha from client-side, to be a single Iroha reflecting surface. So, I would like to move everything listed (+ the squash tool?) into kagami.

I believe it is going to be a better UX not only because everything is in a single place, but also because the CLI structure/inputs/outputs will be consistent among all its subcommands.

As for the CLI structure, I would like to combine schema and codec in a single subcommand. I am also not sure how to deal with that "client" subcommands needs extra configuration, maybe even via a file - unlike the other subcommands. Though structure, naming etc is for later consideration.

As for feature gates, seems simple to implement and useful in some cases. E.g. in JS SDK I need only schema/encoding/genesis, and compiling the binary in CI only with these features will work faster.

nxsaken commented 1 month ago

My vision was to have a single command users would need to keep in mind. Having iroha and kagami sounds better than having multiple commands, but I think an experience similar to Docker or Cargo would be even better. Docker allows you to launch and connect to containers, and do Compose stuff using the same command, but different subcommands. In my mind smth like this would make Iroha a more polished, less frictional experience.

I'm sure there is a way to keep binaries separate, while also providing a singular interface to them – Cargo does that already. Maybe it's not via features, but with some sort of launcher pattern (as an option, checking at runtime if the binary that the user is trying to launch is installed, warning them, and maybe installing it for them). Research would be needed here, I don't think focusing on implementation details is very useful at this ideation stage.

0x009922 commented 4 weeks ago

I think an experience similar to Docker or Cargo would be even better. Docker allows you to launch and connect to containers, and do Compose stuff using the same command, but different subcommands.

docker binary is only a client and does not control the state of the Docker daemon - it only interacts with it. Docker daemon is a separate entity, ran as a system service. Thus, I would agree with Marin that the daemon of Iroha and it's client should rather be separate binaries.

Apart from that, I share your opinion.

nxsaken commented 4 weeks ago

Yes, I agree with both of you on that. I didn't intend to argue that iroha and irohad be the same binary – I only want to let users launch irohad via iroha, which is not unheard of.

mversic commented 4 weeks ago

Yes, I agree with both of you on that. I didn't intend to argue that iroha and irohad be the same binary – I only want to let users launch irohad via iroha, which is not unheard of.

but it's unnecessary. It makes sense for docker because the user starts the deamon. With iroha only node admins will start the deamon. There is no reason to mix them into the same binary