Skip to content

Commit 804cc64

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 24d9734 commit 804cc64

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
@@ -4972,15 +4972,23 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
49724972
return true;
49734973
}
49744974

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

4982+
/* Otherwise, the protocol update is tied to activation of the
4983+
"staking vault" fork. */
4984+
const CBlockIndex* tip;
4985+
{
4986+
LOCK(cs_main);
4987+
tip = chainActive.Tip();
4988+
}
4989+
if (tip != nullptr && ActivationState(tip).IsActive(Fork::StakingVaults))
4990+
return MN_REWARD_SCRIPT_VERSION;
4991+
49844992
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
49854993
}
49864994

0 commit comments

Comments
 (0)