Nothing Special   »   [go: up one dir, main page]

Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

node: Mode system #853

Open
wants to merge 83 commits into
base: master
Choose a base branch
from
Open

node: Mode system #853

wants to merge 83 commits into from

Conversation

Jim8y
Copy link
Contributor
@Jim8y Jim8y commented Apr 3, 2022

updated to work under neo-project/neo-modules#709

This pr implements #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.

roman-khimov and others added 7 commits February 10, 2022 17:51
Allow to flush the mempool in just 10 blocks.
* typo, comment, code optimization.

* optimise code

* Update ConsoleColorSet.cs

* Update ConsoleColorSet.cs

* revert all visiblities

* revert change to visibility

* remove null check and optimise code

* remove null check

* Revert some changes

* Revert some changes

* revert recursion

* revert unnessary optimise

* revert unnecessary optimise

* revert almost all changes that has nothing to do witht typo

* revert if statement changes

* revert more unnesary optimise code

* revert change to using packages order

* revert change in wallet

* Update neo-cli/CLI/MainService.Contracts.cs

Co-authored-by: Shargon <shargon@gmail.com>

* Update neo-cli/CLI/MainService.Contracts.cs

Co-authored-by: Shargon <shargon@gmail.com>

* Update Neo.ConsoleService/ConsoleServiceBase.cs

* Update MainService.Node.cs

* Update MainService.Node.cs

* Update Logger.cs

* remove default

* remove static

* remove static

* remove token.cancel

* Update MainService.Node.cs

* Update MainService.Tools.cs

Co-authored-by: Erik Zhang <erik@neo.org>
Co-authored-by: Shargon <shargon@gmail.com>
@Jim8y Jim8y marked this pull request as draft April 3, 2022 01:49
@Jim8y Jim8y marked this pull request as ready for review April 7, 2022 14:26
neo-cli/Modes/Mode Outdated Show resolved Hide resolved
@@ -0,0 +1 @@
{"name":null,"version":"1.0","scrypt":{"n":16384,"r":8,"p":8},"accounts":[{"address":"NbNRXrkfMyrEyEv2euE63Xxxqkno7xvuk2","label":null,"isDefault":false,"lock":false,"key":"","contract":{"script":"","parameters":[{"name":"signature","type":"Signature"}],"deployed":false},"extra":null}],"extra":null}
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

anyone who want to setup a private single node network. such that they can start the private network without modifying anyting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this given account, they will need to create an account by themself, then config the config.json manually.

Copy link
Member

Choose a reason for hiding this comment

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

But there is no private key in the wallet. The user still have to create another wallet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgot that, will update right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can not, they are of the same name~~~all of them are config.json

Copy link
Member

Choose a reason for hiding this comment

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

config.xxx.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

emmmmmmmmm, good idea, will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

config.json config.fs.json DBFTPlugin.json ApplicationLog.json under same folder now

Copy link
Member

Choose a reason for hiding this comment

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

They are still in different folders.

@nicolegys
Copy link
Contributor

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
Copy link
Contributor

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:

@Jim8y
Copy link
Contributor Author
Jim8y commented Apr 8, 2022

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.

@nicolegys
Copy link
Contributor

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

@Jim8y
Copy link
Contributor Author
Jim8y commented Oct 27, 2022

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.

@nicolegys
Copy link
Contributor

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
Copy link
Contributor

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.

@Jim8y
Copy link
Contributor Author
Jim8y commented Oct 31, 2022

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 and others added 2 commits October 31, 2022 09:19
Co-authored-by: Nicole <43694095+nicolegys@users.noreply.github.com>
Co-authored-by: Nicole <43694095+nicolegys@users.noreply.github.com>
@nicolegys
Copy link
Contributor

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.

@superboyiii
Copy link
Member

@shargon Could you review again?

@@ -14,6 +14,10 @@ expect {
timeout { exit 1 }
}

sleep 5
Copy link
Member

Choose a reason for hiding this comment

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

5 seconds is required?

Copy link
Contributor Author
@Jim8y Jim8y Dec 14, 2022

Choose a reason for hiding this comment

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

Yes, has to wait for 5 seconds, at least

@superboyiii
Copy link
Member

@Liaojinghui Please solve conflicts

@Jim8y
Copy link
Contributor Author
Jim8y commented Feb 2, 2023

@Liaojinghui Please solve conflicts

Resolved

@shargon shargon changed the title Mode system node: Mode system Dec 5, 2023
@shargon shargon added the node label Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants