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

[GUI|MINE] Mining Tab #969

Merged
merged 1 commit into from
Oct 17, 2021
Merged

Conversation

WetOne
Copy link
Collaborator

@WetOne WetOne commented Oct 2, 2021

Problem
Mining requires use of QT

Root Cause
No Mining interface in the QT implementation

Solution
Implement a Mining Tab to allow for mining to be activated and controlled through the GUI.. The mining tab will control mining activity initiated through the CLI.

@CaveSpectre11 CaveSpectre11 added Component: GUI Primarily related to the display of the user interface Component: Miner Both PoW and PoS block creation Tag: Waiting For Code Review Waiting for code review from a core developer labels Oct 3, 2021
@CaveSpectre11 CaveSpectre11 self-requested a review October 3, 2021 14:52
@@ -0,0 +1,53 @@
// Copyright (c) 2019 The Veil developers
Copy link
Collaborator

Choose a reason for hiding this comment

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

NIT: Be sure to give appropriate copyright when adding files (e.g. 2021) or update to include 2021 if it's not done yet (there's a script we can run but might as well do it when we've edited a file)

Comment on lines 59 to 66
void MiningWidget::setWalletModel(WalletModel *model){
this->walletModel = model;

connect(model, SIGNAL(updateMiningFields()), this, SLOT(updateMiningFields()));
}

MiningWidget::~MiningWidget()
{
delete ui;
}

void MiningWidget::onUpdateAlgorithm() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

NIT. I know it's a copied and edited file, but be sure to try and clean up a new file to a single style.

void module::method(params){
void module::method(params) {
void module::method(params)
{

Comment on lines 106 to 112
if (nThreads > (nCores - 1)) {
openToastDialog("Too many threads", mainWindow->getGUI());
return;
}

if ((nAlgo == MINE_SHA256D) && (nThreads > (nCores - 1)))
openToastDialog(QString::fromStdString("SHA256D limited to " + (nCores-1)), mainWindow->getGUI());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Two comments here. First: I'm contemplating it, but for cli based mining, they -can- override this check; so I'm leaning towards a "do it anyway" type button in case they really want to do it.

Second: The second "if" statement won't be hit. If (nThreads > (nCores - 1)) then it will pop "Too many threads" and won't ever get down to the check about the SHA256D limitation. The only way it can get to the MIN_SHA256D check is if the second condition isn't met. Quite simply, that first nThreads check shouldn't be there, since it is intended to restrict SHA256D (Per PR #879)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can implement an override in a later iteration. This PR can lay down a baseline. I'm inclined to leave the first check and remove the 2nd check (first check applies to ProgPow as well). It is almost irrelevant as the GUI currently restricts the user. I'm inclined to leave it for security check. Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with the first as a safety check (until the option to override is added), given that the GUI should prevent the casual user from hitting this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

With a better understanding of the history of the checks I'm OK with removing the first one. I'd like to do something where if the user exceeds the recommended number of threads (which would be Cores -1) a popup appears allowing the user to override. I'm still inclined to have that be a separate PR.

I have the formatting changes ready but have not pushed them. @CaveSpectre11, let me know if you want the thread limits changed in this PR or a different one. After that I will either push the changes I have now or add the other changes and push it in one go.

openToastDialog(QString::fromStdString("SHA256D limited to " + (nCores-1)), mainWindow->getGUI());

if ((nAlgo == MINE_RANDOMX) && (nThreads < 4)) {
openToastDialog(QString::fromStdString("RandomX must be at least 4 threads"), mainWindow->getGUI());
Copy link
Collaborator

@Zannick Zannick Oct 8, 2021

Choose a reason for hiding this comment

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

Is there some way to indicate that this message doesn't prevent mining but changes the threads and starts anyway? Actually, scratch that. I would prefer the GUI enforce that during selection instead of on enabling mining--it wouldn't have to be a pop-up there. And I see below you already have the range being set for randomx.

(I guess that means that this is a safety check just in case the user manages to get a lower number anyway? Then it's fine.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You pretty much hit it on the head. The GUI is the first line of defense, performing a range check prior to enabling. This check is for redundancy (in case someone finds a way to get a lower number).

miningAction->setStatusTip(tr("Mining"));
miningAction->setToolTip(miningAction->statusTip());
miningAction->setCheckable(true);
miningAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is above the settings tab, it should have the lower shortcut.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are a couple errors on the key sequence. Good catch. I'm going to clean it up. It will be the following:
Overview -> 1
Send -> 2
Receive-> 3
Mine -> 4
Address -> 5
Settings -> 6

This is the order of the icons top to bottom.

@WetOne
Copy link
Collaborator Author

WetOne commented Oct 10, 2021

The latest push addresses

  1. Copywrite
  2. formatting
  3. the check for # of threads (both in code and adjusts range when algorithm is changed
  4. the activates the Use Max Threads button.

Copy link
Collaborator

@CaveSpectre11 CaveSpectre11 left a comment

Choose a reason for hiding this comment

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

ACK 7703eb2

Copy link
Collaborator

@Zannick Zannick left a comment

Choose a reason for hiding this comment

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

utACK 7703eb2

bool setAlgoResult = SetMiningAlgorithm(algoStr);

if (setAlgoResult) {
openToastDialog(QString::fromStdString("Aglorithm Switch Success!"), mainWindow->getGUI());
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: typo

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is on a message presented to the user, and not a rare message; I'm going to upgrade this above just a 'nit'.


setMineActiveTxt(mineOn);

ui->lblHashRate->setText(QString("Mining at %1 H/s").arg(QString::number(GetHashSpeed())));
Copy link
Collaborator

Choose a reason for hiding this comment

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

In a future PR, we might want to change this to GetRecentHashSpeed() (#967)

Copy link
Collaborator

@Zannick Zannick left a comment

Choose a reason for hiding this comment

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

utACK 781c6a6

@CaveSpectre11 CaveSpectre11 added Code Review: Passed and removed Tag: Waiting For Code Review Waiting for code review from a core developer labels Oct 17, 2021
@CaveSpectre11 CaveSpectre11 merged commit c66163b into Veil-Project:master Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Review: Passed Component: GUI Primarily related to the display of the user interface Component: Miner Both PoW and PoS block creation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants