Skip to content

Commit 0cdcc86

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 fbca783 commit 0cdcc86

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
@@ -5091,15 +5091,23 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
50915091
return true;
50925092
}
50935093

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

5101+
/* Otherwise, the protocol update is tied to activation of the "staking vault"
5102+
fork, which happens by supermajority with block version 5. */
5103+
const CBlockIndex* tip;
5104+
{
5105+
LOCK(cs_main);
5106+
tip = chainActive.Tip();
5107+
}
5108+
if (tip != nullptr && IsSuperMajority(5, tip, Params().RejectBlockOutdatedMajority()))
5109+
return MN_REWARD_SCRIPT_VERSION;
5110+
51035111
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
51045112
}
51055113

0 commit comments

Comments
 (0)