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

[RPC] Cleanup startmasternode command #2833

Merged

Conversation

Fuzzbawls
Copy link
Collaborator

General cleanup of the startmasternode RPC command. This has been a long time coming, and rectifies some long-standing issues with the design and operability of the command.

  • Remove 'local' set support. Long-time NonOp.
  • Remove 'many' set support. Always NonOp.
  • General cleanup of the command's logic.

Adds code coverage for new failure cases as well as code coverage for multi-MN start (ie, not "alias"-only) start commands.

- Remove 'local' set support. Long-time NonOp.
- Remove 'many' set support. Always NonOp.
- General cleanup of the command's logic.
Adds a method to start multiple MNs with a single command, adding code
coverage to the more 'heavy-lifter' portion of the startmasternode
command.
@Fuzzbawls Fuzzbawls added RPC Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes Cleanup labels Apr 1, 2023
@Fuzzbawls Fuzzbawls added this to the 6.0.0 milestone Apr 1, 2023
@Fuzzbawls Fuzzbawls self-assigned this Apr 1, 2023
Copy link
Member

@Liquid369 Liquid369 left a comment

Choose a reason for hiding this comment

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

tACK 815bbc2
Working as intended, no more confusion in starting master nodes with these commands.

Copy link

@panleone panleone left a comment

Choose a reason for hiding this comment

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

Good apart one small change request

if (request.fHelp || request.params.size() < 2 || request.params.size() > 4 ||
(request.params.size() == 2 && (strCommand != "local" && strCommand != "all" && strCommand != "many" && strCommand != "missing" && strCommand != "disabled")) ||
( (request.params.size() == 3 || request.params.size() == 4) && strCommand != "alias"))
(strCommand == "alias" && request.params.size() < 3))

Choose a reason for hiding this comment

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

Improve this if:
if the strCommand is "alias" you must use either 3 or 4 params
if the strCommand is valid but not "alias" you must use 2 params
if the strCommand is not valid you should throw error anyways

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if the strCommand is "alias" you must use either 3 or 4 params

"alias" requires at least 3 arguments, this is specifically covered in this conditional check.

if the strCommand is valid but not "alias" you must use 2 params

This is no longer the case, as shown in the changes to the functional tests that use named arguments with the "all" command whilst reloading the masternode.conf file (here and here).

if the strCommand is not valid you should throw error anyways

This does that, and is tested in the functional tests (here) by returning a RPC_INVALID_PARAMETER error code. This is done towards the end of the RPC function call and not at the beginning intentionally (here).

Choose a reason for hiding this comment

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

if the strCommand is not valid you should throw error anyways

This does that, and is tested in the functional tests (here) by returning a RPC_INVALID_PARAMETER error code. This is done towards the end of the RPC function call and not at the beginning intentionally (here).

Yep I saw that my main point was that (as a user) I would prefer that if I inserted an invalid strCommand the output would be error + how to use that rpc command (as it was done before) instead of a simple "Invalid strCommand" and same for the number of parameters

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved to this approach for a few reasons:

  1. It allows greater code coverage and testability.
  2. A user's natural instinct upon getting an RPC_INVALID_PARAMETER error (SHOULD) be to then check the help output.
  3. This new behavior is much much more inline with the rest of our RPC commands, and greatly simplifies the logic checks being done for when to show the actual help output.

Choose a reason for hiding this comment

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

ok still don't totally agree but I'm not blocking the PR for this small thing

Copy link

@panleone panleone left a comment

Choose a reason for hiding this comment

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

tACK 815bbc2

@Fuzzbawls Fuzzbawls merged commit 25bcf86 into PIVX-Project:master Apr 19, 2023
@Fuzzbawls Fuzzbawls modified the milestones: 6.0.0, 5.6.0 Feb 6, 2024
@Fuzzbawls Fuzzbawls removed the Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes label Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants