8000 [RPC][Mining] Add ability to switch between mining algorithms without restarting wallet by CaveSpectre11 · Pull Request #878 · Veil-Project/veil · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[RPC][Mining] Add ability to switch between mining algorithms without restarting wallet #878

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

Merged
merged 3 commits into from
Dec 10, 2020

Conversation

CaveSpectre11
Copy link
Collaborator

Note

This is built on top of #876 and also contains a couple corrections to get the getnetworkhashps help.

Problem

In order to switch mining algorithms, you must shut down the wallet and restart with a new -mine= flag.

Root Cause

Never implemented

Solution

Add setminingalgo cli command to allow you to switch between different algorithms. This RPC command requires you to turn off mining before issuing the command and will error if it does not work.

Testing

$ veil-cli help setminingalgo
setminingalgo algorithm

Changes your mining algorithm to [algorithm].  Note that mining must be turned off when command is used.

Arguments:
1. algorithm   (string, required) Algorithm to mine [progpow, randomx, sha256d].

Result:
{
  "success": true|false, (boolean) Status of the switch
  "message": "text",     (text) Informational message about the switch
}

Examples:
> veil-cli setminingalgo sha256d
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "setminingalgo", "params": [sha256d] }' -H 'content-type: text/plain;' http://127.0.0.1:58812/
$ veil-cli setminingalgo randomx
{
  "success": true,
  "message": "Mining algorithm changed from sha256d to randomx"
}
 veil-cli getmininginfo
{
[...]
  "algorithm": "randomx",
  "difficulty": 0.003707938785486674,
  "networkhashps": 22.73835278085342,
[...]
}
$ veil-cli setminingalgo sha257d
error code: -8
error message:
sha257d is not a supported mining type
$ veil-cli setminingalgo sha256d
{
  "success": true,
  "message": "Mining algorithm changed from randomx to sha256d"
}
$ veil-cli getmininginfo
{
[...]
  "algorithm": "sha256d",
  "difficulty": 18.1774015474177,
  "networkhashps": 23.05669884097939,
[...]
}
$ veil-cli generatecontinuous true 1
$ veil-cli setminingalgo progpow
error code: -8
error message:
mining must be stopped to change algorithm
$ veil-cli generatecontinuous false
$ veil-cli setminingalgo progpow
{
  "success": true,
  "message": "Mining algorithm changed from sha256d to progpow"
}
$ veil-cli getmininginfo
{
[...]
  "algorithm": "progpow",
  "difficulty": 164.7481194885794,
  "networkhashps": 23.16038554216868,
[...]
}

@CaveSpectre11 CaveSpectre11 added Component: RPC Related to the console commands themselves. Component: Miner Both PoW and PoS block creation Tag: Needs Release Notes Any PR or Issue that needs notable mention in release notes labels Dec 5, 2020
@CaveSpectre11 CaveSpectre11 self-assigned this Dec 5, 2020
Copy link
Collaborator
@codeofalltrades codeofalltrades left a comment

Choose a reason for hiding this comment

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

ACK 6ed4626

@codeofalltrades codeofalltrades added Code Review: Passed Tag: Waiting For QA A pull review is waiting for QA to test the pull request labels Dec 6, 2020
@seanPhill
Copy link
Collaborator

This worked nicely in my test of #879 incorporating this.

@codeofalltrades codeofalltrades merged commit 8d209f5 into Veil-Project:master Dec 10, 2020
codeofalltrades added a commit that referenced this pull request Dec 10, 2020
6cc4d59 [RPC][Mining] Add sanity checks to generatecontinuous (Cave Spectre)

Pull request description:

  ### Note
  This is built on top of #878 and requires code added in #877 and #878
  ### Problem
  `generatecontinuous` can get users in trouble by not knowing what their settings will do to their resources

  ### Solution
  Add checks in `generatecontinuous`:

  - Warn if RandomX is set to less than 4 threads.
  - Warn if Sha256D is more than one thread less than the number of cores
  - Provide ability to override the warnings with a new optional parameter
  - Disallow generatecontinuous true if already running
  - Rework the result of the command to provide a JSON status

  ### Testing
   ```
  $ veil-cli generatecontinuous true 1
  {
    "success": true,
    "algorithm": "sha256d",
    "threads": 1,
    "message": "Mining started"
  }
  $ veil-cli generatecontinuous true 1
  error code: -32603
  error message:
  Mining already active
  $ veil-cli generatecontinuous false
  {
    "success": true,
    "algorithm": "sha256d",
    "threads": 0,
    "message": "Mining stopped"
  }
  ```
  ```
  $ ./veil-cli setminingalgo randomx
  {
    "success": true,
    "message": "Mining algorithm changed from sha256d to randomx"
  }
  $ veil-cli generatecontinuous true 1
  error code: -8
  error message:
  Error: RandomX must be at least 4 threads
  ```
  ```
  $ veil-cli setminingalgo sha256d
  {
    "success": true,
    "message": "Mining algorithm changed from randomx to sha256d"
  }
  $ veil-cli generatecontinuous true 100
  error code: -8
  error message:
  Error: Available cores: 4, limit sha256d to 3 threads
  $ ./veil-cli generatecontinuous true 4 true
  {
    "success": true,
    "algorithm": "sha256d",
    "threads": 4,
    "message": "Warning: Available cores: 4, limit sha256d to 3 threads
  ```

Tree-SHA512: 01bb9d485cb7d382a4cbca6fa89424cb59bd320e50cf3364397bf0d246b6a862d48616425a9bf6960dbed50fb164a96611c208e35c9ed8878bbe80f4b1f7a5de
@CaveSpectre11 CaveSpectre11 added Dev Status: Merged Issue is completely finished. QA: Passed This has passed QA testing and can be merged to master and removed Tag: Waiting For QA A pull review is waiting for QA to test the pull request labels Dec 11, 2020
@CaveSpectre11 CaveSpectre11 deleted the switchmining branch December 11, 2020 14:22
@CaveSpectre11 CaveSpectre11 added this to the v1.1.1 milestone Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Review: Passed Component: Miner Both PoW and PoS block creation Component: RPC Related to the console commands themselves. Dev Status: Merged Issue is completely finished. QA: Passed This has passed QA testing and can be merged to master Tag: Needs Release Notes Any PR or Issue that needs notable mention in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0