Skip to content

Commit a8c4114

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 1b017fa commit a8c4114

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

divi/src/main.cpp

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

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

5081+
/* Otherwise, the protocol update is tied to activation of the "staking vault"
5082+
fork, which happens by supermajority with block version 5. */
5083+
const CBlockIndex* tip;
5084+
{
5085+
LOCK(cs_main);
5086+
tip = chainActive.Tip();
5087+
}
5088+
if (tip != nullptr && IsSuperMajority(5, tip, Params().RejectBlockOutdatedMajority()))
5089+
return MN_REWARD_SCRIPT_VERSION;
5090+
50835091
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
50845092
}
50855093

0 commit comments

Comments
 (0)