Skip to content

Commit c46d48f

Browse files
committed
Active reward scripts with the staking vault.
This implements ActiveProtocol, to actually activate the protocol change for custom reward scripts outside of regtest (where it is already activated from the start). The activation will happen together with the planned staking-vault fork, i.e. when 95% of blocks are version 5 or above. This makes sure that the upgrade happens only when the network has largely updated to a new code version.
1 parent 5e59b2e commit c46d48f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

divi/src/main.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5103,15 +5103,23 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
51035103
return true;
51045104
}
51055105

5106-
// Note: whenever a protocol update is needed toggle between both implementations (comment out the formerly active one)
5107-
// so we can leave the existing clients untouched (old SPORK will stay on so they don't see even older clients).
5108-
// Those old clients won't react to the changes of the other (new) SPORK because at the time of their implementation
5109-
// it was the one which was commented out
51105106
int ActiveProtocol()
51115107
{
5108+
/* On regtest, we set the new protocol as active without any further
5109+
ado. This allows proper testing of the changed logic. */
51125110
if (Params().NetworkID() == CBaseChainParams::REGTEST)
51135111
return MN_REWARD_SCRIPT_VERSION;
51145112

5113+
/* Otherwise, the protocol update is tied to activation of the "staking vault"
5114+
fork, which happens by supermajority with block version 5. */
5115+
const CBlockIndex* tip;
5116+
{
5117+
LOCK(cs_main);
5118+
tip = chainActive.Tip();
5119+
}
5120+
if (tip != nullptr && IsSuperMajority(5, tip, Params().RejectBlockOutdatedMajority()))
5121+
return MN_REWARD_SCRIPT_VERSION;
5122+
51155123
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
51165124
}
51175125

0 commit comments

Comments
 (0)