Skip to content

Commit bd5b3f5

Browse files
committed
Activate 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 9c8c2d4 commit bd5b3f5

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
@@ -4954,15 +4954,23 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
49544954
return true;
49554955
}
49564956

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

4964+
/* Otherwise, the protocol update is tied to activation of the
4965+
"staking vault" fork. */
4966+
const CBlockIndex* tip;
4967+
{
4968+
LOCK(cs_main);
4969+
tip = chainActive.Tip();
4970+
}
4971+
if (tip != nullptr && ActivationState(tip).IsActive(Fork::StakingVaults))
4972+
return MN_REWARD_SCRIPT_VERSION;
4973+
49664974
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
49674975
}
49684976

0 commit comments

Comments
 (0)