Skip to content
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

refactor: move network command into a plugin #3306

Merged
merged 42 commits into from
Jan 4, 2023
Merged

Conversation

tbruyelle
Copy link
Contributor

@tbruyelle tbruyelle commented Dec 15, 2022

Resolve #3144

The PR removes completely the network code and thanks to a couple other removals, removes the tendermint/spn dependency from the CLI.

The network code has been moved into a plugin, see related PR ignite/cli-plugin-network#1

In order to make the change as smooth as possible for the user, unlike other plugins, the ignite network or ignite n command is still present in the available commands. I added a concept of "default plugins", which is a list of trusted plugins for which we want to have the related command available, even if the user hasn't fetched and installed the plugin yet.

So the "network" command has been added in this "default plugins" list (more can be added afterward, it should work the same), and as a result, when ignite is run without args, the network sub-command is listed.

Now the cool part of this is when the user runs ignite network (or ignite n chain or whatever sub commands), the attached command will act as a proxy that will add the plugin to the global config, fetch and compile it, and then run it immediately. The only difference for the user is these preliminary steps, which by the way happen only the first time the user runs the ignite network command. Once the plugin is installed, it's as fast as before.

From now, everything related to network commands can be tested, like the usual demo, it should be a good way to ensure nothing is broken. Just compile ignite from this branch and play with it.

@tbruyelle tbruyelle changed the title feat: network plugin feat: move network code into a plugin Dec 15, 2022
@tbruyelle tbruyelle changed the title feat: move network code into a plugin feat: move network command into a plugin Dec 15, 2022
@tbruyelle
Copy link
Contributor Author

@tbruyelle conflicts

fixed

@aljo242
Copy link
Contributor

aljo242 commented Jan 3, 2023

@tbruyelle
Copy link
Contributor Author

https://github.com/ignite/cli/actions/runs/3830513402/jobs/6518479544#step:5:1744

should be OK after my last commit I hope, this was introduced by the merge.

@lumtis
Copy link
Contributor

lumtis commented Jan 4, 2023

I'm not sure how long you are supposed to wait but it seems like I'm stuck when running the command

ignite network chain list
◤ Building plugin "github.com/ignite/cli-plugin-network@main"

EDIT: The command fails with an error after some time

Also, I have no prompt and stuck when not running a final command (example: just ignite network). Is it supposed to be the case?

ignite network


@tbruyelle
Copy link
Contributor Author

I'm not sure how long you are supposed to wait but it seems like I'm stuck when running the command

ignite network chain list
◤ Building plugin "github.com/ignite/cli-plugin-network@main"

EDIT: The command fails with an error after some time

Can you detail the error please, on my side the command works well.

Also, I have no prompt and stuck when not running a final command (example: just ignite network). Is it supposed to be the case?

ignite network

I can reproduce, that's a regression, I'm on it.

@tbruyelle
Copy link
Contributor Author

@lubtd Please recompile ignite with the latest commit and retry, you should have more meaningful output.

@lumtis
Copy link
Contributor

lumtis commented Jan 4, 2023

Can you detail the error please, on my side the command works well.

I get

	error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
	fatal: the remote end hung up unexpectedly
	fatal: early EOF
	fatal: index-pack failed

but I realize I had unstable connectivity, let me retry

How long does it take to you to get the plugin built?

Copy link
Contributor

@lumtis lumtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works now @tbruyelle 👍

Plugin build process takes several minutes though, is it normal?

@tbruyelle
Copy link
Contributor Author

tbruyelle commented Jan 4, 2023

It works now @tbruyelle +1

Plugin build process takes several minutes though, is it normal?

On my machine it only takes a few seconds, that might be related to cli-plugin-network dependency to CLI, which is not a tag for the moment, so the build has to find the version and due to the size of the CLI repo, it takes time.

If you rm ~/.ignite/plugins and try again, it's faster no ? (because the CLI dependency is now cached into $GOPATH/pkg)

@aljo242
Copy link
Contributor

aljo242 commented Jan 4, 2023

It works now @tbruyelle +1
Plugin build process takes several minutes though, is it normal?

On my machine it only takes a few seconds, that might be related to cli-plugin-network dependency to CLI, which is not a tag for the moment, so the build has to find the version and due to the size of the CLI repo, it takes time.

If you rm ~/.ignite/plugins and try again, it's faster no ?

Yes, if I remove and rebuild, its significantly faster!

@tbruyelle
Copy link
Contributor Author

Yes, if I remove and rebuild, its significantly faster!

OK, so that's the reason. I can reproduce the long build by running the following commands :

$ rm -rf ~/.ignite/plugins
$ go clean -modcache
$ ignite network

Unfortunately GOSUMDB=off has already been set when the plugin is built, so I don't know other improvement than using a tag dependency in cli-plugin-network.

@aljo242
Copy link
Contributor

aljo242 commented Jan 4, 2023

@jeronimoalbi do you think you could review/approve?

@tbruyelle tbruyelle merged commit a712f70 into main Jan 4, 2023
@tbruyelle tbruyelle deleted the feat/network-plugin branch January 4, 2023 18:02
Jchicode pushed a commit to Jchicode/cli that referenced this pull request Aug 9, 2023
* wip: remove network cmd declaration

and couple of other changes to accomodate plugin network code.

* fix: allow plugin.Use to have more than one word

* fix missing feed OSArg

* remove appd start-with-http-tunneling command

* comment

* chore: remove spn dependency from cli

* attempt to add legacy plugin command

* fix after rebase

* feat: add plugin proxy command for default plugins

Declare cli-plugin-network as a default plugin.

* test: add case for ensureDefaultPlugins

* test: add for Config.HasPlugin

* chore: add comment

* add CL

* fix linter

* fix: plugin add doesn't kill the plugin on stop

* docs: move CL entry to changes

* fix network integration tests

The network integration tests used to fetch the SPN version from CLI
go.mod, but this is no longer possible since the dependency has been
removed.

To fix that, the SPN version is now read from the cli-plugin-network's
go.mod which is cloned from the declared version in defaultPlugins.

A fix has also been added to support persistant flags.

Finally pluginsconfig.HasPlugin has been updated so it can return true
if a local plugin with a module name equals to the given path exists.
This permits to use `ignite` with a local cli-plugin-network.

* fix lint

* set networl plugin version after merge

* add network plugin command to gen-cli-docs

TODO: need to handle hidden commands

* fix linter

* fix test

* fix: pass events.Bus to plugin.Load

Co-authored-by: Alex Johnson <[email protected]>
Co-authored-by: Danilo Pantani <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move ignite network commands to a plugin
5 participants