Skip to content

Commit

Permalink
Proposed stake fix
Browse files Browse the repository at this point in the history
This update will require all users to update to the new client version
before January 1st 2014 at 00:00:00 GMT after which:

Older client versions will no longer be able to initiate a connection to
this version.

This version will no longer accept blocks from any older versions that
remain connected in the interim.

Seven days after older versions are disconnected (8th January 2014 at
00:00:00 GMT) the new stake percentage will take effect. This will be a
massive reduction to prevent further over inflation from this point
forward.
  • Loading branch information
Petr1fied committed Dec 17, 2013
1 parent f73c419 commit dac7168
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 15 deletions.
4 changes: 4 additions & 0 deletions src/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ namespace Checkpoints
(100000, uint256("0x0000004abff9346b6b1c2a716d95ea7bec86fed7b196924c3875ada3a9105b8e"))
(110000, uint256("0x0000012d5e0f7129e097fbf900962da98a813b82f2cb0bdc920e3495e7ae1251"))
(129500, uint256("0x000004c66fe139813f4f6a8a1a6ba4481f4c3e3a4515946a6a7a66f960a45c3c"))
(140000, uint256("0x7b866924978e8ad085003c603f42e80b5b215e391dc0d170c08306c54a74b5c7"))
(150000, uint256("0x8b3de9f9f9f1e26b4dd3b149fe58892823bb86b2a3165fc86b36bd631d7c0bca"))
(160000, uint256("0x0000084697be26791727bfa0ef74022a64f1fb0ab48632507a26b2ccb0f3c1f9"))
(168000, uint256("0x3e162e2caf9bea8288f322819a9fa3d6630f677144bb61aea1cd0b74926ef133"))
;

static MapCheckpoints mapCheckpointsTestnet =
Expand Down
66 changes: 54 additions & 12 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,10 +989,14 @@ int64 GetProofOfStakeReward(int64 nCoinAge)
{
static int64 nRewardCoinYear = 1; // creation amount per coin-year
int64 nSubsidy = nCoinAge * 1 * nRewardCoinYear;
//int64 currentTime = GetTime();
//if(currentTime > 1383220800) //Fork at Mid-day, All Hallow's Eve, 2013.
// {nSubsidy = nCoinAge * .01 * nRewardCoinYear;} // 1% of the old stake; but hey still 7 days and a fortnight.
// well shit, that didn't work so well, did it? Bummer. Ok, on to the next idea, for now roll it back.

// Reduce stake drastically 7 days after we stop accepting connections/blocks from
// older clients. (8th January 2014 at 00:00:00 GMT)
int64 currentTimestamp = GetTime();
if(currentTimestamp >= 1389139200)
{
nSubsidy = nCoinAge * 0.0001 * nRewardCoinYear;
}
if (fDebug && GetBoolArg("-printcreation"))
{printf("GetProofOfStakeReward(): create=%s nCoinAge=%"PRI64d"\n", FormatMoney(nSubsidy).c_str(), nCoinAge);}

Expand Down Expand Up @@ -2850,6 +2854,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
}

int64 nTime;
bool badVersion = false;
int64 currentTimestamp = GetTime();
CAddress addrMe;
CAddress addrFrom;
uint64 nNonce = 1;
Expand All @@ -2863,6 +2869,22 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
return false;
}

// Start disconnecting older client versions from 01/01/2014 @ 00:00:00 GMT
if(currentTimestamp >= 1388534400)
{
if(pfrom->nVersion < 70000)
{
badVersion = true;
}
}

if(badVersion)
{
printf("partner %s using obsolete version %i; disconnecting\n", pfrom->addr.ToString().c_str(), pfrom->nVersion);
pfrom->fDisconnect = true;
return false;
}

if (pfrom->nVersion == 10300)
pfrom->nVersion = 300;
if (!vRecv.empty())
Expand Down Expand Up @@ -2929,16 +2951,36 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)

// Ask the first connected node for block updates
static int nAskedForBlocks = 0;
if (!pfrom->fClient && !pfrom->fOneShot &&
(pfrom->nStartingHeight > (nBestHeight - 144)) &&
(pfrom->nVersion < NOBLKS_VERSION_START ||
pfrom->nVersion >= NOBLKS_VERSION_END) &&
(nAskedForBlocks < 1 || vNodes.size() <= 1))

// Only accept blocks from older client versions until the
// update deadline of 1st January 2014 at 00:00:00 GMT.
// After the deadline, only accept blocks from protocol
// version 70000 or above.
if(currentTimestamp<1388534400)
{
nAskedForBlocks++;
pfrom->PushGetBlocks(pindexBest, uint256(0));
if (!pfrom->fClient && !pfrom->fOneShot &&
(pfrom->nStartingHeight > (nBestHeight - 144)) &&
(pfrom->nVersion < NOBLKS_VERSION_START ||
pfrom->nVersion >= NOBLKS_VERSION_END) &&
(nAskedForBlocks < 1 || vNodes.size() <= 1))
{
nAskedForBlocks++;
pfrom->PushGetBlocks(pindexBest, uint256(0));
}
}

else
{
if (!pfrom->fClient && !pfrom->fOneShot &&
(pfrom->nStartingHeight > (nBestHeight - 144)) &&
(pfrom->nVersion < NOBLKS_VERSION_START ||
pfrom->nVersion >= NOBLKS2014_VERSION_END) &&
(nAskedForBlocks < 1 || vNodes.size() <= 1))
{
nAskedForBlocks++;
pfrom->PushGetBlocks(pindexBest, uint256(0));
}
}

// Relay alerts
{
LOCK(cs_mapAlerts);
Expand Down
9 changes: 6 additions & 3 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern const std::string CLIENT_DATE;
// network protocol versioning
//

static const int PROTOCOL_VERSION = 60006;
static const int PROTOCOL_VERSION = 70000;

// earlier versions not supported as of Feb 2012, and are disconnected
static const int MIN_PROTO_VERSION = 209;
Expand All @@ -38,15 +38,18 @@ static const int CADDR_TIME_VERSION = 31402;
static const int NOBLKS_VERSION_START = 60002;
static const int NOBLKS_VERSION_END = 60004;

// From 1st January 2014, disallow blocks from older versions.
static const int NOBLKS2014_VERSION_END = 70000;

// BIP 0031, pong message, is enabled for all versions AFTER this one
static const int BIP0031_VERSION = 60000;

// "mempool" command, enhanced "getdata" behavior starts with this version:
static const int MEMPOOL_GD_VERSION = 60002;

#define DISPLAY_VERSION_MAJOR 0
#define DISPLAY_VERSION_MINOR 9
#define DISPLAY_VERSION_REVISION 6
#define DISPLAY_VERSION_MINOR 10
#define DISPLAY_VERSION_REVISION 0
#define DISPLAY_VERSION_BUILD 0

#endif

0 comments on commit dac7168

Please sign in to comment.