-
Notifications
You must be signed in to change notification settings - Fork 92
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
[Staking][Zerocoin][GUI] Show number of confirmations until staking becomes active #913
base: master
Are you sure you want to change the base?
[Staking][Zerocoin][GUI] Show number of confirmations until staking becomes active #913
Conversation
It might be best to just display "Staking Enabled" whenever the value is zero confirmations remaining as it would prevent the wallet from shifting back and forth. It would also be most accurate. |
Looking at what was line 66 in veilstatusbar.cpp, fstakingactive is set depending on if enough blocks passed to allow for staking to be active. If I'm reading this right, the new code checks to ensure mapHashedBlocks is not empty. This could lead to a discontinuity between the slider indicating that staking is active and staking actually being active. See issue #880 for reference about what I'm on about. Please squash you commits. |
I added a line of code to clear the mapHashedBlocks map in miner.cpp line 901 when staking is not enabled so there shouldn't be a discontinuity between actively staking and otherwise. The reason I went with this approach is because I have periodically noticed the wallet showing "Enabling..." many times when it was "Staking Active" for a long time. Additionally, the map for hashing calculations would be a more concrete way of assuring staking is happening, or not, than looking at time between hashings as is related to the issue you mentioned in pull request #880:
At a higher level, if the mapHashedBlocks map is not empty, then the wallet must be staking to add values to it. Thank you for your input. I will squash the commits after performing some fix ups. I also think there might be a more elegant way to handle the confirmations than looping through the list of zerocoins in the wallet to get the minimum number of remaining confirmations before staking can begin. Just noticed this can minimally be handled with code leveraged from MintableCoins() in wallet.cpp. Will revisit. |
If I'm understanding you correctly, staking would then be considered active one block after the user has enabled staking. I should have been more clear regarding the discontinuity. The discontinuity I was referring to was between the cli and GUI (the genesis of issue 880). The code being removed was lifted from the cli to allow users to have the same information from both interfaces (humorously, the issue I'm referring to here is #504 authored by you, ha :) ). If you are changing how active staking is being confirmed through the GUI, then you should also change the same in the cli. If @codeofalltrades and @CaveSpectre11 are OK with staking being dependent on a single block passing after user enables staking, then I am as well. |
If you have mature zerocoin in your wallet, the wallet will be staking. That logic has not been changed. The logic to detect if the wallet is actively or not actively staking has changed. The bools in veilstatusbar.cpp are strictly for display purposes anyway (local to the veilstatusbar.cpp code checks), if I'm understanding your point correctly. |
Yes I will need to change that as well. Good catch |
11e817d
to
9096a38
Compare
squashed, but still need to apply changes to CLI across the board for stakingactive indicator |
Note: The icon sizes for the toggle have shrunk a little bit, but I've noticed there was clipping in many screenshots before and if desired the svgs for the vector images should be more identical than previous (which was off-center and more top heavy as a result if you scroll up to prior version). |
eea2c48
to
d9baa2d
Compare
I'm going to do some additional testing and perform the pull request writeup as the next step for anyone who wants to give additional feedback, particularly in regards to the logic WetOne mentions. -added |
This would be a tough test to time; but maybe it would be best tested on testnet or maybe even in regtest. I would like to see the coin(s) mature, it go to Staking Enabled, and then return to showing the number of confirmations needed after they staked. Not sure the best way to simply test it without a closed network. |
@CaveSpectre11 additionally can have staking enabled (with mature zerocoin), then spend the coins while also minting new ones, or some combination of those events. |
Added a timer to check the staking status more frequently (every 5 seconds until the status changes) when staking is |
with the latest commit, you should be able to toggle the status bar to your heart's content and it will always be accurate :) |
I would like to add a feature where clicking the "Unlock wallet for staking" toggle bottom left of the screen brings up the pop-up to unlock the wallet for staking only as is depicted. Current State: Only the toast dialogue shown below displays (no form pop-up). You still have to go to the settings right side tab to unlock wallet for staking only. Looking for feedback about this change. It touches the same code I've already had to modify as part of this pull request as well. Thanks |
Please try to keep PRs autonomous. Separate PRs can touch the same code areas but unless they're actually dependent on each other, they should be separate PRs; otherwise the PR discussion gets overly confusing and code reviews and testing becomes even more complicated. Even if a PR is dependent on another PR; that second PR can be noted that it includes and is a follow on to another PR (and you can cherry pick the previous PR's commit into the new PR). Please make this an issue if you'd like discussion on it, and if it's completed PR ends up with conflicts after this merges, the conflicts can be easily addressed when rebased with the master branch. |
Created pull request #924 in response to my latest feature addition question. |
ce92ee0
to
ed2e975
Compare
After some extra thought, I think I might want to add an additional mapHashedBlocks.clear() whenever the selectStakeCoins method determines there's no stakable zerocoins. Just to cover the edge case where the wallet sends out the only eligible mature stakable zerocoin while looping in the staking loop (which won't clear out the mapHashedBlocks). UPDATE: Added |
enhancements cleanup rename min to max wording and spelling more UI enhancements/ edge case support better staking status alignment color indicates wallet status. toggle indicates intent. new icons (needs resizing and fixing up) small change for code reduction and clarity make it more readable additional check borrowed from MintableCoins(). less than equals sanity svg and png toggle standardizations. move QString to top. adjust offset with adjusted icon create common shared IsStakingActive code in wallet.cpp log print removal cleanup. qt makefile additions IsStakingActive() check now leverages mining check for stakable inputs clear mapHashedBlocks when staking thread exits timer to perform 5 second checks while enabling or disabling fix for inaccurate wallet toggle status additional clear mapHashedBlocks if no stakable coins
ed2e975
to
c5780c8
Compare
Is this ready for QA? |
Ready for QA |
b8294ee unlock wallet for staking dialogue on click (Rock-N-Troll) Pull request description: Related to pull request: #913 (and mentioned there as well. This is the separated pull request) ![image](https://user-images.githubusercontent.com/34344520/113945740-f2f5fb80-97d4-11eb-91c8-d828cf05411d.png) #913 (comment) Tree-SHA512: 5f6e3b7cbd64999f9c877c2c449ec9bb8123b60ddc14f9ab7c2f8fefccb55381ffb41e83d0f1723da8814c0d2c272ef907d0a0c344a6b19ae4a9c2f3e62054c1
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.
Indenting issues in miner.cpp, veilstatusbar.cpp and ztracker.cpp are extensive enough that it goes beyond what I can let slide on a NIT. Definitely need those addressed.
I can accept 2 space indents on tight code, but standard should be 4 space indents for sections.
"4 space indentation (no tabs) for every block except namespaces."
(from https://github.com/Veil-Project/veil/blob/master/doc/developer-notes.md#coding-style-general)
@@ -898,6 +898,7 @@ void BitcoinMiner(std::shared_ptr<CReserveScript> coinbaseScript, bool fProofOfS | |||
} | |||
|
|||
if (!pwallet || !pwallet->IsStakingEnabled() || (pwallet->IsLocked() && !pwallet->IsUnlockedForStakingOnly())) { | |||
mapHashedBlocks.clear(); |
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.
NIT fix the indentation
ui->checkStaking->setText("Staking Enabled"); | ||
ui->checkStaking->setStyleSheet(toggleOnBlue); |
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.
This indentation is not only off the standard style, but it's off the local code indenting as well
Would like functionality checks if anyone has the capacity to check. Will address the indenting if functionality is correct or when I go back to fix-up the functionality, whichever comes first |
has conflicts to resolve as well. |
Issue Reference: #889
New method
GetConfirmationsRemainingForStaking()
inztracker.cpp
-2
if the ztracker is not fully initialized-1
if there are no zerocoin in the wallet (which will display typicalYou need some zerocoin
text)0
if there is at least 1 zerocoin mature enough for staking in the wallet.