Skip to content

Commit 87574f6

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 2e2a400 commit 87574f6

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
@@ -4984,15 +4984,23 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
49844984
return true;
49854985
}
49864986

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

4994+
/* Otherwise, the protocol update is tied to activation of the
4995+
"staking vault" fork. */
4996+
const CBlockIndex* tip;
4997+
{
4998+
LOCK(cs_main);
4999+
tip = chainActive.Tip();
5000+
}
5001+
if (tip != nullptr && ActivationState(tip).IsActive(Fork::StakingVaults))
5002+
return MN_REWARD_SCRIPT_VERSION;
5003+
49965004
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
49975005
}
49985006

0 commit comments

Comments
 (0)