Skip to content

Commit

Permalink
Fixing staker misses after chain halting
Browse files Browse the repository at this point in the history
  • Loading branch information
StealthSend committed Sep 24, 2021
1 parent c4aa107 commit b419f0e
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Stealth.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ win32 {

TEMPLATE = app
TARGET = "Stealth Qt"
VERSION = 3.1.7.0
VERSION = 3.1.7.5
INCLUDEPATH += src src/json src/qt src/tor
INCLUDEPATH += src/tor/adapter src/tor/common src/tor/ext
INCLUDEPATH += src/tor/ext/curve25519_donna src/tor/ext/ed25519/donna
Expand Down
6 changes: 3 additions & 3 deletions contrib/macdeploy/Info-daemon.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
<string>Stealth [XST] Complete Anonymity 3.1.7.0</string>
<string>Stealth [XST] Complete Anonymity 3.1.7.5</string>
<key>CFBundleIdentifier</key>
<string>org.stealth.stealth-qt</string>
<key>CFBundleShortVersionString</key>
<string>3.1.7.0</string>
<string>3.1.7.5</string>
<key>CFBundleSignature</key>
<string>oXST</string>
<key>CFBundleVersion</key>
<string>3.1.7.0</string>
<string>3.1.7.5</string>
<key>CFBundleName</key>
<string>StealthCoind</string>
</dict>
Expand Down
6 changes: 3 additions & 3 deletions contrib/macdeploy/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleGetInfoString</key>
<string>Stealth [XST] Complete Anonymity 3.1.7.0</string>
<string>Stealth [XST] Complete Anonymity 3.1.7.5</string>
<key>CFBundleExecutable</key>
<string>Stealth Qt</string>
<key>CFBundleIdentifier</key>
<string>org.stealth.stealth-qt</string>
<key>CFBundleShortVersionString</key>
<string>3.1.7.0</string>
<string>3.1.7.5</string>
<key>CFBundleSignature</key>
<string>oXST</string>
<key>CFBundleVersion</key>
<string>3.1.7.0</string>
<string>3.1.7.5</string>
</dict>
</plist>
5 changes: 5 additions & 0 deletions src/blockchain/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ ChainParams::ChainParams()
( XST_FORKFEELESS, 63800 )
( XST_FORKMISSFIX, 63800 )
( XST_FORKREINSTATE, 63900 )
( XST_FORKMISSFIX2, 64000 )
( XST_FORKFEELESS2, 64000 )
);

Expand All @@ -75,6 +76,7 @@ ChainParams::ChainParams()
START_FEELESS_M = 3702300; // start of feeless transactions
START_MISSFIX_M = 3719600; // allow network stalls on transition to qPoS
REINSTATE_M = 3776758; // reinstate disqualified stakers
START_MISSFIX2_M = 5572400; // fixing staker misses after chain halting
START_FEELESS2_M = 5798888; // require feeless inputs to be confirmed

mapForksMainNet = MakeMapIntInt(
Expand All @@ -94,6 +96,7 @@ ChainParams::ChainParams()
/* Jun 2 14:12:17 MST 2021 */ ( START_FEELESS_M, XST_FORKFEELESS )
/* Jun 3 15:45:07 MST 2021 */ ( START_MISSFIX_M, XST_FORKMISSFIX )
/* Jun 6 23:49:52 MST 2021 */ ( REINSTATE_M, XST_FORKREINSTATE )
/* Approx 10/01 2021 1AM MST */ ( START_MISSFIX2_M, XST_FORKMISSFIX2 )
/* Approx 10/13 2021 6AM MST */ ( START_FEELESS2_M, XST_FORKFEELESS2 )
);

Expand Down Expand Up @@ -445,6 +448,7 @@ ChainParams::ChainParams()
START_FEELESS_T = 3965963;
START_MISSFIX_T = 4768119;
REINSTATE_T = 99999999; // placeholder for testnet
START_MISSFIX2_T = 99999999; // placeholder for testnet
START_FEELESS2_T = 99999999; // placeholder for testnet

// should be similar to aryForksMainNet
Expand All @@ -465,6 +469,7 @@ ChainParams::ChainParams()
/* */ ( START_FEELESS_T, XST_FORKFEELESS )
/* */ ( START_MISSFIX_T, XST_FORKMISSFIX )
/* */ ( REINSTATE_T, XST_FORKREINSTATE )
/* */ ( START_MISSFIX2_T, XST_FORKMISSFIX2 )
/* */ ( START_FEELESS2_T, XST_FORKFEELESS2 )
);

Expand Down
2 changes: 2 additions & 0 deletions src/blockchain/chainparams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class ChainParams
int START_FEELESS_M;
int START_MISSFIX_M;
int REINSTATE_M;
int START_MISSFIX2_M;
int START_FEELESS2_M;

mapIntInt_t mapForksMainNet;
Expand Down Expand Up @@ -249,6 +250,7 @@ class ChainParams
int START_FEELESS_T;
int START_MISSFIX_T;
int REINSTATE_T;
int START_MISSFIX2_T;
int START_FEELESS2_T;

mapIntInt_t mapForksTestNet;
Expand Down
11 changes: 7 additions & 4 deletions src/client/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define CLIENT_VERSION_MAJOR 3
#define CLIENT_VERSION_MINOR 1
#define CLIENT_VERSION_REVISION 7
#define CLIENT_VERSION_BUILD 0
#define CLIENT_VERSION_BUILD 5

// cloners: add your new forks higher than highest here
// keep existing
Expand All @@ -30,7 +30,8 @@ enum ForkNumbers
XST_FORKFEELESS, // fork 10
XST_FORKMISSFIX, // fork 11
XST_FORKREINSTATE, // fork 12
XST_FORKFEELESS2, // fork 13
XST_FORKMISSFIX2, // fork 13
XST_FORKFEELESS2, // fork 14
TOTAL_FORKS
};

Expand All @@ -41,8 +42,10 @@ static const int CLIENT_PROTOCOL_VERSION = 64000;

// proto version notes
// ----- ------- ----------------------------------------------------------
// 64000 : fork 13 : XST_FORKFEELESS2
// 3.1.7.0 : Enforcing that feeless inputs are confirmed
// 64000 : fork 14 : XST_FORKFEELESS2
// 64000 : fork 13 : XST_FORKMISSFIX2
// : 3.1.7.5 : Fixing staker misses after chain halting
// : 3.1.7.0 : Enforcing that feeless inputs are confirmed
// 63900 : fork 12 : XST_FORKREINSTATE
// 3.1.6.7 : Improving feeless priority calculation, fixed gettxvolume
// 3.1.6.6 : Fixing ungraceful overflow in feework diff calculation
Expand Down
43 changes: 31 additions & 12 deletions src/qpos/QPRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,13 @@ bool QPRegistry::UpdateOnNewTime(unsigned int nTime,
{
if (!fCurrentBlockWasProduced)
{
if (nFork >= XST_FORKQPOS)
// After FORKFEELESS2, don't dock stakers for blocks
// after the first new queue here because by the 2nd
// queue there has already been a complete queue
// without a block and this could only mean that the
// chain had halted.
if ((nFork >= XST_FORKQPOS) &&
((nFork < XST_FORKFEELESS2) || (nNewQueues <= 1)))
{
StakerMissedBlock(queue.GetCurrentID(), nHeight);
}
Expand Down Expand Up @@ -1629,22 +1635,35 @@ bool QPRegistry::UpdateOnNewBlock(const CBlockIndex *const pindex,

int nFork = GetFork(pindex->nHeight);

// Unfortunately, a line that disqualified stakers accidentally
// remained in a previous commit, so now we have to undo the damage.
if ((GetFork(nBlockHeight) < XST_FORKREINSTATE) &&
(nFork >= XST_FORKREINSTATE))
if (GetFork(nBlockHeight) < XST_FORKMISSFIX2)
{
QPRegistryIterator iter;
for (iter = mapStakers.begin(); iter != mapStakers.end(); ++iter)
// Chain halting destroyed missed and docked block stats, so
// give everyone a fresh start on docked blocks.
if (nFork >= XST_FORKMISSFIX2)
{
QPStaker& staker = iter->second;
if (staker.IsDisqualified())
QPRegistryIterator iter;
for (iter = mapStakers.begin(); iter != mapStakers.end(); ++iter)
{
staker.Requalify(true);
iter->second.ResetDocked();
}
staker.ResetDocked();
}
}
// Unfortunately, a line that disqualified stakers accidentally
// remained in a previous commit, so now we have to undo the damage.
else if ((GetFork(nBlockHeight) < XST_FORKREINSTATE) &&
(nFork >= XST_FORKREINSTATE))
{
QPRegistryIterator iter;
for (iter = mapStakers.begin(); iter != mapStakers.end(); ++iter)
{
QPStaker& staker = iter->second;
if (staker.IsDisqualified())
{
staker.Requalify(true);
}
staker.ResetDocked();
}
}
}

// Q: Why do we update on new time before updating the registry
// for the new block?
Expand Down

0 comments on commit b419f0e

Please sign in to comment.