-
Notifications
You must be signed in to change notification settings - Fork 720
significantly increased the verification cycle for staking. #627
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2959,11 +2959,13 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int | |
| return false; | ||
|
|
||
| if (GetAdjustedTime() - chainActive.Tip()->GetBlockTime() < 60) | ||
| MilliSleep(10000); | ||
| MilliSleep(100); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably fine. I delete these two lines completely when I test.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. Sleep code is not required. |
||
|
|
||
| CAmount nCredit = 0; | ||
| CScript scriptPubKeyKernel; | ||
| bool fKernelFound = false; | ||
| int nHeightStart = chainActive.Height(); | ||
|
|
||
| for (std::unique_ptr<CStakeInput>& stakeInput : listInputs) { | ||
| // Make sure the wallet is unlocked and shutdown hasn't been requested | ||
| if (IsLocked() || ShutdownRequested()) | ||
|
|
@@ -2976,6 +2978,10 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int | |
| continue; | ||
| } | ||
|
|
||
| if (chainActive.Height() != nHeightStart) { | ||
| return false; | ||
| } | ||
|
|
||
| // Read block header | ||
| CBlockHeader block = pindex->GetBlockHeader(); | ||
| uint256 hashProofOfStake = 0; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -304,9 +304,9 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface | |
| fBackupMints = false; | ||
|
|
||
| // Stake Settings | ||
| nHashDrift = 45; | ||
| nHashDrift = 60; | ||
| nStakeSplitThreshold = 2000; | ||
| nHashInterval = 22; | ||
| nHashInterval = 2; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means that every 2 seconds you will be hashing the next 60 seconds of timestamps on each UTXO that you have. Right now the settings are at 22/30 because that seemed to be a decent balance between having some overlapping hashes as well as not hashing too far out into the future. Hashing out into the future can be more likely to create an orphan stake. If two people get a valid stake at the same time, whoever has the stake with the lowest timestamp will win the block. The second person is better off waiting until the time is closer and then publishing the stake when there is less time for someone else to produce a stake that orphans it.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The frequency of hash searches is intended. (Every 2 seconds) Currently, orphans occur more frequently due to longer interval + long zpiv spending time. Do not change the nHashDrift. I hope it works as follows. before : 0-30 scan > sleep 22 sec > 31-60 scan It is right to eliminate the duplication. There is one more important thing. In the code example below, nTimeBlockFrom and nStakeModifier are the UTXO fixed values. That is correct for CPivStake. However, it is no longer fixed in the CZPivStake. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Since all of the zpivstake's will have the same modifier, it might make sense to cache the previous round's modifier and then compare it with the current round to see if a complete new set of hashes needs to be generated or if it should only generate the incremental change. |
||
| nStakeSetUpdateTime = 300; // 5 minutes | ||
|
|
||
| //MultiSend | ||
|
|
||
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 don't think this accomplishes anything differently than how the code was before.
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 changed it to a code that I can understand.
If it is the same, there is no problem.