Skip to content

Commit c5f19af

Browse files
committed
Activate new protocol with fork.
This defines a new time-activated "fork", Fork::CustomRewardAddresses. For now, it is scheduled at timestamp 2000000000; that will be set to the actual activation time once it is determined. When this fork becomes active (i.e. the current best block's timestamp goes beyond the activation time), we require peers to use the new protocol version that supports custom reward addresses. The fork has no other (in particular, no consensus-level) consequences.
1 parent e534bb8 commit c5f19af

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

divi/src/ForkActivation.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ const std::set<Fork> manualOverrides = {Fork::StakingVaults,Fork::HardenedStakeM
2222
* activation times.
2323
*/
2424
const std::unordered_map<Fork, int64_t,std::hash<int>> ACTIVATION_TIMES = {
25-
/* FIXME: Set real activation height for staking vaults once
26-
the schedule has been finalised. */
27-
{Fork::TestByTimestamp, 1000000000},
2825
{Fork::StakingVaults, unixTimestampForDec31stMidnight},
2926
{Fork::HardenedStakeModifier, unixTimestampForDec31stMidnight},
3027
{Fork::UniformLotteryWinners, unixTimestampForDec31stMidnight},
28+
29+
/** FIXME: Set actual time once scheduled. */
30+
{Fork::CustomRewardAddresses, 2000000000},
31+
32+
{Fork::TestByTimestamp, 1000000000},
3133
};
3234

3335
} // anonymous namespace

divi/src/ForkActivation.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,23 @@ class CBlockIndex;
1818
*/
1919
enum Fork
2020
{
21-
/* Test forks not actually deployed / active but used for unit tests. */
22-
TestByTimestamp,
2321
/**
2422
* Staking vaults with SCRIPT_REQUIRE_COINSTAKE and a couple of other,
2523
* related changes.
2624
*/
2725
StakingVaults,
2826
HardenedStakeModifier,
2927
UniformLotteryWinners,
28+
29+
/**
30+
* Custom reward addresses for masternodes. This is activated like other
31+
* forks based on block time; but it only affects the network protocol
32+
* we require from peers, not the actual consensus logic.
33+
*/
34+
CustomRewardAddresses,
35+
36+
/* Test forks not actually deployed / active but used for unit tests. */
37+
TestByTimestamp,
3038
};
3139

3240
/**

divi/src/main.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4872,15 +4872,24 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
48724872
return true;
48734873
}
48744874

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

4882+
/* Otherwise, the protocol update is tied to time-based activation of
4883+
a network fork (which in fact does not fork consensus but just the
4884+
network protocol). */
4885+
const CBlockIndex* tip;
4886+
{
4887+
LOCK(cs_main);
4888+
tip = chainActive.Tip();
4889+
}
4890+
if (tip != nullptr && ActivationState(tip).IsActive(Fork::CustomRewardAddresses))
4891+
return MN_REWARD_SCRIPT_VERSION;
4892+
48844893
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
48854894
}
48864895

0 commit comments

Comments
 (0)