-
Notifications
You must be signed in to change notification settings - Fork 90
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] Update Staking Slider to be reflective of status #880
Conversation
src/qt/veil/veilstatusbar.cpp
Outdated
} | ||
bool fStakingActive = false; | ||
if (nTimeLastHashing) | ||
fStakingActive = GetAdjustedTime() + MAX_FUTURE_BLOCK_TIME - nTimeLastHashing < 70; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define 70 as a static const, with a reflective name and description; then use it here and in the toast dialog further down
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with using it within the time check.
I suggest changing the toast to something along the lines of: "This may take a few minutes" as
- The display changing in the Qt is a function of when staking is active and the calls are made (there is no periodic task that performs this check, only when new blocks come in). In my testing I've had a few minutes pass before the display is updated though calls through the command line show active already. This has to do with how the display is updated (when the command line is used, the calculation is done on the spot).
- The 70 was copied from other code and I have no knowledge of what the actual high water mark is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is merely to adjust away from using magic numbers. Instead of "70" hardcoded in two places [the code and the message], make it
static const STAKING_DELAY = 70
or something to that effect; so that it's defined; and if adjusted anytime in the future you don't have the message (stating 70 seconds) and the code diverging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the message to be less definitive of the timeframe (as the user won't see the change real-time). Added the constant and used it in the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you take care of the "enabling..." thing while it's synching?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. Works like it should now. Gave it a quick test too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NACK 7556f9b
src/qt/veil/veilstatusbar.cpp
Outdated
if (fStakingActive) { | ||
ui->checkStaking->setText("Staking Enabled"); | ||
}else{ | ||
ui->checkStaking->setText("Enabling..."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7556f9b
to
7c927b5
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 7c927b5
@WetOne one obscure use case that still has a problem. This came up due to a discussion with Hort regarding a problem he's had for a while. So we set out to see if this fixes his problem. First, the problem we found: After taking a look:
So a check on (if you're feeling really randy and want to play with veild and confirm that it works there too... look in
which probably would work with a simple "else set staking enabled false". The initial problem we were looking at [not necessarily with your code, but with the current release]
I think we've determined your code handles that and doesn't turn on staking; but only if 'staking=0' is "fixed". |
I like this implementation on the whole, but another potential annoyance is that if the wallet is locked and you click the slider where it says "Unlock wallet for staking" it then tells you to unlock the wallet, and when you click over on the padlock icon and type your password, unlocking it, then the slider activates staking. This might annoy some people, in that clicking "unlock wallet for staking" doesn't actually unlock the wallet, as you have to go to another control for that. |
I'll have to play around with it when I get a chance. You're saying that it doesn't activate staking when you unlock for staking; only when you unlock the wallet as a whole? Yea, that would be an issue. It should start staking [assuming staking is enabled underneath] when it's unlocked for staking or when it's fully unlocked.
Well, that should be the expected behavior; unlock for staking.... turns on staking. unlock for staking shouldn't need a full unlock for spending to work. |
To test, I locked it again with the padlock icon and then unlocked for staking from the other slider in the Settings page. |
@CaveSpectre11, @codeofalltrades Quick update: I modified line 75 of mnemonicwalletinit.cpp to be
and then ran "veil-qt -staking=0". The GUI starts with "Unlock wallet for staking". OK. After unlocking the wallet it sits at "Enabling..." and doesn't transition to enabled. Using the CLI shows that staking is enabled but staking doesn't go active. I'm going to investigate this further when I get the chance later today. I don't know what is keeping the enabled and the actual staking in two different states. I did put instrumentation to verify that the staking flag when starting the GUI was being accepted. Bottom line: either I put the one line change in the wrong spot (or the change is wrong, should probably default staking to true) or this is more than a one line change. |
The two flags are inverted logic. But that exchanges mode might be wrong? I would think it should be "if exchangesandservicesmode, true || staking false. But it could very well be that exchangesandservicesmode is "working" due to some code elsewhere; since it would imply that code would pass through and disable staking if exchangesandservices mode is not set. So maybe that code path isn't exercised. Maybe throw some debug logging in and see if that code is called at all; and if not, find where exchangesandservices mode disables staking. |
I fixed the inverted logic and verified that SetStakingEnabled(false) being called in mnemonic wallet. Then ran the qt with -staking=0, unlocked my wallet (staking stayed disabled), and hit the slider. The text went to Enabling... but never got to staking enabled. through the CLI staking enabled is set to true but staking active doesn't go to true. I'm going to look through what is holding back the activity. |
Right place, wrong interpretation of so So the check should be
|
7c927b5
to
cad2120
Compare
@CaveSpectre11, @codeofalltrades Made the change in mnemonicalletinit.cpp to include the check for staking being disabled. There is still an issue when launching with staking disabled, unlocking, and then trying to enable staking. |
Just to help explain what we realized. @codeofalltrades; so the problem is that, like so many other places, args are checked in the middle of the code, rather than on startup. In this case what's happening rests right here:
If we come up with So on a separate PR; that will all be fixed. It's out of scope for this as starting with 'staking=0' has never been able to start staking without restarting the wallet. That second PR will move the check for '-staking=0' to the init, but take it off the check to start the staking thread. That way the staking thread will start regardless if staking is enabled or not. That will allow the thread to lay dormant until staking is enabled. The dormancy is here:
This will also allow for a cli command to be able to turn staking on and off as well, and no longer require the wallet to be restarted. You can set your desired default, and then enable or disable when you chose to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK cad2120
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK cad2120
Bounty Paid: 6200 + 100 for using PR form |
Problem
The staking slider does not always indicate the present state of staking. There is a delay between when staking is enabled/disabled and when the actual enabling/disabling takes place.
Root Cause
The Qt indicates the state that the wallet is in. Some amount of time is required to ensure that the state change has taken affect. Additionally, staking is not performed while syncing. When the user initially opens the user interface, staking is displayed as active while syncing. Staking is initially active but will not be performed until syncing is complete.
Solution
Issues Addressed
245: #245
504: #504
Bounty Payment Address
sv1qqphsvuwhk29xcn2q9gdth9x73qpm8kcktmuxyd8szl50sgt2nt47egpqwnxr83hfj7s6fnec2jr0cv5yc7r6s7nvxhd9969qrgy4cgnznwewqqqauut5m