neo-node icon indicating copy to clipboard operation
neo-node copied to clipboard

node: Mode system

Open Jim8y opened this issue 4 years ago • 30 comments

updated to work under https://github.com/neo-project/neo-modules/pull/709

This pr implements neo-project/neo-node#863 Mode system is intended to help developers to save and load neo node configurations.

  1. cli provides some default settings, such as mainnet, testnet, private net. Maybe Oracle net and FS net in the future.
  2. user can load from these default settings.
  3. user can have their own node setttings and save them as a mode
  4. user can delete existing modes
  5. if no mode is assigned from the console, load mainnet
  6. Does not support runtime mode switch.
image image

mainnet mode:

dotnet neo-cli.dll /mode mainnet

testnet mode:

dotnet neo-cli.dll /mode testnet

privatenet mode:

dotnet neo-cli.dll /mode privatenet

when user load into the privatenet mode, a single node blockchain network will be setup with the default primary account NbVj8GhwToNv4WF2gVaoco6hbkMQ8hrHWP. Please note that the secret key of this account is publicly available to everyone,

do not send any asset to this account in main net

you will lose your token and we will not be responsible for that.

Create your own mode You can config your own network by modifying the config.json and config.fs.json in the root directory, as well as the config.json of Plugins. Then run mode save [mode name] to save your configuration as a mode. If the name you assigned is an existing mode, existing mode will be updated.

Your configurations will not be updated into mode automatically, you must manually run mode save [mode name] to save them.

Jim8y avatar Apr 03 '22 01:04 Jim8y

mode delete Cannot delete a directory which is not empty. Image

save as an existing mode name There is no warning and the original mode configs will be overwritten. Image

nicolegys avatar Apr 08 '22 10:04 nicolegys

The logic of mode save is a little strange for me. If I want to save a mode, firstly I need to start neo-cli with some specified mode in ./Mode/ folder or with default mode mainnet, and corresponding config files will be generated in ./ folder. Then I modify or replace the config files in ./ folder , use mode save <modeName> cmd to copy the config files to ./Mode/ folder. Why don't I directly create a new mode in ./Mode/ folder?:joy:

nicolegys avatar Apr 08 '22 11:04 nicolegys

The logic of mode save is a little strange for me. If I want to save a mode, firstly I need to start neo-cli with some specified mode in ./Mode/ folder or with default mode mainnet, and corresponding config files will be generated in ./ folder. Then I modify or replace the config files in ./ folder , use mode save <modeName> cmd to copy the config files to ./Mode/ folder. Why don't I directly create a new mode in ./Mode/ folder?😂

Cause config.json are spread everywhere, with save mode we can collect config file from the node and Plugins. If user directly creates mode under Modes folder, how could they deal with Plugins.

Jim8y avatar Apr 08 '22 11:04 Jim8y

@nicolegys May you please test this?

Jim8y avatar Jul 03 '22 03:07 Jim8y

After I install a new plugin, neo-cli will remind me to restart it. But if I restart it immediately without saving this mode, in this pr, the new installed plugin will be removed. Need to add some words in this warning to remind users saving mode before restarting neo-cli.

https://github.com/neo-project/neo-node/blob/fd9203f1ce75f163b8c6a8d9870cd20c6abbc4c3/neo-cli/CLI/MainService.Plugins.cs#L43

nicolegys avatar Jul 19 '22 10:07 nicolegys

After I install a new plugin, neo-cli will remind me to restart it. But if I restart it immediately without saving this mode, in this pr, the new installed plugin will be removed. Need to add some words in this warning to remind users saving mode before restarting neo-cli.

https://github.com/neo-project/neo-node/blob/fd9203f1ce75f163b8c6a8d9870cd20c6abbc4c3/neo-cli/CLI/MainService.Plugins.cs#L43

This issue should have been solved in my last commit. The reason of that issue is the plugin folder name is kinda different from the plugin name.

Jim8y avatar Jul 19 '22 12:07 Jim8y

1658829598028

Need to remind users to restart/resync neo-cli if new plugins are auto-installed.

nicolegys avatar Jul 26 '22 10:07 nicolegys

1658831583979 exception.

nicolegys avatar Jul 26 '22 10:07 nicolegys

Need to remind users to restart/resync neo-cli if new plugins are auto-installed.

Well, actually, it is supposed to be loaded automatically....will check this logic.

Jim8y avatar Jul 26 '22 12:07 Jim8y

async issue still exists.

nicolegys avatar Aug 04 '22 07:08 nicolegys

@Liaojinghui Can we move on? I think it's useful.

superboyiii avatar Sep 05 '22 03:09 superboyiii

  1. If plugins are auto-installed/auto-uninstalled when starting neo-cli, type exit and neo-cli will throw an exception. 1662634153298

  2. reinstall plugin will replace this plugin's config file in mode\xxx by the default config file.

  3. e.g. Both ApplicationLogs and RpcServer are not installed but in \mode\testnet, now I start neo-cli with testnet mode, I could find that RpcServer's config file in \mode\testnet be replaced by the default one. Because RpcServer is installed as a dependency of ApplicationLogs.

nicolegys avatar Sep 08 '22 10:09 nicolegys

  1. If plugins are auto-installed/auto-uninstalled when starting neo-cli, type exit and neo-cli will throw an exception. 1662634153298
  2. reinstall plugin will replace this plugin's config file in mode\xxx by the default config file.
  3. e.g. Both ApplicationLogs and RpcServer are not installed but in \mode\testnet, now I start neo-cli with testnet mode, I could find that RpcServer's config file in \mode\testnet be replaced by the default one. Because RpcServer is installed as a dependency of ApplicationLogs.

2. ... hasn't been fixed.

nicolegys avatar Sep 13 '22 10:09 nicolegys

If use lower case to install plugins, it can't find folders like Plugins/applicationlogs.

1663226371028

1663227689871

nicolegys avatar Sep 15 '22 07:09 nicolegys

Doesn' the GetActualPath work?

Jim8y avatar Sep 15 '22 12:09 Jim8y

This issue still exists. neo-project/neo#3000

nicolegys avatar Sep 21 '22 07:09 nicolegys

Threw an exception when reinstalling StateService, but not always. Image

nicolegys avatar Sep 22 '22 07:09 nicolegys

  1. If plugins are auto-installed/auto-uninstalled when starting neo-cli, type exit and neo-cli will throw an exception. 1662634153298
  2. reinstall plugin will replace this plugin's config file in mode\xxx by the default config file.
  3. e.g. Both ApplicationLogs and RpcServer are not installed but in \mode\testnet, now I start neo-cli with testnet mode, I could find that RpcServer's config file in \mode\testnet be replaced by the default one. Because RpcServer is installed as a dependency of ApplicationLogs.
  1. ... hasn't been fixed. To Reproduce 1.Make sure that ApplicationLogs is before RpcServer in .PLUGINS file, and both of them are not installed. 1663833620087 2.Start neo-cli.

nicolegys avatar Sep 22 '22 08:09 nicolegys

Threw an exception when reinstalling StateService, but not always. Image

This is an issue in neo core, and has being addressed in https://github.com/neo-project/neo/pull/2569 . This pr can not and should not handle that.

Jim8y avatar Sep 24 '22 16:09 Jim8y

No more issues,need review.

nicolegys avatar Sep 27 '22 09:09 nicolegys

@Liaojinghui Please fix format.

superboyiii avatar Oct 09 '22 06:10 superboyiii

1666863841910 It uses an error plugin path when starting neo-cli in the different directory with neo-cli.dll.

nicolegys avatar Oct 27 '22 09:10 nicolegys

1666863841910 It uses an error plugin path when starting neo-cli in the different directory with neo-cli.dll.

The path issue is not a problem should be addressed in this pr. it is a nature feature of C# on windows platform.

Relative path will always be relative to the executing folder, unless you publish it in a self-contain mode.

Jim8y avatar Oct 27 '22 14:10 Jim8y

1666863841910 It uses an error plugin path when starting neo-cli in the different directory with neo-cli.dll.

The path issue is not a problem should be addressed in this pr. it is a nature feature of C# on windows platform.

Relative path will always be relative to the executing folder, unless you publish it in a self-contain mode.

It was published in the self-contain mode. Actually, this issue is because method PluginExists uses the wrong path to find the specified plugin. 1667211617870

nicolegys avatar Oct 31 '22 10:10 nicolegys

In addtion, as you said, relative path is an old issue that also exists in master branch, and it happens not only in the places I mentioned in this pr. I'll create annother issue if needed.

nicolegys avatar Oct 31 '22 10:10 nicolegys

In addtion, as you said, relative path is an old issue that also exists in master branch, and it happens not only in the places I mentioned in this pr. I'll create annother issue if needed.

You dont have to, cause this issue does not exist in the official publish package as it is published in the self-contain mode.

Jim8y avatar Oct 31 '22 13:10 Jim8y

In addtion, as you said, relative path is an old issue that also exists in master branch, and it happens not only in the places I mentioned in this pr. I'll create annother issue if needed.

You dont have to, cause this issue does not exist in the official publish package as it is published in the self-contain mode.

I have said that this issue also exists when it is published in the self-contain mode. I've tested it both on v3.4.0 and master branch, both on windows and linux. The cause of this issue is, in our code, files are read or generated based on the current execution directory, not the relative directory. And this issue was not raised before because of few usage scenarios, so it's not a high priority. Please be more careful.

nicolegys avatar Nov 01 '22 06:11 nicolegys

@shargon Could you review again?

superboyiii avatar Nov 18 '22 08:11 superboyiii

@Liaojinghui Please solve conflicts

superboyiii avatar Feb 02 '23 06:02 superboyiii

@Liaojinghui Please solve conflicts

Resolved

Jim8y avatar Feb 02 '23 11:02 Jim8y