Skip to content

Commit 8395f5b

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 2ef10e3 commit 8395f5b

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

divi/src/ForkActivation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ const std::unordered_map<Fork, int64_t,std::hash<int>> ACTIVATION_TIMES = {
2525
{Fork::TestByTimestamp, 1000000000},
2626
{Fork::HardenedStakeModifier, unixTimestampForDec31stMidnight},
2727
{Fork::UniformLotteryWinners, unixTimestampForDec31stMidnight},
28+
29+
/** FIXME: Set actual time once scheduled. */
30+
{Fork::CustomRewardAddresses, 2000000000},
2831
};
2932

3033
} // anonymous namespace

divi/src/ForkActivation.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ enum Fork
2222
TestByTimestamp,
2323
HardenedStakeModifier,
2424
UniformLotteryWinners,
25+
26+
/**
27+
* Custom reward addresses for masternodes. This is activated like other
28+
* forks based on block time; but it only affects the network protocol
29+
* we require from peers, not the actual consensus logic.
30+
*/
31+
CustomRewardAddresses,
2532
};
2633

2734
/**

divi/src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "coins.h"
2121
#include <defaultValues.h>
2222
#include "FeeRate.h"
23+
#include "ForkActivation.h"
2324
#include "init.h"
2425
#include "kernel.h"
2526
#include "libzerocoin/bignum.h"

divi/src/version.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
#include <version.h>
22

3+
#include <chain.h>
34
#include <chainparams.h>
5+
#include <ForkActivation.h>
46
#include <Settings.h>
57

8+
extern CChain chainActive;
69
extern Settings& settings;
710

8-
// Note: whenever a protocol update is needed toggle between both implementations (comment out the formerly active one)
9-
// so we can leave the existing clients untouched (old SPORK will stay on so they don't see even older clients).
10-
// Those old clients won't react to the changes of the other (new) SPORK because at the time of their implementation
11-
// it was the one which was commented out
1211
int ActiveProtocol()
1312
{
1413
if (settings.ParameterIsSet("-activeversion"))
1514
return settings.GetArg("-activeversion", 0);
1615

16+
/* On regtest, we set the new protocol as active without any further
17+
ado. This allows proper testing of the changed logic. */
1718
if (Params().NetworkID() == CBaseChainParams::REGTEST)
1819
return MN_REWARD_SCRIPT_VERSION;
1920

21+
/* Otherwise, the protocol update is tied to time-based activation of
22+
a network fork (which in fact does not fork consensus but just the
23+
network protocol). */
24+
const CBlockIndex* tip = chainActive.Tip();
25+
if (tip != nullptr && ActivationState(tip).IsActive(Fork::CustomRewardAddresses))
26+
return MN_REWARD_SCRIPT_VERSION;
27+
2028
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
2129
}

0 commit comments

Comments
 (0)